<div dir="ltr">One thing to note is that the qAddTopDecls issue isn't a fundamental issue, just a matter of implementation: <a href="https://ghc.haskell.org/trac/ghc/ticket/10853">https://ghc.haskell.org/trac/ghc/ticket/10853</a></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 4, 2016 at 6:56 AM, Christopher Done <span dir="ltr"><<a href="mailto:chrisdone@gmail.com" target="_blank">chrisdone@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><p style="margin:0px 0px 1.2em!important">Good evening,</p><p style="margin:0px 0px 1.2em!important">Is there a way with TH to generate instances for a class in GHCi? I want to generate instances for a serialization class.</p>
<p style="margin:0px 0px 1.2em!important">I tried to write some TH to do it, but <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">$(foo)</code> in GHCi’s REPL says that it can only be <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">Q Exp</code>, not <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">Q [Dec]</code>. Sadness.</p>
<p style="margin:0px 0px 1.2em!important">I found <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">qAddTopDecls</code>. I tried to add the class declarations via <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">$(foo >>= qAddTopDecls; stringE "OK!")</code> and it says “Only function, value, and foreign import declarations may be added with <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">addTopDecl</code>". Woe.</p><p style="margin:0px 0px 1.2em!important">I could create a file and then load in that file, but loading modules loses all GHCi's state, which would defeat the purpose of using a REPL in the first place.</p>
<p style="margin:0px 0px 1.2em!important">Any hope?</p>
<p style="margin:0px 0px 1.2em!important">Ciao!</p>
<div title="MDH:SXMgdGhlcmUgYSB3YXkgd2l0aCBUSCB0byBnZW5lcmF0ZSBpbnN0YW5jZXMgZm9yIGEgY2xhc3Mg
aW4gR0hDaT88YnI+PGJyPkkgd2FudCB0byBnZW5lcmF0ZSBpbnN0YW5jZXMgZm9yIGEgc2VyaWFs
aXphdGlvbiBjbGFzcy48YnI+PGJyPkkgdHJpZWQgdG8gd3JpdGUgc29tZSBUSCB0byBkbyBpdCwg
YnV0IGAkKGZvbylgIGluIEdIQ2kncyBSRVBMIHNheXMgdGhhdCBpdCBjYW4gb25seSBiZSBgUSBF
eHBgLCBub3QgYFEgW0RlY11gLiBTYWRuZXNzLjxicj48YnI+SSBmb3VuZCBgcUFkZFRvcERlY2xz
YC4gSSB0cmllZCB0byBhZGQgdGhlIGNsYXNzIGRlY2xhcmF0aW9ucyB2aWEgYCQoZm9vICZndDsm
Z3Q7PSBxQWRkVG9wRGVjbHM7IHN0cmluZ0UgIk9LISIpYCBhbmQgaXQgc2F5cyDigJxPbmx5IGZ1
bmN0aW9uLCB2YWx1ZSwgYW5kIGZvcmVpZ24gaW1wb3J0IGRlY2xhcmF0aW9ucyBtYXkgYmUgYWRk
ZWQgd2l0aCBgYWRkVG9wRGVjbGAiLiBXb2UuPGJyPjxicj5BbnkgaG9wZT88YnI+PGJyPkNpYW8h" style="min-height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0"></div></div></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>