简体   繁体   English

找不到模块Test.HUnit

[英]Can't find module Test.HUnit

I am trying to make some unit tests in Haskell and this is basically what I have done in my code: 我试图在Haskell中进行一些单元测试,这基本上就是我在代码中所做的:

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

run = runTestTT tests   

When I try to compile it with the gchi I get this message: 当我尝试使用gchi编译它时,我收到此消息:

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

How can I make HUnit work? 我如何让HUnit工作?

I am using GHCi version 7.8.3 我使用GHCi版本7.8.3

Thanks 谢谢

Edit: 编辑:

I tried installing HUnit through cabal as an answer suggested but then I got the error: 我尝试通过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.

Then I used the command: 然后我使用了命令:

cabal install base

and I got this message: 我收到了这条消息:

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

So I used the command: 所以我使用了命令:

cabal install base -reinstall

to reinstall just in case and I got the message: 重新安装以防万一,我收到了消息:

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)

What should I do? 我该怎么办?

Turns out I had mistakenly installed two versions of ghc (7.6.3 and 7.8.3) so I removed them both along with cabal and reinstalled everything. 结果我错误地安装了两个版本的ghc(7.6.3和7.8.3),所以我将它们与cabal一起移除并重新安装了所有东西。 Now it works! 现在它有效!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM