I'm trying to understand haskell error messages, as they are confusing for novice programmer. The simplest example I could find is this:
Prelude> 1 + True
<interactive>:2:3:
No instance for (Num Bool)
arising from a use of `+'
Possible fix: add an instance declaration for (Num Bool)
In the expression: 1 + True
In an equation for `it': it = 1 + True
Why does compiler look for (Num Bool) regardless of parameter order? Why does it work after I define the following?
instance Num Bool where (+) a b = True;
[...]
Prelude> 1 + True
True
How can I make sure (+) can be applied to (Num Bool) only when second argument is also (Num Bool)?