TH reification prints invisible arguments to rank-2-kinded type as visible
If you run the following program:
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
module Bug where
import Data.Kind
import Language.Haskell.TH hiding (Type)
newtype T (f :: forall a. a -> Type) = MkT (f Bool)
$(pure [])
main :: IO ()
main = do
putStrLn $(reify ''T >>= stringE . pprint)
putStrLn $(reify ''T >>= stringE . show)
You'll get:
$ /opt/ghc/8.6.1/bin/runghc Bug.hs
newtype Bug.T (f_0 :: forall (a_1 :: *) . a_1 -> *)
= Bug.MkT (f_0 * GHC.Types.Bool)
TyConI (NewtypeD [] Bug.T [KindedTV f_6989586621679016168 (ForallT [KindedTV a_6989586621679016167 StarT] [] (AppT (AppT ArrowT (VarT a_6989586621679016167)) StarT))] Nothing (NormalC Bug.MkT [(Bang NoSourceUnpackedness NoSourceStrictness,AppT (AppT (VarT f_6989586621679016168) StarT) (ConT GHC.Types.Bool))]) [])
These are the parts that are suspect:
f_0 * GHC.Types.BoolAppT (AppT (VarT f_6989586621679016168) StarT) (ConT GHC.Types.Bool)
Notice how f/VarT f accepts */StarT as a visible argument, despite the fact that its kind forall a. a -> Type indicates that this should be invisible.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.6.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Template Haskell |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |