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

Vincent Hanquez tab at snarc.org
Thu May 16 08:59:28 CEST 2013


Hi,

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)
  ...

I'ld want to propose to extends Bits to do so generically:

  class Bits a where
    ...  
    bSwap : a -> a

I'm attaching a patch that do as explained, and add a default implementation
for bSwap, so that compatibility is assured for existing instances.

-- 
Vincent
-------------- next part --------------
A non-text attachment was scrubbed...
Name: base-bswap.patch
Type: text/x-diff
Size: 2996 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/libraries/attachments/20130516/4af29e37/attachment-0001.patch>


More information about the Libraries mailing list