O'Reilly logo

Get Programming with Haskell by Will Kurt

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

Lesson 30. Introducing the Monad type class

After reading lesson 30, you’ll be able to

  • Understand the limitations of both Functor and Applicative
  • Use Monad’s (>>=) operator to chain together functions in a context
  • Write IO code without do-notation

You’ve just finished learning about two important type classes, Functor and Applicative. Each has allowed you to perform increasingly powerful computations within a context such as Maybe or IO. Functor allows you to change individual values in a context:

GHCi> (+ 2) <$> Just 3
Just 5

Applicative increases your power by enabling you to use partial application in a context. This, in turn, allows you to use multiple arguments in a context:

GHCi> pure (+) <*> Just 3 <*> Just 2
Just 5

In this lesson, ...

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