Impredicativity bug: forall not hoisted properly
Try compiling this:
{-# OPTIONS -fglasgow-exts #-}
module Bug where
data T a = MkT
out :: forall a. T a -> ()
out MkT = ()
inHoisted :: forall r. () -> (forall a. T a -> r) -> r
inHoisted _ foo = foo MkT
inUnhoisted :: () -> forall r. (forall a. T a -> r) -> r
inUnhoisted _ foo = foo MkT
testHoisted :: ()
testHoisted = inHoisted () out
testUnhoisted :: ()
testUnhoisted = inUnhoisted () out
Results:
Bug.hs:18:17:
Couldn't match expected type `T a -> ()'
against inferred type `forall a1. T a1 -> r'
Expected type: (T a -> ()) -> ()
Inferred type: (forall a1. T a1 -> r) -> r
In the expression: inUnhoisted () out
In the definition of `testUnhoisted':
testUnhoisted = inUnhoisted () out
Expected: testUnhoisted to compile, just like testHoisted
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.6 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
Edited by Simon Peyton Jones