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

Working with monad

In this recipe, we will define our own Maybe type. We will define the Functor and Applicative instances for our Maybe, which are prerequisites for creating a Monad instance. Then, we will continue to create an instance of Monad, and, finally, we will use them in an example.

Maybe is a simple type and its monad instance is simple to implement and understand. Hence, when we work with the Maybe monad, it becomes clearer why and how the monad works.

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