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

Henning Thielemann lemming at henning-thielemann.de
Thu May 16 10:59:03 CEST 2013


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

?



More information about the Libraries mailing list