If I type the following into a Haskell script:
expressionTypeSigValue = 0 :: Integral a => a
typeSigValue :: Integral a => a
typeSigValue = 0
then load it in GHCi (v. 8.0.2), it informs me that the two constants have different types:
*Main> :t expressionTypeSigValue
expressionTypeSigValue :: Integer
*Main> :t typeSigValue
typeSigValue :: Integral a => a
I presume that the Integer
type of expressionTypeSigValue
is a result of type defaulting (correct me if I'm wrong). But I do not understand why the interpreter is not required to treat the two kinds of type signatures in the same way. Can someone explain this please?