Version 8 (modified by simonpj, 5 years ago) (diff)

Name changed from Commentary/Compiler/TemplateHaskell to TemplateHaskell/Conversions

Template Haskell design

See New directions for Template Haskell for the general overview of changes. There are some details about Part B:Add new MetaML-style constructs for strongly-typed metaprogramming.

Template Haskell Conversions

There are various conversions between datatypes involved in the Template Haskell implementation. The following diagram summarises the operations and how they compose, and proposes a refactoring.

         TcSplice.reify            Convert.convertToHsDecls
TyThing ----------------> TH.Dec ---------------------------> HsSyn RdrName
   |                    ^   |
   |                   /    |
   |  A               /     |
   |                 /      | 
   v                / B     |
HsSyn Name --------'        |
   |                        | C
   |                        |
   | DsMeta.dsBracket       |
   |                        |
   V                        |
 Core <---------------------'

We currently have TcSplice.reify for reifying a TyThing into TH syntax, and Convert for converting TH syntax back into HsSyn. Also, we have DsMeta for converting the contents of TH brackets into the Core code which generates the TH syntax for those brackets.

We need A, for Haddock.

Hence, we could:

  • Refactor TcSplice.reify into pieces A and B.
  • implement C, and replace DsMeta.dsBracket with the composition C.B.

Code for A is in #3355