[Haskell-cafe] Why is Bool no instance of Num and Bits?
ndmitchell at gmail.com
Fri May 8 11:57:33 EDT 2009
Nope, it's in the Haskell standard. It means we can type:
1 + (2 :: Int) and have it work
Otherwise what type would 1 have? Integer? Float? It's just a way of
giving constants the type :: Num a => a
On Fri, May 8, 2009 at 4:53 PM, Andrew Wagner <wagner.andrew at gmail.com> wrote:
> Hmm, I never knew that. Is that a GHC thing? Is it strictly necessary? Seems
> like it could be done in the Num instance for Integers, Ints, etc.
> On Fri, May 8, 2009 at 11:51 AM, Neil Mitchell <ndmitchell at gmail.com> wrote:
>> > Err, I'm not seeing the danger of this
>> > (+) :: forall a. (Num a) => a -> a -> a
>> > Doesn't this require the two parameters to be the same instance of Num?
>> I didn't at first, then I remembered:
>> 1 + True
>> fromInteger 1 + True
>> And if we have Num for Bool, it type checks.
More information about the Haskell-Cafe