[GHC] #16177: Rename Q (TExp a) to Code a

GHC ghc-devs at haskell.org
Mon Jan 14 11:01:43 UTC 2019


#16177: Rename Q (TExp a) to Code a
-------------------------------------+-------------------------------------
           Reporter:  mpickering     |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Template       |           Version:  8.6.3
  Haskell                            |
           Keywords:                 |  Operating System:  Unknown/Multiple
  TypedTemplateHaskell               |
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 I propose that we modify the typed template haskell API so that quoting an
 expression of type `t` results in a value of type `Code t` rather than `Q
 (TExp a)` and the splice construct requires an argument of type `Code a`
 to produce a value of type `a`.

 The definition of `Code` is as follows.

 {{{
 newtype Code a = Code (Q (TExp a))
 }}}

 There are two good reasons to do this.

 1. `Q (TExp a)` is ugly and leaks implementation details to the user.
 Using effects from the `Q` monad is unsafe and against the principle of
 staged programming.
 2. Writing instances for `Q (TExp a)` is quite difficult. It's much easier
 when the newtype is defined but at the cost of constant wrapping and
 unwrapping.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16177>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list