How to convert a Integer to a ByteString in Haskell
We'd like to serialize data in a specific binary format. We use Data.ByteString s internally. So, the question is: How to convert the different data types we use to a ByteString . For String we have no problem, we can use encodeLazyByteString UTF8 "string" . But we'd also like to convert Integer s to ByteString s (big-endian). Does anyone know how to do that and/or has any good tips using Haskell and binary formats? Thanks! A perfect job for Data.Binary: Prelude> :m + Data.Binary Prelude Data.Binary> encode (pi :: Double) Chunk "\SOH\SOH\NUL\NUL\NUL\NUL\NUL\NUL\NUL\a\CAN-DT\251!\EM\255\255\255