Working with MVar
In this recipe, we will look at MVar and Chan as the basic ingredients of a concurrent pipeline. We will create a Forex Order processing system, in which the orders to buy or sell currency are sent to an exchange. The exchange backend will process the orders, and print the summary.
How to do it...
- Create a new project called
working-with-mvarwith thesimplestack template:
stack new working-with-mvar simple
- Add dependencies on the
containersandrandomlibraries in thebuild-dependssub-section of theexecutablesection. Also add the-threadedoption to theghc-optionssubsection:
executable working-with-mvar
hs-source-dirs: src
main-is: Main.hs
ghc-options: -threaded
default-language: Haskell2010
build-depends: base >= 4.7 && < 5
, containers
, random- Open
src/Main.hs. We will be adding our source here. Define...