[Haskell-cafe] Is it possible to print out types of instances in
scope
Jeremy Shaw
jeremy.shaw at linspireinc.com
Sun Jan 16 03:13:08 EST 2005
Hello,
Is it possible to write a function that would display all the instances
of a class currently in scope[1]?
For example, for 'Show a' it should output something like:
The instances of 'Show a' currently in scope are:
Show Int
Show Float
Show Char
Show ...
Depending on what modules are imported at compile time, the list would
grow or shrink.
I am willing to accept all sorts of restrictions at this point in time
such as:
~ Yes, but only if the classes are declared in this way (but not for
ones declared in the standard library)
~ Yes, but it requires template haskell
It is currently my belief that the compiler "knows" the answer, but
there is no way to get the list from the compiler...
I would be interested in any information, links, examples, papers,
etc, that you can provide that would tell me:
~ Yes it can be done
~ It could be done with a compiler extension
~ It could never be done
~ It could be done, but it would be a really horrible idea, and here's why
So don't hold back :)
Thanks!
Jeremy Shaw.
[1] I suppose by 'currently in scope' I mean all the instances that
type checker is considering when it type checks the function at
compile time. But I am really not picky about what I mean right now as
I can't get anything remotely ressembling this to happen.
More information about the Haskell-Cafe
mailing list