Remix.run Logo
▲ Union Types and Option Types (2025)(tibleiz.net)
20 points by g0xA52A2A a day ago | 9 comments
▲ks2048 an hour ago | parent | next [-]

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.

▲tylermk04 23 minutes ago | parent [-]

Rosetta code is often helpful. Not exactly for language features, necessarily: https://rosettacode.org/wiki/Monads/Maybe_monad

▲p1necone an hour ago | parent | prev | next [-]

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.

▲beached_whale 9 minutes ago | parent [-]

when serializing these things it's generally going to be best to put the tag first though. That way it's cheap to figure out how to parse it.

▲gnabgib a day ago | parent | prev | next [-]

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

▲direwolf20 2 hours ago | parent | prev | next [-]

i read Onion Types

▲budro 2 minutes ago | parent | next [-]

Well poor design can require you to peel off multiple layers of optionals, and so they're often a significant smell just like onions are.

▲SoleilAbsolu an hour ago | parent | prev [-]

So shallot be...

▲ 2 hours ago | parent | prev [-]
[deleted]