RE: getting type information about local bindings

Don't try to get the type environment out. Instead, look at the syntax tree produced by the type checker. Each binder is an Id. There's a function idType :: Id -> Type that tells you the type of each binder. Quite how you present it to the user in a good way isn't clear to me, Simon | -----Original Message----- | From: Bernard James POPE [mailto:bjpop@cs.mu.OZ.AU] | Sent: 10 November 2000 05:56 | To: glasgow-haskell-users@haskell.org | Cc: bjpop@cs.mu.OZ.AU | Subject: getting type information about local bindings | | | Hi all, | | 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 | my time. | | 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. | | Regards, | Bernie. | | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users |
participants (1)
-
Simon Peyton-Jones