[Haskell-cafe] Writing binary files

Donald Bruce Stewart dons at cse.unsw.edu.au
Mon Aug 21 08:34:11 EDT 2006


ndmitchell:
> Hi,
> 
> I'm trying to write out a binary file, in particular I want the
> following functions:
> 
> hPutInt :: Handle -> Int -> IO ()
> 
> hGetInt :: Handle -> IO Int
> 
> For the purposes of these functions, Int = 32 bits, and its got to
> roundtrip - Put then Get must be the same.
> 
> How would I do this? I see Ptr, Storable and other things, but nothing
> which seems directly useable for me.
> 

use the Binary class (or one of its cousins)

    darcs get http://www.n-heptane.com/nhlab/repos/NewBinary

-- Don


More information about the Haskell-Cafe mailing list