<p dir="ltr">Yes, I would find DeriveLift useful and a pleasant improvement to the Template Haskell ecosystem.</p>
<p dir="ltr">I am relatively new to TH and was wondering about a few things (if this hijacks the thread we can start a new one);</p>
<p dir="ltr">Other quotations,  [m| for 'Q Match' would be helpful to define collections of matches that can be combined and manipulated. One can use Q (Pat,Body,[Decl]) but you lose the ability for the Body to refer to a variable bound in the Pat. One can use Q Exp for just a Lambda, but you cant just combine lambdas to create a Match expression without some machinery.</p>
<p dir="ltr">Promotion of a Pat to an Exp. A subset of Pat can create an expression such that \ $pat -> $(promote pat) is id.</p>
<p dir="ltr">Tom</p>
<div class="gmail_quot<blockquote class=" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There is a Lift typeclass defined in template-haskell [1] which, when<br>
a data type is an instance, permits it to be directly used in a TH<br>
quotation, like so<br>
<br>
    data Example = Example<br>
<br>
    instance Lift Example where<br>
      lift Example = conE (mkNameG_d "<package-name>" "<module-name>" "Example")<br>
<br>
    e :: Example<br>
    e = [| Example |]<br>
<br>
Making Lift instances for most data types is straightforward and<br>
mechanical, so the proposal is to allow automatic derivation of Lift<br>
via a -XDeriveLift extension:<br>
<br>
    data Example = Example deriving Lift<br>
<br>
This is actually a pretty a pretty old proposal [2], dating back to<br>
2007. I wanted to have this feature for my needs, so I submitted a<br>
proof-of-concept at the GHC Trac issue page [3].<br>
<br>
The question now is: do we really want to bake this feature into GHC?<br>
Since not many people opined on the Trac page, I wanted to submit this<br>
here for wider visibility and to have a discussion.<br>
<br>
Here are some arguments I have heard against this feature (please tell<br>
me if I am misrepresenting your opinion):<br>
<br>
* We already have a th-lift package [4] on Hackage which allows<br>
derivation of Lift via Template Haskell functions. In addition, if<br>
you're using Lift, chances are you're also using the -XTemplateHaskell<br>
extension in the first place, so th-lift should be suitable.<br>
* The same functionality could be added via GHC generics (as of GHC<br>
7.12/8.0, which adds the ability to reify a datatype's package name<br>
[5]), if -XTemplateHaskell can't be used.<br>
* Adding another -XDerive- extension places a burden on GHC devs to<br>
maintain it in the future in response to further Template Haskell<br>
changes.<br>
<br>
Here are my (opinionated) responses to each of these:<br>
<br>
* th-lift isn't as fully-featured as a -XDerive- extension at the<br>
moment, since it can't do sophisticated type inference [6] or derive<br>
for data families. This is something that could be addressed with a<br>
patch to th-lift, though.<br>
* GHC generics wouldn't be enough to handle unlifted types like Int#,<br>
Char#, or Double# (which other -XDerive- extensions do).<br>
* This is a subjective measurement, but in terms of the amount of code<br>
I had to add, -XDeriveLift was substantially simpler than other<br>
-XDerive extensions, because there are fewer weird corner cases. Plus,<br>
I'd volunteer to maintain it :)<br>
<br>
Simon PJ wanted to know if other Template Haskell programmers would<br>
find -XDeriveLift useful. Would you be able to use it? Would you like<br>
to see a solution other than putting it into GHC? I'd love to hear<br>
feedback so we can bring some closure to this 8-year-old feature<br>
request.<br>
<br>
Ryan S.<br>
<br>
-----<br>
[1] <a href="http://hackage.haskell.org/package/template-haskell-2.10.0.0/docs/Language-Haskell-TH-Syntax.html#t:Lift" rel="noreferrer" target="_blank">http://hackage.haskell.org/package/template-haskell-2.10.0.0/docs/Language-Haskell-TH-Syntax.html#t:Lift</a><br>
[2] <a href="https://mail.haskell.org/pipermail/template-haskell/2007-October/000635.html" rel="noreferrer" target="_blank">https://mail.haskell.org/pipermail/template-haskell/2007-October/000635.html</a><br>
[3] <a href="https://ghc.haskell.org/trac/ghc/ticket/1830" rel="noreferrer" target="_blank">https://ghc.haskell.org/trac/ghc/ticket/1830</a><br>
[4] <a href="http://hackage.haskell.org/package/th-lift" rel="noreferrer" target="_blank">http://hackage.haskell.org/package/th-lift</a><br>
[5] <a href="https://ghc.haskell.org/trac/ghc/ticket/10030" rel="noreferrer" target="_blank">https://ghc.haskell.org/trac/ghc/ticket/10030</a><br>
[6] <a href="https://ghc.haskell.org/trac/ghc/ticket/1830#comment:11" rel="noreferrer" target="_blank">https://ghc.haskell.org/trac/ghc/ticket/1830#comment:11</a><br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</div>