
On Wed, Oct 26, 2011 at 09:15:41AM -0700, Nathan Howell wrote:
On Wed, Oct 26, 2011 at 6:53 AM, Magicloud Magiclouds < magicloud.magiclouds@gmail.com> wrote:
But in Haskell, could I write a code to list the classes that a type instanced? TemplateHaskell as well.
It's possible with TemplateHaskell. Look at classInstances and the ClassI data constructor.
http://haskell.org/ghc/docs/7.0.4/html/libraries/template-haskell-2.5.0.0/La...
No, this lists all the instances of a class. OP asked for the classes of which a given type is an instace. Presumably it is possible, since Haddock does it! In the documentation generated for a type it lists classes of which the type is an instance. So you might want to look at how Haddock does it. I suspect the only way is through the GHC API. -Brent