[Haskell-cafe] Binary IO of a list of ints

Jamie Love jamie.love at aviarc.com.au
Thu Jan 24 06:14:58 EST 2008

Hi there

I have a list of ints, with values between 0 and 255 and I need to print 
them out in little endian form to a file.

I've been using Data.Binary for single values, e.g.

runPut $ do
    put 'B'
    put (0 :: Int32)

I'm wondering how I can go about writing a list of Ints out. My thought 
was to do something like:

foldr (\x B.hPut output (runPut $ do put (x :: Word8))) data

(where output is my file handle), but apart from giving me type errors, 
it seems a rather arduous way to do it.

Could anyone suggest a better way to do this?

Jamie Love
Senior Consultant
Aviarc Australia
Mobile: +61 400 548 048


This message has been scanned for viruses and dangerous content 
by MailScanner and is believed to be clean.

More information about the Haskell-Cafe mailing list