Commit 02a5c580 authored by Ryan Scott's avatar Ryan Scott Committed by Ben Gamari

Filter out invisible kind arguments during TH reification

Previously, all kind arguments were being reified, which would cause
something like this:

```
type Id a = a
data Proxy (a :: Id k) = Proxy
```

to output

```
data Proxy (a :: Id * k) = Proxy
```

when `Proxy`'s `Info` is reified. The fix is simple: simply call
`filterOutInvisibleTypes` on the kind arguments of a kind synonym
application.

Fixes #11463.

Test Plan: ./validate

Reviewers: austin, bgamari, goldfire

Reviewed By: goldfire

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2081

GHC Trac Issues: #11463
parent 46e8f199
......@@ -1650,12 +1650,14 @@ reifyKind ki
reify_kc_app :: TyCon -> [TyCoRep.Kind] -> TcM TH.Kind
reify_kc_app kc kis
= fmap (mkThAppTs r_kc) (mapM reifyKind kis)
= fmap (mkThAppTs r_kc) (mapM reifyKind vis_kis)
where
r_kc | isTupleTyCon kc = TH.TupleT (tyConArity kc)
| kc `hasKey` listTyConKey = TH.ListT
| otherwise = TH.ConT (reifyName kc)
vis_kis = filterOutInvisibleTypes kc kis
reifyCxt :: [PredType] -> TcM [TH.Pred]
reifyCxt = mapM reifyPred
......
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeInType #-}
module Main where
import Data.Kind
import Language.Haskell.TH
type Id1 a = a
type Id2 k (a :: k) = a
data Proxy1 (a :: Id1 k) = Proxy1
data Proxy2 (a :: Id2 * k) = Proxy2
$(return [])
main :: IO ()
main = do
putStrLn $(reify ''Proxy1 >>= stringE . pprint)
putStrLn $(reify ''Proxy2 >>= stringE . pprint)
data Main.Proxy1 (a_0 :: Main.Id1 k_1) = Main.Proxy1
data Main.Proxy2 (a_0 :: Main.Id2 * k_1) = Main.Proxy2
......@@ -397,5 +397,6 @@ test('T10603', normal, compile, ['-ddump-splices -dsuppress-uniques'])
test('T11452', normal, compile_fail, ['-v0'])
test('T9022', normal, compile_and_run, ['-v0'])
test('T11145', normal, compile_fail, ['-v0 -dsuppress-uniques'])
test('T11463', normal, compile_and_run, ['-v0 -dsuppress-uniques'])
test('T11680', normal, compile_fail, ['-v0'])
test('T11809', normal, compile, ['-v0'])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment