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

Vincent Hanquez tab at snarc.org
Thu May 16 10:52:30 CEST 2013


On Thu, May 16, 2013 at 10:24:31AM +0200, Henning Thielemann wrote:
> 
> On Thu, 16 May 2013, Vincent Hanquez wrote:
> 
> >I'm trying to expose some byte swapping (bSwap) capabilities in base, namely
> >operation to allow to swap endianness on word{16,32,64}, i.e.:
> >
> > bswap16 :: Word16 -> Word16
> > bswap16 a = (a `shiftR` 8) .|. (a `shiftL` 8)
> > ...
> 
> 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.

I don't think swap it's a good name, and also Data.Tuple already got
a swap that does what i think 'swap' should do.

-- 
Vincent



More information about the Libraries mailing list