3 ms·
> My go-to example of a monoid is (the set of strings, string concatenation, the empty string). There's an interesting reason why strings are a good example -
by TheMatten 5y ago
> My go-to example of a monoid is (the set of strings, string concatenation, the empty string).
There's an interesting reason why strings are a good example - when you think of `string` as `List<char>`, that `List` in it actually turns out to be a "free monoid". That is, minimal amount of structure needed to encode monoid operations in such a way that you can interpret them later as needed into something else. And one possible interpretation function is something commonly called `reduce` - you can basically think of `[1,2,3].reduce((x, y) => x + y, 0)` as interpretation of this monoidal structure into monoid of integers with addition.