6

我正在尝试在 Haskell 中进行一些单元测试,这基本上是我在代码中所做的:

module Test where
import Test.HUnit
test = TestList [TestLabel "running all the tests!"
$ TestList [
. . . . .
]]  

run = runTestTT tests   

当我尝试使用 gchi 编译它时,我收到以下消息:

 Could not find module ‘Test.HUnit’
Use -v to see a list of the files searched for.
Failed, modules loaded: none

如何让 HUnit 工作?

我正在使用 GHCi 版本 7.8.3

谢谢

编辑:

作为建议的答案,我尝试通过 cabal 安装 HUnit,但随后出现错误:

Could not find module ‘Test.HUnit’ Perhaps you haven't installed the "dyn" libraries for 
package ‘HUnit-1.2.5.2’? 
Use -v to see a list of the files searched for.

然后我使用了命令:

cabal install base

我收到了这条消息:

Resolving dependencies...
All the requested packages are already installed:
base-4.7.0.1
Use --reinstall if you want to reinstall anyway.

所以我使用了命令:

cabal install base -reinstall

重新安装以防万一,我收到消息:

Resolving dependencies...
cabal: Could not resolve dependencies:
rejecting: base-4.7.0.1, 4.7.0.0, 4.6.0.1, 4.6.0.0, 4.5.1.0, 4.5.0.0, 4.4.1.0,
4.4.0.0, 4.3.1.0, 4.3.0.0, 4.2.0.2, 4.2.0.1, 4.2.0.0, 4.1.0.0, 4.0.0.0 (only
already installed instances can be used)
rejecting: base-3.0.3.2 (conflict: base => base>=4.0 && <4.3)
rejecting: base-3.0.3.1 (conflict: base => base>=4.0 && <4.2)

我应该怎么办?

4

1 回答 1

1

结果我错误地安装了两个版本的 ghc(7.6.3 和 7.8.3),所以我将它们与 cabal 一起删除并重新安装了所有东西。现在它起作用了!

于 2014-11-02T14:32:52.960 回答