由于最新的 Ubuntu 13.04 没有 haskell 平台,我只下载了 GHCi,直到现在都没有问题。
但现在我想和单子(monad)一起工作。导入它们
import Control.Monad.State
例如不起作用。错误信息:
Could not find module `Control.Monad.State'
Perhaps you meant
Control.Monad.ST (from base)
Control.Monad.ST.Safe (from base)
Control.Monad.Fix (from base)
Use -v to see a list of the files searched for.
Failed, modules loaded: none.
我如何手动下载它们,还是有完全不同的问题?
最佳答案
您需要在 GHC 可以找到的地方安装该库。
通过 Cabal 安装
安装 cabal
如果你还没有安装cabal-install
然后先这样做。做这两种方法之一。
通过操作系统打包:
sudo apt-get install cabal-install
或手动:
wget http://hackage.haskell.org/package/cabal-install-1.18.0.2/cabal-install-1.18.0.2.tar.gz
tar xzf cabal-install-1.18.0.2.tar.gz
cd cabal-install-1.18.0.2
sh ./bootstrap.sh
export PATH=$PATH:$HOME/.cabal/bin
使用 cabal
安装后
cabal-install
然后做:cabal update
cabal install mtl
这是“Monad 转换器库”,其中包含许多常见的 monad,例如
State
,您在示例中看到。通过 OS 打包安装
所有这些的替代方法是安装
mtl
的 ubuntu 包装。 .也就是说,我不知道有任何活跃的 Haskell 开发人员使用 Haskell 包的 OS 包而不是 cabal。 ubuntu 包是 libghc-ghc-mtl-dev
:sudo apt-get install libghc-ghc-mtl-dev
关于haskell - 导入单子(monad)不起作用(泄漏的 haskell 平台),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20177511/