[Haskell-cafe] Bit fiddling

Bulat Ziganshin bulatz at HotPOP.com
Wed May 18 04:05:02 EDT 2005

Hello Florian,

Wednesday, May 18, 2005, 12:44:14 AM, you wrote:

FW> I'm toying a bit with Haskell and wondering what's the best way to
FW> implement bit fiddling.  Most of my applications involve serializing
FW> and deserializing small blobs (IP packets, for instance), and after
FW> browsing the GHC library documentation, I'm not sure which appraoch I
FW> should use.  That's why I'd appreciate pointers to sample code.

you can find Binary.hs in the GHC 6.4 sources (sources of compiler
itself) and close to this ByteStream library on my page

with help of my library all you need to deserialize data is just:

(sign::Word32, block_type::Int16, crc::Word64)  <-  ByteStream.readMemory buf bufsize

there is no such easy serialization, i just don't need it because my
program uses only low-level functions, but i can add for you
something like:

(buf,bufsize) <- ByteStream.writeMemory (sign, block_type, crc)

Best regards,
 Bulat                            mailto:bulatz at HotPOP.com

More information about the Haskell-Cafe mailing list