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