Incremental multi-level input processing with left-fold enumerator: predictable, high-performance, safe, and elegant A practical alternative to Handle and Lazy IO for input processing Non-solution: Handle and Lazy IO GHCBufferIO.hs Using the conventional Handle IO and Lazy IO for part 1 of the running example: reading headers, sequences of lines terminated by the empty line Non-solution: Manual buffering BufferNaive.hs Reading lines from an explicitly allocated and filled buffer. Although the code is fairly efficient, it is a burden to write. A sole CR as line terminator is not handled. The code is complex already. This is the point: a more scalable solution is required. Incremental input parsers, processors and transformers Iteratee.hs Pure Iteratees IterateeM.hs Monadic and General Iteratees The main library IterateeMCPS.hs The CPS version of the above, which is in some sense simpler, making monadic Iteratees look pure Sample applications and the comparison with Lazy IO GetContentsLess.hs Emulating typical getContents code without any unsafe operations Wc.hs Contrasting Lazy and Iteratee IO on the example of Unix wc: counting lines and words in a file and in a sequence of files Random and Binary IO RandomIO.hs Random and Binary IO with Iteratee Tiff.hs TIFF library and its sample application: an extensive example of random and binary IO and on-demand incremental processing with iteratees LowLevelIO.hs Low-level IO operations These operations are either missing from the GHC run-time library, or implemented suboptimally or heavy-handedly Sample input test files Test files for part 1 of the running example: reading headers, the sequence of lines terminated by the empty line. Each line is terminated by CR, LF, or CRLF. We should return the headers in order. In the case of error, we should return the headers read so far and the description of the error. test1.txt all lines are always terminated by CRLF. Set the buffer size is set to 5, to ensure case coverage with respect to CRLF and the buffer boundary test2.txt lines are variously terminated by CR, LF, or CRLF test3.txt The version of test1.txt without the empty line Test files for both parts of the running example: reading headers and reading lines from the chunk-encoded content test_full1.txt Headers plus correctly chunk-encoded content; the last line has not terminated test_full3.txt Headers plus correctly chunk-encoded content the last line is NL-terminated test_full2.txt Chunk framing error on the second chunk Test files for binary and random IO test4.txt Sample binary numbers gnu-head-sm.tif A sample file for TIFF processing The image is a GNU logo (from http://www.gnu.org) (converted from JPEG to TIFF). Copyleft by GNU. January 1, 2010.