Types

Not to be confused with types from the Stream or
stream-fusion packages, a Stream is a sequence of chunks
generated by an Enumerator. In contrast to Oleg’s implementation,
this stream does not support error handling -- errors encountered
while generating a stream are reported in the Step type instead.

(Chunks []) is used to indicate that a stream is still active, but
currently has no available data. Iteratees should ignore empty chunks.

The primary data type for this library, which consumes
input from a Stream until it either generates a value or encounters
an error. Rather than requiring all input at once, an iteratee will
return Continue when it is capable of processing more data.

In general, iteratees begin in the Continue state. As each chunk is
passed to the continuation, the iteratee returns the next step:
Continue for more data, Yield when it's finished, or Error to
abort processing.

While Iteratees consume data, enumerators generate it. Since
Iteratee is an alias for m (Step e a m b), Enumerators can
be considered step transformers of type
Step e a m b -> m (Step e a m b).

Enumerators typically read from an external source (parser, handle,
random generator, etc). They feed chunks into an Iteratee until the
source runs out of data (triggering EOF) or the iteratee finishes
processing (Yields a value).

Enumeratees

A common pattern in Enumeratee implementations is to check whether
the inner Iteratee has finished, and if so, to return its output.
checkDone passes its parameter a continuation if the Iteratee
can still consume input, or yields otherwise.

Parser combinators

Oleg’s original IterateeM.hs includes some basic iteratees
for parsing, so this section ports them to the new interface. However,
in practice most parsing will be performed with enumerator-based
interfaces to existing parser libraries (such as Parsec or Attoparsec).