pipes-extra-0.2.0: Various basic utilities for Pipes.

Safe HaskellSafe-Infered

Control.Pipe.PutbackPipe

Description

This module contains an alternative pipe implementation, PutbackPipe, providing an additional primitive putback, which allows data to be inserted into the input stream of the current pipe.

PutbackPipes can be used to implement pipes with left-over data, and can be composed vertically (using the Monad instance), but not horizontally.

To make use of a PutbackPipe within a Pipeline, you need to convert it to a regular Pipe using runPutback.

Synopsis

Documentation

newtype PutbackPipe a b m r Source

The PutbackPipe data type.

Constructors

PutbackPipe 

Fields

unPutback :: Pipe (Either a a) (Either b a) m r
 

Instances

fromPipe :: Monad m => Pipe a b m r -> PutbackPipe a b m rSource

Create a PutbackPipe from a regular pipe.

putback :: Monad m => a -> PutbackPipe a b m ()Source

Put back an element into the input stream.

yield :: Monad m => b -> PutbackPipe a b m ()Source

Same as yield for regular pipes.

await :: Monad m => PutbackPipe a b m aSource

Same as await for regular pipes.

tryAwait :: Monad m => PutbackPipe a b m (Maybe a)Source

Same as tryAwait for regular pipes.

runPutback :: Monad m => PutbackPipe a b m r -> Pipe a b m rSource

Convert a PutbackPipe to a regular pipe.