comments on the GHC API

Simon Marlow simonmar at
Wed Mar 23 08:58:01 EST 2005

On 22 March 2005 17:49, Matthias Neubauer wrote:

> ... we also need the state after renaming, but we then have to stop, I
> suppose!

Yes, the HaRE folks also want the renamed abstract syntax too.  We
haven't quite figured out how best to make it available: renaming is
intertwined with typechecking a bit.

> Because we want to do do our own typechecking, stopping after ghc's
> typechecking would be to late: in case of a type error, ghc falls back
> into the wrong context (at least that's what's happening right now
> when doing a :load inside ghci ...).
>>>   We, for our part, would need parts of the intermediate result
>>>   (that is, the type environment and class declarations) existing
>>>   either before parsing A, after parsing A, or, even better, after
>>>   renaming A. Other users may be interested in other intermediate
>>> results. 
> Is there a way to get access to all the identifiers that are
> *imported* into the current module? Having that piece of information
> at hand, we could then use *lookupThing* to cumulate the initial type
> environment and the initial class environment for our analysis.
> Or do you see another/better way of doing that?

The ModIface contains the usages, which includes everything that is
*used* by the current module (not quite the same as everything that is
imported, because this is a list of original names, not imported names).

There is also the mi_globals list (in ModIface), which contains
everything in scope at the top level of the module.  From that I guess
you could find everything that is imported by subtracting things that
are defined in the local module.


More information about the Glasgow-haskell-users mailing list