|Haskell Performance Resource|
Before continuing, I strongly recommend reading Performance/Strings first. Fast I/O and string handling overlap in many places, so this page will only discuss the parts that are not specific to strings.
Iteratees are a relatively new approach to streaming I/O. If your code uses I/O extensively (for example, in a web server), iteratees are the best way to do it.
Using the Conduit library, a program to read a file and pipe it to stdout can be written as follows:
main = runResourceT (sourceFile "test.txt" $$ sinkHandle stdout)
If this is too high-level for you,
buffer-based IO is an alternative (
hPutBuf). This can be
particularly effective when combined with packed strings (see wc).
Some external libraries also provide memory mapped IO.
In 2006, someone came up with a solution called Streams. However, it does not seem to be maintained anymore.