Module
Data.Unfoldable
- Package
- purescript-unfoldable
- Repository
- purescript/purescript-unfoldable
This module provides a type class for unfoldable functors, i.e.
functors which support an unfoldr
operation.
This allows us to unify various operations on arrays, lists, sequences, etc.
#Unfoldable Source
class Unfoldable t where
This class identifies data structures which can be unfolded,
generalizing unfoldr
on arrays.
The generating function f
in unfoldr f
in understood as follows:
- If
f b
isNothing
, thenunfoldr f b
should be empty. - If
f b
isJust (Tuple a b1)
, thenunfoldr f b
should consist ofa
appended to the result ofunfoldr f b1
.
Members
Instances
#replicate Source
replicate :: forall a f. Unfoldable f => Int -> a -> f a
Replicate a value some natural number of times. For example:
replicate 2 "foo" == ["foo", "foo"] :: Array String
#replicateA Source
replicateA :: forall a f m. Applicative m => Unfoldable f => Traversable f => Int -> m a -> m (f a)
Perform an Applicative action n
times, and accumulate all the results.
#none Source
none :: forall a f. Unfoldable f => f a
The container with no elements - unfolded with zero iterations. For example:
none == [] :: forall a. Array a
#singleton Source
singleton :: forall a f. Unfoldable f => a -> f a
Contain a single value. For example:
singleton "foo" == ["foo"] :: Array String
#fromMaybe Source
fromMaybe :: forall a f. Unfoldable f => Maybe a -> f a
Convert a Maybe to any Unfoldable like lists and arrays.
- Modules
- Data.
Unfoldable