Closed jerbaroo closed 2 years ago
Yes, but you'd have to do a little extra work to get there. The current implementation of SI dimensions does not include torque, but if it did, torque would be inter-convertible with energy. However, there is no reason you could not define a separate dimension (call it TorqueD
) representing torque. This would be a new "base" dimension, not related to any other. Let's assume we have import qualified Data.Dimensions.DI as D
. Then, you would then have functions toTorque :: MkQu_D (D.Length :* D.Force) -> MkQu_D TorqueD
and fromTorque :: MkQu_D TorqueD -> MkQu_D (D.Length :* D.Force)
. These functions would internally be implemented using the unsafe Qu
constructor from Data.Metrology.Unsafe
, but (provided your representation of torque is consistent in your LCSU with your representation of length and force) they would actually be safe. With this setup, you would then be protected from adding your torque to your energy.
I hope this gives you enough to go on -- wasn't sure how much detail to include.
Hopefully my answer was sufficient -- closing.
https://www.researchgate.net/publication/326550053_Physical-type_correctness_in_scientific_Python
Is it possible with this
units
package to e.g. prevent addition of a value of type torque to a value of type energy?