我正在Ubuntu 16.04堆栈ghci版本8.我想在Haskell中导入System.Random,但似乎我有麻烦,可能涉及Cabal。我已经看到了类似的帖子这个网站上,但他们通常会说,这是因为旧的版本,但我使用的版本8如何安装system.random。也许在堆栈版本8 cabal问题
我得到的错误:
Failed to load interface for ‘System.Random’
Use -v to see a list of the files searched for.
还告诉我,我有一个系统问题。随机。在网上看,我发现我需要先安装Cabal。
当我键入
Cabal --version
我得到
cabal-install version 1.22.6.0
using version 1.22.5.0 of the Cabal library
告诉我,我已经拥有它。所以,当我尝试用
sudo apt-get install cabal-install cabal update
更新我得到
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package cabal
E: Unable to locate package update
这是奇怪的。如果我不理它,并尝试通过
cabal install random
反正安装随机我得到
Resolving dependencies...
All the requested packages are already installed:
random-1.1
Use --reinstall if you want to reinstall anyway.
这样看来我也有阴谋的随机包装。但我无法加载程序
import System.Random
命令。
编辑:看来我有堆栈ghci版本8.0.1和ghci版本7.10.3。 System.random在ghci中加载,但不是堆栈ghci。
当我尝试在堆栈中加载文件时,我也会得到以下内容。进入
stack ghci R.hs
我得到
Warning: Couldn't find a component for file target /home/aa/workspace/share/haskell/chenw/hw4/R.hs. Attempting to load anyway.
Configuring GHCi with the following packages:
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/aa/.ghc/ghci.conf
Loaded GHCi configuration from /tmp/ghci19674/ghci-script
这是否意味着有什么毛病我安装堆栈的?
'命令和apt-get安装阴谋安装小集团update'失败并不奇怪。该命令是'cabal update';它与apt-get无关。 – Ryan
@Ryan,我刚刚尝试过“cabal update && cabal install cabal-install”,但它仍然不起作用。 – domoremath
https://docs.haskellstack.org/en/stable/GUIDE/#adding-dependencies。 'stack install'也可能工作。 – Ryan