I am working on a quaternion library and I was wondering if it might make sense to add a DivisionRing type class again, as follows:
class Ring a <= DivisionRing a where
recip :: a -> a
with the law that x * recip x = recip x * x = one for all nonzero x. There's no requirement for the ring to be commutative, and so this would allow us to provide a DivisionRing Quaternion instance.
If we were going to do this, we should change Field so that DivisionRing is a subclass as well.
Now of course with any EuclideanRing you can simply write one / x for recip x. Also, admittedly, the only 'useful' instance I can think of is Quaternion; I did some googling and wasn't really able to find any other useful examples of non-commutative division rings. But I think it would be nice to have a way of asking for the multiplicative inverse of an element of an arbitrary division ring without requiring it to be commutative.
I am working on a quaternion library and I was wondering if it might make sense to add a
DivisionRingtype class again, as follows:with the law that
x * recip x = recip x * x = onefor all nonzerox. There's no requirement for the ring to be commutative, and so this would allow us to provide aDivisionRing Quaternioninstance.If we were going to do this, we should change
Fieldso thatDivisionRingis a subclass as well.Now of course with any
EuclideanRingyou can simply writeone / xforrecip x. Also, admittedly, the only 'useful' instance I can think of isQuaternion; I did some googling and wasn't really able to find any other useful examples of non-commutative division rings. But I think it would be nice to have a way of asking for the multiplicative inverse of an element of an arbitrary division ring without requiring it to be commutative.