
Right now though, I'm not sure all this is going in the right direction. Dealing with all those mutable buffers is quite a headache (for the library writer, not the user), and lazy bytestrings have shown us that there are simpler ways to get good I/O performance. What's more, as Duncan Coutts has pointed out to me on more than one occasion, it's much easier to layer streams when the streams are lazy lists. As much as I hate to say it, there's a lot to be said for lazy I/O in this respect. However, lazy I/O has other problems - deterministically catching errors, unpredictable resource usage, unpredictable interaction with other I/O, and so on. Is there a nice solution? Something else we might look at is Oleg's left folds:
http://okmij.org/ftp/Haskell/#fold-stream http://www.haskell.org/pipermail/haskell/2003-September/012741.html
I initially used lazy I/O with lazy bytestrings in my web server but I'm changing that behvior to use left folds instead precisely because of the reasons you (and Oleg) mentioned. Unfortunately, that means I need a incremental Parsec for bytestrings (I think) so there's yet another library to write. Oh well. :) -- Johan