Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find module `Control.Parallel'

Tags:

haskell

ghc

I'm following this guide and I got to the "Write your first parallel Haskell program", where you have you use 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. When I run ghc-pkg list parallel is not on the list.

How do I go about solving that?

like image 911
tdranv Avatar asked Oct 21 '25 07:10

tdranv


1 Answers

You can do either of two things here:

  1. You can start a new project using cabal, and add parallel as a dependency. To do so, I'll refer you to Cabal's quickstart guide.
  2. Alternatively, you can just skip the parallel package. In the example you listed, you need to import Control.Parallel to make use of par and pseq. However, these functions are also part of GHC.Conc, which is part of the 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.
like image 141
Rik Van Toor Avatar answered Oct 23 '25 23:10

Rik Van Toor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!