堆栈 repl 应该从 *其他* 包加载测试模块吗?



我有一个项目,它拉入了两个本地包。我的stack.yaml有:

packages:
- '.'
- '../creatur-wains'
- '../creatur-wains-test-utils'

creatur-wainscreatur-wains-test-utils都定义了一个名为ALife.Creatur.Wain.TestUtils的模块,但creatur-wains它只是测试代码的一部分,而不是库的一部分。当我使用ghci时,这不是问题。我可以加载两个包,并且只有creatur-wains-test-utilsTestUtils版本可见。

但是,Stack 似乎也从creatur-wains中提取了测试模块,因此我收到以下错误:

$ stack repl
The following GHC options are incompatible with GHCi and have not been passed to it: -Werror -threaded
Configuring GHCi with the following packages: creatur-dvector-wains, creatur-wains-test-utils, creatur-wains
* * * * * * * *
The following modules are present in multiple packages:
* ALife.Creatur.Wain.TestUtils (in creatur-wains, creatur-wains-test-utils)
* * * * * * * *
Not attempting to start ghci due to these duplicate modules.
Use --no-load to try to start it anyway, without loading any modules (but these are still likely to cause errors)

我可以使用--no-load来解决此问题,并逐个添加包,但这有点乏味。这是stack repl可取的行为,还是错误?

来自stack ghci文档 (https://docs.haskellstack.org/en/stable/ghci/(:

与堆栈构建类似,默认设置是使用项目中的所有库和可执行文件加载 ghci。

因此,要仅加载一个包,您需要执行stack ghci creatur-wains

最新更新