goldfirere / units

The home of the units Haskell package
94 stars 19 forks source link

Added VectorSpace instance for Qu. #38

Closed leftaroundabout closed 9 years ago

leftaroundabout commented 9 years ago

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 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.

goldfirere commented 9 years ago

Good idea -- don't know why I didn't think of this before.