'Untouchable' error with constraint variable in rank-2 type
The following program compiles fine with GHC 7.6.3:
{-# LANGUAGE ConstraintKinds, RankNTypes, GADTs #-}
data Dict c where Dict :: c => Dict c
foo :: Dict c -> (c => r) -> r
foo Dict x = x
bar :: Dict ()
bar = Dict
main :: IO ()
main = print $ foo bar "Hello"
However, it produces the following error with HEAD:
ConstraintIssue.hs:12:8:
No instance for (Show s0) arising from a use of ‛print’
The type variable ‛s0’ is ambiguous
Note: there are several potential instances:
instance Show Double -- Defined in ‛GHC.Float’
instance Show Float -- Defined in ‛GHC.Float’
instance (Integral a, Show a) => Show (GHC.Real.Ratio a)
-- Defined in ‛GHC.Real’
...plus 24 others
In the expression: print
In the expression: print $ foo bar "Hello"
In an equation for ‛main’: main = print $ foo bar "Hello"
ConstraintIssue.hs:12:24:
Couldn't match expected type ‛s0’ with actual type ‛[Char]’
‛s0’ is untouchable
inside the constraints (())
bound by a type expected by the context: (()) => s0
at ConstraintIssue.hs:12:16-30
In the second argument of ‛foo’, namely ‛"Hello"’
In the second argument of ‛($)’, namely ‛foo bar "Hello"’
In the expression: print $ foo bar "Hello"
If the type signature of 'main' is removed, the code compiles OK.
If the empty constraint () is replaced with an equality constraint such as Int ~ Int, then the above error occurs with both 7.6.3 and HEAD, which I guess is intended behaviour.
Trac metadata
Trac field | Value |
---|---|
Version | 7.7 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |