Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve a list of all imports in a Haskell project

So, my ultimate goal is to evaluate the accuracy of the dependencies in a cabal file, by ensuring that all the entities that the project imports exist in the versions that it claims to work with.

A good start would be finding a list of all the imported entities that a single source file uses, optionally with information as to where they come from.

I'm willing to ignore the case of class instances for the moment, since detecting their use is not so straightforward.

Ideal answer would be a pointer at a tool that does exactly this, but I will also accept an answer that points me at the resources I'd need to write one myself (does GHC collect this information? does it dump it anywhere? can it be persuaded to do so?)

like image 397
Ben Millwood Avatar asked Oct 04 '22 20:10

Ben Millwood


1 Answers

Ultimately, haskell-names should be able to do things like that with minimum effort. One caveat is that you'd need to re-"compile" every package that you refer to using haskell-names own "compiler" in order to generate interface files. In future I also plan to distribute pre-compiled interfaces for all hackage packages (probably from via hackage itself).

Right now haskell-names is work in progress and cannot compile base yet.

GHC API has the advantage that you already have the interface files if you have installed the packages, but I'm not sure whether it gives access to the list of imported entities.

like image 185
Roman Cheplyaka Avatar answered Oct 10 '22 16:10

Roman Cheplyaka