I'd like to be able to display a Length Double by automatically selecting an appropriate metric prefix for meter based on the value of the Length Double rather than requiring a static selection of prefix.
As far as I can tell, we don't have support for this. Now that we have reified Prefixes, a list of siPrefixes, and the applyPrefix function (https://github.com/bjornbm/dimensional/blob/master/src/Numeric/Units/Dimensional/SIUnits.hs#L112-L116) we are close, we just need a function to select the correct prefix.
Proposed interface: (the Floating context being required to access logBase and RealFrac being required for truncate)
withAppropriatePrefix :: (Floating a, RealFrac a) => Unit 'Metric d a -> Quantity d a -> Unit 'NonMetric d a
We could possibly also expose:
appropriatePrefix :: (Floating a, RealFrac a) => Unit 'Metric d a -> Quantity d a -> Prefix
where
withAppropriatePrefix u q = applyPrefix (appropriatePrefix u q) u
Are there any reasons why this is undesirable? Are these names any good?
I'd like to be able to display a
Length Doubleby automatically selecting an appropriate metric prefix formeterbased on the value of theLength Doublerather than requiring a static selection of prefix.As far as I can tell, we don't have support for this. Now that we have reified
Prefixes, a list ofsiPrefixes, and theapplyPrefixfunction (https://github.com/bjornbm/dimensional/blob/master/src/Numeric/Units/Dimensional/SIUnits.hs#L112-L116) we are close, we just need a function to select the correct prefix.Proposed interface: (the
Floatingcontext being required to accesslogBaseandRealFracbeing required fortruncate)We could possibly also expose:
where
Are there any reasons why this is undesirable? Are these names any good?