[Haskell-cafe] Is there a way to generate instances from the GHCi REPL?

Christopher Done chrisdone at gmail.com
Thu Feb 4 14:56:53 UTC 2016


Good evening,

Is there a way with TH to generate instances for a class in GHCi? I want to
generate instances for a serialization class.

I tried to write some TH to do it, but $(foo) in GHCi’s REPL says that it
can only be Q Exp, not Q [Dec]. Sadness.

I found qAddTopDecls. I tried to add the class declarations via $(foo >>=
qAddTopDecls; stringE "OK!") and it says “Only function, value, and foreign
import declarations may be added with addTopDecl". Woe.

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.

Any hope?

Ciao!
​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160204/c1817ac9/attachment.html>


More information about the Haskell-Cafe mailing list