Combining monads

In Chapter 6Exploring Built-In Effects, we talked about standard effects such as Option, Try, Either, and Future. In Chapter 9, Familiarizing Yourself with Basic Monads, we moved on and implemented monads for all of them. In our examples, we demonstrated how Scala provides nice syntax for the code formulated in monadic terms by having for-comprehension, which is a syntactic sugar for the combination of map, flatMap, and possibly filter methods. In all our examples, we used for-comprehension to define a sequence of steps which constitute some process where the result of the previous computation is consumed by the next step. 

For an instance, this is the way we defined the process of fishing in terms of Option in Chapter ...

Get Learn Scala Programming 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.