-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add proper support for units #5
Comments
I implemented a limited support for units of measurement via units package, please see Redfin.Language.Units and changes to Redfin.Examples.Energy. For now, units are only used in the verification constraints (as we do in the paper). To be used as an underlying representation for units, a numeric type must be an instance of At this moment, we have everything we claimed to have in the paper, and the syntax closely resembles our examples, but the proper support for units in the high-level language is still to be implemented. |
@geo2a Thank you, looks promising! Can't GHC infer
But we can't do integers, can we? So the example from the paper doesn't really work. |
No, it can't, since the I made the examples more ad-hoc, and now they resemble the paper ones as closely as possible
We can, and we do, but with a limitation. The current implementation of fixed-point numbers (see Redfin.Data.Fixed has 8 out of 64 bits devoted to the fractional part. Therefore, we can cook up 56-bit values as |
Looks good!
What about switching from data Fixed = Fixed { getFixed :: Value, fixedToValue :: Value }
unsafeValueToFixed :: Value -> Fixed
unsafeValueToFixed x = Fixed (sShiftLeft x $ literal fracBits) x Or something similar. Perhaps, we could also split integer and fractional parts into separate fields. |
For example,
Variable Milli Watt
. To be able to useNum
instance, we should probably allow arbitrary addition and multiplication, but still reflect meaningless results in the type:1 :: Variable Milli Watt + 2 :: Variable Milli Watt == 3 :: Variable Milli Watt
.1 :: Variable Milli Watt + 2 :: Variable Micro Watt == 3 :: Variable Error Watt
.1 :: Variable Milli Watt + 2 :: Variable Milli Seconds == 3 :: Variable Milli Error
.The text was updated successfully, but these errors were encountered: