[Haskell-cafe] Is it possible to get the information of instances of a type?

Magicloud Magiclouds magicloud.magiclouds at gmail.com
Thu Oct 27 08:16:33 CEST 2011

On Thu, Oct 27, 2011 at 7:04 AM, Evan Laforge <qdunkan at gmail.com> wrote:
>> 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.
> ghci :info does it too.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

Generally looked into GHC's source, seems like the :info (line 850 of
compiler/main/InteractiveEval.hs) is internal function. At last, GHC
parsed the code, it sure knew the type info.


More information about the Haskell-Cafe mailing list