[Haskell-cafe] GHC API - list all exports of a module

Jochen Keil jochen.keil at gmail.com
Mon Feb 2 16:58:29 UTC 2015


Hi Erik,

On 02.02.2015 12:55, Erik Hesselink wrote:
> On Mon, Feb 2, 2015 at 12:46 PM, Jochen Keil <jochen.keil at gmail.com> wrote:
>> Hello Peter,
>>
>> On 02.02.2015 12:31, Peter Simons wrote:
>>> Hi Jochen,
>>>
>>>  > My main goal would be to have a program which takes two modules of
>>>  > different versions, compare them and highlight the differences
>>>  > between them.
>>>
>>> maybe http://hackage.haskell.org/package/hackage-diff would work for
>>> your purposes?
>>
>> Thanks for the hint, this looks pretty good.
>>
>> One thing though: hackage-diff uses haskell-src-exts for parsing
>> modules. Does haskell-src-exts re-use the GHC API or does it run its own
>> parser? (from a quick glance I'd say the latter case)
> 
> There are basically two routes to choose from with such a tool (of
> which a few already exist, I think): you can use GHC and its API, like
> you're doing, or you can use haskell-src-exts, which is a separate
> parser, and use haskell-names for name resolution (and
> haskell-packages for dependency information). Sadly there's no
> haskell-type-exts for typechecking (yet). The GHC route is probably
> more powerful, the haskell-suite route is simpler and doesn't depend
> on GHC.

thanks for the clarification!
Indeed it seems to me that the GHC approach is more powerful, because
after running the typechecker I would have the AST available for
comparing modules (did I get this right?). Drawback would obviously be
the need for running the typechecker. :)

So, just for the sake of my curiosity:
Is there a way to get the exported declarations (and not just the
RdrNames) from GHC without running the typechecker?
I don't understand why it's necessary to run the typechecker in order to
get this list. The parser already returns a list with all declarations,
so shouldn't it be possible to filter this list for only the exported ones?

Thanks,
  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/2020e2ec/attachment.sig>


More information about the Haskell-Cafe mailing list