-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic prefix selection #164
base: master
Are you sure you want to change the base?
Conversation
…onsistent with what happens when it is larger than the largest unit.
@@ -141,12 +141,12 @@ data Prefix = Prefix | |||
-- | The name of a metric prefix. | |||
prefixName :: PrefixName, | |||
-- | The scale factor denoted by a metric prefix. | |||
scaleFactor :: Rational | |||
scaleExponent :: Int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change limiting? I'm thinking of, e.g., Kilo (=1024) as used in KB. Not saying that this example is particularly relevant to the intended use of dimensional, but do any relevant prefixes that are not powers of ten exist? Is there a reasonable workaround for defining such prefixes without Prefix
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question.
Options: We could expose Prefix
, we could expose Prefix
from an 'Internal' module (actually we may already?).
We could add the IEC/ISO binary prefixes (kibi
, mebi
, etc) (which are approved by NIST but not by BIPM). If we wanted to get carried away we could change Metricality
to have three alternatives instead of two, introduce amount of data as a base dimension, and limit their use only to where ISO/NIST say they should be used.
Outside of units for amount of data (which we currently don't recognize at all), I am not aware of any prefixes that are not powers of ten.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want me to redo this to work around the change to scaleExponent
? Or leave it as is?
Even in the case of moving to binary prefixes we could conceivably keep this API and add scaleBase
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't thought of any other prefixes so you can leave as is. Regarding the binary prefixes I wouldn't want to pollute dimensional with them. I think they would be better handled by an ad hoc data type (outside of the scope of dimensional) rather than adding another dimension.
On 25 aug. 2016, at 01:36, Douglas McClean [email protected] wrote:
In src/Numeric/Units/Dimensional/UnitNames/Internal.hs:
@@ -141,12 +141,12 @@ data Prefix = Prefix
-- | The name of a metric prefix.
prefixName :: PrefixName,
-- | The scale factor denoted by a metric prefix.
scaleFactor :: Rational
Do you want me to redo this to work around the change to scaleExponent? Or leave it as is?scaleExponent :: Int
Even in the case of moving to binary prefixes we could conceivably keep this API and add scaleBase?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
…ld versions of GHC.
For consideration as an implementation of #163.