需要一个使用GHC解析和类型检查Haskell的教程 [英] Need a tutorial for using GHC to parse and typecheck Haskell
问题描述
我正在开发一个分析Haskell代码的项目。我决定使用GHC来解析源代码并推断类型,而不是编写自己的代码来实现。现在,我正在抨击Haddock文档,但是它的进展缓慢。有谁知道一个很好的教程?
编辑:澄清,我不寻找像hlint的东西。我正在编写我自己的工具来分析Haskell代码的运行时特性,所以就像我在写一个不同的hlint。我期待的基本上是维基页面的扩展 GHC作为一个图书馆。亚当,这是相当强奸的雪橇。
一个这样的程序是 ghctags
,它随GHC源代码树一起提供。我写了原始版本,但我不能推荐它 - 代码上有太多足迹,我不能再遵循它。我能说的最好的是,尽管很难遵循,但它至少 ,难以遵循 - 比GHC的所有更简单。
I'm working on a project for analyzing Haskell code. I decided to use GHC to parse the source and infer types rather than write my own code to do that. Right now, I'm slogging through the Haddock docs, but it's slow going. Does anyone know of a good tutorial?
EDIT: To clarify, I'm not looking for something like hlint. I'm writing my own tool to analyze the runtime characteristics of Haskell code, so it's like I'm writing a different hlint. What I'm looking for is basically an expansion of the wiki page GHC As a library.
Adam, this is pretty tough sledding. Ever since its launch in 2006, the GHC API has been somewhat underdocumented. What I would recommend is to try to find some small applications that have been written using the GHC API. The right place to ask is probably the GHC users' mailing list.
One such program is ghctags
, which ships with the GHC source tree. I wrote the original version, but I can't recommend it—there are so many footprints on the code that I can no longer follow it. The best I can say is that although it's hard to follow, it's at least small and hard to follow—much simpler than all of GHC.
这篇关于需要一个使用GHC解析和类型检查Haskell的教程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!