[GHC] #14296: Add `Lift Exp` instance to `Language.Haskell.TH.Syntax`

GHC ghc-devs at haskell.org
Fri Sep 29 08:14:05 UTC 2017


#14296: Add `Lift Exp` instance to `Language.Haskell.TH.Syntax`
-------------------------------------+-------------------------------------
        Reporter:  heisenbug         |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Template Haskell  |              Version:  8.2.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Poor/confusing    |  Unknown/Multiple
  error message                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #14030            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by heisenbug):

 Replying to [comment:2 RyanGlScott]:
 > However, it should be noted that a derived `Lift` instance for `Exp`
 would not produce the code above. The problem with that instance is that
 if `x :: Exp`, then `$(lift x)` would not necessarily equal `x` (or even
 be of type `Exp`!), which is a rule you'd generally expect to hold. (I
 realize this law isn't started anywhere in the Haddocks at the moment, but
 it probably should be.)

 Interesting. I did not think about that too deeply. Maybe worth
 documenting this. But in my case (the specific usage in `[e|eqTypeRep
 (typeRep @ Maybe)|]`) the invariant is satisfied: `lift eqTypeRep` should
 encode an `Exp`. After all, I use it in this context `[p|($here -> Just
 HRefl)|]` as the view function. So I should be safe, right? Should I err,
 the type checker will remind me after quotation expansion, won't it?

 What about the derivation mechanism for `Lift` instances? Will it do ''the
 right thing'' in this case too?

 Anyway, thanks for the insight!

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


More information about the ghc-tickets mailing list