Copyright | (C) 2012 Edward Kmett |
---|---|

License | BSD-style (see the file LICENSE) |

Maintainer | Edward Kmett <ekmett@gmail.com> |

Stability | provisional |

Portability | Rank-2 Types |

Safe Haskell | Safe-Inferred |

Language | Haskell2010 |

## Synopsis

- type Source b = forall k. Machine k b
- type SourceT m b = forall k. MachineT m k b
- source :: Foldable f => f b -> Source b
- repeated :: o -> Source o
- cycled :: Foldable f => f b -> Source b
- cap :: Process a b -> Source a -> Source b
- plug :: Monad m => MachineT m k o -> SourceT m o
- iterated :: (a -> a) -> a -> Source a
- replicated :: Int -> a -> Source a
- enumerateFromTo :: Enum a => a -> a -> Source a
- unfold :: (r -> Maybe (a, r)) -> r -> Source a
- unfoldT :: Monad m => (r -> m (Maybe (a, r))) -> r -> SourceT m a

# Sources

type SourceT m b = forall k. MachineT m k b Source #

A `SourceT`

never reads from its inputs, but may have monadic side-effects.

repeated :: o -> Source o Source #

Repeat the same value, over and over.

This can be constructed from a plan with
```
repeated :: o -> Source o
repeated = repeatedly . yield
```

Examples:

`>>>`

[1,1,1,1,1]`run $ taking 5 <~ repeated 1`

cycled :: Foldable f => f b -> Source b Source #

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:

`>>>`

[1,2,1,2,1]`run $ taking 5 <~ cycled [1,2]`

iterated :: (a -> a) -> a -> Source a Source #

`iterated`

`f x`

returns an infinite source of repeated applications
of `f`

to `x`

replicated :: Int -> a -> Source a Source #

`replicated`

`n x`

is a source of `x`

emitted `n`

time(s)

enumerateFromTo :: Enum a => a -> a -> Source a Source #

Enumerate from a value to a final value, inclusive, via `succ`

Examples:

`>>>`

[1,2,3]`run $ enumerateFromTo 1 3`