haskell - 无法加载模块“System.Random”
问题描述
我无法添加 System.Random 模块来使用它我的源 haskell 文件。
import System.Random
这是堆栈 ghc 产生的错误:
/Users/admin1/Haskell/PROJECTS/L4/src/Lib4.hs:32:1: error:
Could not load module ‘System.Random’
It is a member of the hidden package ‘random-1.1’.
You can run ‘:set -package random’ to expose it.
(Note: this unloads all the modules in the current scope.)
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
32 | import System.Random
| ^^^^^^^^^^^^^^^^^^^^
Failed, five modules loaded.
非常感谢您提前。PS 我正在使用 Stack 和 GHC 版本:版本 2.3.1,Git 版本 x86_64 hpack-0.33.0,Mac OSX 上的 ghc-8.8.3
解决方案
正如错误所说:
It is a member of the hidden package ‘random-1.1’.
这可能意味着您没有在 中列出它build-depends
,因此它不会暴露给您的模块。
您可以更改.cabal
文件并添加它,例如:
-- project.cabal file
-- …
executable …
-- …
build-depends:
base >= 4.7 && < 5
, random >= 1.1
-- , …
推荐阅读
- python - KivyMD:在 MDTextField 中只输入数字的最佳方式是什么?
- python - 将数表示为素数之和的方法
- json - 使用多个上下文的 Oracle json 路径复合表达式不起作用
- r - 创建一个方阵,使每个元素等于 2^|jk| 在 R 中
- k3s - k3s中如何自定义kubeconfig服务器IP
- github - 在 Vercel (Zeit) 上部署 Nestjs 应用程序时遇到问题
- c# - 转换列表
动态的 - bash - 列出名称长度在 3 到 6 个字符之间的所有文件
- scala - 在 scala 中使用 docker 运行测试用例
- android - 如何从磨损操作系统发送通知到手机