Control.Monad.Consumer
Description
A monad for consuming streams - I believe this is basically just a specialized version of the State monad.
- newtype Consumer c a = Consumer ([c] -> (a, [c]))
- runConsumer :: [c] -> Consumer c a -> (a, [c])
- evalConsumer :: [c] -> Consumer c a -> a
- execConsumer :: [c] -> Consumer c a -> [c]
- class Monad m => MonadConsumer m c | m -> c where
- newtype ConsumerT c m a = ConsumerT {
- runConsumerT :: [c] -> m (a, [c])
Consumer Monad
Constructors
| Consumer ([c] -> (a, [c])) |
Instances
| Monad (Consumer c) | |
| Functor (Consumer c) | |
| MonadFix (Consumer c) | |
| Applicative (Consumer a) | |
| MonadConsumer (Consumer c) c |
runConsumer :: [c] -> Consumer c a -> (a, [c])Source
Execute a stateful computation, as a result we get the result of the computation, and the final state.
evalConsumer :: [c] -> Consumer c a -> aSource
Execute a stateful computation, ignoring the final state.
execConsumer :: [c] -> Consumer c a -> [c]Source
Execute a stateful computation, just for the side effect.
class Monad m => MonadConsumer m c | m -> c whereSource
Methods
Arguments
| :: Monad m' | |
| => m (m' c) | return next element from stream |
Arguments
| :: Monad m' | |
| => m (m' c) | peek at next element, but leave it in the stream |
Arguments
| :: c | |
| -> m c | push and element onto the beginning on the stream |
Instances
| MonadConsumer (Consumer c) c | |
| Monad m => MonadConsumer (ConsumerT c m) c |
Consumer Monad Transformer
newtype ConsumerT c m a Source
Constructors
| ConsumerT | |
Fields
| |