[Haskell-cafe] GHC.Ptr, Foreign.Storable, Data.Storable.Endian, looking for good examples of usage
Aaron Gray
aaronngray.lists at gmail.com
Tue Jan 11 22:43:40 CET 2011
On 11 January 2011 18:54, Antoine Latter <aslatter at gmail.com> wrote:
> On Tue, Jan 11, 2011 at 10:22 AM, Aaron Gray <aaronngray.lists at gmail.com>
> wrote:
> > On 11 January 2011 00:02, Antoine Latter <aslatter at gmail.com> wrote:
> >>
> >> On Mon, Jan 10, 2011 at 5:23 PM, Aaron Gray <aaronngray.lists at gmail.com
> >
> >> wrote:
> >> > On 10 January 2011 22:30, Henning Thielemann
> >> > <lemming at henning-thielemann.de>
> >> > wrote:
> >> >>
> >> >> John Lato schrieb:
> >> >>
> >> >> > You could use my "word24" package[1] (GHC only) to provide
> >> >> > non-aligned
> >> >> > 24-bit word and int types with Storable instances. You should be
> >> >> > able
> >> >> > to write a binary instance (or whatever blaze-builder needs) fairly
> >> >> > simply from this. Little-endian only ATM, but BE could be added if
> >> >> > necessary.
> >> >>
> >> >> Good to know that! However, I think for the original poster the
> binary
> >> >> package is perfect. This way he does not worry about unsafe peeking
> and
> >> >> poking around in memory.
> >> >>
> >> >
> >> > Yes. I have came back to looking at the binary package, the only thing
> >> > is I
> >> > think I have to build my own primatives with it as it is big-endian,
> >> > where
> >> > ActionScript Byte Code format is little-endian. It does provide some
> >> > little-endian functions but they are not brought to the surface. It
> also
> >> > seems to roll its own serializations.
> >>
> >> The 'binary' package supports big-endian, little-endian and
> >> host-endian construction in the Data.Binary.Builder module, so you
> >> hopefully won't need to reimplement too much.
> >>
> >
> > Are there any examples of usage anywhere ? It does not seem to have 24bit
> > values either.
> > I am still thinking of implementing my own following the straight
> > Data.Binary package as an example.
> > Aaron
> >
>
> I used Data.Binary.Builder in an implementation of the memcached
> binary protocol:
>
> http://hackage.haskell.org/packages/archive/starling/0.3.0/doc/html/Network-Starling-Core.html
>
>
Nice code, I like the Serialize and Deserialize classes. Its a
shame Data.Binary does not use them.
> I'm sure other folks can chime in with good examples if that one isn't
> clear - the package 'binary' is pretty popular.
>
> You'd have to write your own putWord24be/le or whatever you need out
> of the 'singleton :: Word8 -> Builder' function. But that seems
> simpler than reimplementing Data.Binary.
>
Yes.
Thanks,
Aaron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110111/810dd010/attachment.htm>
More information about the Haskell-Cafe
mailing list