[英]Could not find module `Control.Parallel'
I'm following this guide and I got to the "Write your first parallel Haskell program", where you have you use Control.Parallel
.我正在按照本指南进行操作,然后转到“编写您的第一个并行 Haskell 程序”,您可以在其中使用
Control.Parallel
。 When i try to compile it, I get:当我尝试编译它时,我得到:
A.hs:1:1: error:
Could not find module `Control.Parallel'
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
1 | import Control.Parallel
| ^^^^^^^^^^^^^^^^^^^^^^^
Nowhere does it say that I have to install anything.它没有说我必须安装任何东西。 Despite that, I ran
cabal install --lib parallel
and it installed okay but It still cannot find the package.尽管如此,我还是运行了
cabal install --lib parallel
并且安装正常,但仍然找不到 package。 When I run ghc-pkg list
parallel
is not on the list.当我运行
ghc-pkg list
parallel
时不在列表中。
How do I go about solving that?我该如何解决这个问题?
You can do either of two things here:你可以在这里做两件事之一:
parallel
as a dependency.parallel
添加为依赖项。 To do so, I'll refer you to Cabal's quickstart guide .parallel
package.parallel
package。 In the example you listed, you need to import Control.Parallel
to make use of par
and pseq
.Control.Parallel
以使用par
和pseq
。 However, these functions are also part of GHC.Conc
, which is part of the base
package.GHC.Conc
的一部分,它是base
package 的一部分。 So, to get your program to work without any package management involved, simply replace import Control.Parallel
by import GHC.Conc
, and you should be good.import Control.Parallel
替换为import GHC.Conc
,您应该会很好。 Do not use cabal install or stack install to manage your dependencies.不要使用 cabal install 或 stack install 来管理您的依赖项。
Instead use cabal or stack files to list all of those packages, then use "build" commands to fetch them into your project folder.而是使用 cabal 或堆栈文件列出所有这些包,然后使用“构建”命令将它们提取到您的项目文件夹中。
Both cabal and stack will then supply proper flags to your dependencies when compiling with GHC.在使用 GHC 编译时,cabal 和 stack 都会为您的依赖项提供适当的标志。
Alternatively, find out where did cabal downloaded that source code and pass it with flags to GHC.或者,找出 cabal 在哪里下载了该源代码并将其与标志一起传递给 GHC。 Thought that's unnecessary low level work.
认为这是不必要的低级工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.