proposal/RFC: add bSwap to base in Data.Bits

Edward Kmett ekmett at gmail.com
Thu May 16 11:07:51 CEST 2013


Henning has a point.

EndianSensitive is arguably the more appropriate notion.

What does it mean to 'byteSwap' an 'Integer'? Or a bit vector of length n?

-Edward



On Thu, May 16, 2013 at 4:59 AM, Henning Thielemann <
lemming at henning-thielemann.de> wrote:

>
> On Thu, 16 May 2013, Vincent Hanquez wrote:
>
>  On Thu, May 16, 2013 at 10:24:31AM +0200, Henning Thielemann wrote:
>>
>>>
>>> If at all, I'd suggest a name without the 'b', since the other
>>> functions like 'shift' do not contain a 'b' as well.
>>>
>>
>> apologies if i misunderstood you, but i think that's the whole point.
>> the b is there because it's different than shift.
>> shift works on bits, and bswap works on bytes.
>>
>
> If it would work on bits, I would certainly not call it swap, but
> 'reverse'. On the MC68000 processor there was an assembly instruction
> "swap" that swapped upper and lower 16 bits of a 32 bit word.
>
> However if you really only want to swap byte order (and not 16 bit words
> within 64 bit words and so on), then how about just using a package like
> 'endian':
>
>    http://hackage.haskell.org/**packages/archive/data-endian/**
> 0.0.1/doc/html/Data-Endian.**html<http://hackage.haskell.org/packages/archive/data-endian/0.0.1/doc/html/Data-Endian.html>
>
>
> ?
>
> ______________________________**_________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/**mailman/listinfo/libraries<http://www.haskell.org/mailman/listinfo/libraries>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20130516/61fa4660/attachment.htm>


More information about the Libraries mailing list