所以我一直在搜索和搜索如何解决这个问题,但我一直没有找到解决方法。
首先,我想将 System.Random 导入到我的 Haskell 程序中。
import System.Random
不幸的是,这并不是那么容易......当我在 ghci 中执行程序时,它返回的是:
Could not find module `System.Random'
Use -v to see a list of the files searched for.
所以很明显我按照它说的做了......同样的问题除了我看到它使用的是什么包数据库:
Using binary package database: /usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/package.conf.d/package.cache
我进入那个目录,惊讶地发现……我的随机包不在那里。我转到我的 .cabal/packages 并将我的 random-1.0.1.1 文件复制到
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/
其他包所在的目录。我再次运行程序,仍然得到同样的错误。当我查看 ghc-7.6.3/package.conf.d 时,我意识到没有文件指向 lib 中的随机文件。
我该怎么办??
我很绝望。如何安装包!!!
我也试过 cabal install 但我得到了一个巨大的错误:
Failed to install random-1.0.1.1
Last 10 lines of the build log ( /Users/mikeecb/.cabal/logs/random-1.0.1.1.log ):
cabal: Error: some packages failed to install:
random-1.0.1.1 failed during the configure step. The exception was:
user error (In file included from
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/include/Rts.h:30,
from
/var/folders/lw/mwgzrbns2j10_p75xtydr9_r0000gn/T/ghc3806_0/ghc3806_0.c:1:0:
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/include/Stg.h:65:18:
error: math.h: No such file or directory
In file included from
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/include/Rts.h:32,
from
/var/folders/lw/mwgzrbns2j10_p75xtydr9_r0000gn/T/ghc3806_0/ghc3806_0.c:1:0:
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/include/HsFFI.h:30:20:
error: stdint.h: No such file or directory
In file included from
/var/folders/lw/mwgzrbns2j10_p75xtydr9_r0000gn/T/ghc3806_0/ghc3806_0.c:1:0:
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/include/Rts.h:190:20:
error: stdlib.h: No such file or directory
In file included from
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/include/Rts.h:227,
from
/var/folders/lw/mwgzrbns2j10_p75xtydr9_r0000gn/T/ghc3806_0/ghc3806_0.c:1:0:
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/include/rts/Flags.h:17:19:
error: stdio.h: No such file or directory
In file included from
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/include/Rts.h:227,
from
/var/folders/lw/mwgzrbns2j10_p75xtydr9_r0000gn/T/ghc3806_0/ghc3806_0.c:1:0:
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/include/rts/Flags.h:22:0:
error: expected specifier-qualifier-list before ‘FILE’
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/include/rts/Flags.h:188:0:
error: expected specifier-qualifier-list before ‘FILE’
In file included from
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/include/Rts.h:234,
from
/var/folders/lw/mwgzrbns2j10_p75xtydr9_r0000gn/T/ghc3806_0/ghc3806_0.c:1:0:
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/include/rts/Threads.h:19:23:
error: sys/types.h: No such file or directory
In file included from
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/include/Rts.h:234,
from
/var/folders/lw/mwgzrbns2j10_p75xtydr9_r0000gn/T/ghc3806_0/ghc3806_0.c:1:0:
/usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/include/rts/Threads.h:49:0:
error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘forkProcess’
)
最佳答案
所以看起来是从 Haskell Platform 卸载然后重新安装 GHC对于 Mac OSX,它可以正常工作。
关于haskell - 导入 Haskell 库,如 System.Random,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21340446/