I’m new to PS and am exploring the type classes for numbers and math stuff. I was messing around with implementing some smaller integer types like Int8 with the same classes as Int. Once I started writing property tests to verify the laws were upheld, I realized I couldn’t get the EuclideanRing laws to pass because overflow wrapping messes things up. For instance, the integral domain law is violated because
bottom * 2 is
zero. Also, the submultiplicative euclidean function law is violated because
degree bottom is greater than
degree (bottom * 2); same with
top instead of
This made me we wonder if things worked differently for
Int somehow, but it doesn’t.
Int has the same issue. I’m wondering if I am misunderstanding something or if this is expected and just accepted due to limitations of machine integers. If it’s expected, why use this class with these laws?