Copyright | © 2015 Patryk Zadarnowski <pat@jantar.org> |
---|---|
License | BSD3 |
Maintainer | pat@jantar.org |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
This library defines a set of functions that convert between
the Quiver and Data.Enumerator paradigms. The conversion
is bidirectional: an appropriately-typed stream processor
can be converted into an Iteratee
and back
into a stream processor. In addition, a stream processor can
be fed into an iteratee (or Step
),
resulting in Enumerator
.
The library has been designed specifically for use with Snap, but I'm sure that many other interesting uses of it exist.
- fromStream :: Stream a -> Maybe [a]
- toStream :: Maybe [a] -> Stream a
- toSingletonStream :: Maybe a -> Stream a
- iterateeToConsumer :: Functor m => Iteratee a m r -> Q.Consumer () a m (Either SomeException (r, Maybe [a]))
- stepToConsumer :: Functor m => Step a m r -> Q.Consumer () a m (Either SomeException (r, Maybe [a]))
- consumerToIteratee :: Monad m => Q.Consumer a a' m r -> Iteratee a' m r
- processorToEnumerator :: Monad m => Q.P a a' b () m r1 -> Step b m r2 -> Iteratee a' m (r1, r2)
Documentation
fromStream :: Stream a -> Maybe [a] Source
Converts a Stream
to an optional list.
toSingletonStream :: Maybe a -> Stream a Source
Converts an optional value to a singleton Stream
.
iterateeToConsumer :: Functor m => Iteratee a m r -> Q.Consumer () a m (Either SomeException (r, Maybe [a])) Source
Converts an Iteratee
into a Q.Consumer
.
stepToConsumer :: Functor m => Step a m r -> Q.Consumer () a m (Either SomeException (r, Maybe [a])) Source
Converts a Step
into a Q.Consumer
.
consumerToIteratee :: Monad m => Q.Consumer a a' m r -> Iteratee a' m r Source
Converts a Q.Consumer
into an Iteratee
.
processorToEnumerator :: Monad m => Q.P a a' b () m r1 -> Step b m r2 -> Iteratee a' m (r1, r2) Source
Feed the output of a stream processor to a Step
, effectively converting it into
an Enumerator
, generalised slightly to allow distinct input and output types.
The chunks of the input stream are fed into the stream processor one element at
the time, and its output is fed to the iteratee one element per chunk.