summaryrefslogtreecommitdiff
path: root/compiler/hsSyn
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2017-11-12 21:56:16 +0200
committerAlan Zimmerman <alan.zimm@gmail.com>2017-11-14 23:14:49 +0200
commit47ad6578ea460999b53eb4293c3a3b3017a56d65 (patch)
tree32b57723605cdd983a4d1cc5968a62a3ea8f2dc8 /compiler/hsSyn
parentf57000014e5c27822c9c618204a7b3fe0cb0f158 (diff)
downloadhaskell-47ad6578ea460999b53eb4293c3a3b3017a56d65.tar.gz
TTG3 Combined Step 1 and 3 for Trees That Grow
Further progress on implementing Trees that Grow on hsSyn AST. See https://ghc.haskell.org/trac/ghc/wiki/ImplementingTreesThatGrow Trees that grow extension points are added for - Rest of HsExpr.hs Updates haddock submodule Test Plan: ./validate Reviewers: bgamari, shayan-najd, goldfire Subscribers: goldfire, rwbarton, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D4186
Diffstat (limited to 'compiler/hsSyn')
-rw-r--r--compiler/hsSyn/Convert.hs17
-rw-r--r--compiler/hsSyn/HsBinds.hs36
-rw-r--r--compiler/hsSyn/HsDecls.hs6
-rw-r--r--compiler/hsSyn/HsExpr.hs233
-rw-r--r--compiler/hsSyn/HsExtension.hs129
-rw-r--r--compiler/hsSyn/HsPat.hs2
-rw-r--r--compiler/hsSyn/HsTypes.hs14
-rw-r--r--compiler/hsSyn/HsUtils.hs46
-rw-r--r--compiler/hsSyn/PlaceHolder.hs10
9 files changed, 332 insertions, 161 deletions
diff --git a/compiler/hsSyn/Convert.hs b/compiler/hsSyn/Convert.hs
index c64ea53b1a..f20abab5b9 100644
--- a/compiler/hsSyn/Convert.hs
+++ b/compiler/hsSyn/Convert.hs
@@ -214,7 +214,7 @@ cvtDec (DataD ctxt tc tvs ksig constrs derivs)
; returnJustL $ TyClD (DataDecl { tcdLName = tc', tcdTyVars = tvs'
, tcdFixity = Prefix
, tcdDataDefn = defn
- , tcdDataCusk = PlaceHolder
+ , tcdDataCusk = placeHolder
, tcdFVs = placeHolderNames }) }
cvtDec (NewtypeD ctxt tc tvs ksig constr derivs)
@@ -230,7 +230,7 @@ cvtDec (NewtypeD ctxt tc tvs ksig constr derivs)
; returnJustL $ TyClD (DataDecl { tcdLName = tc', tcdTyVars = tvs'
, tcdFixity = Prefix
, tcdDataDefn = defn
- , tcdDataCusk = PlaceHolder
+ , tcdDataCusk = placeHolder
, tcdFVs = placeHolderNames }) }
cvtDec (ClassD ctxt cl tvs fds decs)
@@ -805,10 +805,12 @@ cvtl e = wrapL (cvt e)
-- Singleton tuples treated like nothing (just parens)
cvt (TupE es) = do { es' <- mapM cvtl es
; return $ ExplicitTuple noExt
- (map (noLoc . Present) es') Boxed }
+ (map (noLoc . (Present noExt)) es')
+ Boxed }
cvt (UnboxedTupE es) = do { es' <- mapM cvtl es
; return $ ExplicitTuple noExt
- (map (noLoc . Present) es') Unboxed }
+ (map (noLoc . (Present noExt)) es')
+ Unboxed }
cvt (UnboxedSumE e alt arity) = do { e' <- cvtl e
; unboxedSumChecks alt arity
; return $ ExplicitSum noExt
@@ -1000,8 +1002,9 @@ cvtStmt (TH.BindS p e) = do { p' <- cvtPat p; e' <- cvtl e; returnL $ mkBindStmt
cvtStmt (TH.LetS ds) = do { ds' <- cvtLocalDecs (text "a let binding") ds
; returnL $ LetStmt (noLoc ds') }
cvtStmt (TH.ParS dss) = do { dss' <- mapM cvt_one dss; returnL $ ParStmt dss' noExpr noSyntaxExpr placeHolderType }
- where
- cvt_one ds = do { ds' <- cvtStmts ds; return (ParStmtBlock ds' undefined noSyntaxExpr) }
+ where
+ cvt_one ds = do { ds' <- cvtStmts ds
+ ; return (ParStmtBlock noExt ds' undefined noSyntaxExpr) }
cvtMatch :: HsMatchContext RdrName
-> TH.Match -> CvtM (Hs.LMatch GhcPs (LHsExpr GhcPs))
@@ -1124,7 +1127,7 @@ cvtp (TildeP p) = do { p' <- cvtPat p; return $ LazyPat noExt p' }
cvtp (BangP p) = do { p' <- cvtPat p; return $ BangPat noExt p' }
cvtp (TH.AsP s p) = do { s' <- vNameL s; p' <- cvtPat p
; return $ AsPat noExt s' p' }
-cvtp TH.WildP = return $ WildPat placeHolderType
+cvtp TH.WildP = return $ WildPat noExt
cvtp (RecP c fs) = do { c' <- cNameL c; fs' <- mapM cvtPatFld fs
; return $ ConPatIn c'
$ Hs.RecCon (HsRecFields fs' Nothing) }
diff --git a/compiler/hsSyn/HsBinds.hs b/compiler/hsSyn/HsBinds.hs
index 9a106e3759..10e1307367 100644
--- a/compiler/hsSyn/HsBinds.hs
+++ b/compiler/hsSyn/HsBinds.hs
@@ -123,47 +123,13 @@ deriving instance (DataIdLR idL idR) => Data (HsValBindsLR idL idR)
-- ---------------------------------------------------------------------
-- Deal with ValBindsOut
+-- TODO: make this the only type for ValBinds
data NHsValBindsLR idL
= NValBinds
[(RecFlag, LHsBinds idL)]
[LSig GhcRn]
deriving instance (DataIdLR idL idL) => Data (NHsValBindsLR idL)
-{-
--- The ValBindsIn pattern exists so we can use the COMPLETE pragma for these
--- patterns
-pattern
- ValBindsIn ::
- (XValBinds idL idR) ->
- (LHsBindsLR idL idR) ->
- [LSig idR] ->
- HsValBindsLR idL idR
-pattern
- ValBindsOut ::
- [(RecFlag, LHsBinds idL)] ->
- [LSig GhcRn] ->
- HsValBindsLR idL idR
-
-pattern
- ValBindsIn x b s
- = ValBinds x b s
-pattern
- ValBindsOut a b
- = XValBindsLR (NValBindsOut a b)
-
-{-#
- COMPLETE
- ValBindsIn,
- ValBindsOut
- #-}
--}
-
--- This is not extensible using the parameterised GhcPass namespace
--- type instance
--- XValBinds (GhcPass pass) (GhcPass pass') = NoFieldExt
--- type instance
--- XNewValBindsLR (GhcPass pass) (GhcPass pass')
--- = NewHsValBindsLR (GhcPass pass) (GhcPass pass')
type instance XValBinds (GhcPass pL) (GhcPass pR) = PlaceHolder
type instance XXValBindsLR (GhcPass pL) (GhcPass pR)
= NHsValBindsLR (GhcPass pL)
diff --git a/compiler/hsSyn/HsDecls.hs b/compiler/hsSyn/HsDecls.hs
index 3641e27f98..9e05a3d1c1 100644
--- a/compiler/hsSyn/HsDecls.hs
+++ b/compiler/hsSyn/HsDecls.hs
@@ -101,7 +101,7 @@ import Name
import BasicTypes
import Coercion
import ForeignCall
-import PlaceHolder ( PlaceHolder(..) )
+import PlaceHolder ( PlaceHolder, placeHolder )
import HsExtension
import NameSet
@@ -1725,10 +1725,10 @@ deriving instance (DataIdLR pass pass) => Data (ForeignDecl pass)
-}
noForeignImportCoercionYet :: PlaceHolder
-noForeignImportCoercionYet = PlaceHolder
+noForeignImportCoercionYet = placeHolder
noForeignExportCoercionYet :: PlaceHolder
-noForeignExportCoercionYet = PlaceHolder
+noForeignExportCoercionYet = placeHolder
-- Specification Of an imported external entity in dependence on the calling
-- convention
diff --git a/compiler/hsSyn/HsExpr.hs b/compiler/hsSyn/HsExpr.hs
index 6fd4d0ec14..6b3440ae8b 100644
--- a/compiler/hsSyn/HsExpr.hs
+++ b/compiler/hsSyn/HsExpr.hs
@@ -744,7 +744,6 @@ data RecordUpdTc = RecordUpdTc
} deriving Data
-- ---------------------------------------------------------------------
-type instance XVarPat (GhcPass _) = PlaceHolder
type instance XVar (GhcPass _) = PlaceHolder
type instance XUnboundVar (GhcPass _) = PlaceHolder
@@ -861,13 +860,23 @@ type LHsTupArg id = Located (HsTupArg id)
-- | Haskell Tuple Argument
data HsTupArg id
- = Present (LHsExpr id) -- ^ The argument
- | Missing (PostTc id Type) -- ^ The argument is missing, but this is its type
+ = Present (XPresent id) (LHsExpr id) -- ^ The argument
+ | Missing (XMissing id) -- ^ The argument is missing, but this is its type
+ | XTupArg (XXTupArg id) -- ^ Note [Trees that Grow] extension point
deriving instance (DataIdLR id id) => Data (HsTupArg id)
+type instance XPresent (GhcPass _) = PlaceHolder
+
+type instance XMissing GhcPs = PlaceHolder
+type instance XMissing GhcRn = PlaceHolder
+type instance XMissing GhcTc = Type
+
+type instance XXTupArg (GhcPass _) = PlaceHolder
+
tupArgPresent :: LHsTupArg id -> Bool
tupArgPresent (L _ (Present {})) = True
tupArgPresent (L _ (Missing {})) = False
+tupArgPresent (L _ (XTupArg {})) = False
{-
Note [Parens in HsSyn]
@@ -1054,11 +1063,13 @@ ppr_expr (ExplicitTuple _ exprs boxity)
= tupleParens (boxityTupleSort boxity) (fcat (ppr_tup_args $ map unLoc exprs))
where
ppr_tup_args [] = []
- ppr_tup_args (Present e : es) = (ppr_lexpr e <> punc es) : ppr_tup_args es
- ppr_tup_args (Missing _ : es) = punc es : ppr_tup_args es
+ ppr_tup_args (Present _ e : es) = (ppr_lexpr e <> punc es) : ppr_tup_args es
+ ppr_tup_args (Missing _ : es) = punc es : ppr_tup_args es
+ ppr_tup_args (XTupArg x : es) = (ppr x <> punc es) : ppr_tup_args es
punc (Present {} : _) = comma <> space
punc (Missing {} : _) = comma
+ punc (XTupArg {} : _) = comma <> space
punc [] = empty
ppr_expr (ExplicitSum _ alt arity expr)
@@ -1149,8 +1160,10 @@ ppr_expr (HsRnBracketOut _ e ps) = ppr e $$ text "pending(rn)" <+> ppr ps
ppr_expr (HsTcBracketOut _ e []) = ppr e
ppr_expr (HsTcBracketOut _ e ps) = ppr e $$ text "pending(tc)" <+> ppr ps
-ppr_expr (HsProc _ pat (L _ (HsCmdTop cmd _ _ _)))
+ppr_expr (HsProc _ pat (L _ (HsCmdTop _ cmd)))
= hsep [text "proc", ppr pat, ptext (sLit "->"), ppr cmd]
+ppr_expr (HsProc _ pat (L _ (XCmdTop x)))
+ = hsep [text "proc", ppr pat, ptext (sLit "->"), ppr x]
ppr_expr (HsStatic _ e)
= hsep [text "static", ppr e]
@@ -1317,10 +1330,10 @@ data HsCmd id
-- For details on above see note [Api annotations] in ApiAnnotation
= HsCmdArrApp -- Arrow tail, or arrow application (f -< arg)
+ (XCmdArrApp id) -- type of the arrow expressions f,
+ -- of the form a t t', where arg :: t
(LHsExpr id) -- arrow expression, f
(LHsExpr id) -- input expression, arg
- (PostTc id Type) -- type of the arrow expressions f,
- -- of the form a t t', where arg :: t
HsArrAppType -- higher-order (-<<) or first-order (-<)
Bool -- True => right-to-left (f -< arg)
-- False => left-to-right (arg >- f)
@@ -1330,6 +1343,7 @@ data HsCmd id
-- For details on above see note [Api annotations] in ApiAnnotation
| HsCmdArrForm -- Command formation, (| e cmd1 .. cmdn |)
+ (XCmdArrForm id)
(LHsExpr id) -- The operator.
-- After type-checking, a type abstraction to be
-- applied to the type of the local environment tuple
@@ -1339,22 +1353,26 @@ data HsCmd id
-- were converted from OpApp's by the renamer
[LHsCmdTop id] -- argument commands
- | HsCmdApp (LHsCmd id)
+ | HsCmdApp (XCmdApp id)
+ (LHsCmd id)
(LHsExpr id)
- | HsCmdLam (MatchGroup id (LHsCmd id)) -- kappa
+ | HsCmdLam (XCmdLam id)
+ (MatchGroup id (LHsCmd id)) -- kappa
-- ^ - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnLam',
-- 'ApiAnnotation.AnnRarrow',
-- For details on above see note [Api annotations] in ApiAnnotation
- | HsCmdPar (LHsCmd id) -- parenthesised command
+ | HsCmdPar (XCmdPar id)
+ (LHsCmd id) -- parenthesised command
-- ^ - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnOpen' @'('@,
-- 'ApiAnnotation.AnnClose' @')'@
-- For details on above see note [Api annotations] in ApiAnnotation
- | HsCmdCase (LHsExpr id)
+ | HsCmdCase (XCmdCase id)
+ (LHsExpr id)
(MatchGroup id (LHsCmd id)) -- bodies are HsCmd's
-- ^ - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnCase',
-- 'ApiAnnotation.AnnOf','ApiAnnotation.AnnOpen' @'{'@,
@@ -1362,7 +1380,8 @@ data HsCmd id
-- For details on above see note [Api annotations] in ApiAnnotation
- | HsCmdIf (Maybe (SyntaxExpr id)) -- cond function
+ | HsCmdIf (XCmdIf id)
+ (Maybe (SyntaxExpr id)) -- cond function
(LHsExpr id) -- predicate
(LHsCmd id) -- then part
(LHsCmd id) -- else part
@@ -1373,7 +1392,8 @@ data HsCmd id
-- For details on above see note [Api annotations] in ApiAnnotation
- | HsCmdLet (LHsLocalBinds id) -- let(rec)
+ | HsCmdLet (XCmdLet id)
+ (LHsLocalBinds id) -- let(rec)
(LHsCmd id)
-- ^ - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnLet',
-- 'ApiAnnotation.AnnOpen' @'{'@,
@@ -1381,8 +1401,8 @@ data HsCmd id
-- For details on above see note [Api annotations] in ApiAnnotation
- | HsCmdDo (Located [CmdLStmt id])
- (PostTc id Type) -- Type of the whole expression
+ | HsCmdDo (XCmdDo id) -- Type of the whole expression
+ (Located [CmdLStmt id])
-- ^ - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnDo',
-- 'ApiAnnotation.AnnOpen', 'ApiAnnotation.AnnSemi',
-- 'ApiAnnotation.AnnVbar',
@@ -1390,12 +1410,33 @@ data HsCmd id
-- For details on above see note [Api annotations] in ApiAnnotation
- | HsCmdWrap HsWrapper
+ | HsCmdWrap (XCmdWrap id)
+ HsWrapper
(HsCmd id) -- If cmd :: arg1 --> res
-- wrap :: arg1 "->" arg2
-- Then (HsCmdWrap wrap cmd) :: arg2 --> res
+ | XCmd (XXCmd id) -- Note [Trees that Grow] extension point
deriving instance (DataIdLR id id) => Data (HsCmd id)
+type instance XCmdArrApp GhcPs = PlaceHolder
+type instance XCmdArrApp GhcRn = PlaceHolder
+type instance XCmdArrApp GhcTc = Type
+
+type instance XCmdArrForm (GhcPass _) = PlaceHolder
+type instance XCmdApp (GhcPass _) = PlaceHolder
+type instance XCmdLam (GhcPass _) = PlaceHolder
+type instance XCmdPar (GhcPass _) = PlaceHolder
+type instance XCmdCase (GhcPass _) = PlaceHolder
+type instance XCmdIf (GhcPass _) = PlaceHolder
+type instance XCmdLet (GhcPass _) = PlaceHolder
+
+type instance XCmdDo GhcPs = PlaceHolder
+type instance XCmdDo GhcRn = PlaceHolder
+type instance XCmdDo GhcTc = Type
+
+type instance XCmdWrap (GhcPass _) = PlaceHolder
+type instance XXCmd (GhcPass _) = PlaceHolder
+
-- | Haskell Array Application Type
data HsArrAppType = HsHigherOrderApp | HsFirstOrderApp
deriving Data
@@ -1411,12 +1452,23 @@ type LHsCmdTop p = Located (HsCmdTop p)
-- | Haskell Top-level Command
data HsCmdTop p
- = HsCmdTop (LHsCmd p)
- (PostTc p Type) -- Nested tuple of inputs on the command's stack
- (PostTc p Type) -- return type of the command
- (CmdSyntaxTable p) -- See Note [CmdSyntaxTable]
+ = HsCmdTop (XCmdTop p)
+ (LHsCmd p)
+ | XCmdTop (XXCmdTop p) -- Note [Trees that Grow] extension point
deriving instance (DataIdLR p p) => Data (HsCmdTop p)
+data CmdTopTc
+ = CmdTopTc Type -- Nested tuple of inputs on the command's stack
+ Type -- return type of the command
+ (CmdSyntaxTable GhcTc) -- See Note [CmdSyntaxTable]
+ deriving Data
+
+type instance XCmdTop GhcPs = PlaceHolder
+type instance XCmdTop GhcRn = CmdSyntaxTable GhcRn -- See Note [CmdSyntaxTable]
+type instance XCmdTop GhcTc = CmdTopTc
+
+type instance XXCmdTop (GhcPass _) = PlaceHolder
+
instance (SourceTextX (GhcPass p), OutputableBndrId (GhcPass p))
=> Outputable (HsCmd (GhcPass p)) where
ppr cmd = pprCmd cmd
@@ -1437,9 +1489,9 @@ isQuietHsCmd :: HsCmd id -> Bool
-- Parentheses do display something, but it gives little info and
-- if we go deeper when we go inside them then we get ugly things
-- like (...)
-isQuietHsCmd (HsCmdPar _) = True
+isQuietHsCmd (HsCmdPar {}) = True
-- applications don't display anything themselves
-isQuietHsCmd (HsCmdApp _ _) = True
+isQuietHsCmd (HsCmdApp {}) = True
isQuietHsCmd _ = False
-----------------------
@@ -1449,70 +1501,72 @@ ppr_lcmd c = ppr_cmd (unLoc c)
ppr_cmd :: forall p. (SourceTextX (GhcPass p), OutputableBndrId (GhcPass p))
=> HsCmd (GhcPass p) -> SDoc
-ppr_cmd (HsCmdPar c) = parens (ppr_lcmd c)
+ppr_cmd (HsCmdPar _ c) = parens (ppr_lcmd c)
-ppr_cmd (HsCmdApp c e)
+ppr_cmd (HsCmdApp _ c e)
= let (fun, args) = collect_args c [e] in
hang (ppr_lcmd fun) 2 (sep (map ppr args))
where
- collect_args (L _ (HsCmdApp fun arg)) args = collect_args fun (arg:args)
+ collect_args (L _ (HsCmdApp _ fun arg)) args = collect_args fun (arg:args)
collect_args fun args = (fun, args)
-ppr_cmd (HsCmdLam matches)
+ppr_cmd (HsCmdLam _ matches)
= pprMatches matches
-ppr_cmd (HsCmdCase expr matches)
+ppr_cmd (HsCmdCase _ expr matches)
= sep [ sep [text "case", nest 4 (ppr expr), ptext (sLit "of")],
nest 2 (pprMatches matches) ]
-ppr_cmd (HsCmdIf _ e ct ce)
+ppr_cmd (HsCmdIf _ _ e ct ce)
= sep [hsep [text "if", nest 2 (ppr e), ptext (sLit "then")],
nest 4 (ppr ct),
text "else",
nest 4 (ppr ce)]
-- special case: let ... in let ...
-ppr_cmd (HsCmdLet (L _ binds) cmd@(L _ (HsCmdLet _ _)))
+ppr_cmd (HsCmdLet _ (L _ binds) cmd@(L _ (HsCmdLet {})))
= sep [hang (text "let") 2 (hsep [pprBinds binds, ptext (sLit "in")]),
ppr_lcmd cmd]
-ppr_cmd (HsCmdLet (L _ binds) cmd)
+ppr_cmd (HsCmdLet _ (L _ binds) cmd)
= sep [hang (text "let") 2 (pprBinds binds),
hang (text "in") 2 (ppr cmd)]
-ppr_cmd (HsCmdDo (L _ stmts) _) = pprDo ArrowExpr stmts
+ppr_cmd (HsCmdDo _ (L _ stmts)) = pprDo ArrowExpr stmts
-ppr_cmd (HsCmdWrap w cmd)
+ppr_cmd (HsCmdWrap _ w cmd)
= pprHsWrapper w (\_ -> parens (ppr_cmd cmd))
-ppr_cmd (HsCmdArrApp arrow arg _ HsFirstOrderApp True)
+ppr_cmd (HsCmdArrApp _ arrow arg HsFirstOrderApp True)
= hsep [ppr_lexpr arrow, larrowt, ppr_lexpr arg]
-ppr_cmd (HsCmdArrApp arrow arg _ HsFirstOrderApp False)
+ppr_cmd (HsCmdArrApp _ arrow arg HsFirstOrderApp False)
= hsep [ppr_lexpr arg, arrowt, ppr_lexpr arrow]
-ppr_cmd (HsCmdArrApp arrow arg _ HsHigherOrderApp True)
+ppr_cmd (HsCmdArrApp _ arrow arg HsHigherOrderApp True)
= hsep [ppr_lexpr arrow, larrowtt, ppr_lexpr arg]
-ppr_cmd (HsCmdArrApp arrow arg _ HsHigherOrderApp False)
+ppr_cmd (HsCmdArrApp _ arrow arg HsHigherOrderApp False)
= hsep [ppr_lexpr arg, arrowtt, ppr_lexpr arrow]
-ppr_cmd (HsCmdArrForm (L _ (HsVar _ (L _ v))) _ (Just _) [arg1, arg2])
+ppr_cmd (HsCmdArrForm _ (L _ (HsVar _ (L _ v))) _ (Just _) [arg1, arg2])
= hang (pprCmdArg (unLoc arg1)) 4 (sep [ pprInfixOcc v
, pprCmdArg (unLoc arg2)])
-ppr_cmd (HsCmdArrForm (L _ (HsVar _ (L _ v))) Infix _ [arg1, arg2])
+ppr_cmd (HsCmdArrForm _ (L _ (HsVar _ (L _ v))) Infix _ [arg1, arg2])
= hang (pprCmdArg (unLoc arg1)) 4 (sep [ pprInfixOcc v
, pprCmdArg (unLoc arg2)])
-ppr_cmd (HsCmdArrForm (L _ (HsConLikeOut _ c)) _ (Just _) [arg1, arg2])
+ppr_cmd (HsCmdArrForm _ (L _ (HsConLikeOut _ c)) _ (Just _) [arg1, arg2])
= hang (pprCmdArg (unLoc arg1)) 4 (sep [ pprInfixOcc (conLikeName c)
, pprCmdArg (unLoc arg2)])
-ppr_cmd (HsCmdArrForm (L _ (HsConLikeOut _ c)) Infix _ [arg1, arg2])
+ppr_cmd (HsCmdArrForm _ (L _ (HsConLikeOut _ c)) Infix _ [arg1, arg2])
= hang (pprCmdArg (unLoc arg1)) 4 (sep [ pprInfixOcc (conLikeName c)
, pprCmdArg (unLoc arg2)])
-ppr_cmd (HsCmdArrForm op _ _ args)
+ppr_cmd (HsCmdArrForm _ op _ _ args)
= hang (text "(|" <> ppr_lexpr op)
4 (sep (map (pprCmdArg.unLoc) args) <> text "|)")
+ppr_cmd (XCmd x) = ppr x
pprCmdArg :: (SourceTextX (GhcPass p), OutputableBndrId (GhcPass p))
=> HsCmdTop (GhcPass p) -> SDoc
-pprCmdArg (HsCmdTop cmd _ _ _)
+pprCmdArg (HsCmdTop _ cmd)
= ppr_lcmd cmd
+pprCmdArg (XCmdTop x) = ppr x
instance (SourceTextX (GhcPass p), OutputableBndrId (GhcPass p))
=> Outputable (HsCmdTop (GhcPass p)) where
@@ -1551,6 +1605,7 @@ a function defined by pattern matching must have the same number of
patterns in each equation.
-}
+-- AZ:TODO complete TTG on this, once DataId etc is resolved
data MatchGroup p body
= MG { mg_alts :: Located [LMatch p body] -- The alternatives
, mg_arg_tys :: [PostTc p Type] -- Types of the arguments, t1..tn
@@ -1566,6 +1621,7 @@ type LMatch id body = Located (Match id body)
-- ^ May have 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnSemi' when in a
-- list
+-- AZ:TODO complete TTG on this, once DataId etc is resolved
-- For details on above see note [Api annotations] in ApiAnnotation
data Match p body
= Match {
@@ -1654,6 +1710,7 @@ hsLMatchPats (L _ (Match { m_pats = pats })) = pats
-- 'ApiAnnotation.AnnOpen','ApiAnnotation.AnnClose'
-- 'ApiAnnotation.AnnRarrow','ApiAnnotation.AnnSemi'
+-- AZ:TODO complete TTG on this, once DataId etc is resolved
-- For details on above see note [Api annotations] in ApiAnnotation
data GRHSs p body
= GRHSs {
@@ -1665,6 +1722,7 @@ deriving instance (Data body,DataIdLR p p) => Data (GRHSs p body)
-- | Located Guarded Right-Hand Side
type LGRHS id body = Located (GRHS id body)
+-- AZ:TODO complete TTG on this, once DataId etc is resolved
-- | Guarded Right Hand Side.
data GRHS id body = GRHS [GuardLStmt id] -- Guards
body -- Right hand side
@@ -1937,11 +1995,16 @@ data TransForm -- The 'f' below is the 'using' function, 'e' is the by functio
-- | Parenthesised Statement Block
data ParStmtBlock idL idR
= ParStmtBlock
+ (XParStmtBlock idL idR)
[ExprLStmt idL]
[IdP idR] -- The variables to be returned
(SyntaxExpr idR) -- The return operator
+ | XParStmtBlock (XXParStmtBlock idL idR)
deriving instance (DataIdLR idL idR) => Data (ParStmtBlock idL idR)
+type instance XParStmtBlock (GhcPass pL) (GhcPass pR) = PlaceHolder
+type instance XXParStmtBlock (GhcPass pL) (GhcPass pR) = PlaceHolder
+
-- | Applicative Argument
data ApplicativeArg idL
= ApplicativeArgOne -- A single statement (BindStmt or BodyStmt)
@@ -2122,9 +2185,11 @@ Bool flag that is True when the original statement was a BodyStmt, so
that we can pretty-print it correctly.
-}
-instance (SourceTextX (GhcPass idL), OutputableBndrId (GhcPass idL))
+instance (SourceTextX (GhcPass idL), OutputableBndrId (GhcPass idL),
+ Outputable (XXParStmtBlock (GhcPass idL) idR))
=> Outputable (ParStmtBlock (GhcPass idL) idR) where
- ppr (ParStmtBlock stmts _ _) = interpp'SP stmts
+ ppr (ParStmtBlock _ stmts _ _) = interpp'SP stmts
+ ppr (XParStmtBlock x) = ppr x
instance (SourceTextX (GhcPass idL), SourceTextX (GhcPass idR),
OutputableBndrId (GhcPass idL), OutputableBndrId (GhcPass idR),
@@ -2277,31 +2342,45 @@ pprQuals quals = interpp'SP quals
-- | Haskell Splice
data HsSplice id
= HsTypedSplice -- $$z or $$(f 4)
+ (XTypedSplice id)
SpliceDecoration -- Whether $$( ) variant found, for pretty printing
(IdP id) -- A unique name to identify this splice point
(LHsExpr id) -- See Note [Pending Splices]
| HsUntypedSplice -- $z or $(f 4)
+ (XUntypedSplice id)
SpliceDecoration -- Whether $( ) variant found, for pretty printing
(IdP id) -- A unique name to identify this splice point
(LHsExpr id) -- See Note [Pending Splices]
| HsQuasiQuote -- See Note [Quasi-quote overview] in TcSplice
+ (XQuasiQuote id)
(IdP id) -- Splice point
(IdP id) -- Quoter
SrcSpan -- The span of the enclosed string
FastString -- The enclosed string
+ -- AZ:TODO: use XSplice instead of HsSpliced
| HsSpliced -- See Note [Delaying modFinalizers in untyped splices] in
-- RnSplice.
-- This is the result of splicing a splice. It is produced by
-- the renamer and consumed by the typechecker. It lives only
-- between the two.
+ (XSpliced id)
ThModFinalizers -- TH finalizers produced by the splice.
(HsSplicedThing id) -- The result of splicing
+ | XSplice (XXSplice id) -- Note [Trees that Grow] extension point
deriving Typeable
deriving instance (DataIdLR id id) => Data (HsSplice id)
+
+type instance XTypedSplice (GhcPass _) = PlaceHolder
+type instance XUntypedSplice (GhcPass _) = PlaceHolder
+type instance XQuasiQuote (GhcPass _) = PlaceHolder
+type instance XSpliced (GhcPass _) = PlaceHolder
+type instance XXSplice (GhcPass _) = PlaceHolder
+
+
-- | A splice can appear with various decorations wrapped around it. This data
-- type captures explicitly how it was originally written, for use in the pretty
-- printer.
@@ -2452,25 +2531,26 @@ pprSpliceDecl e ImplicitSplice = ppr_splice_decl e
ppr_splice_decl :: (SourceTextX (GhcPass p), OutputableBndrId (GhcPass p))
=> HsSplice (GhcPass p) -> SDoc
-ppr_splice_decl (HsUntypedSplice _ n e) = ppr_splice empty n e empty
+ppr_splice_decl (HsUntypedSplice _ _ n e) = ppr_splice empty n e empty
ppr_splice_decl e = pprSplice e
pprSplice :: (SourceTextX (GhcPass p), OutputableBndrId (GhcPass p))
=> HsSplice (GhcPass p) -> SDoc
-pprSplice (HsTypedSplice HasParens n e)
+pprSplice (HsTypedSplice _ HasParens n e)
= ppr_splice (text "$$(") n e (text ")")
-pprSplice (HsTypedSplice HasDollar n e)
+pprSplice (HsTypedSplice _ HasDollar n e)
= ppr_splice (text "$$") n e empty
-pprSplice (HsTypedSplice NoParens n e)
+pprSplice (HsTypedSplice _ NoParens n e)
= ppr_splice empty n e empty
-pprSplice (HsUntypedSplice HasParens n e)
+pprSplice (HsUntypedSplice _ HasParens n e)
= ppr_splice (text "$(") n e (text ")")
-pprSplice (HsUntypedSplice HasDollar n e)
+pprSplice (HsUntypedSplice _ HasDollar n e)
= ppr_splice (text "$") n e empty
-pprSplice (HsUntypedSplice NoParens n e)
+pprSplice (HsUntypedSplice _ NoParens n e)
= ppr_splice empty n e empty
-pprSplice (HsQuasiQuote n q _ s) = ppr_quasi n q s
-pprSplice (HsSpliced _ thing) = ppr thing
+pprSplice (HsQuasiQuote _ n q _ s) = ppr_quasi n q s
+pprSplice (HsSpliced _ _ thing) = ppr thing
+pprSplice (XSplice x) = ppr x
ppr_quasi :: OutputableBndr p => p -> p -> FastString -> SDoc
ppr_quasi n quoter quote = whenPprDebug (brackets (ppr n)) <>
@@ -2483,16 +2563,27 @@ ppr_splice herald n e trail
= herald <> whenPprDebug (brackets (ppr n)) <> ppr e <> trail
-- | Haskell Bracket
-data HsBracket p = ExpBr (LHsExpr p) -- [| expr |]
- | PatBr (LPat p) -- [p| pat |]
- | DecBrL [LHsDecl p] -- [d| decls |]; result of parser
- | DecBrG (HsGroup p) -- [d| decls |]; result of renamer
- | TypBr (LHsType p) -- [t| type |]
- | VarBr Bool (IdP p) -- True: 'x, False: ''T
- -- (The Bool flag is used only in pprHsBracket)
- | TExpBr (LHsExpr p) -- [|| expr ||]
+data HsBracket p
+ = ExpBr (XExpBr p) (LHsExpr p) -- [| expr |]
+ | PatBr (XPatBr p) (LPat p) -- [p| pat |]
+ | DecBrL (XDecBrL p) [LHsDecl p] -- [d| decls |]; result of parser
+ | DecBrG (XDecBrG p) (HsGroup p) -- [d| decls |]; result of renamer
+ | TypBr (XTypBr p) (LHsType p) -- [t| type |]
+ | VarBr (XVarBr p) Bool (IdP p) -- True: 'x, False: ''T
+ -- (The Bool flag is used only in pprHsBracket)
+ | TExpBr (XTExpBr p) (LHsExpr p) -- [|| expr ||]
+ | XBracket (XXBracket p) -- Note [Trees that Grow] extension point
deriving instance (DataIdLR p p) => Data (HsBracket p)
+type instance XExpBr (GhcPass _) = PlaceHolder
+type instance XPatBr (GhcPass _) = PlaceHolder
+type instance XDecBrL (GhcPass _) = PlaceHolder
+type instance XDecBrG (GhcPass _) = PlaceHolder
+type instance XTypBr (GhcPass _) = PlaceHolder
+type instance XVarBr (GhcPass _) = PlaceHolder
+type instance XTExpBr (GhcPass _) = PlaceHolder
+type instance XXBracket (GhcPass _) = PlaceHolder
+
isTypedBracket :: HsBracket id -> Bool
isTypedBracket (TExpBr {}) = True
isTypedBracket _ = False
@@ -2504,16 +2595,17 @@ instance (SourceTextX (GhcPass p), OutputableBndrId (GhcPass p))
pprHsBracket :: (SourceTextX (GhcPass p), OutputableBndrId (GhcPass p))
=> HsBracket (GhcPass p) -> SDoc
-pprHsBracket (ExpBr e) = thBrackets empty (ppr e)
-pprHsBracket (PatBr p) = thBrackets (char 'p') (ppr p)
-pprHsBracket (DecBrG gp) = thBrackets (char 'd') (ppr gp)
-pprHsBracket (DecBrL ds) = thBrackets (char 'd') (vcat (map ppr ds))
-pprHsBracket (TypBr t) = thBrackets (char 't') (ppr t)
-pprHsBracket (VarBr True n)
+pprHsBracket (ExpBr _ e) = thBrackets empty (ppr e)
+pprHsBracket (PatBr _ p) = thBrackets (char 'p') (ppr p)
+pprHsBracket (DecBrG _ gp) = thBrackets (char 'd') (ppr gp)
+pprHsBracket (DecBrL _ ds) = thBrackets (char 'd') (vcat (map ppr ds))
+pprHsBracket (TypBr _ t) = thBrackets (char 't') (ppr t)
+pprHsBracket (VarBr _ True n)
= char '\'' <> pprPrefixOcc n
-pprHsBracket (VarBr False n)
+pprHsBracket (VarBr _ False n)
= text "''" <> pprPrefixOcc n
-pprHsBracket (TExpBr e) = thTyBrackets (ppr e)
+pprHsBracket (TExpBr _ e) = thTyBrackets (ppr e)
+pprHsBracket (XBracket e) = ppr e
thBrackets :: SDoc -> SDoc -> SDoc
thBrackets pp_kind pp_body = char '[' <> pp_kind <> vbar <+>
@@ -2547,6 +2639,7 @@ data ArithSeqInfo id
(LHsExpr id)
(LHsExpr id)
deriving instance (DataIdLR id id) => Data (ArithSeqInfo id)
+-- AZ: Sould ArithSeqInfo have a TTG extension?
instance (SourceTextX (GhcPass p), OutputableBndrId (GhcPass p))
=> Outputable (ArithSeqInfo (GhcPass p)) where
diff --git a/compiler/hsSyn/HsExtension.hs b/compiler/hsSyn/HsExtension.hs
index fb689c56d2..86a0bd9431 100644
--- a/compiler/hsSyn/HsExtension.hs
+++ b/compiler/hsSyn/HsExtension.hs
@@ -149,7 +149,7 @@ type ForallXPat (c :: * -> Constraint) (x :: *) =
type family XValBinds x x'
type family XXValBindsLR x x'
-type ForallXValBindsLR (c :: * -> Constraint) (x :: *) (x' :: *)=
+type ForallXValBindsLR (c :: * -> Constraint) (x :: *) (x' :: *) =
( c (XValBinds x x')
, c (XXValBindsLR x x')
)
@@ -410,6 +410,104 @@ type ForallXExpr (c :: * -> Constraint) (x :: *) =
)
-- ---------------------------------------------------------------------
+type family XPresent x
+type family XMissing x
+type family XXTupArg x
+
+type ForallXTupArg (c :: * -> Constraint) (x :: *) =
+ ( c (XPresent x)
+ , c (XMissing x)
+ , c (XXTupArg x)
+ )
+
+-- ---------------------------------------------------------------------
+
+type family XTypedSplice x
+type family XUntypedSplice x
+type family XQuasiQuote x
+type family XSpliced x
+type family XXSplice x
+
+type ForallXSplice (c :: * -> Constraint) (x :: *) =
+ ( c (XTypedSplice x)
+ , c (XUntypedSplice x)
+ , c (XQuasiQuote x)
+ , c (XSpliced x)
+ , c (XXSplice x)
+ )
+
+-- ---------------------------------------------------------------------
+
+type family XExpBr x
+type family XPatBr x
+type family XDecBrL x
+type family XDecBrG x
+type family XTypBr x
+type family XVarBr x
+type family XTExpBr x
+type family XXBracket x
+
+type ForallXBracket (c :: * -> Constraint) (x :: *) =
+ ( c (XExpBr x)
+ , c (XPatBr x)
+ , c (XDecBrL x)
+ , c (XDecBrG x)
+ , c (XTypBr x)
+ , c (XVarBr x)
+ , c (XTExpBr x)
+ , c (XXBracket x)
+ )
+
+-- ---------------------------------------------------------------------
+
+type family XCmdTop x
+type family XXCmdTop x
+
+type ForallXCmdTop (c :: * -> Constraint) (x :: *) =
+ ( c (XCmdTop x)
+ , c (XXCmdTop x)
+ )
+
+-- ---------------------------------------------------------------------
+
+type family XCmdArrApp x
+type family XCmdArrForm x
+type family XCmdApp x
+type family XCmdLam x
+type family XCmdPar x
+type family XCmdCase x
+type family XCmdIf x
+type family XCmdLet x
+type family XCmdDo x
+type family XCmdWrap x
+type family XXCmd x
+
+type ForallXCmd (c :: * -> Constraint) (x :: *) =
+ ( c (XCmdArrApp x)
+ , c (XCmdArrForm x)
+ , c (XCmdApp x)
+ , c (XCmdLam x)
+ , c (XCmdPar x)
+ , c (XCmdCase x)
+ , c (XCmdIf x)
+ , c (XCmdLet x)
+ , c (XCmdDo x)
+ , c (XCmdWrap x)
+ , c (XXCmd x)
+ )
+
+-- ---------------------------------------------------------------------
+
+type family XParStmtBlock x x'
+type family XXParStmtBlock x x'
+
+type ForallXParStmtBlock (c :: * -> Constraint) (x :: *) (x' :: *) =
+ ( c (XParStmtBlock x x')
+ , c (XXParStmtBlock x x')
+ )
+
+-- ---------------------------------------------------------------------
+
-- | The 'SourceText' fields have been moved into the extension fields, thus
-- placing a requirement in the extension field to contain a 'SourceText' so
-- that the pretty printing and round tripping of source can continue to
@@ -501,6 +599,8 @@ type OutputableX p =
, Outputable (XAppTypeE p)
, Outputable (XAppTypeE GhcRn)
+
+ -- , Outputable (XXParStmtBlock (GhcPass idL) idR)
)
-- TODO: Should OutputableX be included in OutputableBndrId?
@@ -513,12 +613,15 @@ type DataId p =
, ForallXHsLit Data p
, ForallXPat Data p
- -- AZ: The following ForAllXXXX shoulbe be unnecessary? Driven by ValBindsOut
- -- , ForallXPat Data (GhcPass 'Parsed)
- , ForallXPat Data (GhcPass 'Renamed)
- -- , ForallXPat Data (GhcPass 'Typechecked)
- , ForallXType Data (GhcPass 'Renamed)
- , ForallXExpr Data (GhcPass 'Renamed)
+ -- Th following GhcRn constraints should go away once TTG is fully implemented
+ , ForallXPat Data GhcRn
+ , ForallXType Data GhcRn
+ , ForallXExpr Data GhcRn
+ , ForallXTupArg Data GhcRn
+ , ForallXSplice Data GhcRn
+ , ForallXBracket Data GhcRn
+ , ForallXCmdTop Data GhcRn
+ , ForallXCmd Data GhcRn
, ForallXOverLit Data p
, ForallXType Data p
@@ -527,7 +630,12 @@ type DataId p =
, ForallXFieldOcc Data p
, ForallXAmbiguousFieldOcc Data p
- , ForallXExpr Data p
+ , ForallXExpr Data p
+ , ForallXTupArg Data p
+ , ForallXSplice Data p
+ , ForallXBracket Data p
+ , ForallXCmdTop Data p
+ , ForallXCmd Data p
, Data (NameOrRdrName (IdP p))
@@ -554,6 +662,11 @@ type DataIdLR pL pR =
, ForallXValBindsLR Data pL pR
, ForallXValBindsLR Data pL pL
, ForallXValBindsLR Data pR pR
+
+ , ForallXParStmtBlock Data pL pR
+ , ForallXParStmtBlock Data pL pL
+ , ForallXParStmtBlock Data pR pR
+ , ForallXParStmtBlock Data GhcRn GhcRn
)
-- |Constraint type to bundle up the requirement for 'OutputableBndr' on both
diff --git a/compiler/hsSyn/HsPat.hs b/compiler/hsSyn/HsPat.hs
index 71f932c2e6..863f00c99b 100644
--- a/compiler/hsSyn/HsPat.hs
+++ b/compiler/hsSyn/HsPat.hs
@@ -602,7 +602,7 @@ mkNilPat ty = mkPrefixConPat nilDataCon [] [ty]
mkCharLitPat :: (SourceTextX (GhcPass p))
=> SourceText -> Char -> OutPat (GhcPass p)
mkCharLitPat src c = mkPrefixConPat charDataCon
- [noLoc $ LitPat PlaceHolder
+ [noLoc $ LitPat noExt
(HsCharPrim (setSourceText src) c)]
[]
diff --git a/compiler/hsSyn/HsTypes.hs b/compiler/hsSyn/HsTypes.hs
index d9c1b46d0e..be70fe8ec8 100644
--- a/compiler/hsSyn/HsTypes.hs
+++ b/compiler/hsSyn/HsTypes.hs
@@ -74,7 +74,7 @@ import GhcPrelude
import {-# SOURCE #-} HsExpr ( HsSplice, pprSplice )
-import PlaceHolder ( PlaceHolder(..) )
+import PlaceHolder ( PlaceHolder, placeHolder )
import HsExtension
import HsLit () -- for instances
@@ -275,8 +275,8 @@ data LHsQTyVars pass -- See Note [HsType binders]
deriving instance (DataIdLR pass pass) => Data (LHsQTyVars pass)
mkHsQTvs :: [LHsTyVarBndr GhcPs] -> LHsQTyVars GhcPs
-mkHsQTvs tvs = HsQTvs { hsq_implicit = PlaceHolder, hsq_explicit = tvs
- , hsq_dependent = PlaceHolder }
+mkHsQTvs tvs = HsQTvs { hsq_implicit = placeHolder, hsq_explicit = tvs
+ , hsq_dependent = placeHolder }
hsQTvExplicit :: LHsQTyVars pass -> [LHsTyVarBndr pass]
hsQTvExplicit = hsq_explicit
@@ -366,12 +366,12 @@ the explicitly forall'd tyvar 'a' is bound by the HsForAllTy
mkHsImplicitBndrs :: thing -> HsImplicitBndrs GhcPs thing
mkHsImplicitBndrs x = HsIB { hsib_body = x
- , hsib_vars = PlaceHolder
- , hsib_closed = PlaceHolder }
+ , hsib_vars = placeHolder
+ , hsib_closed = placeHolder }
mkHsWildCardBndrs :: thing -> HsWildCardBndrs GhcPs thing
mkHsWildCardBndrs x = HsWC { hswc_body = x
- , hswc_wcs = PlaceHolder }
+ , hswc_wcs = placeHolder }
-- Add empty binders. This is a bit suspicious; what if
-- the wrapped thing had free type variables?
@@ -1223,7 +1223,7 @@ instance Outputable (FieldOcc pass) where
ppr = ppr . rdrNameFieldOcc
mkFieldOcc :: Located RdrName -> FieldOcc GhcPs
-mkFieldOcc rdr = FieldOcc PlaceHolder rdr
+mkFieldOcc rdr = FieldOcc placeHolder rdr
-- | Ambiguous Field Occurrence
diff --git a/compiler/hsSyn/HsUtils.hs b/compiler/hsSyn/HsUtils.hs
index edd5da674c..e5f0fb6187 100644
--- a/compiler/hsSyn/HsUtils.hs
+++ b/compiler/hsSyn/HsUtils.hs
@@ -50,7 +50,7 @@ module HsUtils(
-- Patterns
mkNPat, mkNPlusKPat, nlVarPat, nlLitPat, nlConVarPat, nlConVarPatName, nlConPat,
nlConPatName, nlInfixConPat, nlNullaryConPat, nlWildConPat, nlWildPat,
- nlWildPatName, nlWildPatId, nlTuplePat, mkParPat, nlParPat,
+ nlWildPatName, nlTuplePat, mkParPat, nlParPat,
mkBigLHsVarTup, mkBigLHsTup, mkBigLHsVarPatTup, mkBigLHsPatTup,
-- Types
@@ -219,7 +219,7 @@ mkLHsPar le@(L loc e) | hsExprNeedsParens e = L loc (HsPar noExt le)
| otherwise = le
mkParPat :: LPat (GhcPass name) -> LPat (GhcPass name)
-mkParPat lp@(L loc p) | hsPatNeedsParens p = L loc (ParPat PlaceHolder lp)
+mkParPat lp@(L loc p) | hsPatNeedsParens p = L loc (ParPat noExt lp)
| otherwise = lp
nlParPat :: LPat (GhcPass name) -> LPat (GhcPass name)
@@ -263,7 +263,7 @@ mkHsFractional f = OverLit noExt (HsFractional f) noExpr
mkHsIsString src s = OverLit noExt (HsIsString src s) noExpr
noRebindableInfo :: PlaceHolder
-noRebindableInfo = PlaceHolder -- Just another placeholder;
+noRebindableInfo = placeHolder -- Just another placeholder;
mkHsDo ctxt stmts = HsDo noExt ctxt (mkLocatedList stmts)
mkHsComp ctxt stmts expr = mkHsDo ctxt (stmts ++ [last_stmt])
@@ -305,7 +305,7 @@ emptyTransStmt = TransStmt { trS_form = panic "emptyTransStmt: form"
, trS_stmts = [], trS_bndrs = []
, trS_by = Nothing, trS_using = noLoc noExpr
, trS_ret = noSyntaxExpr, trS_bind = noSyntaxExpr
- , trS_bind_arg_ty = PlaceHolder
+ , trS_bind_arg_ty = placeHolder
, trS_fmap = noExpr }
mkTransformStmt ss u = emptyTransStmt { trS_form = ThenForm, trS_stmts = ss, trS_using = u }
mkTransformByStmt ss u b = emptyTransStmt { trS_form = ThenForm, trS_stmts = ss, trS_using = u, trS_by = Just b }
@@ -314,7 +314,7 @@ mkGroupByUsingStmt ss b u = emptyTransStmt { trS_form = GroupForm, trS_stmts = s
mkLastStmt body = LastStmt body False noSyntaxExpr
mkBodyStmt body = BodyStmt body noSyntaxExpr noSyntaxExpr placeHolderType
-mkBindStmt pat body = BindStmt pat body noSyntaxExpr noSyntaxExpr PlaceHolder
+mkBindStmt pat body = BindStmt pat body noSyntaxExpr noSyntaxExpr placeHolder
mkTcBindStmt pat body = BindStmt pat body noSyntaxExpr noSyntaxExpr unitTy
-- don't use placeHolderTypeTc above, because that panics during zonking
@@ -345,21 +345,22 @@ unqualSplice :: RdrName
unqualSplice = mkRdrUnqual (mkVarOccFS (fsLit "splice"))
mkUntypedSplice :: SpliceDecoration -> LHsExpr GhcPs -> HsSplice GhcPs
-mkUntypedSplice hasParen e = HsUntypedSplice hasParen unqualSplice e
+mkUntypedSplice hasParen e = HsUntypedSplice noExt hasParen unqualSplice e
mkHsSpliceE :: SpliceDecoration -> LHsExpr GhcPs -> HsExpr GhcPs
mkHsSpliceE hasParen e = HsSpliceE noExt (mkUntypedSplice hasParen e)
mkHsSpliceTE :: SpliceDecoration -> LHsExpr GhcPs -> HsExpr GhcPs
mkHsSpliceTE hasParen e
- = HsSpliceE noExt (HsTypedSplice hasParen unqualSplice e)
+ = HsSpliceE noExt (HsTypedSplice noExt hasParen unqualSplice e)
mkHsSpliceTy :: SpliceDecoration -> LHsExpr GhcPs -> HsType GhcPs
mkHsSpliceTy hasParen e = HsSpliceTy noExt
- (HsUntypedSplice hasParen unqualSplice e)
+ (HsUntypedSplice noExt hasParen unqualSplice e)
mkHsQuasiQuote :: RdrName -> SrcSpan -> FastString -> HsSplice GhcPs
-mkHsQuasiQuote quoter span quote = HsQuasiQuote unqualSplice quoter span quote
+mkHsQuasiQuote quoter span quote
+ = HsQuasiQuote noExt unqualSplice quoter span quote
unqualQuasiQuote :: RdrName
unqualQuasiQuote = mkRdrUnqual (mkVarOccFS (fsLit "quasiquote"))
@@ -461,13 +462,10 @@ nlWildConPat con = noLoc (ConPatIn (noLoc (getRdrName con))
nlWildPat)))
nlWildPat :: LPat GhcPs
-nlWildPat = noLoc (WildPat placeHolderType ) -- Pre-typechecking
+nlWildPat = noLoc (WildPat noExt ) -- Pre-typechecking
nlWildPatName :: LPat GhcRn
-nlWildPatName = noLoc (WildPat placeHolderType ) -- Pre-typechecking
-
-nlWildPatId :: LPat GhcTc
-nlWildPatId = noLoc (WildPat placeHolderTypeTc ) -- Post-typechecking
+nlWildPatName = noLoc (WildPat noExt ) -- Pre-typechecking
nlHsDo :: HsStmtContext Name -> [LStmt GhcPs (LHsExpr GhcPs)]
-> LHsExpr GhcPs
@@ -517,7 +515,8 @@ types on the tuple.
mkLHsTupleExpr :: [LHsExpr (GhcPass a)] -> LHsExpr (GhcPass a)
-- Makes a pre-typechecker boxed tuple, deals with 1 case
mkLHsTupleExpr [e] = e
-mkLHsTupleExpr es = noLoc $ ExplicitTuple noExt (map (noLoc . Present) es) Boxed
+mkLHsTupleExpr es
+ = noLoc $ ExplicitTuple noExt (map (noLoc . (Present noExt)) es) Boxed
mkLHsVarTuple :: [IdP (GhcPass a)] -> LHsExpr (GhcPass a)
mkLHsVarTuple ids = mkLHsTupleExpr (map nlHsVar ids)
@@ -526,7 +525,7 @@ nlTuplePat :: [LPat GhcPs] -> Boxity -> LPat GhcPs
nlTuplePat pats box = noLoc (TuplePat noExt pats box)
missingTupArg :: HsTupArg GhcPs
-missingTupArg = Missing placeHolderType
+missingTupArg = Missing noExt
mkLHsPatTup :: [LPat GhcRn] -> LPat GhcRn
mkLHsPatTup [] = noLoc $ TuplePat noExt [] Boxed
@@ -704,11 +703,11 @@ mkHsWrapCoR co e = mkHsWrap (mkWpCastR co) e
mkLHsWrapCo :: TcCoercionN -> LHsExpr (GhcPass id) -> LHsExpr (GhcPass id)
mkLHsWrapCo co (L loc e) = L loc (mkHsWrapCo co e)
-mkHsCmdWrap :: HsWrapper -> HsCmd id -> HsCmd id
+mkHsCmdWrap :: HsWrapper -> HsCmd (GhcPass p) -> HsCmd (GhcPass p)
mkHsCmdWrap w cmd | isIdHsWrapper w = cmd
- | otherwise = HsCmdWrap w cmd
+ | otherwise = HsCmdWrap noExt w cmd
-mkLHsCmdWrap :: HsWrapper -> LHsCmd id -> LHsCmd id
+mkLHsCmdWrap :: HsWrapper -> LHsCmd (GhcPass p) -> LHsCmd (GhcPass p)
mkLHsCmdWrap w (L loc c) = L loc (mkHsCmdWrap w c)
mkHsWrapPat :: HsWrapper -> Pat (GhcPass id) -> Type -> Pat (GhcPass id)
@@ -964,8 +963,8 @@ collectStmtBinders (BindStmt pat _ _ _ _)= collectPatBinders pat
collectStmtBinders (LetStmt (L _ binds)) = collectLocalBinders binds
collectStmtBinders (BodyStmt {}) = []
collectStmtBinders (LastStmt {}) = []
-collectStmtBinders (ParStmt xs _ _ _) = collectLStmtsBinders
- $ [s | ParStmtBlock ss _ _ <- xs, s <- ss]
+collectStmtBinders (ParStmt xs _ _ _) = collectLStmtsBinders
+ $ [s | ParStmtBlock _ ss _ _ <- xs, s <- ss]
collectStmtBinders (TransStmt { trS_stmts = stmts }) = collectLStmtsBinders stmts
collectStmtBinders (RecStmt { recS_stmts = ss }) = collectLStmtsBinders ss
collectStmtBinders ApplicativeStmt{} = []
@@ -1005,7 +1004,7 @@ collect_lpat (L _ pat) bndrs
go (SigPat _ pat) = collect_lpat pat bndrs
- go (SplicePat _ (HsSpliced _ (HsSplicedPat pat)))
+ go (SplicePat _ (HsSpliced _ _ (HsSplicedPat pat)))
= go pat
go (SplicePat _ _) = bndrs
go (CoPat _ _ pat _) = go pat
@@ -1236,7 +1235,8 @@ lStmtsImplicits = hs_lstmts
hs_stmt (LetStmt binds) = hs_local_binds (unLoc binds)
hs_stmt (BodyStmt {}) = emptyNameSet
hs_stmt (LastStmt {}) = emptyNameSet
- hs_stmt (ParStmt xs _ _ _) = hs_lstmts [s | ParStmtBlock ss _ _ <- xs, s <- ss]
+ hs_stmt (ParStmt xs _ _ _) = hs_lstmts [s | ParStmtBlock _ ss _ _ <- xs
+ , s <- ss]
hs_stmt (TransStmt { trS_stmts = stmts }) = hs_lstmts stmts
hs_stmt (RecStmt { recS_stmts = ss }) = hs_lstmts ss
diff --git a/compiler/hsSyn/PlaceHolder.hs b/compiler/hsSyn/PlaceHolder.hs
index 19b4af017d..9d99c9a3cb 100644
--- a/compiler/hsSyn/PlaceHolder.hs
+++ b/compiler/hsSyn/PlaceHolder.hs
@@ -8,7 +8,6 @@ module PlaceHolder where
import GhcPrelude ( Eq(..), Ord(..) )
-import Type ( Type )
import Outputable hiding ( (<>) )
import Name
import NameSet
@@ -36,21 +35,18 @@ data PlaceHolder = PlaceHolder
instance Outputable PlaceHolder where
ppr _ = text "PlaceHolder"
+placeHolder :: PlaceHolder
+placeHolder = PlaceHolder
+
placeHolderType :: PlaceHolder
placeHolderType = PlaceHolder
-placeHolderTypeTc :: Type
-placeHolderTypeTc = panic "Evaluated the place holder for a PostTcType"
-
placeHolderNames :: PlaceHolder
placeHolderNames = PlaceHolder
placeHolderNamesTc :: NameSet
placeHolderNamesTc = emptyNameSet
-placeHolderHsWrapper :: PlaceHolder
-placeHolderHsWrapper = PlaceHolder
-
{-
Note [Pass sensitive types]