Retrieve a list of all imports in a Haskell project

谁说我不能喝 提交于 2020-01-02 04:30:12

问题


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?)


回答1:


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.



来源:https://stackoverflow.com/questions/15203191/retrieve-a-list-of-all-imports-in-a-haskell-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!