Union Types and Option Types (2025)
g0xA52A2A
61 points
27 comments
November 02, 2026
Related Discussions
Found 5 related stories in 38.2ms across 3,874 title embeddings via pgvector HNSW
- Compile-Time Dependent Types ibobev · 79 pts · October 26, 2026 · 44% similar
- How AI may drive union-resistant tech workers to the bargaining table civilchaos · 16 pts · November 01, 2026 · 43% similar
- Replacing implicit optionals with a None type in TypeDB flyingsilverfin · 13 pts · November 17, 2026 · 43% similar
- The need for at least a third option dethos · 17 pts · November 20, 2026 · 41% similar
- Unit-testing in the Ü programming language Panzerschrek · 14 pts · November 19, 2026 · 39% similar
Discussion Highlights (8 comments)
gnabgib
(2025) And about CopperLang (203 points, 3 days ago, 120 comments) https://news.ycombinator.com/item?id=50308754
direwolf20
i read Onion Types
p1necone
One simple but non obvious (at least to me) trick when implementing tagged unions: put the union discriminator/tag at the end , not the beginning - that way a pointer to a union is also a pointer to the value, no need to increment the pointer to point past the tag after discriminating.
ks2048
What is the best source for cross-language description of language features? Eg: “optional types”: which langs have them and how do they work? Same with “union types” etc.
cardboardguru
Swift has already answered all these questions.
jakobnissen
It seems bizarre to me that Copper includes Union types and then, for implementation reasons, does not include so many of its basic features, and even its basic properties. Like, what do you mean you can’t have three union members? And that the order of the union matters? These are some of the most useful properties of union types, and the arguments for what Copper did are weak sauce.
Panzerschrek
var value = maybeValue.notNil // I know what I'm doing How does it work exactly? Does it perform a runtime check, or just trusts the programmer?
Panzerschrek
> The option type, despite being simpler than union type introduces many new concepts and requires additional knowledge that make the language more complex. That's why I do such things in my language in a different way. Optional and union types are just library container classes. More methods may be added if necessary, internal layout may be changed, etc. without changing the language core itself. But in such an approach the language itself should provide necessary means allowing creation of such library abstractions.