Proposal: add new Data.Bits.Bits(bitZero) method

ARJANEN Loïc Jean David arjanen.loic at gmail.com
Sun Feb 16 18:16:14 UTC 2014


Le dimanche 16 février 2014, 17:49:23 Henning Thielemann a écrit :
> Am 16.02.2014 17:42, schrieb Herbert Valerio Riedel:
> >> Introduce a new class method
> >> 
> >>    class Bits a where
> >>    
> >>        ...
> >>        -- | Value with all bits cleared
> >>        bitZero :: a
> >>        ...
> >> 
> >> modulo naming of 'bitZero'
> > 
> > (I'm hesitant to consume "zero" from the namespace as was suggested by
> > Henning)
> Let me defend "zero": Functions in the module that contain "Bit" in the
> name (clearBit, setBit, testBit) access a single bit. All functions that
> access many bits do not contain "Bit" (rotate, shift, xor, popCount). I
> propose to import the "zero" function with qualification, as well as the
> other functions from the module.
> 
> I also propose to provide a default implementation of "zero", like
> "clearBit (bit 0) 0". This way, the "zero" method can be introduced
> without breaking existing code.

I'm in favour of that modified proposal, so +1 for a "zero" member of Bits.

And if we fear problems with collisions, we could always name the member 
something like zeroValue or zeroBits.


More information about the Libraries mailing list