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-evalwith thesimplestack template:
stack new working-with-eval simple
- Add a dependency on the
parallellibrary in the build-depends sub-section of the executable section. Also add-threadedand-fprof-auto -rtsopts -eventlogto 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 theMainmodule and import the relevant modules:
moduleMainwhere import Control.Parallel.Strategies
- Create a data type...