Uh oh!
There was an error while loading. Please reload this page.
WIP: Prototyping Erased Union types - #10566
Conversation
Swoorup
commented
Dec 3, 2020
One thing that is bit bugging me, atm is how to support pattern matching on erased union since the I'll do a few more experimentation how this could be supported. |
…rce as current F# spec
…e order while pretty print
…Solver.fs? Fix minor issue in type relation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
dsyme
commented
Jan 12, 2021
@Swoorup There's a lot of good foundational work here. As I mentioned on twitter this will interact with widening, for example to get to widen both to work. Plus there is the question of subtyping - which you've made a start on - used in member calls and explicit coercions for example, e.g. These three things actually use slightly different mechanisms and all three need to be adjusted. The second is actually the hardest because it introduces constrained type variables to represent the flexibility in the use of For (1), in the branch https://github.com/dotnet/fsharp/tree/experiment/widen-literals I started looking at our treatment of widening w.r.t. branching constructs. I'll take a look at resurrecting that. |
dsyme
commented
Jan 18, 2021
dsyme
commented
Jan 18, 2021
@Swoorup I have pushed a set of changes that incorporates feature/auto-widen into this PR and checked that the two features play nicely together. I'm really happy with how this is looking - much more testing is needed of course. If you'd like to hammer on this that would be great. I'll also need to start work on an RFC for feature/auto-widen. Here is a set of working examples: letf1(x :(int|string|int64))= printfn "x = %A" x
f1 1
f1 1L
f1 "z"letf2(x :(int|string))= f1 x
f2 1
f2 "z"letdata:(int|string)[]=[|1;"a";4;|]
printfn "data = %A" data
letv=(1:(int | string))letv2:(int | string) =1letf():(int | string) = Unchecked.defaultof<int>letdata2:(string *(int|string))[]=[|("a",1);("b",("a":(int | string)))|]
printfn "data2 = %A" data2 |
dsyme
commented
Jan 19, 2021
@Swoorup I added a language feature flag so you will need |
dsyme
commented
Jan 19, 2021
@Swoorup I'd like to suggest we open a new PR from a feature branch |
Swoorup
commented
Jan 19, 2021
I agree. Liking how the progress on this has ramped up so quickly. It does seem straightforward. 😄 |
dsyme
commented
Jan 19, 2021
Closing in favour of #10896 Work will now be on feature/erased-unions |
RFC https://github.com/fsharp/fslang-design/blob/master/RFCs/FS-1092-anonymous-type-tagged-unions.md
I am currently experimenting hacking the compiler to support union types. I'll admit I don't have much knowledge of the F# compiler and this is a merely an exploration to see if the features would fit well within F#.
What currently works:
type A = (int | (int64 | int16)is same as((int | int64) | int16)type C = (int | string)same as(string | int)What doesn't:
Would be nice not to have:> _every time to convert to union type.Links: