4 ms·
`min` and `max` operate on semigroups, not on monoids. They don't have to have a default value, and any nicely strongly typed language should prevent them from
by mFixman 7y ago
`min` and `max` operate on semigroups, not on monoids. They don't have to have a default value, and any nicely strongly typed language should prevent them from acting on empty lists.
You could invent a monoid instance of `float` for `<` which includes `inf` as an empty element and, if you ignore NaN, it kinda sorta works in isolation. However, adding infinity breaks a lot of other nice properties to the numbering system.
For example, the following identity of `min` is valid in the finite numbers.
```
n < min A ⟺ (∀ a ∈ A) n < a
```
The right part of the equation is always true if `A = ∅`, and according to our new monoid the left part is true if and only if `n ≠ ∞`.