<div dir="ltr">I agree with every one of Ian's points here. <div><br></div><div>Just bolting the functions in non-overloaded in Data.Word would be a useful starting point and side-steps concerns of what it means when you have (Finite)Bits instances that don't evenly divide into bytes, etc.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 17, 2013 at 2:37 PM, Ian Lynagh <span dir="ltr"><<a href="mailto:ian@well-typed.com" target="_blank">ian@well-typed.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Thu, May 16, 2013 at 11:36:46AM +0200, Vincent Hanquez wrote:<br>
> On Thu, May 16, 2013 at 05:07:51AM -0400, Edward Kmett wrote:<br>
> > Henning has a point.<br>
> ><br>
> > EndianSensitive is arguably the more appropriate notion.<br>
><br>
> Yes, Bits is not necessarily the best fit in term of naming or feature, but<br>
> nothing close to EndianSensitive is in base.<br>
<br>
</div>There's no reason that the recommended interface to the primitives needs<br>
to be in base. It would be a little unfriendly to only export the<br>
primitives, but we could just export<br>
byteSwap16 :: Word16 -> Word16<br>
byteSwap32 :: Word32 -> Word32<br>
byteSwap64 :: Word64 -> Word64<br>
and leave it up to packages like data-endian to provide a more<br>
user-friendly interface.<br>
<br>
The problem with adding a Bytes class is there are various questions,<br>
like "should there be an instance Bytes a => Bytes [a]?", "should there<br>
be a toWord8s :: a -> [Word8]" method?", and "would Word8s be a better<br>
name for the class?". If the class goes into base, then it's a lot<br>
harder to change the answers to these questions (and, indeed, to the<br>
questions that we don't think to ask before the class is in a released<br>
GHC).<br>
<br>
I think that adding the functions above, probably to Data.Word, would be<br>
my preference.<br>
<br>
<br>
Oh, and for the record, I also prefer "byteSwap" to "bswap", and dislike<br>
using (Finite)Bits for this.<br>
<br>
<br>
Thanks<br>
<span class="HOEnZb"><font color="#888888">Ian<br>
<br>
</font></span></blockquote></div><br></div>