A Source never reads from its inputs.
Modulemachines-0.7.4Haskell2010
Data.Machine.Source
- 2 types
- 10 values
- Packagemachines-0.7.4
- Exports12
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceSource.hs
Sources
12 declarationsA SourceT never reads from its inputs, but may have monadic side-effects.
Repeat the same value, over and over.
This can be constructed from a plan with
repeated :: o -> Source o
repeated = repeatedly . yield
Examples:
run $ taking 5 <~ repeated 1[1,1,1,1,1]
Loop through a Foldable container over and over.
This can be constructed from a plan with
cycled :: Foldable f => f b -> Source b
cycled = repeatedly (traverse_ yield xs)
Examples:
run $ taking 5 <~ cycled [1,2][1,2,1,2,1]
iterated f x returns an infinite source of repeated applications
of f to x
replicated n x is a source of x emitted n time(s)
Enumerate from a value to a final value, inclusive, via succ
Examples:
run $ enumerateFromTo 1 3[1,2,3]
Effectful unfold variant.