Unicode.Internal.Unfold

unicode-data-0.4.0.1: Access Unicode Character Database (UCD)

Copyright | (c) 2022 Composewell Technologies and Contributors
License | BSD-3-Clause
Maintainer | streamly@composewell.com
Stability | experimental
Portability | GHC
Safe Haskell | Safe-Inferred
Language | Haskell2010

Unicode.Internal.Unfold

Description

Since: 0.3.1

Synopsis

- data Unfold a b = forall s. Unfold (s -> Step s b) (a -> Step s b)
- data Step s a
  - = Yield !a !s
  - | Stop
- toList :: Unfold a a -> a -> [a]

# Documentation

data Unfold a b #

An `Unfold a b` is a generator of a stream of values of type `b` from a seed of type `a`.

Since: 0.3.1

Constructors

forall s. Unfold |
Fields (s -> Step s b) Step function: compute the next step from the current one. (a -> Step s b) Inject function: initialize the state with a seed value.

data Step s a #

A stream is a succession of `Step`s.

Since: 0.3.1

Constructors

Yield !a !s | Produces a single value and the next state of the stream.
Stop | Indicates there are no more values in the stream.

#### Instances

Instances details

Functor (Step s) # |
Instance details Defined in Unicode.Internal.Unfold Methods fmap :: (a -> b) -> Step s a -> Step s b (<$) :: a -> Step s b -> Step s a

toList :: Unfold a a -> a -> [a] #

Convert an 'Unfold a a' to a list [a], if the resulting list is empty the seed is used as a default output.