Proposal: Remove Num superclass of Bits

Roman Leshchinskiy rl at cse.unsw.edu.au
Sat Oct 15 12:54:55 CEST 2011


On 15/10/2011, at 10:56, Bas van Dijk wrote:

> On 15 October 2011 00:01, Ian Lynagh <igloo at earth.li> 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.
> 
> This would, for example, enable Vectors to get an instance for Bits:
> http://trac.haskell.org/vector/ticket/59

Thinking about this some more, I don't believe that Vectors could be easily made instances of Bits even if the Num superclass is removed. The Bits class assumes that there is exactly one value with no bits set (0), exactly one value with only the nth bit set (bit n), etc. This isn't necessarily true for vectors because they can store different numbers of leading zeroes. So the only sensible Bits instance would have to trim those leading zeroes. That is, length (xs .&. ys) could be anything between 0 and min (length xs) (length ys). I'm not sure how useful such an instance would be.

Roman





More information about the Libraries mailing list