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