proposal/RFC: add bSwap to base in Data.Bits
Herbert Valerio Riedel
hvr at gnu.org
Thu May 16 12:40:23 CEST 2013
On 2013-05-16 08:59:28 +0200, Vincent Hanquez wrote:
> 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.
I'm not against providing "generic" byteswap primitives, but I'm
skeptical about adding a *byte*-swap to the 'Bits' typeclass, whose
declared scope is according to the documentation:
| The Bits class defines bitwise operations over integral types.
And I haven't seen any operation relying on the concept of bytes in
'Bits'.
Wouldn't it be more logical to add a new typeclass depending on the
byte-notion such as e.g.
class Bits a => Bytes a where
...
which could then provide byte-operations such as little/big endian
swaps?
cheers,
hvr
More information about the Libraries
mailing list