wiki:TemplateHaskell/Conversions

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 do not have (A), (B), or (C).

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

Last modified 5 years ago Last modified on Feb 13, 2015 10:34:15 PM