Skip to content

Too-eager variable capture in forall types

h's type is ineffable: GHCi infers Capture a, but listing that type in the souce code fails the typecheck. Listing no type allows the following:

{-# OPTIONS_GHC -fglasgow-exts #-}

data Capture a = Base a
               | Capture (Capture (forall x . Divide x -> Divide a))

g :: Capture (forall a . Divide a -> Divide a)
g = Base id

h = Capture g

l :: Capture a
l = h

m :: Capture Int
m = h

data Divide a where
    Pint :: Int -> Divide Int
    Pbool :: Bool -> Divide Bool

foo :: Capture a -> Divide a
foo (Capture (Base f)) = f (Pbool True)

unfoo :: Divide a -> a
unfoo (Pint x) = x
unfoo (Pbool x) = x

oops = unfoo (foo h) -- Illegal instruction
oopsAgain = unfoo (foo l) -- Illegal instruction
oopsOnceMore = unfoo (foo m)
{-
<interactive>: internal error: interpretBCO: hit a CASEFAIL
    (GHC version 6.6 for i386_unknown_linux)
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
Aborted
-}
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
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information