O'Reilly logo

Haskell Cookbook by Yogesh Sajanikar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. Create a new project called working-with-ioref with the simple stack template:
        stack new working-with-ioref simple
  1. 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):
        executable working-with-type-family
          hs-source-dirs:      src
          main-is:             Main.hs
          ghc-options:         -threaded
          default-language:    Haskell2010
          build-depends:       base >= 4.7 && < 5
  1. Open src/Main.hs. We will be adding our source here. Define the Main module:
        module Main where
  1. Import the module Data.IORef for IORef, and multithreading (Control.Concurrent ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required