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 31. Making Monads easier with do-notation

After reading lesson 31, you’ll be able to

  • Use do-notation to simplify working with Monads
  • Translate from Monad methods and lambdas to do-notation
  • Generate code from one instance of Monad to all Monads

The Monad type class allows for powerful abstraction when using types in context. But the use of the Monad methods >>=, >>, and return quickly becomes cumbersome. In this lesson, you’ll look at two useful tools that make working with Monads significantly easier. The first is do-notation, which you already made heavy use of in unit 4. Now you’ll get a sense of how do-notation works behind the scenes. After this, you’ll learn about how List works as a Monad. This leads to another abstraction ...

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