隐式定义中的Ord,带有警卫的错误

Cur*_*ous 0 haskell

我收到了以下错误

Prelude> abs n | n>=0 = n+100 | otherwise =n
Prelude> abs 10
110
Prelude> abs -1

<interactive>:44:1: error:
    * Non type-variable argument in the constraint: Num (t -> t)
      (Use FlexibleContexts to permit this)
    * When checking the inferred type
        it :: forall t. (Ord t, Num (t -> t), Num t) => t -> t
Run Code Online (Sandbox Code Playgroud)
  1. 为什么存在Ord隐式类型定义?
  2. 这个错误在说什么?
  3. 这个定义有什么问题?

Ale*_*lov 5

当您编写abs -1x -1Haskell解析-为二元运算符时.所以它抱怨abs(这是一个函数)不是一个数字.正如Zpalmtree所说,你需要写作abs (-1).