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-eval with the simple stack template:
        stack new working-with-eval simple
  1. Add a dependency on the parallel library in the build-depends sub-section of the executable section. Also add -threaded and -fprof-auto -rtsopts -eventlog to 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
  1. Open src/Main.hs. We will be adding our source here. Add the Main module and import the relevant modules:
        module Main where

        import Control.Parallel.Strategies
  1. Create a data type for the binary tree:
        data BTree a 

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