Module

Data.Unfoldable1

Package
purescript-unfoldable
Repository
purescript/purescript-unfoldable

#Unfoldable1 Source

class Unfoldable1 t  where

This class identifies non-empty data structures which can be unfolded.

The generating function f corresponds to the uncons operation of a non-empty list or array; it always return a value, and then optionally a value to continue unfolding from.

Members

Instances

#replicate1 Source

replicate1 :: forall a f. Unfoldable1 f => Int -> a -> f a

Replicate a value n times. At least one value will be produced, so values n < 1 less than one will be ignored.

replicate1 0 "foo" == NEL.singleton "foo" :: NEL.NonEmptyList String
replicate1 2 "foo" == NEL.cons "foo" (NEL.singleton "foo") :: NEL.NonEmptyList String

#replicate1A Source

replicate1A :: forall a f m. Apply m => Unfoldable1 f => Traversable1 f => Int -> m a -> m (f a)

Perform an Apply action n times (at least once, so values n < 1 less than one will be ignored), and accumulate the results.

#singleton Source

singleton :: forall a f. Unfoldable1 f => a -> f a

Contain a single value. For example:

singleton "foo" == NEL.singleton "foo" :: NEL.NonEmptyList String

#range Source

range :: forall f. Unfoldable1 f => Int -> Int -> f Int

Create an Unfoldable1 containing a range of values, including both endpoints.

range 0 0 "foo" == NEL.singleton 0 :: NEL.NonEmptyList Int
range 1 2 "foo" == NEL.cons 1 (NEL.singleton 2) :: NEL.NonEmptyList Int
range 2 0 "foo" == NEL.cons 2 (NEL.cons 1 (NEL.singleton 0)) :: NEL.NonEmptyList Int