Closed ceedubs closed 8 years ago
I'm pretty sure you can upgrade it to a CommutativeRing[Unit]
with no problems (it is a zero ring: https://en.wikipedia.org/wiki/Zero_ring). There's little harm in having these instances, even if they are mostly just a novelty.
+1 to Ring. Also I think you get Lattice here.
actually, BoundedSemilattice
is what we I should have said instead of Lattice
.
@non @johnynek thanks for the fast feedback and suggestions. I've made the unit algebra extend CommutativeRing
and BoundedSemilattice
.
Am I doing the right law-checking? It's straightforward for order
and boundedSemilattice
, but I wasn't sure what to do for CommutativeRing
. I didn't spot a def commutativeRing
in RingLaws
that would have been the obvious answer.
Also thanks for the link @non. That was helpful.
:+1:
I don't think we should be able to get anything beyond Rng
here. I think a Ring implies that 1 and 0 are different. OTOH, the laws seem to pass...
Ah - nevermind - this ring is the only ring where 1 != 0! Carry on :)
Mostly I wanted the
Order
instance forUnit
. The use-case is that in some tests we want to check if something two instances ofError Xor Unit
are equal, and the derivedEq
instance forXor
needs anEq
instance for both sides.I have no idea whether the
CommutativeRig[Unit]
is a good idea or is useful. It seems to be law-abiding though. Let me know if you want me to rip it out.