
Hal Daume III wrote:
There's a Binary module that comes with GHC that you can get somewhere (I believe Simon M wrote it). I have hacked it up a bit and added support for bit-based writing, to bring it more in line with the NHC module. Mine, with various information, etc., is available at:
Hmmm, I'm not sure if that is what Ron asked for. What I guess is needed is support for things like: "read the next 4 bytes as a low-endian unsigned integer" "read the next 8 bytes as a big-endian IEEE 754 double" "write the Int16 as a low-endian signed integer" "write the (StorableArray Int Int32) as big-endian signed integers" ... plus perhaps some String I/O with a few encodings. Alas, we do *not* have something in our standard libs, although there were a few discussions about it. I know that one can debate ages about byte orders, external representation of arrays and floats, etc. Nevertheless, I guess covering only low-/big-endian systems, IEEE 754 floats, and arrays as a simple 0-based sequence of its elements (with an explicit length stated somehow) would make at least 90% of all users happy and would be sufficient for most "real world" file formats. Currently one is bound to hGetBuf/hPutBuf, which is not really a comfortable way of doing binary I/O. Cheers, S.