How come GHCi doesn't display the polymorphic type in this error message?

Viewed 81

I am ascribing the type of a variable with type Num a => a -> a to Int, which throws an error, as expected. However, the error isn't exactly as I expected.

GHCi

λ> let x = typeInference 1
λ> :t x
x :: Num a => a -> a
λ> x :: Int

<interactive>:141:1: error:
    • Couldn't match expected type 'Int'
                  with actual type 'Integer -> Integer'
    • Probable cause: 'x' is applied to too few arguments
      In the expression: x :: Int
      In an equation for 'it': it = x :: Int
λ>

typeInferance definition

typeInference :: Num a => a -> a -> a
typeInference x y = x + y + 1

I expected the error message to say with actual type 'Num a => a -> a', which is the polymorphic type, why doesn't it? Does this have to do with GHCi's type defaulting?

1 Answers
Related