-
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
Prevent hertz and becquerel intermingling? #188
Comments
This is in fact a special case of checking the correctness of "kind of quantity" as defined by the ISO 80000 standard. See this introduction for more details. Checking kind-of-quantity is unfortunately much more complicated than basic dimensional analysis because there are no rules for arithmetic. Meaningful combinations of kinds-of-quantities must be stored in some database together with the kind-of-quantity corresponding to the result. |
I'm not sure that there's a desirable way in Haskell to address "the well-known tricky cases such as making both Hz and Bq compatible with 1/s but not with each other", because the Haskell type system doesn't have subtyping in favor of better inference (among other benefits). It might be possible to address the kind-of-quantity situation with a second layer of newtypes. I've sketched it below, using a terrible name in the hope that someone can come up with a better one:
You could then use I'm not opposed to this if all the details can be worked out. Probably involves splitting the dimensional arithemetic operators into typeclasses, which I've been considering anyway. Also would involve finding a good list of quantity names, for which the ISO standard may be a source. This may also lead to a solution for #23? But the amount of churn this would introduce could be considerable. And there is a question of whether to allow named quantity synonyms for "bare" quantity types, or only for these second-level newtypes. If you do allow it, you potentially have two confusingly similar types named |
In a discussion of dimensional units at https://disqus.com/home/discussion/khinsen/there_is_no_such_thing_as_software_development/?utm_content=read_more#comment-3900504830 it was noted that there is the question of "the well-known tricky cases such as making both Hz and Bq compatible with 1/s but not with each other" and I checked and
dimensional
does not handle this becausebut
DActivity
is just an alias toDFrequency
.The text was updated successfully, but these errors were encountered: