简体   繁体   English

找不到模块“Control.Parallel”

[英]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:你可以在这里做两件事之一:

  1. You can start a new project using cabal, and add parallel as a dependency.您可以使用 cabal 启动一个新项目,并将parallel添加为依赖项。 To do so, I'll refer you to Cabal's quickstart guide .为此,我将向您推荐 Cabal 的快速入门指南
  2. Alternatively, you can just skip the parallel package.或者,您可以跳过parallel package。 In the example you listed, you need to import Control.Parallel to make use of par and pseq .在您列出的示例中,您需要导入Control.Parallel以使用parpseq 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.因此,要让您的程序在不涉及任何 package 管理的情况下运行,只需将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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM