我在文件顶部导入 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.
我尝试使用 apt-cache 搜索 quickcheck
并得到了一个糟糕的包列表。尝试安装 libghc-test-framework-dev
只是因为我认为这个名称似乎合适,但错误仍然存在。
如何安装 QuickCheck 模块?
最佳答案
如果你有兴趣在你的包管理器之外管理你的 Haskell 包(如果你有兴趣使用最新版本的东西,这可能是有益的)那么 Cabal 是 Haskell 包管理器,它允许你做
apt-get install cabal-install
cabal update
cabal install QuickCheck
使 QuickCheck 在全局范围内可用。
最近更推荐的是使用 sandbox
cabal 的特点。这与 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
关于testing - 在 Ubuntu 上找不到模块 `Test.QuickCheck',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19661885/