quiver-enumerator-0.0.0.1: Bridge between Quiver and Iteratee paradigms

Copyright© 2015 Patryk Zadarnowski <pat@jantar.org>
LicenseBSD3
Maintainerpat@jantar.org
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Control.Quiver.Enumerator

Description

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.

Synopsis

Documentation

fromStream :: Stream a -> Maybe [a] Source

Converts a Stream to an optional list.

toStream :: Maybe [a] -> Stream a Source

Converts an optional list to a Stream.

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.