GHC.Ptr, Foreign.Storable, Data.Storable.Endian, looking for good examples of usage

Hi, I am trying to work out how to use GHC.Ptr, Foreign.Storable, Data.Storable.Endian, and am looking for good examples of usage. Many thanks in advance, Aaron

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? The package storablevector uses a lot of Ptr, peek, and poke. Maybe this is of some help.

On 9 January 2011 21:30, Henning Thielemann
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.
The package storablevector uses a lot of Ptr, peek, and poke. Maybe this is of some help.
Okay thanks, Aaron

On Sun, Jan 9, 2011 at 6:05 PM, Aaron Gray
On 9 January 2011 21:30, Henning Thielemann
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. Although the 24-bit access might be difficult - how are they aligned? I guess with either of these you'd have to peek a Word8 and then a Word16 and then munge them together, depending. Antoine http://hackage.haskell.org/package/binary http://hackage.haskell.org/package/blaze-builder
The package storablevector uses a lot of Ptr, peek, and poke. Maybe this is of some help.
Okay thanks, Aaron
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

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

On Sun, Jan 9, 2011 at 8:11 PM, Aaron Gray
On 10 January 2011 01:08, Antoine Latter
wrote: 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.
Hah hah, yes. That would make a lot more sense.
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.
It has a larger surface area and more types, so it can be intimidating, but it has the module 'Blaze.ByteString.Builder.Word' which is an idealogical equivalent to the word primitives in Data.Binary.Builder. Antoine
Many thanks, Aaron

On Sun, 09 Jan 2011 14:48:09 +0100, Aaron Gray
Hi,
I am trying to work out how to use GHC.Ptr, Foreign.Storable, Data.Storable.Endian, and am looking for good examples of usage.
Many thanks in advance,
Aaron
You can lookup, which packages use these, by looking at the reverse dependencies: http://bifunctor.homelinux.net/~roel/hackage/packages/archive/pkg-list.html Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html --

On 9 January 2011 22:34, Henk-Jan van Tuyl
On Sun, 09 Jan 2011 14:48:09 +0100, Aaron Gray
wrote: Hi,
I am trying to work out how to use GHC.Ptr, Foreign.Storable, Data.Storable.Endian, and am looking for good examples of usage.
Many thanks in advance,
Aaron
You can lookup, which packages use these, by looking at the reverse dependencies:
http://bifunctor.homelinux.net/~roel/hackage/packages/archive/pkg-list.html
Handy I did not notice that, nice.
Thanks, Aaron
Regards, Henk-Jan van Tuyl
-- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html --
participants (4)
-
Aaron Gray
-
Antoine Latter
-
Henk-Jan van Tuyl
-
Henning Thielemann