Skip to content

GHCi 8.2 simply ignores TH splice using datatype with a forall'd kind signature

This is a pretty bizarre behavior I've noticed recently that only happens in GHC 8.2 or later. If you try to use a Template Haskell splice with a very particular feature (a datatype whose kind uses forall) in GHCi, then GHCi will flat-out ignore it!

$ /opt/ghc/8.2.1/bin/ghci
GHCi, version 8.2.0.20170427: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
λ> :set -XGADTs -XTypeInType -XTemplateHaskell -XRankNTypes 
λ> import Language.Haskell.TH (stringE, pprint)
λ> import Data.Kind (Type)
λ> $([d| data Foo :: forall a. a -> Type where MkFoo :: Foo Int |] >>= stringE . pprint)
λ> print (5 + length $([d| data Foo :: forall a. a -> Type where MkFoo :: Foo Int |] >>= stringE . pprint))
λ> 5
5
λ> it
5
λ> $([d| data Foo :: forall a. a -> Type where MkFoo :: Foo Int |] >>= stringE . pprint)
λ> it
5

Notice how none of my attempts to use the splice seemed to register with GHCi.

This isn't really a regression //per se//, since GHC 8.0.1 nor 8.0.2 even allowed you to get that far:

$ /opt/ghc/8.0.2/bin/ghci
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
λ> :set -XGADTs -XTypeInType -XTemplateHaskell -XRankNTypes 
λ> import Language.Haskell.TH (stringE, pprint)
λ> import Data.Kind (Type)
λ> $([d| data Foo :: forall a. a -> Type where MkFoo :: Foo Int |] >>= stringE . pprint)

<interactive>:4:3: error:
    Exotic form of kind not (yet) handled by Template Haskell
      forall a. a -> Type
Trac metadata
Trac field Value
Version 8.2.1-rc1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
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