Working character by character in Haskell

Jan-Willem Maessen jmaessen@alum.mit.edu
Fri, 19 Oct 2001 12:05:59 -0400


"Simon Marlow" <simonmar@microsoft.com> writes:
> To really match the C program, you need to use IOExts.hGetBuf and
> IOExts.hPutBuf, and do the operations on raw characters in memory.
> Using a UArray of Word8 would be better, but there aren't any
> operations to do IO to/from a UArray yet (actually I've written
> these, but they aren't in the tree yet).

So why don't getContents / putStr / etc. deforest cleanly to calls to
hGetBuf and hPutBuf?  I'm genuinely curious; my own experience in this
direction is "The engineering is challenging".  These functions are so
commonly used, though---and they're vastly easier to use, actually
portable, etc.  The effort would surely be repaid.

Plus, I'm curious to hear about any challenges which may be involved
in pulling this off. :-)  If it's genuinely tricky, the tricks are
likely to be generally useful for other stream-ish things.

-Jan-Willem Maessen
Eager Haskell Project
jmaessen@mit.edu