
On Thu, 7 Apr 2005, Malcolm Wallace wrote:
"Simon Marlow"
writes: shiftL 2 . clearBit 7 . setBit 4 . setBit 1
instead of flip shiftL 2 . flip clearBit 7 . flip setBit 4 . flip setBit 1
or (`shiftL` 2) . (`clearBit` 7) . (`setBit` 4) . (`setBit` 1)
On the whole I agree, but I'm inclined against changing this because it would break so much code gratuitously. I vote for just putting this down to a small mistake in the original design, and leaving it. If there's overwhelming support for the change of course we'll make it, but I doubt there will be.
For what it's worth, the old library NHC.Bits http://cvs.haskell.org/cgi-bin/cvsweb.cgi/nhc98/src/prelude/Bit/Bit.hs implements the 'set' and 'clear' operations with arguments the natural way round, although the left and right shift have the same order as Data.Bits and the C language.
If both infix operators and alphanumeric function names exist, then one could use different orders as it is done for 'subtract' and '(-)'.
I slightly prefer the NHC names ^>> and ^<< for shifting too, since they are naturally infix. Henning's example composition would look like this:
(^<< 2) . clear 7 . set 4 . set 1
Indeed, removing the 'Bit' suffix from the bit functions would also be nice. That would promote the use of qualification, that is Bit.clear, Bit.set and so on.