This chapter covers:
- Defining the functor by generalizing the map operation
- Deriving general purpose methods by applying the functor
- Revisiting and formalizing the functor law
- Defining various combinators that constitute the monad
- Introducing and proving the laws that govern the monad
- Discovering the true meaning of the monad
Many developers break out in a cold sweat on hearing the term monad. We have visions of people sitting in their lofty ivory towers, completely disconnected from the reality that we live in. We hear them mumbling away about academic concepts that have little or no bearing on the real world.
Even though individuals have used the term monad in such ways in the past, we hope to show that this can be no further from the truth. The monad concept is highly practical in its application, and can truly transform the way we write code. Granted, this term (along with its relative the functor, which we will also come to know in this chapter) does find its origins in the academic roots of category theory. Despite this, we will learn that it’s highly practical and nothing to fear.
This chapter serves to demystify the ominous monad, and by the end of it you should have a working understanding of what it is, as well as how to apply it in a pragmatic way to your daily programming challenges. This could well be one of the most important lessons to learn from this book.