A Monad is just a Monoid…

Michele Stieven
6 min readApr 14, 2020

--

If you’re a programmer and you ran into the concept of Functional Programming, you either know how to complete this sentence or you will, eventually.

I will not demonstrate what makes a Monad a Monoid, that is Category Theory stuff and you may not want to know it. This article is to demonstrate the correlation between a Monad and a Monoid in the most practical terms and why it matters. Specifically, we’ll be able to see which problems are solved by a Monad and how a Monad composes functions.

Important disclaimer: I’m not going to talk about Category Theory here. Therefore, the Monoid that I want to highlight in this article is not the “Monoid in the category of endofunctors” that Category Theory wants to highlight. This article is by a programmer, for programmers. It’s about function composition rather than Monoidal Categories. Therefore, if some of this annoys you, please consider that for 99% of programmers this “simplification” could be useful: not in order to get a PhD in Mathematics, but in order to work as a programmer. Someone warned me that my “monad is a monoid” sentence in this sense was wrong: they’re true, it is a monoid if we talk about Categories, so I edited this article. But for now, let’s just try to see the Monoid which is hidden by the Monad implementation in FP.

--

--

Responses (4)