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:
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:
In this lesson, you’ll look at the final evolution of this process, the Monad type class. Through one more operator, the Monad type class will allow you to perform any arbitrary computation in a context you’d like. You already saw this power in unit 4 with do-notation, which is syntactic sugar for the methods of the Monad type class.