
On 10 January 2011 01:08, Antoine Latter
On Sun, Jan 9, 2011 at 6:05 PM, Aaron Gray
wrote: On 9 January 2011 21:30, Henning Thielemann < lemming@henning-thielemann.de> wrote:
On Sun, 9 Jan 2011, Aaron Gray wrote:
I am trying to work out how to use GHC.Ptr, Foreign.Storable, Data.Storable.Endian, and am looking for good examples of usage.
What do you intend to do with them?
An (ABC) ActionScript Byte Code backend for Haskell. Basically I need to write little-endian binary to a file, and was wondering the best way to do this; I need various types including a 24bit type.
Ah, I would recommend the 'binary' package on hackage, specifically the module Data.Binary.Builder. Another recently popular alternative is the 'blaze-builder' package.
It does say that it is designed to work with bigendian data, but there are some little-endian primatives in Data.Binary.Get/Put
Although the 24-bit access might be difficult - how are they aligned?
They are non aligned, they are actually used as jump offsets in the byte code.
I guess with either of these you'd have to peek a Word8 and then a Word16 and then munge them together, depending.
Three put/getWord8's would probably be neater.
http://hackage.haskell.org/package/binary http://hackage.haskell.org/package/blaze-builder
Blaze looks a bit more specialized. Many thanks, Aaron