[Haskell-cafe] GHC API - list all exports of a module
Jochen Keil
jochen.keil at gmail.com
Mon Feb 2 11:21:43 UTC 2015
Dear Cafe,
currently I'm working on a small program for which I need a list of all
*exported* function and data types. In order to achieve this I've been
toying around with the GHC API.
My observations so far:
* Using the pure `parser` function yields a `HsModule` object, which
gives me a list of all exports and all declarations (internal
& exported). I cannot or don't know how to use the list of exports
(just `RdrName`s) to filter the declarations.
* Using `parseModule` (which is essentially the same as the `parser`
function) and `typecheckModule` on a `ModuleGraph` yields
a `TypecheckedModule` object which contains a list of exported `Name`s
which in turn can be used to get additional information about them.
So, the second approach seems more promising, but I'm not too happy with
it. The reason is that calling `typecheckModule` results in
a compilation of the module and all of its dependencies, which I think
is not necessary for what I want to achieve. This is especially
cumbersome for large modules like `GHC.hs` where I'm struggling to
figure out all of the dependencies without the build system.
My main goal would be to have a program which takes two modules of
different versions, compare them and highlight the differences between
them. I think that'd be helpful for upgrading dependant packages or for
writing compatibility layers.
Thank you and all the best,
Jochen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20150202/c0cf087e/attachment.sig>
More information about the Haskell-Cafe
mailing list