Impredicative type instantiation without -XImpredicativeTypes
Consider this module:
{-# LANGUAGE RankNTypes #-}
module Bug where
rank2 :: ((forall a. a -> a) -> b) -> ()
rank2 _ = ()
foo :: () -> ()
foo x = x
quux :: (forall a. a -> a) -> Int
quux _ = 5
bar = foo . rank2 $ quux
The (.)
in the definition of bar
requires an impredicative instantiation -- that is, one of its type variables is instantiated to a forall-type. Yet, the module compiles without -XImpredicativeTypes
. To confirm this behavior, the following is an excerpt from -ddump-simpl
:
Bug.bar =
break<7>()
(break<6>()
GHC.Base..
@ ()
@ ()
@ ((forall a_a1Tj. a_a1Tj -> a_a1Tj) -> GHC.Types.Int)
Bug.foo
(Bug.rank2 @ GHC.Types.Int))
Bug.quux
Note the third type argument to (.)
.
Fixing this would be a breaking change that could affect users.
Trac metadata
Trac field | Value |
---|---|
Version | 7.9 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |