In Chapter 6, Exploring 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 6, Exploring Built-In Effects:
val buyBait: String => Option[Bait]
val makeBait: String => Option[Bait]
val castLine: Bait => Option[Line...