In GHCi, if I define two functions like so:
> let succ = (+ 1)
> let pred = (- 1)
And then call them both, like so:
> succ 5
> pred 5
Why does one (succ
) run just fine, while the other fails with the following error?
<interactive>:3:1:
Could not deduce (Num (a0 -> t))
arising from the ambiguity check for ‘it’
from the context (Num (a -> t), Num a)
bound by the inferred type for ‘it’: (Num (a -> t), Num a) => t
at <interactive>:3:1-6
The type variable ‘a0’ is ambiguous
When checking that ‘it’
has the inferred type ‘forall a t. (Num (a -> t), Num a) => t’
Probable cause: the inferred type is ambiguous
What is causing the type inference to fail in one function and not the other?