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 combine-trans with the simple Stack template.
  2. Add mtl to the build-depends subsection of the executable section:
        executable combine-trans          hs-source-dirs: src          main-is: Main.hs          default-language: Haskell2010          build-depends: base >= 4.7 && < 5                 , mtl
  1. Open src/Main.hs and add the following imports after the initial module declaration. Import Prelude as well to avoid a clash with some names:
        import Prelude hiding (Either(..))        import Control.Monad.Reader        import Control.Monad.Writer        import Data.Monoid
  1. Define Cursor data type to show Cursor position from top-left position of the screen:
        data Cursor = Cursor Int Int deriving Show
  1. Define monoid instance for Cursor. When we combine two cursors, we simply sum ...

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