There are not that many basic identities. I can really only think of
n + 0 = n, 0 + n = n, n * 0 = 0, 0 * n = 0, 1 * n = n, n * 1 = n
I don’t think rules beyond these need to be covered (though it wouldn’t hurt). One could even argue that any rule coverage is better than none; it doesn’t have to be all or nothing.
Without these rules, a Scala project using scala.compiletime.ops.int
might eventually have to move away from it and define its own Int
compile-time types. The latter can at least cover half of these cases (and would be able to cover all of them with this addition).
For a “real-world” use-case, see here. Given how physical quantities are encoded in this library, no generic function like nano
could be coded as easily and safely without the n + 0 = n
reduction rule.
More generally, these rules are about allowing certain types of generic functions to type-check. The advantages of being able to write generic code are well known.