GHC API question: resolving dependencies for modules
matthewtpickering at gmail.com
Mon Jun 25 21:08:53 UTC 2018
I'm sorry of my poor form for not really answering your question here
but it's because no one really knows how to use the GHC API.
If you are stuck on this path then you could look at how GHC uses the
API or an existing user of the API like haddock or haskell-indexer.
However, these solutions are not going to be as robust as using a
plugin and you will end up with writing a lot of code probably in
order to get it to work.
On Mon, Jun 25, 2018 at 9:34 AM, Dmitriy Kovanikov <kovanikov at gmail.com> wrote:
> Thanks a lot for your suggestion! I’ve looked into GHC source plugins.
> And, specifically, into your `hashtag-coerce` example:
> * https://github.com/mpickering/hashtag-coerce
> As far as I can see, this allows only to analyse source code (to produce
> warnings or errors).
> While my actual goal is actually to refactor code automatically. And I would
> like to avoid full compilation process to make it work faster.
> On 21 Jun 2018, at 5:51 PM, Matthew Pickering <matthewtpickering at gmail.com>
> 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 gmail.com>
> 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: https://lpaste.net/9026688686753841152
> And here is the code for my test modules:
> * test/X.hs: https://lpaste.net/6844657232357883904
> * test/Y.hs: https://lpaste.net/8673289058127970304
> 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
> * error messages: https://lpaste.net/3316737208131518464
> 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 haskell.org
More information about the ghc-devs