On Tue, Apr 28, 2015 at 07:51:50AM -0700, Kevin Meredith wrote:
> Given the fact that A is specialized for Float and Double, is it expected,
> i.e. does it only make sense from a math point-of-view, if A has type of
> Float or Double?
>
> In particular, does it only make sense for test for the construction of a
> new Quaternion if A is a Float or Double?
No. Remember that specialization is just an optimization detail. There
are plenty of other valid quaternion types, including:
- Quaternion[Real], which is more precise than Double/Float
- Quaternion[Rational], which could represent Hurwitz quaternions [1]
- Quaternion[SafeLong], which could represent Lipschitz quaternions [1]
> Also, is there no more constrained type than A since that's the best we can
> do for Float and Double, children of *AnyVal*?
Right. There are basically no useful subtyping relationships for
numbers in Scala (or Java) so we always use generic types and type
classes.
-- Erik
[1]
https://en.wikipedia.org/wiki/Hurwitz_quaternion