CHAPTER 7

image

More Monads: Now for Recommendations

The previous chapter introduced monads. In particular, the tasks of handling errors using Maybe, constants using Reader, logging using Writer, and state were presented through the same point of view, making clear how monad functions form the scaffolding that combines code for all of them.

The list monad can also represent multiple outcomes of a function. This is useful for modeling paths between years in time machines. However, you must be careful to ensure that the code does not enter into an infinite loop. You can avoid that problem by using the Logic monad. As you can see, lists are important ...

Get Beginning Haskell: A Project-Based Approach now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.