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 ...

Get Get Programming with Haskell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.