检索Haskell项目中所有导入的列表 [英] Retrieve a list of all imports in a Haskell project

查看:128
本文介绍了检索Haskell项目中所有导入的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我的最终目标是通过确保项目导入的所有实体存在于声称使用的版本中来评估cabal文件中依赖项的准确性。



一个好的开始是找到单个源文件使用的所有导入实体的列表,可选地提供关于它们来自哪里的信息。



我现在愿意忽略类实例的情况,因为检测它们的用法并不那么简单。



理想的答案是指向工具的指针这也正是如此,但我也会接受一个答案,指出我需要自己编写的资源(GHC是否收集这些信息?它是否可以将它转储到任何地方?是否可以说服它?)? p>

解决方案

最终, haskell-names 应该能够以最小的努力做到这一点。
需要注意的一点是,为了生成接口文件,需要使用haskell-names自己的编译器重新编译您引用的每个包。在将来,我还计划为所有hackage包(可能来自hackage本身)分发预编译的接口。

现在haskell-names正在工作,并且无法编译 base 还有。

GHC API的优点是,如果您已经安装了软件包,但我不确定它是否允许访问导入实体列表。


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

解决方案

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.

这篇关于检索Haskell项目中所有导入的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆