【发布时间】:2013-06-25 06:13:52
【问题描述】:
当您在 yesod 中创建脚手架站点时,它会将测试放入单独的目录中,如下所示:
YourProj/
YourProj/SomeModule.hs
YourProj/Handlers/FooHandler.hs
...
YourProj/tests/main.hs
YourProj/tests/FooTests.hs
所以,现在我想启动 ghci 并从 YourProj/tests/main.hs 或 YourProj/tests/FooTests.hs 导入一些代码来玩。我该怎么做?我试过了:
cabal-dev ghci
> :set -itests
> :load tests/TestImport.hs
tests/TestImport.hs:15:8:
Could not find module `Control.Monad.IO.Class'
It is a member of the hidden package `transformers-0.3.0.0'.
Perhaps you need to add `transformers' to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
所以,虽然我成功添加了子目录,但由于测试套件的 cabal 文件中 build-depends 参数的不同 cabal 配置,我仍然遇到问题。
我将如何启动 cabal-dev ghci 并从 Yesod 的测试中导入一些代码?
【问题讨论】:
-
好的,我手动将测试套件中的 build-depends 行添加到 main build-depends 部分,现在它抱怨“不在范围内:`$'”。
-
只需要导入
Prelude,cabal文件默认开启NoImplicitPrelude。 -
@MichaelSnoyman 谢谢,现在一切正常!我会在这里写一个答案。
标签: haskell cabal yesod ghci cabal-dev