-
Notifications
You must be signed in to change notification settings - Fork 789
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 new Units type to ease UoM conversions #17518
base: main
Are you sure you want to change the base?
Conversation
❗ Release notes required
|
Few questions:
I think before the implementation we need to start with RFC, and once that is approved and discussed, we can proceed with implementation |
|
I think we should still start with rfc for it, so everyone agrees on specifics. |
I put together a draft RFC here fsharp/fslang-design#784 is there something else I missed? |
That looks like a good start, now we need some comments on it. I'll probably be also good to have all types next to examples so people get a good understanding how many methods/functions are added |
@roboz0r : We have dicussed this addition and have an idea on how to bring the same functionality with a new compiler intrinsic, instead of adding many new functions to FSharp.Core. This would especially mean a lot smaller size footprint. |
(coverting to draft due to the suggestions above) |
Description
Creates a new
Units
type to meet some of the goals in fsharp/fslang-suggestions#892The type adds
Units.Add
,Units.Remove
, andUnits.Cast
methods for supported primitive types to simplify UoM conversions. It also addsUnits.Add*
,Units.Remove*
, andUnits.Cast*
e.g.Units.AddArray
to perform UoM conversions on common collection types without allocations.I haven't added any tests as the code doesn't actually do anything, it's just a wrapper over
retype
. Happy to add anything you think would be helpful.Checklist