Open tixxit opened 7 years ago
For later reference: Numeric[Complex[A]]
was removed in f15f609be6e2cde7337c9be3dcb81254351d443a
Maybe Scalar[_]
is a better name for a type class that applies to, well, scalar numerics, having an ordering, as contrasted with non-scalars like Complex
or Quaternion
. IMO, Complex
should not imply in any way that it has an ordering. So I'm in the "no-wiggling" camp, barring extenuating design circumstances.
Maybe this falls into the other heading of "should there be Numeric
and friends"; You can imagine some very fine-grained type-classes, for each kind of numeric/algebraic property. HasMultiplication
, HasCommutativeMultiplication
, HasOrdering
, HasAdditiveInverse
, HasMultiplicativeInverse
, HasRootsOfPositiveNumbers
, HasRootsOfNegativeNumbers
, etc. They could still be usefully bundled per variety of numeric construct, so having them doesn't imply removing higher-level type classes.
Scalar != ordered. This is why we separated Ring/Field from Order/Signed.
Complex numbers form a field but not ordered. Integers are an ordered ring. Rationals are an ordered field.
...
A complex number can be a scalar (in a complex vector space), or not (when the complex numbers are viewed as a two-dimensional real vector space).
We already have those fine-grained typeclasses: look at AdditiveXXX
and MultiplicativeXXX
in typelevel/algebra.
I see! I was working with an older, less general definition "representable by position on a scale or line; having only magnitude" (which implies having an ordering, and would exclude complex numbers)
At any rate, seems wrong to associate complex numbers with any type class also associated with having ordering.
Thanks for the alternate definition, indeed the etymology says something! Do you happen to have a source?
(I have a physics background, so my definitions tends to be coloured by previous training. But Spire needs to be user friendly and have clear docs.)
That particular phrasing I copied from: http://www.dictionary.com/browse/scalar
I found a similar definition in my old Munem and Foulis Calculus text: "Since real numbers can be represented by points on a number scale, such quantities are often called scalars." In fact, even my (also old) Halliday & Resnick physics text referred to them as "having magnitude only" and obeying the "ordinary rules of algebra."
That was a trip down memory lane :)
As @denisrosset makes our type classes more and more sane, we're also starting to find some instances are no longer lawful. This issue is specifically covering
Numeric[Complex[_]]
and, really, the broader issue of just how "wiggly" we want to be about laws andNumeric
. In this issue, let's just assume thatNumeric
will stay and we are just arguing about whether or not we should bring backNumeric[Complex[A]]
, which was removed becauseNumeric
now requires anOrder
, or if we can safely say thatNumeric
instances must extendOrder
in a sane wayWe can create a separate issue to deal with whether or not
Numeric
and friends should just be removed entirely.