Introduction to monads

It took us three chapters to get to the moment where we're ready to discuss the origins of the flatMap method in regards to the effects we looked at in Chapter 6Exploring Built-In Effects. The reason for this is not the complexity of the topic, but the richness of the family of abstractions related to it.

After this introduction, a suspicious reader will think with disappointment—OK, now they are going to use their usual trick and say that there is an abstraction for flatMap, flattener or flatMapative, pull some laws out of thin air, and consider themselves done. What cheaters!

Well, technically we're not cheating because we're not pulling things out of anywhere. Instead, we're taking them from category theory, the ...

Get Learn Scala Programming now with O’Reilly online learning.

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