Control.Parallel compile issue in Haskell

2020-08-09 11:01发布

The compiler is complaining each time on different example applications of parallel Haskell; with this message:

Could not find module `Control.Parallel.Strategies'

The ghc compiler command:

ghc -threaded -i/sudo/dir/par-modules/3 -cpp -DEVAL_STRATEGIES -eventlog --make parFib.hs

Same with simpler

ghc -O2 --make -threaded parFib.hs

What detail am I overlooking? Am I missing some PATH variable.

Imports can look like this:

module Main where
import System
#  if defined(EVAL_STRATEGIES)
import Control.Parallel
import Control.Parallel.Strategies
#endif

Cheers

3条回答
时光不老,我们不散
2楼-- · 2020-08-09 11:26

You must install the parallel package from Hackage. In most sane setups, this should be as simple as typing

cabal install parallel # note: not sudo cabal install parallel!

at your command prompt.

查看更多
家丑人穷心不美
3楼-- · 2020-08-09 11:26

I'm adding a new answer (instead of a comment) for visibility reasons.

After trying Daniel's answer, I still wasn't able to do import Control.Parallel, neither from ghci, nor with the compiler. The install command returned a warning message like this:

➜  ~ cabal install parallel
Resolving dependencies...
Up to date
Warning: You asked to install executables, but there are no executables in
target: parallel. Perhaps you want to use --lib to install libraries instead.

What ultimately resolved the issue was:

cabal install --lib parallel
查看更多
仙女界的扛把子
4楼-- · 2020-08-09 11:33

Like Daniel said, you'll need the parallel package. However if you'd prefer to use your system's package manager (which some people think you should), you can.

Note that, at least in the Fedora repos, you'll need ghc-parallel-devel, not just ghc-parallel to build.

#yum install ghc-parallel-devel
查看更多
登录 后发表回答