[GHC] #2041: Allow splicing in concrete syntax
GHC
ghc-devs at haskell.org
Sun Apr 19 21:29:44 UTC 2015
#2041: Allow splicing in concrete syntax
-------------------------------------+-------------------------------------
Reporter: igloo | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: ⊥
Component: Template Haskell | Version: 6.8.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: | Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by ezyang):
The feature as stated here is rather conservatively stated, but in a more
generalized form it could greatly improve the usability of Template
Haskell. Basically, you are asking for proper quote/antiquote (antiquotes
are nested splices.)
There's a few ways this could be implemented:
1. (Original String) As this ticket suggests, a new constructor is defined
which contains bits of concrete syntax. When, converting from the TH
representation to GHC representation, the GHC parser is invoked to convert
syntax into concrete representation.
2. (Monadic String) Alternately, some new methods could be added to the
Quasi monad, which is the "hook" interface that allows template-haskell to
call into GHC's code. These methods would like in the Q monad. This has
the benefit of letting us error out early if syntax is not well-formed.
3. (ghc-api) We could make splices accept proper `ghc` AST returns, in
which case we skip the TH conversion pass. In this case, a user could
just directly call out to the ghc-api to parse syntax, and then that could
be inserted into the TH splcie.
4. (Parser) Introduce a new syntactic form for quotation (something like
quasi-quote syntax? quasi-quote with a special sigil?); contents of the
quotation are parsed by the parser. Some tricky stuff happens.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/2041#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list