How to convert ByteString representation of an integer to ... ok integer? Is there a special reading function for ByteStrings or do I need to unzip first than using regular reading?
Thank.
You can use readInteitherreadInteger of Data.ByteString.Char8. If you want to read some other data types, you need to write your own parser; the best option is probably attoparsec , which is a library for writing fast partners ByteStringand Textsimilar to Parsec.
readInt
readInteger
Data.ByteString.Char8
ByteString
Text
In addition to great suggestions, you can also use Data.Binary.Get to read integers of a fixed length.
ghci> :m +Data.Binary.Get ghci> :t runGet getWord64le ByteString -> Word64