<div class="gmail_quote">On 11 January 2011 18:54, Antoine Latter <span dir="ltr">&lt;<a href="mailto:aslatter@gmail.com">aslatter@gmail.com</a>&gt;</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 &lt;<a href="mailto:aaronngray.lists@gmail.com">aaronngray.lists@gmail.com</a>&gt; wrote:<br>
&gt; On 11 January 2011 00:02, Antoine Latter &lt;<a href="mailto:aslatter@gmail.com">aslatter@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; On Mon, Jan 10, 2011 at 5:23 PM, Aaron Gray &lt;<a href="mailto:aaronngray.lists@gmail.com">aaronngray.lists@gmail.com</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt; &gt; On 10 January 2011 22:30, Henning Thielemann<br>
&gt;&gt; &gt; &lt;<a href="mailto:lemming@henning-thielemann.de">lemming@henning-thielemann.de</a>&gt;<br>
&gt;&gt; &gt; wrote:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; John Lato schrieb:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt; You could use my &quot;word24&quot; package[1] (GHC only) to provide<br>
&gt;&gt; &gt;&gt; &gt; non-aligned<br>
&gt;&gt; &gt;&gt; &gt; 24-bit word and int types with Storable instances.  You should be<br>
&gt;&gt; &gt;&gt; &gt; able<br>
&gt;&gt; &gt;&gt; &gt; to write a binary instance (or whatever blaze-builder needs) fairly<br>
&gt;&gt; &gt;&gt; &gt; simply from this.  Little-endian only ATM, but BE could be added if<br>
&gt;&gt; &gt;&gt; &gt; necessary.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Good to know that! However, I think for the original poster the binary<br>
&gt;&gt; &gt;&gt; package is perfect. This way he does not worry about unsafe peeking and<br>
&gt;&gt; &gt;&gt; poking around in memory.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Yes. I have came back to looking at the binary package, the only thing<br>
&gt;&gt; &gt; is I<br>
&gt;&gt; &gt; think I have to build my own primatives with it as it is big-endian,<br>
&gt;&gt; &gt; where<br>
&gt;&gt; &gt; ActionScript Byte Code format is little-endian. It does provide some<br>
&gt;&gt; &gt; little-endian functions but they are not brought to the surface. It also<br>
&gt;&gt; &gt; seems to roll its own serializations.<br>
&gt;&gt;<br>
&gt;&gt; The &#39;binary&#39; package supports big-endian, little-endian and<br>
&gt;&gt; host-endian construction in the Data.Binary.Builder module, so you<br>
&gt;&gt; hopefully won&#39;t need to reimplement too much.<br>
&gt;&gt;<br>
&gt;<br>
&gt; Are there any examples of usage anywhere ? It does not seem to have 24bit<br>
&gt; values either.<br>
&gt; I am still thinking of implementing my own following the straight<br>
&gt; Data.Binary package as an example.<br>
&gt; Aaron<br>
&gt;<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&#39;m sure other folks can chime in with good examples if that one isn&#39;t<br>
clear - the package &#39;binary&#39; is pretty popular.<br>
<br>
You&#39;d have to write your own putWord24be/le or whatever you need out<br>
of the &#39;singleton :: Word8 -&gt; Builder&#39; 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>