3 ms·
Concatenation is just addition, though: addition is the monoid operation on numbers with the identity of 0, concatenation is the monoid operation on lists with
by fiddlerwoaroof 6y ago
Concatenation is just addition, though: addition is the monoid operation on numbers with the identity of 0, concatenation is the monoid operation on lists with identity of [].
The problem is almost always not the overloading of + but the implicit type coercion rules
- gowld 6y agoList[Int] has more than one monoid
- fiddlerwoaroof 6y agoBut, when I'm thinking in List[Any], I expect to be working on the Monoid for List[Any], not the Monoid for List[Int]: things like special-casing List[Int] are exactly what make programming languages difficult to learn and use.