[Haskell-cafe] Why is Bool no instance of Num and Bits?

Stephan Friedrichs deduktionstheorem at web.de
Fri May 8 10:48:27 EDT 2009


Deniz Dogan wrote:
>> instance Num Bool where
>>    (+) False = id
>>    (+) True  = not
>>
>>    (*) True  True = True
>>    (*) _     _    = False
>>
> 
> Isn't "XOR" for booleans (/=)?

Oh right. And (*) would be (&&):

instance Num Bool where
    (+) = (/=)
    (*) = (&&)
    -- ...

//Stephan

-- 

Früher hieß es ja: Ich denke, also bin ich.
Heute weiß man: Es geht auch so.

 - Dieter Nuhr


More information about the Haskell-Cafe mailing list