Description

We introduce input processing with left-fold enumerator -- Iteratee IO -- as a safe, declarative and practical alternative to Handle and Lazy IO for input processing. The approach is general and applies to processing data from various collections, from in-memory data structures to databases, files, sockets, etc. The input data may come from a file or from an embedded (e.g., chunk-encoded or encrypted) stream; the depth of embedding is arbitrary. The approach is naturally incremental. It permits IO interleaving without any unsafe operations. The approach is algebraic and declarative. The left-fold enumerator as a general concept has been used in other functional languages. Our running example is HTTP request processing in Haskell, specifically, reading lines (terminated by CR, LF or CRLF) from a file descriptor and then from the chunk-encoded body. The main example illustrates multiplexing across two file descriptors and the full IO interleaving.

Preview

Tags

Users

  • @draganigajic

Comments and Reviews