[Haskell-cafe] Binary IO

Donald Bruce Stewart dons at cse.unsw.edu.au
Sat Jun 24 02:59:32 EDT 2006


m4d.skills:
> 
>    Greetings,
>    I am considering writing -in Haskell of course - a small
>    program to translate binary files to human readable text.
>    The trouble is that I can find no easily digestible tutorial
>    style info on how to do binary IO in Haskell.
>    I have read about some of the libraries that people have
>    created to do binary IO, but the documentation wasn't
>    sufficient to get me started (perhaps because I'm a bit
>    dense, and also relatively new to Haskell).
>    What I would like is to see a short example showing some
>    code that reads from a binary file.  I would also
>    like to know what the most widely used library for doing
>    binary IO in Haskell is.
>    I would greatly appreciate it if someone could post a small
>    example or two illustrating how to do
>    binary IO in Haskell using the most widely used binary IO
>    lib (if there is such a thing).  Failing that, I would
>    appreciate a link to some Haskell code that does binary IO
>    that I could study.
>    Lastly, if there is a good tutorial on doing binary IO in
>    Haskell then I would appreciate a link to that as well.
>    Thanks in advance,
>    Jeff Lasslett

Here's a howto:
    http://www.haskell.org/hawiki/BinaryIo

Look for the instance Binary  code. That's where you set up your binary
parsers for each Haskell type. lso, these day,s you can do a fair bit of
binary hacking with Data.ByteString, without the Binary class layer over
the top.  Hope that helps.

-- Don


More information about the Haskell-Cafe mailing list