简体   繁体   中英

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:

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:

 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?

I am using GHCi version 7.8.3

Thanks

Edit:

I tried installing HUnit through cabal as an answer suggested but then I got the error:

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. Now it works!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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