Skip to content

TTG follow-up: Template Haskell related

These are TODOs regarding TTG to follow !4782 (closed):

Quoting @simonpj:

I see that UntypedSpliceFlavour is used only in the client specific GHC.Hs.Expr; but it is defined in the client-independent L.H.S.Expr. Let's move it next to PendingRnSplice.

In L.H.S.Expr I see

 | HsQuasiQuote        -- See Note [Quasi-quote overview] in GHC.Tc.Gen.Splice

But that Note doesn't exist. Can we find it from history?

In L.H.S.Expr I see

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]

The (IdP id) part is very GHC-specific. It should be in XTypedSplice.

Formally in #16830 (closed)

  • HsSpliced should be moved to XSplice. See the TODO there from @alanz.

From @Ericson2314

  • Inline HsSplice altogether!

Just as we now have Hs{Untyped,Typed}Bracket, untyped and typed splices, and quasiquotes, are all distinct syntax, and come from morally distinct extensions. They should have separate top-level AST nodes too, for that reason, and for consistency's sake!

To close this issue we should

  • Move UntypedSpliceFlavour to client specific GHC.Hs.Expr next to PendingRnSplice
  • Find Note [Quase-quote overview] in GHC.Tc.Gen.Splice that no longer exists from history
  • Refactor IdP id GHC-specific part into XTypedSplice from the constructor of HsSplice in L.H.S.Expr
Edited by Rodrigo Mesquita
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information