Skip to content

putting left equation sides in parantheses causes GHC.Prim.Any specialization

I put this code into a file:

identity : a -> a
(identity) = id

I get this error message:

Inferred type is less polymorphic than expected
  Quantified type variable `a' escapes
In the expression: id
In a pattern binding: (identity) = id

This may be correct, I don’t know.

However, I can also do this:

(identity) = id

GHCi accepts this. If I enter :type identity into GHCi, I get this:

identity :: GHC.Prim.Any -> GHC.Prim.Any

This seems weird, in my opinion.

This is also accepted by GHCi:

(identity) = id
hello      = identity "hello"

Evaluating hello yields "hello", and :type identity yields this:

identity :: [Char] -> [Char]
Trac metadata
Trac field Value
Version 6.12.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information