Here the monad-pattern is used to avoid repetitive code. This is similar to how some other languages use macros to simplify syntax, although macros achieve the same goal in a very different way. Note that it is the combination of the monad pattern and the monad-friendly syntax in Haskell which result in the cleaner code.

Understanding the Context

In terms that an OOP programmer would understand (without any functional programming background), what is a monad? What problem does it solve and what are the most common places it's used? Update To Here is my attempt to contribute to monads-beginners that you probably never have found anywhere else. A monad is a highly composable unit (a kind of building block of programming) in functional programming.

Key Insights

(IMO, introducing "Monad laws" without any context and rationalization is merely a useless classification and hazard to understand the concept. No worry, I do the job later in this article ... Also, every monad has a dedicated corpus, a body which is itself assembled from parts, which themselves have their dedicated monads, lower in the hierarchy. Only the monas monadum exists without one. All in all, this is a very difficult topic.

Final Thoughts

I hope I was of any help, and did not add to your confusion. It seems monad is just a higher level of abstraction in terms of programming, or it's just a continous and non-differentiable function definition in mathematics. Either way, they're not new concept, especially in mathematics. What about other libraries? Boost.Hana defines concepts for Functor, Applicative, Monad, and many others, giving you a way to implement automatically all the abstractions that leverage those concepts at the cost of giving some minimal definition. The monad patterns appears quite often when you package applications, although in a quite convoluted way.

The idea is that packages themselves are monads, having a functor that allows you to chain modifications of the package. In pseudo-code, keeping your notation, it could be something like package >>= apply_patch >>= change_version >>= add_tests.