diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-06-12 17:03:32 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-06-12 17:03:38 -0400 |
commit | 9a3ca8deb43626c2aee10eddc029880cd2c4b4da (patch) | |
tree | a7ede045964725015a1589d54654437ebaa43de3 /compiler | |
parent | 6ddb3aaf5265d15a422dbaeb5396c2c20acc9ff1 (diff) | |
download | haskell-9a3ca8deb43626c2aee10eddc029880cd2c4b4da.tar.gz |
Support signatures at the kind level in Template Haskell
`repNonArrowKind` was missing a case for `HsKindSig`, which this
commit adds. Fixes #13781.
Test Plan: make test TEST=T13781
Reviewers: goldfire, austin, bgamari
Reviewed By: goldfire
Subscribers: rwbarton, thomie
GHC Trac Issues: #13781
Differential Revision: https://phabricator.haskell.org/D3627
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/deSugar/DsMeta.hs | 13 | ||||
-rw-r--r-- | compiler/prelude/THNames.hs | 32 |
2 files changed, 32 insertions, 13 deletions
diff --git a/compiler/deSugar/DsMeta.hs b/compiler/deSugar/DsMeta.hs index f7f2fd597e..d23ac3894a 100644 --- a/compiler/deSugar/DsMeta.hs +++ b/compiler/deSugar/DsMeta.hs @@ -1069,6 +1069,12 @@ repTyLit (HsStrTy _ s) = do { s' <- mkStringExprFS s -- represent a kind -- +-- It would be great to scrap this function in favor of repLTy, since Types +-- and Kinds are the same things. We have not done so yet for engineering +-- reasons, as repLTy returns a monadic TypeQ, whereas repLKind returns a pure +-- Kind, so in order to replace repLKind with repLTy, we'd need to go through +-- and purify repLTy and every monadic function it calls. This is the subject +-- GHC Trac #11785. repLKind :: LHsKind GhcRn -> DsM (Core TH.Kind) repLKind ki = do { let (kis, ki') = splitHsFunType ki @@ -1109,6 +1115,10 @@ repNonArrowKind (HsTupleTy _ ks) = do { ks' <- mapM repLKind ks ; kcon <- repKTuple (length ks) ; repKApps kcon ks' } +repNonArrowKind (HsKindSig k sort) = do { k' <- repLKind k + ; sort' <- repLKind sort + ; repKSig k' sort' + } repNonArrowKind k = notHandled "Exotic form of kind" (ppr k) repRole :: Located (Maybe Role) -> DsM (Core TH.Role) @@ -2351,6 +2361,9 @@ repKStar = rep2 starKName [] repKConstraint :: DsM (Core TH.Kind) repKConstraint = rep2 constraintKName [] +repKSig :: Core TH.Kind -> Core TH.Kind -> DsM (Core TH.Kind) +repKSig (MkC k) (MkC sort) = rep2 sigTDataConName [k, sort] + ---------------------------------------------------------- -- Type family result signature diff --git a/compiler/prelude/THNames.hs b/compiler/prelude/THNames.hs index 1b9e624c67..9502e9e654 100644 --- a/compiler/prelude/THNames.hs +++ b/compiler/prelude/THNames.hs @@ -94,7 +94,7 @@ templateHaskellNames = [ -- Type forallTName, varTName, conTName, appTName, equalityTName, tupleTName, unboxedTupleTName, unboxedSumTName, - arrowTName, listTName, sigTName, litTName, + arrowTName, listTName, sigTName, sigTDataConName, litTName, promotedTName, promotedTupleTName, promotedNilTName, promotedConsTName, wildCardTName, -- TyLit @@ -428,9 +428,10 @@ recordPatSynName = libFun (fsLit "recordPatSyn") recordPatSynIdKey -- data Type = ... forallTName, varTName, conTName, tupleTName, unboxedTupleTName, - unboxedSumTName, arrowTName, listTName, appTName, sigTName, equalityTName, - litTName, promotedTName, promotedTupleTName, promotedNilTName, - promotedConsTName, wildCardTName :: Name + unboxedSumTName, arrowTName, listTName, appTName, sigTName, + sigTDataConName, equalityTName, litTName, promotedTName, + promotedTupleTName, promotedNilTName, promotedConsTName, + wildCardTName :: Name forallTName = libFun (fsLit "forallT") forallTIdKey varTName = libFun (fsLit "varT") varTIdKey conTName = libFun (fsLit "conT") conTIdKey @@ -441,6 +442,9 @@ arrowTName = libFun (fsLit "arrowT") arrowTIdKey listTName = libFun (fsLit "listT") listTIdKey appTName = libFun (fsLit "appT") appTIdKey sigTName = libFun (fsLit "sigT") sigTIdKey +-- Yes, we need names for both the monadic sigT as well as the pure SigT. Why? +-- Refer to the documentation for repLKind in DsMeta. +sigTDataConName = thCon (fsLit "SigT") sigTDataConKey equalityTName = libFun (fsLit "equalityT") equalityTIdKey litTName = libFun (fsLit "litT") litTIdKey promotedTName = libFun (fsLit "promotedT") promotedTIdKey @@ -947,8 +951,9 @@ recordPatSynIdKey = mkPreludeMiscIdUnique 372 -- data Type = ... forallTIdKey, varTIdKey, conTIdKey, tupleTIdKey, unboxedTupleTIdKey, unboxedSumTIdKey, arrowTIdKey, listTIdKey, appTIdKey, sigTIdKey, - equalityTIdKey, litTIdKey, promotedTIdKey, promotedTupleTIdKey, - promotedNilTIdKey, promotedConsTIdKey, wildCardTIdKey :: Unique + sigTDataConKey, equalityTIdKey, litTIdKey, promotedTIdKey, + promotedTupleTIdKey, promotedNilTIdKey, promotedConsTIdKey, + wildCardTIdKey :: Unique forallTIdKey = mkPreludeMiscIdUnique 381 varTIdKey = mkPreludeMiscIdUnique 382 conTIdKey = mkPreludeMiscIdUnique 383 @@ -959,13 +964,14 @@ arrowTIdKey = mkPreludeMiscIdUnique 387 listTIdKey = mkPreludeMiscIdUnique 388 appTIdKey = mkPreludeMiscIdUnique 389 sigTIdKey = mkPreludeMiscIdUnique 390 -equalityTIdKey = mkPreludeMiscIdUnique 391 -litTIdKey = mkPreludeMiscIdUnique 392 -promotedTIdKey = mkPreludeMiscIdUnique 393 -promotedTupleTIdKey = mkPreludeMiscIdUnique 394 -promotedNilTIdKey = mkPreludeMiscIdUnique 395 -promotedConsTIdKey = mkPreludeMiscIdUnique 396 -wildCardTIdKey = mkPreludeMiscIdUnique 397 +sigTDataConKey = mkPreludeMiscIdUnique 391 +equalityTIdKey = mkPreludeMiscIdUnique 392 +litTIdKey = mkPreludeMiscIdUnique 393 +promotedTIdKey = mkPreludeMiscIdUnique 394 +promotedTupleTIdKey = mkPreludeMiscIdUnique 395 +promotedNilTIdKey = mkPreludeMiscIdUnique 396 +promotedConsTIdKey = mkPreludeMiscIdUnique 397 +wildCardTIdKey = mkPreludeMiscIdUnique 398 -- data TyLit = ... numTyLitIdKey, strTyLitIdKey :: Unique |