<div dir="auto">Why the double splice? What about this makes you generate code that when run will generate code?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 3, 2022, 10:10 PM Michael Sloan <<a href="mailto:mgsloan@gmail.com">mgsloan@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hmm, the documentation does list 5 bullets of why this is a nice way of doing things. But yes, considering this didn't catch on no doubt either the docs are poor quality or the thing isn't really something people want. FWIW I wrote this many years ago, before deriving via. I just figured you might be interested as it is very similar to your query.<div><br></div><div>The examples could be better. One thing to note is that you can list a bunch of instances:</div><div><div dir="auto"><div dir="auto"><pre style="white-space:pre-wrap;margin-top:1em;margin-bottom:0px;padding:0.5rem 1rem;background-color:rgb(247,247,247);border:1px solid rgb(221,221,221);border-radius:0.3em;color:rgb(17,17,17);font-size:14px;letter-spacing:0.024px">$($(derive [d|
instance Deriving (Storable X)
instance Deriving (Eq X)
instance Deriving (Show X)
|]))</pre></div></div><br></div><div>(purely an example, afaik it wouldn't make sense to use TH to generate some canonical Eq and Show instances)</div><div><br></div><div>Whereas with typical `$(mkStorable [t| Storable X|] $)` style you need multiple splices and you need to know the names of these TH functions.<br><br>In retrospect this would probably be better without the `Deriving` wrapper, I think I needed that to disambiguate from the instantiators, which indeed aren't properly documented at all (I don't recall how they work, and don't feel like digging into it much further)</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 25, 2022 at 11:21 PM David Feuer <<a href="mailto:david.feuer@gmail.com" target="_blank" rel="noreferrer">david.feuer@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">I must admit that looks rather mysterious to me. The documentation I saw doesn't make the benefit of the nested splice terribly obvious.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 25, 2022, 10:53 PM Michael Sloan <<a href="mailto:mgsloan@gmail.com" target="_blank" rel="noreferrer">mgsloan@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">You might also be interested in <a href="https://hackage.haskell.org/package/th-utilities-0.2.5.0/docs/TH-Derive.html" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">https://hackage.haskell.org/package/th-utilities-0.2.5.0/docs/TH-Derive.html</a> - though afaik it didn't catch on.<div dir="auto"><br></div><div dir="auto">The cleverness there is to use nesting splicing, where the inner one generates code involving something like "runDeriver (Proxy @ Storable X) ...", where runDeriver is a method of a typeclass. The instances of this class implement the code generation that is ultimately used for the output.</div><div dir="auto"><br></div><div dir="auto"><pre style="margin-top:1em;margin-bottom:0px;padding:0.5rem 1rem;background-color:rgb(247,247,247);border:1px solid rgb(221,221,221);border-radius:0.3em;color:rgb(17,17,17);font-size:14px;letter-spacing:0.024px">$($(derive [d|
instance Deriving (Storable X)
|]))</pre></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Oct 22, 2022, 13:48 David Feuer <<a href="mailto:david.feuer@gmail.com" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">david.feuer@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Okay, I found it: recursion-schemes.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Oct 22, 2022, 3:05 PM David Feuer <<a href="mailto:david.feuer@gmail.com" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">david.feuer@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">That doesn't work out so well when the class has a bunch of methods. I definitely saw the nice way on Hackage ... somewhere.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Oct 22, 2022, 2:49 PM Brandon Allbery <<a href="mailto:allbery.b@gmail.com" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">allbery.b@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I'm not aware of anything specifically like that, but the `make…`<br>
functions in <a href="https://hackage.haskell.org/package/deriving-compat-0.6.1/docs/Data-Deriving.html" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">https://hackage.haskell.org/package/deriving-compat-0.6.1/docs/Data-Deriving.html</a><br>
may allow you to do something similar?<br>
<br>
On Sat, Oct 22, 2022 at 2:32 PM David Feuer <<a href="mailto:david.feuer@gmail.com" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">david.feuer@gmail.com</a>> wrote:<br>
><br>
> I remember seeing a package that offered a function used something like this:<br>
><br>
> $(deriveThingy [d| instance Foo a => Thingy a |])<br>
><br>
> to allow the user to specify the constraint(s) for a generated instance. I'd love to borrow the code for that, but I can't remember what package it was in, what class it derived, etc. Can anyone help?<br>
> _______________________________________________<br>
> Haskell-Cafe mailing list<br>
> To (un)subscribe, modify options or view archives go to:<br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
> Only members subscribed via the mailman list are allowed to post.<br>
<br>
<br>
<br>
-- <br>
brandon s allbery kf8nh<br>
<a href="mailto:allbery.b@gmail.com" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">allbery.b@gmail.com</a><br>
</blockquote></div>
</blockquote></div>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>