haskell - 使用 ghci 时如何重用 cabal 编译模块

标签 haskell ghci

我有一个相当大的 haskell 项目,在某些文件上运行 ghci 可能需要编译数十或数百个模块才能得到提示,这可能需要几分钟时间。我正在使用 cabal,所以我通常已经在 dist/下编译了目标文件。但是 ghci 只查找源 .hs 文件旁边的 .o 文件;它不知道 cabal 的 dist/。有什么简单而好的方法可以让 ghci 加载这些目标文件而不是自己重新编译所有内容吗?

我要求一个简单而好的方法,因为我有复杂而丑陋的方法来做到这一点。 :) 例如,这将使 ghci 重用 cabal 编译的模块。我想出了这个命令 通过复制和修改 cabal 运行 ghc 的方式,确保它设置的所有内容都与上次 cabal 构建相同,这是确保 ghci 加载模块所必需的。

ghci -package-conf dist/package.conf.inplace -i -idist/build/git-annex/git-annex-tmp -i。 -idist/build/autogen -Idist/build/autogen -Idist/build/git-annex/git-annex-tmp -optP-include -optPdist/build/autogen/cabal_macros.h -odir dist/build/git-annex/git-annex-tmp -hidir dist/build/git-annex/git-annex-tmp -stubdir dist/build/git-annex/git-annex-tmp -XHaskell98 dist/build/git-annex/git-annex-tmp/Utility/libdiskfree.o dist/build/git-annex/git-annex-tmp/Utility/libmounts.o

在我看来,“cabal ghci”应该可以计算此命令行并运行它,或者也许有一个我不知道的工具已经这样做了。

最佳答案

您可以设置 odir 和 ohi 选项以指向 cabal 构建目录,如下所示:http://www.haskell.org/ghc/docs/7.6.1/html/users_guide/separate-compilation.html#output-files

关于haskell - 使用 ghci 时如何重用 cabal 编译模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15125825/

相关文章:

generics - 当我在 Haskell 中编写 "show"和 "read"时发生了什么?

c++ - 用 C++ 编写 Haskell 解释器(使用 ghc 或 hugs 作为库)

haskell - 是否使用@-patterns 来获取模式值冗余?

haskell - Haskell 中的函数保护语法

Python 等价于 Haskell 的 [1..](索引列表)

algorithm - 存在的搜索和查询没有大惊小怪

haskell - 加载模块中的函数不在范围内

haskell - 在 ghci 中读取 vs map

haskell - 在惰性函数式语言的模板实例化求值器中实现 `case` 表达式有困难吗?