Ambiguity Caused By PolyKind and Not Helpful Error Messages
The following code results in a confusing/wrong error message, blaming a type variable (a
) being a fixed Skolem variable:
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE PolyKinds #-}
data I a
type family F x
type instance F (I a) = a
identity :: F (I a) -> F (I a)
identity x = x
with the error message
• Couldn't match type ‘F (I a0)’ with ‘F (I a)’
Expected type: F (I a) -> F (I a)
Actual type: F (I a0) -> F (I a0)
NB: ‘F’ is a type function, and may not be injective
The type variable ‘a0’ is ambiguous
• In the ambiguity check for ‘identity’
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
In the type signature: identity :: F (I a) -> F (I a)
|
9 | identity :: F (I a) -> F (I a)
| ^^^^^^^^^^^^^^^^^^
Trac metadata
Trac field | Value |
---|---|
Version | 8.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | simonpj |
Operating system | |
Architecture |