Working with strategies
In this recipe, we will use the parallel
library. This library provides a set of strategies to allow us to program concurrent tasks easily.
How to do it...
- Create a new project called
working-with-eval
with thesimple
stack template:
stack new working-with-eval simple
- Add a dependency on the
parallel
library in the build-depends sub-section of the executable section. Also add-threaded
and-fprof-auto -rtsopts -eventlog
to enable multithreading and profiling:
executable working-with-eval hs-source-dirs: src main-is: Main.hs ghc-options: -threaded -fprof-auto -rtsopts -eventlog default-language: Haskell2010 build-depends: base >= 4.7 && < 5 , parallel
- Open
src/Main.hs
. We will be adding our source here. Add theMain
module and import the relevant modules:
moduleMainwhere import Control.Parallel.Strategies
- Create a data type...