iterIO-0.1: Iteratee-based IO with pipe operators




This module contains miscellaneous functions plus a few pieces of functionality that are missing from the standard Haskell libraries.



iterLoop :: (MonadIO m, ChunkData t, Show t) => m (Iter t m (), Onum t m a)Source

Create a loopback (Iter, Onum) pair. The iteratee and enumerator can be used in different threads. Any data fed into the Iter will in turn be fed by the Onum into whatever Iter it is given. This is useful for testing a protocol implementation against itself.

inumSplit :: (MonadIO m, ChunkData t) => Inum t t m aSource

Returns an Iter that always returns itself until a result is produced. You can fuse inumSplit to an Iter to produce an Iter that can safely be fed (e.g., with enumPure) from multiple threads.

Functionality missing from system libraries

class Show t => SendRecvString t whereSource

SendRecvString is the class of string-like objects that can be used with datagram sockets.

hShutdown :: Handle -> CInt -> IO IntSource

Flushes a file handle and calls the shutdown system call so as to write an EOF to a socket while still being able to read from it. This is very important when the same file handle is being used to to read data in an Onum and to write data in an Iter. Proper protocol functioning may require the Iter to send an EOF (e.g., a TCP FIN segment), but the Onum may still be reading from the socket in a different thread.

Debugging functions

traceInput :: (ChunkData t, Monad m) => String -> Iter t m ()Source

For debugging, print a tag along with the current residual input. Not referentially transparent.

traceI :: (ChunkData t, Monad m) => String -> Iter t m ()Source

For debugging. Print the current thread ID and a message. Not referentially transparent.