在GHCi中,如果我定义两个函数,如下所示:
> let succ = (+ 1)
> let pred = (- 1)
Run Code Online (Sandbox Code Playgroud)
然后将它们称为两者,如下所示:
> succ 5
> pred 5
Run Code Online (Sandbox Code Playgroud)
为什么one(succ)运行得很好,而另一个失败并出现以下错误?
<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 …Run Code Online (Sandbox Code Playgroud) haskell ×1