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

John Dorsey haskell at colquitt.org
Fri May 8 12:43:39 EDT 2009


> > Does that also mean that you could write:
> >
> > if 3 - 4 then ... else ...  (= if (fromInteger 3 :: Bool) - (fromInteger 4
> > :: Bool) then ... else ...)
> 
> No. 3 - 4 is an Integer, the proposal is to convert Bools to Ints, not
> Ints to Bools.

Rather, (3 - 4) is a "(Num t) => t", so yes, this would work with instance
Num Bool.

  *Main> if 3 - 4 then "yessirree" else "yep"
  "yep"

> Yeah, the more people give examples of the power of Num Bool, the more
> it seems like a very bad idea!

+1

John



More information about the Haskell-Cafe mailing list