sousit-0.3: Source/Sink/Transform: An alternative to lazy IO and iteratees.

Safe HaskellSafe-Inferred

Data.SouSiT

Contents

Synopsis

Sink

data Sink i m r Source

Instances

Monad m => Monad (Sink i m) 
Monad m => Functor (Sink i m) 
(Functor (Sink i m), Monad m) => Applicative (Sink i m) 

type Fetch i a = Sink i Identity aSource

input :: Monad m => Sink a m aSource

Reads the next element. The sink returns a fail if it is closed before the input is received.

inputOr :: Monad m => m a -> Sink a m aSource

Reads the next element. If the sink is closed while waiting for the input, then the parameter is returned as the sinks result.

skip :: (Eq n, Num n, Monad m) => n -> Sink a m ()Source

Skips n input elements. If the sink is closed before then the result will also be ().

liftSink :: (Monad m, Monad m') => (forall x. m x -> m' x) -> Sink i m r -> Sink i m' rSource

Changes the monad of a sink based upon a conversion function that maps the original monad to the new one.

liftFetch :: Monad m => Fetch i a -> Sink i m aSource

Lift the (pure) fetch sink into any monad.

Source

class Source src whereSource

Something that produces data to be processed by a sink

Methods

transfer :: Monad m => src m a -> Sink a m r -> m rSource

data FeedSource m a Source

A basic instance of FeedSource (and Source)

Instances

data SimpleSource m a Source

A basic instance of Source

Constructors

SimpleSource (forall r. Sink a m r -> m r) 

Instances

feedToSink :: FeedSource m a -> forall r. Sink a m r -> m (Sink a m r)Source

($$) :: (Source src, Monad m) => src m a -> Sink a m r -> m rSource

Transfer the data from the source into the sink

(=+=) :: Monad m => FeedSource m a -> FeedSource m a -> FeedSource m aSource

Concatenates two sources.

(=+|=) :: (Source src2, Monad m) => FeedSource m a -> src2 m a -> SimpleSource m aSource

Concatenates two sources.

Transform

type Transform a b = forall m r. Monad m => Sink b m r -> Sink a m rSource

(=$=) :: Monad m => (Sink b m r -> Sink a m r) -> (Sink c m r -> Sink b m r) -> Sink c m r -> Sink a m rSource

Merges two transforms into one.

(=$) :: Monad m => (Sink b m r -> Sink a m r) -> Sink b m r -> Sink a m rSource

Apply a transform to a sink.

($=) :: (Source src, Monad m) => src m a -> (forall r. Sink b m r -> Sink a m r) -> SimpleSource m bSource

Apply a transform to a source.