我正在我的文件顶部导入QuickCheck:
import Test.QuickCheck
...
使用ghc Lab1.hs
编译文件会出现此错误:
Lab1.hs:1:8:
Could not find module `Test.QuickCheck'
Use -v to see a list of the files searched for.
Failed, modules loaded: none.
我尝试了quickcheck
的apt-cache搜索,并得到了一个可怕的包列表。试图安装libghc-test-framework-dev
只是因为我觉得这个名字似乎合适,但错误仍然存在。
如何安装QuickCheck模块?
答案 0 :(得分:17)
如果您有兴趣在软件包管理器之外管理Haskell软件包(如果您对使用最新版本的东西感兴趣可能会有所帮助),那么Cabal是Haskell软件包管理器,它允许您执行< / p>
apt-get install cabal-install
cabal update
cabal install QuickCheck
使全球范围内的QuickCheck可用。
最近推荐的是使用Cabal的sandbox
功能。这非常类似于Python的virtualenv
或Ruby的bundle
,如果你对它们更熟悉的话。为此,您必须创建一个“cabalized”项目
cabal init # in an empty directory
然后将QuickCheck
(和您的其他库依赖项)放在生成的build-depends:
文件的<folder name>.cabal
插槽中。
完成此操作后,您可以使用Cabal进行所有进一步的包管理和编译命令。
cabal sandbox init # creates your local package sandbox
cabal install --only-dependencies # gets and installs all the build-dependencies
cabal repl # starts up GHCi in the local sandbox
cabal build # configures and builds the local project
cabal sandbox delete # cleans up the sandbox
答案 1 :(得分:2)
在Ubuntu 14.04.1中:
sudo apt-get install libghc-quickcheck2-dev
在:
> :m +Test.QuickCheck
<no location info>:
Could not find module `Test.QuickCheck'
It is not a module in the current program, or in any known package.
后:
Prelude> :m +Test.QuickCheck
Prelude Test.QuickCheck>