|
|
|
|
|
by throwaway17_17
597 days ago
|
|
I don’t think it is appropriate to say Rust has ‘union types’. Rust has sum types, implemented as Enums and (unsafe) Union types. There is a distinct difference between sum types and union types from a type theoretic perspective. |
|
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/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-fo...
I believe Java's checked exceptions behave somewhat like union types.