Proposal: Explicitly require "Data.Bits.bit (-1) == 0" property

Herbert Valerio Riedel hvr at gnu.org
Sun Feb 16 10:14:12 UTC 2014


Hello *,

Right now, there seems to be no "defined" way to create a zero
'Bits'-value (w/o requiring also a 'Num' instance), that has all bits
cleared without involving at least two operations from the 'Bits' class
(e.g. `clearBit (bit 0) 0` or `let x = bit 0 in xor x x`).

OTOH, introducing a new method 'class Bits a where bitZero :: a' seems
overkill to me.

However, "bit (-1)"[1] seems to result in just such a zero-value for all
'Bits' instances from base, so I'd hereby propose to simply document
this as an expected property of 'bit', as well as the recommended way to
introduce a zero-value (for when 'Num' is not available).

Discussion period: 2 weeks

 [1]: ...or more generally 'bit n == 0' for n<0, as it's usually
      implemented as 'bit n = 1 shift n'


More information about the Libraries mailing list