Skip to content
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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Conversation

dmcclean
Copy link
Collaborator

For consideration as an implementation of #163.

@@ -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
Copy link
Owner

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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?

Copy link
Owner

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
    
  •            scaleExponent :: Int
    
    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?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants