iteratee-mtl-0.5.0.0: Iteratee-based I/O

Data.Iteratee.Iteratee

Contents

Description

Monadic and General Iteratees: incremental input parsers, processors and transformers

Synopsis

Types

Error handling

throwErr :: Monad m => SomeException -> Iteratee s m aSource

Report and propagate an unrecoverable error. Disregard the input first and then propagate the error. This error cannot be handled by enumFromCallbackCatch, although it can be cleared by checkErr.

throwRecoverableErr :: Monad m => SomeException -> (Stream s -> Iteratee s m a) -> Iteratee s m aSource

Report and propagate a recoverable error. This error can be handled by both enumFromCallbackCatch and checkErr.

checkErr :: (Monad m, NullPoint s) => Iteratee s m a -> Iteratee s m (Either SomeException a)Source

Check if an iteratee produces an error. Returns Right a if it completes without errors, otherwise Left SomeException. checkErr is useful for iteratees that may not terminate, such as Data.Iteratee.head with an empty stream.

Basic Iteratees

identity :: (Monad m, NullPoint s) => Iteratee s m ()Source

The identity iteratee. Doesn't do any processing of input.

skipToEof :: Monad m => Iteratee s m ()Source

Skip the rest of the stream

isStreamFinished :: Monad m => Iteratee s m (Maybe SomeException)Source

Get the stream status of an iteratee.

Nested iteratee combinators

convStream :: (Monad m, Nullable s) => Iteratee s m s' -> Enumeratee s s' m aSource

Convert one stream into another, not necessarily in lockstep. The transformer mapStream maps one element of the outer stream to one element of the nested stream. The transformer below is more general: it may take several elements of the outer stream to produce one element of the inner stream, or the other way around. The transformation from one stream to the other is specified as Iteratee s el s'.

unfoldConvStream :: (Monad m, Nullable s) => (acc -> Iteratee s m (acc, s')) -> acc -> Enumeratee s s' m aSource

The most general stream converter. Given a function to produce iteratee transformers and an initial state, convert the stream using iteratees generated by the function while continually updating the internal state.

joinI :: (Monad m, Nullable s) => Iteratee s m (Iteratee s' m a) -> Iteratee s m aSource

joinIM :: Monad m => m (Iteratee s m a) -> Iteratee s m aSource

Enumerators

type Enumerator s m a = Iteratee s m a -> m (Iteratee s m a)Source

Each enumerator takes an iteratee and returns an iteratee an Enumerator is an iteratee transformer. The enumerator normally stops when the stream is terminated or when the iteratee moves to the done state, whichever comes first. When to stop is of course up to the enumerator...

type Enumeratee sFrom sTo m a = Iteratee sTo m a -> Iteratee sFrom m (Iteratee sTo m a)Source

Basic enumerators

enumChunk :: Monad m => Stream s -> Enumerator s m aSource

Applies the iteratee to the given stream. This wraps enumEof, enumErr, and enumPure1Chunk, calling the appropriate enumerator based upon Stream.

enumEof :: Monad m => Enumerator s m aSource

The most primitive enumerator: applies the iteratee to the terminated stream. The result is the iteratee in the Done state. It is an error if the iteratee does not terminate on EOF.

enumErr :: (Exception e, Monad m) => e -> Enumerator s m aSource

Another primitive enumerator: tell the Iteratee the stream terminated with an error.

enumPure1Chunk :: Monad m => s -> Enumerator s m aSource

The pure 1-chunk enumerator It passes a given list of elements to the iteratee in one chunk This enumerator does no IO and is useful for testing of base parsing

enumCheckIfDone :: Monad m => Iteratee s m a -> m (Bool, Iteratee s m a)Source

Checks if an iteratee has finished. This enumerator runs the iteratee, performing any monadic actions. If the result is True, the returned iteratee is done.

enumFromCallback :: (Monad m, NullPoint s) => (st -> m (Either SomeException ((Bool, st), s))) -> st -> Enumerator s m aSource

Create an enumerator from a callback function

enumFromCallbackCatch :: (IException e, Monad m, NullPoint s) => (st -> m (Either SomeException ((Bool, st), s))) -> (e -> m (Maybe EnumException)) -> st -> Enumerator s m aSource

Create an enumerator from a callback function with an exception handler. The exception handler is called if an iteratee reports an exception.

Enumerator Combinators

(>>>) :: Monad m => Enumerator s m a -> Enumerator s m a -> Enumerator s m aSource

The composition of two enumerators: essentially the functional composition It is convenient to flip the order of the arguments of the composition though: in e1 >>> e2, e1 is executed first

eneeCheckIfDone :: (Monad m, NullPoint elo) => ((Stream eli -> Iteratee eli m a) -> Iteratee elo m (Iteratee eli m a)) -> Enumeratee elo eli m aSource

Misc.

seek :: (Monad m, NullPoint s) => FileOffset -> Iteratee s m ()Source

Seek to a position in the stream

Classes