iteratee-0.1.0: Iteratee-based I/O

Data.Iteratee.Char

Contents

Description

Utilties for Char-based iteratee processing.

Synopsis

Type synonyms

type Stream = StreamG [] CharSource

A particular instance of StreamG: the stream of characters. This stream is used by many input parsers.

type Iteratee m a = IterateeG [] Char m aSource

type IterateeM m a = IterateeGM [] Char m aSource

Word and Line processors

line :: Monad m => IterateeM m (Either Line Line)Source

Read the line of text from the stream The line can be terminated by CR, LF or CRLF. Return (Right Line) if successful. Return (Left Line) if EOF or a stream error were encountered before the terminator is seen. The returned line is the string read so far.

print_lines :: IterateeGM [] Line IO ()Source

Print lines as they are received. This is the first impure iteratee with non-trivial actions during chunk processing

enum_lines :: Monad m => IterateeG [] Line m a -> IterateeGM [] Char m (IterateeG [] Line m a)Source

Convert the stream of characters to the stream of lines, and apply the given iteratee to enumerate the latter. The stream of lines is normally terminated by the empty line. When the stream of characters is terminated, the stream of lines is also terminated, abnormally. This is the first proper iteratee-enumerator: it is the iteratee of the character stream and the enumerator of the line stream.

enum_words :: Monad m => IterateeG [] String m a -> IterateeGM [] Char m (IterateeG [] String m a)Source

Convert the stream of characters to the stream of words, and apply the given iteratee to enumerate the latter. Words are delimited by white space. This is the analogue of List.words One should keep in mind that enum_words is a more general, monadic function.