Re:dotNET (OK, C#) gets union types
by goto11 on Saturday May 23, 2026 @07:14PM
(#48252541)
Well it is a type union. The union of string and string is just string.
[ Parent
| on HN ]
Re:dotNET (OK, C#) gets union types
by bertylicious on Saturday May 23, 2026 @11:10PM
(#48253972)
No, it's a union of a left value (that happens to be a string) and a right value (that happens to be a string). But the compiler-generated code can't tell them apart.
What you are describing is something different called a disjoint union which will maintain the identities of the left and right values when there is overlap.
The C# unions appear to behave like unions, not disjoint unions.
Re:dotNET (OK, C#) gets union types
by bertylicious on Sunday May 24, 2026 @03:05AM
(#48255167)
My mistake. I see my oversight now. `Either String String` is not equivalent to `String | String`, but to `Left String | Right String`. The same must be done for the C# version.
You are correct that this requires support for disjoint unions (aka tagged unions), which Haskell always had and C# will soon have.