-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
trait EuclidianRing should not be a Ring #4570
Comments
cc @non We implemented this stuff a very long time ago and may well have made a few mistakes in the encoding. How should this have been encoded? It seems that extending What do you propose as our best course of action? |
I think the "right" (ideal) representation would extend a I like the way NumHask models algebra, although the names are different. NumHask's Integral ~ Cats Possibly the "right" (pragmatic) solution is to mark this issue as Won't fix and simply leave it as a signpost for the next generation of library writers. Its likely a breaking change and I'd guess very few people care. I don't have strong knowledge or views on why GCDRing is separated from EuclidianRing. Is there any known trait that extends GCDRing but not EuclidianRing? |
I wouldn't be surprised if no one has ever used this code. The breakage cross section may be very low here. That said, an abstraction that is never used it also tautologically not useful. I imagine that you can add a trait to your own code just as well if you intend to use it. If we had confidence of the improvement adding a new trait costs very little. |
Well, I think a solution could be to
Practically this would allow natural numbers to be supported since they can provide a |
The docs give it away
EuclideanRing implements a Euclidean domain
.However, there's a problem: a Euclidian domain need not be a Ring.
Approximately & intuitively, euclidean domains defines some set of of integral or whole numbers. These might well be the set of natural numbers (0, 1, 2, 3 etc), which don't have closed subtraction operation.
A ring however, must include a subtraction operation; that's what the
n
in ring signifies (n for 'negation').Unfortunately, the trait hierarchy in the algebra package is over-constrained: it makes
EuclideanRing
extendRing
even though the operations it introduces, based arounddivmod
, dividing whole numbers to yield a quotient and a remainder, do not require the negation aspect of rings.The impact is that it's not possible to implement a complete & correct algebra for natural numbers (non-negative integers) using the Cats hierarchy.
The text was updated successfully, but these errors were encountered: