Why is there no representation for TH in TH?

Note that:

  • Expin template-haskellcompliance HsExprwith GHC AST
  • Typein template-haskellcompliance HsTypewith GHC AST
  • Decin template-haskellcompliance HsDeclwith GHC AST

However, there is one set of constructors that are missing from the types template-haskell: those related to TH-splice and quasiquartals. For example, why Expdoesn’t it have the following constructor?

SpliceE :: Exp -> Exp

I came across this one here . I would like to know if there is something fundamental in this matter, or is there only additional work that needs to be done using TH types? I suspect the problem is that with this one could send TH into an infinite loop - to have a splice creating another splice, and so on. However, there are already many ways to make GHC divergent ... :)


My use case wants to have an additional TH stage (so that I can raise the value at the level of the level - at the parent stage it is the value, but I can generate code with this value raised to the type level for using promote)

+4
source share

Source: https://habr.com/ru/post/1692838/