
Library and FFI guys (esp Manuel) | I can see Bool can be an instance of Bit but why does it | need to be an instance of Num? We can't remember who made the change or why. The advantage of making Num a superclass of bits is that (as someone mentioned) it allows us to give a default implementation of bit and
testBit:
bit i = 1 `shift` i x `testBit` i = (x .&. bit i) /= 0
So the choice is
a) Keep Num as superclass, and offer the default implementations
b) Remove Num and require instances of Bits to supply bit and
testBit
Myself I'd go for (b), but others on the libraries list may want to
weigh in. (The FFI folk should be interested because the Bits library
is part of the FFI spec. Note to Manuel: section 5.2 would be better
with an explicit class declaration for Bits!)
[SimonMar things we could make do with just Eq to implement testBit.]
Simon
| -----Original Message-----
| From: haskell-admin@haskell.org [mailto:haskell-admin@haskell.org] On
Behalf Of Dominic Steinitz
| Sent: 06 April 2003 14:08
| To: Glynn Clements
| Cc: haskell@haskell.org
|
| Is this a recent change? I've downloaded Ian Lynagh's DES module and
it
| doesn't compile because of this. I assume it used to. I don't see the
| rationale for this. I can see Bool can be an instance of Bit but why
does it
| need to be an instance of Num?
|
| Dominic Steinitz
| ----- Original Message -----
| From: "Glynn Clements"
participants (1)
-
Simon Peyton-Jones