pipe-enumerator-0.3.0.0: A bidirectional bridge between pipes and iteratees

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

Pipes.Enumerator

Description

This module defines a set of functions that convert between the Pipes and Data.Enumerator paradigms. The conversion is bidirectional: an appropriately-typed pipe can be converted into an Iteratee and back into a pipe. In addition, a pipe can be fed into an iteratee (or, more specifically, Step), resulting in an 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.

iterateeToPipe :: Monad m => Iteratee a m r -> P.Proxy () (Maybe a) b' b m (Either SomeException (r, Maybe [a])) Source

Converts an Iteratee into a Consumer.

stepToPipe :: Monad m => Step a m r -> P.Proxy () (Maybe a) b' b m (Either SomeException (r, Maybe [a])) Source

Converts a Step into a Consumer.

pipeToIteratee :: Monad m => P.Proxy a' (Maybe a) () b m r -> Iteratee a m r Source

Converts a Pipe into an Iteratee. Any output of the pipe is quietly discarded.

pipeToEnumerator :: Monad m => P.Proxy a' (Maybe a) () b m r' -> Step b m r -> Iteratee a m r Source

Feed the output of a Pipe 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 pipe one element at the time, and the pipe's output is fed to the iteratee one element per chunk. Once the input reaches EOF, the pipe is fed an infinite stream of Nothing until it ends with a pure value, which is discarded. In effect, both the pipe and the iteratee are always consumed fully.