GHC API question: resolving dependencies for modules

Matthew Pickering matthewtpickering at
Thu Jun 21 09:51:20 UTC 2018

This doesn't answer your question directly but if you want to gather
information about a module then using a source plugin would probably
be easier and more robust than using the GHC API.

You need to write a function of type:

ModSummary -> TcGblEnv -> TcM TcGblEnv

In `TcGblEnv` you will find `tcg_rdr_env` which contains all top-level
things and describes how they came to be in scope.

Source plugins will be in GHC 8.6.



On Thu, Jun 21, 2018 at 10:06 AM, Dmitriy Kovanikov <kovanikov at> wrote:
> Hello!
> I’m trying to use GHC as a library. And my goal is to be able to gather
> information about where each function or data type came from. I’ve started
> by simply calling `getNamesInScope` function and observing its result. Here
> is my code:
> * Main.hs:
> And here is the code for my test modules:
> * test/X.hs:
> * test/Y.hs:
> Unfortunately, my implementation doesn't work since I’m not very familiar
> with GHC API.
> And I see the following errors after executing my `Main.hs` file (I’m using
> ghc-8.2.2):
> * error messages:
> Could you please point me to places or parts of GHC API or some
> documentation about module dependencies and how to make ghc see imports of
> other modules? I can’t find simple and small enough usage example of this
> part of the library.
> Thanks in advance,
> Dmitrii Kovanikov
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at

More information about the ghc-devs mailing list