On Mon, 2004-06-21 at 17:52, Simon Peyton-Jones wrote:
The "right place" to find the type info for a given syntax tree is in the syntax tree. The type checker has processed your fragment [| let f = \x -> x + 2 in f |] You just want to see the types. Currently there is no way to do that, but people often ask for it.
One idea: add (Maybe Type) fields to many TH syntax forms, where the type checker can record types. That's simple and direct.
A general question to TH aficionados: would this be useful? Remember that the type may not be fully precise, because it's the result of type-checking an as-yet-unspliced fragment.
I would certainly find this useful. I'm currently hacking Mark Jones's Typing Haskell in Haskell implementation to work with TH so that I can find the types of locally defined functions. This obviously not an ideal long term solution (though it would be better if TH could tell us the kinds of types and if we could ask questions about instances of classes - eg "is this type foo (or more generally this tuple of types) an instance of this class bar"). Duncan