Skip to content

feat: Support unit16, char, sbyte, uint[32]#29

Open
Choc13 wants to merge 1 commit into
fsprojects:masterfrom
Choc13:uom-all-basic-types
Open

feat: Support unit16, char, sbyte, uint[32]#29
Choc13 wants to merge 1 commit into
fsprojects:masterfrom
Choc13:uom-all-basic-types

Conversation

@Choc13

@Choc13 Choc13 commented Aug 2, 2023

Copy link
Copy Markdown

Based on #28 and the desire to support UOM for uint32 I've added UOM for all missing basic CLR types (except nativeint and unativeint).

Comment thread src/FSharp.UMX.fs
[<MeasureAnnotatedAbbreviation>] type DateOnly<[<Measure>] 'm> = DateOnly
[<MeasureAnnotatedAbbreviation>] type TimeOnly<[<Measure>] 'm> = TimeOnly
#else
[<MeasureAnnotatedAbbreviation>] type uint32<[<Measure>] 'm> = uint32

@Choc13 Choc13 Aug 2, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the uint alias and the ability to support for UOM in FSharp.Core wasn't added until around F# 5. To work around this I think we need to use conditional compilation to add support for uint32 prior to this point in time hence the #else in the preprocessor directive.

I feel like this might not be the most accurate preprocessor directive to use though. So if anyone knows of a more F# language version specific one that we could use please let me know. I kinda wanted to use FSHARP5_OR_GREATER but couldn't find a reference for any commonly defined F# specific directives.

Comment thread src/FSharp.UMX.fsproj
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="FSharp.Core" Version="4.3.4" />
<PackageReference Condition=" '$(TargetFramework)' == 'netstandard2.0' " Include="FSharp.Core" Version="4.3.4" />
<PackageReference Condition=" '$(TargetFramework)' == 'net6.0' " Include="FSharp.Core" Version="6.0.7" />

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to target a newer version of FSharp.Core to pick up the uint alias. Again, I chose to do this when compiling for net6.0 as it felt like it was then safe to assume we could use this later version. If that's not acceptable or if there's a better condition to target than just net6.0 let me know.

@Choc13 Choc13 force-pushed the uom-all-basic-types branch 6 times, most recently from eb61d74 to 896598c Compare August 2, 2023 09:53
@Choc13 Choc13 force-pushed the uom-all-basic-types branch from 896598c to 89b68a5 Compare August 2, 2023 09:54
@bartelink

Copy link
Copy Markdown
Member

@eiriktsarpalis Not sure who releases and how but this seems pretty close to releasable?
@T-Gro any recent additions missing and/or can you answer any of the author's queries re how to most correctly handle the version conditionality?
(I see I'm a package owner so maybe I should do it myself...)

@bartelink bartelink changed the title Add UOM for all basic types. feat: Support unit16, char, sbyte, uint[32] Jun 6, 2026
@T-Gro

T-Gro commented Jun 7, 2026

Copy link
Copy Markdown

@bartelink :

Any of the mentioned version are out of support for a long time, I don't think this is still relevant?

@bartelink

Copy link
Copy Markdown
Member

@T-Gro sorry for being cryptic and not doing more homework.

This PR proposes to multi-target net6.0 and ns2.0 and is just filling out the set with new types in newer SDKs i.e. Half
But also in play is any new aliases e.g. uint

I was doing pretty indiscriminate atting in the hopes that someone off the top of their head might have a combined list of relevant System.* types and/or F# aliases that have come into play since the last release (which was some time ago).

My main motivation is just to clear down the PR list given there's nothing complex here and it's annoying for people to have to pollyfill things like this in their apps even if it's not hard. That and the fact that various package scanners can flag packages purely based on age, so having a new release would be helpful as a soft signal that UMX has not been either outlawed or superseded by an alternate technique and/or in-the-box support in FSharp.Core.

@Choc13 The net6.0 can easily take a dependency on e.g. SDK 10.x, and I think it's fine to add shimming to let people express uint and/or uint32 as you see fit independent of whether an old compiler can necessarily utilise them

If anyone has the time or interest to get do a round of work to get it to a point where they're happy with it, I'll do my best to get and/or nudge someone into getting it merged and released quickly.

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.

3 participants