<div dir="ltr">+1 to liftData<br><br>Removing 'Lift' altogether definitely isn't the way to go, though. As Richard points out, we want to be able to lift more than just ADTs.  Also ADTs which hide their implementation can have either opaque Data instances, no Data instance, or Data instances which involve using functions for constructors.<div><br></div><div>An example of the latter is Data.Map.Map's Data instance, which uses 'fromList' as a constructor.  This results in $(dataToExpQ (\_ -> Nothing) (fromList [(1,2)])) causing the compiletime error "Illegal data constructor name: ‘fromList’".</div><div><br></div><div>I think 'dataToExpQ' and related functions should be modified to handle this case.  It should be rather easy - if the constructor Name is lowercase, generate a 'VarE' instead of a 'ConE'.  I suppose this is a separate proposal, but it came up when thinking about this proposal.</div><div><br></div><div>-Michael</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 17, 2015 at 4:21 AM, Edward Z. Yang <span dir="ltr"><<a href="mailto:ezyang@mit.edu" target="_blank">ezyang@mit.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I propose adding the following function to <a href="http://Language.Haskell.TH" target="_blank">Language.Haskell.TH</a>:<br>
<br>
    -- | 'liftData' is a variant of 'lift' in the 'Lift' type class which<br>
    -- works for any type with a 'Data' instance.<br>
    liftData :: Data a => a -> Q Exp<br>
    liftData = dataToExpQ (const Nothing)<br>
<br>
I don't really know which submodule this should come from;<br>
since it uses 'dataToExpQ', you might put it in Language.Haskell.TH.Quote<br>
but arguably 'dataToExpQ' doesn't belong in this module either,<br>
and it only lives there because it is a useful function for defining<br>
quasiquoters and it was described in the quasiquoting paper.<br>
<br>
I might propose getting rid of the 'Lift' class entirely, but you<br>
might prefer that class since it doesn't go through SYB (and have<br>
the attendant slowdown).<br>
<br>
This mode of use of 'dataToExpQ' deserves more attention.<br>
<br>
Discussion period: 1 month<br>
<br>
Cheers,<br>
Edward<br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div><br></div>