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.
Working with MVar
How to do it...
- Create a new project called working-with-mvar with the simple stack template:
stack new working-with-mvar simple
- Add dependencies on the containers and random libraries in the build-depends sub-section of the executable section. Also add the -threaded option to the ghc-options subsection:
executable working-with-mvar hs-source-dirs: src main-is: Main.hs ...