简体   繁体   English

在Ubuntu上找不到模块`Test.QuickCheck'

[英]Could not find module `Test.QuickCheck' on Ubuntu

I'm importing QuickCheck at the top of my file: 我在我的文件顶部导入QuickCheck:

import Test.QuickCheck
...

Compiling the file with ghc Lab1.hs gives me this error: 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.

I tried an apt-cache search for quickcheck and got a dire list of packages. 我尝试使用apt-cache搜索quickcheck并得到一个可怕的包列表。 Tried installing libghc-test-framework-dev just because I thought the name seemed appropriate, but the error persists. 尝试安装libghc-test-framework-dev只是因为我觉得这个名字似乎合适,但是错误仍然存​​在。

How do I install the QuickCheck module? 如何安装QuickCheck模块?

If you're interested in managing your Haskell packages outside of your package manager (which may be beneficial if you're interested in using the latest versions of things) then Cabal is the Haskell package manager which would allow you to do 如果您有兴趣在包管理器之外管理Haskell包(如果您对使用最新版本的东西感兴趣可能会有所帮助)那么Cabal是Haskell包管理器,可以让您做

apt-get install cabal-install
cabal update
cabal install QuickCheck

to make QuickCheck available globally. 使QuickCheck在全球范围内可用。

What's more recommended of late however is to use the sandbox feature of Cabal. 然而,最近推荐的是使用Cabal的sandbox功能。 This is very similar to Python's virtualenv or Ruby's bundle if you're more familiar with those. 这非常类似于Python的virtualenv或Ruby的bundle如果你更熟悉那些。 To do this, you must create a "cabalized" project 为此,您必须创建一个“cabalized”项目

cabal init        # in an empty directory

and then put QuickCheck (and your other library dependencies) in the build-depends: slot of the generated <folder name>.cabal file. 然后将QuickCheck (和您的其他库依赖项)放在生成的<folder name>.cabal文件的build-depends: slot中。

After you've done this you use Cabal for all further package management and compilation commands. 完成此操作后,您可以使用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

In Ubuntu 14.04.1: 在Ubuntu 14.04.1中:

sudo apt-get install libghc-quickcheck2-dev

Before: 之前:

> :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.

After: 后:

Prelude> :m +Test.QuickCheck
Prelude Test.QuickCheck>

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

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