Dealing with binary data 1 Handling Binary Data with Haskell
Many programming problems call for the use of binary formats for
compactness, ease-of-use, compatibility or speed. This page
quickly covers some common libraries for handling binary data in
Haskell. Everything else in this tutorial will be based on
bytestrings. Normal Haskell number of useful properties like
coverage of the Unicode space and laziness,however when it comes
to dealing with bytewise data, involves a space-inflation of
about 24x and a large reduction in speed. Bytestrings are packed
arrays of bytes or 8-bit chars. If you have experience in C,
their memory representation would be the same as a
uint8_t—although bytestrings know their length and don't allow
overflows, etc. There are two major flavours of bytestrings:
strict and lazy. Strict bytestrings are exactly what you would
expect—a linear array of bytes in memory. Lazy bytestrings are a
list of strict bytestrings; often this is called a cord in other
languages. When reading a lazy by