3 ms·
disjoint union vs union. Scala3 is the only programming language to implement both AFAIK. C# has a proposal to add both unions and disjoint unions: https://gi
by jasdfasd 2y ago
disjoint union vs union.
Scala3 is the only programming language to implement both AFAIK.
C# has a proposal to add both unions and disjoint unions: https://github.com/dotnet/csharplang/blob/main/proposals/TypeUnions.md https://github.com/dotnet/csharplang/blob/main/proposals/Typ...
OCaml has polymorphic variants which are open disjoint unions.
Kotlin is looking to add union types for errors: https://youtrack.jetbrains.com/issue/KT-68296/Union-Types-for-Errors https://youtrack.jetbrains.com/issue/KT-68296/Union-Types-fo...
I believe Java's checked exceptions behave somewhat like union types.
- deleted 2y ago[deleted]
- om2 2y agoWhat’s the difference between a union type and a disjoint union type? In that C# proposal I couldn’t tell which syntax was which branch of your dichotomy.
- noelwelsh 2y agodisjoint union is sum type / enum / algebraic data type. Defined at the point of declaration. Each case is distinct (hence, disjoint) union is what Typescript has. Defined at the point of use. Cases need not be distinct.