3 ms·
From a programming perspective it is a way go generalize adding two things together, but where the order might matter (or might not!). + is a monoid. It adds t
by quickthrower2 6y ago
From a programming perspective it is a way go generalize adding two things together, but where the order might matter (or might not!).
+ is a monoid. It adds to numbers together. (3+3)+4 = 3+(3+4)
But also concatenation is a monoid
"a" + ("b" + "c") = ("a" + "b") + "c".
Monoids have an empty thing you can add to anything.
E.g. 0 for + and "" for concatenation.
In Haskell, Monoids are abstracted out into a typeclass so that you can write code on any monoid. For example fold up a list of monoid elements into a single element.