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 using the simple Stack template:
        stack new fibonacci-state simple
  1. Open fibonacci-state.cabal and add packages mtl and containers to the build-depends subsection of the executable section:
         executable fibonacci-state         hs-source-dirs: src         main-is: Main.hs         default-language: Haskell2010         build-depends: base >= 4.7 && < 5                 , mtl                 , containers
  1. Build the project so that the dependent packages will be pulled by stack:
        stack build
  1. Open src/Main.hs. We will be editing this file.
  2. Import the following modules after initial module declaration:
        import Control.Applicative        import Control.Monad.State        import Data.Map.Strict as M

The module Control.Monad.State defines the state, monad.Data.Map.Strict defines the strict ...

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