logoalt Hacker News

Union Types and Option Types (2025)

34 points • by g0xA52A2A • last Monday at 8:08 PM • 14 comments • view on HN

Comments

jakobnissen • today at 5:52 AM

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.

gnabgib • last Monday at 8:39 PM

(2025) And about CopperLang (203 points, 3 days ago, 120 comments) https://news.ycombinator.com/item?id=50308754

p1necone • today at 12:21 AM

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.

➕ show 1 reply
ks2048 • today at 12:53 AM

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.

➕ show 2 replies
cardboardguru • today at 3:28 AM

Swift has already answered all these questions.

direwolf20 • yesterday at 11:53 PM

i read Onion Types

➕ show 2 replies