<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Thanks a lot for your suggestion! I’ve looked into GHC source plugins. <div class="">And, specifically, into your `hashtag-coerce` example:</div><div class=""><br class=""></div><div class="">* <a href="https://github.com/mpickering/hashtag-coerce" class="">https://github.com/mpickering/hashtag-coerce</a></div><div class=""><br class=""></div><div class="">As far as I can see, this allows only to analyse source code (to produce warnings or errors).</div><div class="">While my actual goal is actually to refactor code automatically. And I would</div><div class="">like to avoid full compilation process to make it work faster.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Dmitrii<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 21 Jun 2018, at 5:51 PM, Matthew Pickering <<a href="mailto:matthewtpickering@gmail.com" class="">matthewtpickering@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">This doesn't answer your question directly but if you want to gather<br class="">information about a module then using a source plugin would probably<br class="">be easier and more robust than using the GHC API.<br class=""><br class="">You need to write a function of type:<br class=""><br class="">```<br class="">ModSummary -> TcGblEnv -> TcM TcGblEnv<br class="">```<br class=""><br class="">In `TcGblEnv` you will find `tcg_rdr_env` which contains all top-level<br class="">things and describes how they came to be in scope.<br class=""><br class="">Source plugins will be in GHC 8.6.<br class=""><br class="">Cheers,<br class=""><br class="">Matt<br class=""><br class=""><br class="">On Thu, Jun 21, 2018 at 10:06 AM, Dmitriy Kovanikov <<a href="mailto:kovanikov@gmail.com" class="">kovanikov@gmail.com</a>> wrote:<br class=""><blockquote type="cite" class="">Hello!<br class=""><br class="">I’m trying to use GHC as a library. And my goal is to be able to gather<br class="">information about where each function or data type came from. I’ve started<br class="">by simply calling `getNamesInScope` function and observing its result. Here<br class="">is my code:<br class=""><br class="">* Main.hs: <a href="https://lpaste.net/9026688686753841152" class="">https://lpaste.net/9026688686753841152</a><br class=""><br class="">And here is the code for my test modules:<br class=""><br class="">* test/X.hs: <a href="https://lpaste.net/6844657232357883904" class="">https://lpaste.net/6844657232357883904</a><br class="">* test/Y.hs: <a href="https://lpaste.net/8673289058127970304" class="">https://lpaste.net/8673289058127970304</a><br class=""><br class="">Unfortunately, my implementation doesn't work since I’m not very familiar<br class="">with GHC API.<br class="">And I see the following errors after executing my `Main.hs` file (I’m using<br class="">ghc-8.2.2):<br class=""><br class="">* error messages: <a href="https://lpaste.net/3316737208131518464" class="">https://lpaste.net/3316737208131518464</a><br class=""><br class="">Could you please point me to places or parts of GHC API or some<br class="">documentation about module dependencies and how to make ghc see imports of<br class="">other modules? I can’t find simple and small enough usage example of this<br class="">part of the library.<br class=""><br class="">Thanks in advance,<br class="">Dmitrii Kovanikov<br class=""><br class="">_______________________________________________<br class="">ghc-devs mailing list<br class=""><a href="mailto:ghc-devs@haskell.org" class="">ghc-devs@haskell.org</a><br class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs<br class=""><br class=""></blockquote></div></div></blockquote></div><br class=""></div></body></html>