Binary I/O in haskell.

Immanuel Litzroth immanuell@enfocus.be
Tue, 28 Jan 2003 11:07:18 +0000


>If you dont want to wait for libraries in development, the easiest way
>to do real binary IO is via hGetArray and hPutArray which let you get
>and put raw arrays of bytes (Word8). unfortunatly, there is no way to do
>binary IO in pure Haskell 98.
>
>http://haskell.cs.yale.edu/ghc/docs/latest/html/base/Data.Array.IO.html

This is what i have been using (since yesterday). I did notice something 
odd.
I create an array with newArray (0,1023) 0, open a file and pass the handle 
and the array to
hGetArray. This gives me an Array with 1024 bytes, which I then cast to an 
array with Word16
with the castIOUArray (since my data is Word16 little endian and my machine 
is LE (intel)).
When i get the bounds of this new array it still gives 1024 and  
dereferencing the new array's
values gives me the correct values in the first half of the array, the 
second half is 0.
What exactly does the castIOUArray function do?


>there is some work on a standard Binary library in progress as well.
Can you give me a pointer to this library?
Thanks for your reply
Immanuel


_________________________________________________________________
Receive your Hotmail & Messenger messages on your mobile phone with MSN 
Mobile http://www.msn.be/gsm/smsservices