
On 15 October 2011 19:23, Johan Tibell
On Sat, Oct 15, 2011 at 3:56 AM, Roman Leshchinskiy
wrote: On 15/10/2011, at 11:11, Ian Lynagh wrote:
On Sat, Oct 15, 2011 at 11:56:27AM +0200, Bas van Dijk wrote:
On 15 October 2011 00:01, Ian Lynagh
wrote: Removing the Num superclass of Bits was also mentioned, but that would need its own proposal.
Ok, I would like to propose removing the Num superclass of Bits.
Would we just remove default methods like bit i = 1 `shiftL` i x `testBit` i = (x .&. bit i) /= 0 ?
The Num superclass is only needed to be able to say 0 and 1. Perhaps we should just add the methods zero and one to Bits?
That sounds reasonable. _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
We can also combine Gábor's and Roman's solutions to get both portability and convenience: zero, one :: a #ifdef __GLASGOW_HASKELL__ default zero, one :: Num a => a zero = 0 one = 1 #endif This way, not existing instances need to be adapted. Another problem is that the default implementation of popCount uses a '-': popCount :: a -> Int popCount = go 0 where go !c 0 = c go c w = go (c+1) (w .&. w - 1) Bas