summaryrefslogtreecommitdiff
path: root/compiler/Language/Haskell/Syntax/Expr.hs
diff options
context:
space:
mode:
authorromes <rodrigo.m.mesquita@gmail.com>2022-03-11 16:51:09 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-03-18 05:10:58 -0400
commit4a2567f5641a4807584c90015dfc40a791f241b4 (patch)
tree632cd30d5a1d5be5536d4f30cadeaa347ce81382 /compiler/Language/Haskell/Syntax/Expr.hs
parent310890a51372937afa69e1edac1179eba67ac046 (diff)
downloadhaskell-4a2567f5641a4807584c90015dfc40a791f241b4.tar.gz
TTG: Refactor bracket for desugaring during tc
When desugaring a bracket we want to desugar /renamed/ rather than /typechecked/ code; So in (HsExpr GhcTc) tree, we must have a (HsExpr GhcRn) for the quotation itself. This commit reworks the TTG refactor on typed and untyped brackets by storing the /renamed/ code in the bracket field extension rather than in the constructor extension in `HsQuote` (previously called `HsUntypedBracket`) See Note [The life cycle of a TH quotation] and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782
Diffstat (limited to 'compiler/Language/Haskell/Syntax/Expr.hs')
-rw-r--r--compiler/Language/Haskell/Syntax/Expr.hs20
1 files changed, 7 insertions, 13 deletions
diff --git a/compiler/Language/Haskell/Syntax/Expr.hs b/compiler/Language/Haskell/Syntax/Expr.hs
index 0d4b3251a0..2d5d407092 100644
--- a/compiler/Language/Haskell/Syntax/Expr.hs
+++ b/compiler/Language/Haskell/Syntax/Expr.hs
@@ -593,8 +593,8 @@ data HsExpr p
-- 'GHC.Parser.Annotation.AnnClose','GHC.Parser.Annotation.AnnCloseQ'
-- For details on above see Note [exact print annotations] in GHC.Parser.Annotation
- | HsTypedBracket (XTypedBracket p) (HsTypedBracket p)
- | HsUntypedBracket (XUntypedBracket p) (HsUntypedBracket p)
+ | HsTypedBracket (XTypedBracket p) (LHsExpr p)
+ | HsUntypedBracket (XUntypedBracket p) (HsQuote p)
-- | - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnOpen',
-- 'GHC.Parser.Annotation.AnnClose'
@@ -1605,22 +1605,16 @@ data UntypedSpliceFlavour
| UntypedDeclSplice
deriving Data
--- | Haskell Typed Bracket
-data HsTypedBracket p
- = TExpBr (XTExpBr p) (LHsExpr p) -- [|| texp ||]
- | XTypedBracket !(XXTypedBracket p) -- Extension point; see Note [Trees That Grow]
- -- in Language.Haskell.Syntax.Extension
--- | Haskell Untyped Bracket
-data HsUntypedBracket p
+-- | Haskell (Untyped) Quote = Expr + Pat + Type + Var
+data HsQuote 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 (LIdP p)
- -- True: 'x, False: ''T
- | XUntypedBracket !(XXUntypedBracket p) -- Extension point; see Note [Trees That Grow]
- -- in Language.Haskell.Syntax.Extension
+ | VarBr (XVarBr p) Bool (LIdP p) -- True: 'x, False: ''T
+ | XQuote !(XXQuote p) -- Extension point; see Note [Trees That Grow]
+ -- in Language.Haskell.Syntax.Extension
{-
************************************************************************