Sum Types in Languages
Comments focus on sum types (algebraic data types like unions, enums, or discriminated unions), their advantages, implementations in languages such as Rust, Haskell, and TypeScript, and debates over their absence or equivalents in other languages.
Activity Over Time
Top Contributors
Keywords
Sample Comments
You want "sum types", aka "algebraic types".
Do you mean sum types? Like Haskell's Maybe and Rust's Result?
No support for sum types? I didn't see even simple unions covered.
That's what sum types are for.
Congrats, you've re-invented sumtypes!
Sum types are simpler, and harder to misuse, than the common alternatives (unions or dynamic typing).
Languages with sum types, like Haskell and Rust, make these things trivial.
How do you think sum types are implemented in functional languages?
Can someone elaborate on what sum types are and an example in Rust?
Typescript provided none of those besides sum types.