gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 05:02:26 25 4
gpt4 key购买 nike

我有一个相当大的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com