getting type information about local bindings
Bernard James POPE
Fri, 10 Nov 2000 16:56:15 +1100 (EST)
In GHC 4.09 the flag "-ddump-types" causes the type signatures of
top-level bound identifiers to be printed.
I would really like to make use of the type-checker in GHC, however, I would
also like to obtain the types of locally bound identifiers
(things in let expressions and where clauses). Obviously there is going to
be some trickery regarding type variables from enclosing scopes.
I looked in the TcModule.lhs module and noticed that the TcResults
value returned by typecheckModule contains a value environment that only
specifies the types of top bound identifiers.
Further investigation of the code led me to the TcBinds.lhs module
and the tcBindsAndThen function. I can see that local type environments
are not passed upwards during type checking/inference.
At some point I got lost in the code. Does anyone know of a reasonable means
for obtaining this type information? I don't mind doing some hacking, but
I wanted to get advise from the experts as to whether I might be wasting
Perhaps such a thing is done somewhere when generating Core code?
As an aside I dare say that such an extension would be useful to other
people, particularly those writing source transformation code.