Accept HsSyn in splices and generate it in quotes (ghc-api)
I propose a language pragma GhcTemplateHaskell
, which, when enabled, causes Template Haskell splices to accept HsSyn
return values, and causes TH quotes to return HsSyn
trees. Users of GhcTemplateHaskell
would stop using the template-haskell
library and just directly manipulate the frontend ASTs using the ghc-api
.
Given our ghc-api track record, you would probably not be able to write code using this without having it break every GHC release. However, clients who are willing to track GHC development would reap the following benefits:
- All syntax in Haskell would be supported in quotes; the AST would never lag behind. Additionally, you could use the ghc-api parser to parse Haskell code to be returned in a splice. (#2041)
- Locations from quoting would be preserved. (Problem 2 of #10330)
I don't think this would be difficult to implement, but it definitely could be a ball of wax. I broke this proposal off from #2041.
Trac metadata
Trac field | Value |
---|---|
Version | 7.11 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | low |
Resolution | Unresolved |
Component | Template Haskell |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |