Proposal: Remove Num superclass of Bits

Bas van Dijk v.dijk.bas at gmail.com
Sun Oct 16 02:50:17 CEST 2011


On 16 October 2011 02:41, John Meacham <john at repetae.net> wrote:
> Or even worse,
>
> if 3 then True else False  would result in 'False' since 3 /= true (1)
> or 'True' since 3 /= false (0)
>
> neither is obvious.

For a C programmer the latter would be obvious. But we're not C programmers...

> Adding just zero and one doesn't completely solve the problem, because
> testBit uses equality with zero, so an Eq instance is needed.

Yes but the Bits class already has Eq as a superclass. This proposal
only deals with removing the Num superclass.

Bas

P.S.
Slight correction for my previous message: These would be better
definitions of .&. and .|.:
x .&. y = ifThenElse x y false
x .|. y = ifThenElse x true y
since these have the same strictness properties as (&&) and (||).



More information about the Libraries mailing list