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 whereThis 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 bisNothing, thenunfoldr f bshould be empty. - If
f bisJust (Tuple a b1), thenunfoldr f bshould consist ofaappended to the result ofunfoldr f b1.
Members
Instances
#replicate Source
replicate :: forall a f. Unfoldable f => Int -> a -> f aReplicate 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 aThe 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 aContain a single value. For example:
singleton "foo" == ["foo"] :: Array String
#fromMaybe Source
fromMaybe :: forall a f. Unfoldable f => Maybe a -> f aConvert a Maybe to any Unfoldable like lists and arrays.
- Modules
- Data.
Unfoldable