Not sure if anybody has suggested this before... it certainly seems an obvious thing to do.
Main benefit is that it allows to introduce units into code that uses generic vector operations, without any changes to the used operators. Also, you get to use linear maps to dimensional quantities.
(Not fromQu, though, that would require HasBasis. Which might in fact also be feasible – again type Basis Qu d l n = Basis n... but this one is a bit more questionable, as the basis-vectors would have to refer to the canonical unit. Should be safe enough, though.)
I hope I haven't overlooked any problems with this proposal. At least the tests run just fine.
Outlook
What would be really interesting is if we had a proper DualSpace type family, so we could implement a sort of InnerSpace-thing with units (dual space vectors have inverse unit). Perhaps I'll suggest adding something like that to the vector-space library.
Not sure if anybody has suggested this before... it certainly seems an obvious thing to do.
Main benefit is that it allows to introduce units into code that uses generic vector operations, without any changes to the used operators. Also, you get to use linear maps to dimensional quantities. (Not from
Qu
, though, that would requireHasBasis
. Which might in fact also be feasible – againtype Basis Qu d l n = Basis n
... but this one is a bit more questionable, as the basis-vectors would have to refer to the canonical unit. Should be safe enough, though.)I hope I haven't overlooked any problems with this proposal. At least the tests run just fine.
Outlook
What would be really interesting is if we had a proper
DualSpace
type family, so we could implement a sort ofInnerSpace
-thing with units (dual space vectors have inverse unit). Perhaps I'll suggest adding something like that to thevector-space
library.