- Create a new project called working-with-ioref with the simple stack template:
stack new working-with-ioref simple
- Add the ghc-options subsection in the section executable. Add the -threaded option for GHC compilation. If it's not provided, any foreign call will block all Haskell threads. Foreign calls are calls made outside the Haskell runtime (typically by calling functions in external functions):
build-depends: base >= 4.7 && < 5
- Open src/Main.hs. We will be adding our source here. Define the Main module:
- Import the module Data.IORef for IORef, and multithreading (Control.Concurrent ...