Trying to consolidate my understanding of monoids and monads, after encountering them for a second time in Just Enough Math.
I learnt about monads first while learning Scala, and have used them. Because they looked really cool. Definition by Martin Odersky in the Reactive Programming course was in code, so was pretty unambiguous.
Learnt about monoids more in Just Enough Math. Definition was in English, so left a little room for interpretation in my mind. Though integers and polynomials are monoids. There’s a mathematical definition on SO, so pretty unambiguous, if only I understood what the symbols meant. Odersky covered them extremely briefly while explaining the associativity law of monads by saying that they were “a simpler form of monads that doesn’t bind anything. For instance integers are a monoid.“
In any case they look to be good for the same thing, which is parallelisation. This is because:
- You can pretty much perform operation on two of them in any order you like*
- The operation gives you another monoid/monad of the same type
*there’s a clause somewhere that stipulates you must maintain the left-to-right order
And it’s worth a link to the original article which started the SO thread: A monad is just a monoid in the category of endofunctors, what’s the problem?