[Haskell-cafe] Template Haskell: Generate annotated function of a typeclass

Ismael Figueroa Palet ifigueroap at gmail.com
Fri Apr 13 20:37:43 CEST 2012


Hi all, I think this is the right place for the following questions and I
thank beforehand for your answers :-)


I'm experimenting with typeclasses and TH, and I want to define a 'macro'
that works more or less like this:

Given the name of a typeclass and a function, return the expressions
corresponding to the type-annotated instances, for instance

$(foo Show show)

should translate to:

["(show :: Int -> String)",  "(show :: Bool -> String)", ....]

for all instances currently in scope.

I'm currently playing with the isInstance function (I'm running GHC 7.4.1)
and can get a list of instances, and check if a given type is part of a
typeclass or not. But I don't know how to create the expression
corresponding to "instantiated function", as above.

Thanks!
-- 
Ismael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120413/83e0f8b7/attachment.htm>


More information about the Haskell-Cafe mailing list