I'm getting following error
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
- Why there is
Ord
in implicit type definition? - What the error is saying?
- what is wrong in the definition?
-1
in brackets, e.g.abs (-1)
, this is due to haskell's parsing, someone else can explain better than I can the other questions.abs -1
to Haskell looks likeabs - 1
, as ifabs
were a number, this is the quirk of Haskell's parsing @Zpalmtree was talking about.