summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Deriv/Generate.hs
diff options
context:
space:
mode:
authorromes <rodrigo.m.mesquita@gmail.com>2022-03-19 17:42:46 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-06-01 07:44:44 -0400
commit7975202ba9010c581918413808ee06fbab9ac85f (patch)
treeffebdbd9d9fcef2300b1a6d3950bb5dd3f8435c4 /compiler/GHC/Tc/Deriv/Generate.hs
parent392ce3fca5d33688add52309a05914efa163e6f6 (diff)
downloadhaskell-7975202ba9010c581918413808ee06fbab9ac85f.tar.gz
TTG: Rework and improve splices
This commit redefines the structure of Splices in the AST. We get rid of `HsSplice` which used to represent typed and untyped splices, quasi quotes, and the result of splicing either an expression, a type or a pattern. Instead we have `HsUntypedSplice` which models an untyped splice or a quasi quoter, which works in practice just like untyped splices. The `HsExpr` constructor `HsSpliceE` which used to be constructed with an `HsSplice` is split into `HsTypedSplice` and `HsUntypedSplice`. The former is directly constructed with an `HsExpr` and the latter now takes an `HsUntypedSplice`. Both `HsType` and `Pat` constructors `HsSpliceTy` and `SplicePat` now take an `HsUntypedSplice` instead of a `HsSplice` (remember only /untyped splices/ can be spliced as types or patterns). The result of splicing an expression, type, or pattern is now comfortably stored in the extension fields `XSpliceTy`, `XSplicePat`, `XUntypedSplice` as, respectively, `HsUntypedSpliceResult (HsType GhcRn)`, `HsUntypedSpliceResult (Pat GhcRn)`, and `HsUntypedSpliceResult (HsExpr GhcRn)` Overall the TTG extension points are now better used to make invalid states unrepresentable and model the progression between stages better. See Note [Lifecycle of an untyped splice, and PendingRnSplice] and Note [Lifecycle of an typed splice, and PendingTcSplice] for more details. Updates haddock submodule Fixes #21263 ------------------------- Metric Decrease: hard_hole_fits -------------------------
Diffstat (limited to 'compiler/GHC/Tc/Deriv/Generate.hs')
-rw-r--r--compiler/GHC/Tc/Deriv/Generate.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/GHC/Tc/Deriv/Generate.hs b/compiler/GHC/Tc/Deriv/Generate.hs
index dc4fa5d46b..ad30052579 100644
--- a/compiler/GHC/Tc/Deriv/Generate.hs
+++ b/compiler/GHC/Tc/Deriv/Generate.hs
@@ -1661,8 +1661,8 @@ gen_Lift_binds loc (DerivInstTys{ dit_rep_tc = tycon
mk_untyped_bracket = HsUntypedBracket noAnn . ExpBr noExtField
mk_typed_bracket = HsTypedBracket noAnn
- mk_usplice = HsUntypedSplice EpAnnNotUsed DollarSplice
- mk_tsplice = HsTypedSplice EpAnnNotUsed DollarSplice
+ mk_tsplice = HsTypedSplice (EpAnnNotUsed, noAnn)
+ mk_usplice = HsUntypedSplice EpAnnNotUsed . HsUntypedSpliceExpr noAnn
data_cons = getPossibleDataCons tycon tycon_args
pats_etc mk_bracket mk_splice lift_name data_con
@@ -1677,7 +1677,7 @@ gen_Lift_binds loc (DerivInstTys{ dit_rep_tc = tycon
(map lift_var as_needed)
lift_var :: RdrName -> LHsExpr (GhcPass 'Parsed)
- lift_var x = noLocA (HsSpliceE EpAnnNotUsed (mk_splice x (nlHsPar (mk_lift_expr x))))
+ lift_var x = noLocA (mk_splice (nlHsPar (mk_lift_expr x)))
mk_lift_expr :: RdrName -> LHsExpr (GhcPass 'Parsed)
mk_lift_expr x = nlHsApps (Exact lift_name) [nlHsVar x]