logoalt Hacker News

Sharlinyesterday at 9:33 PM2 repliesview on HN

Discriminated union types are a really fundamental building block of a type system. It's a sad state of matters that many mainstream languages don't have them.


Replies

cubefoxyesterday at 11:20 PM

> Discriminated union types are a really fundamental building block of a type system. It's a sad state of matters that many mainstream languages don't have them.

"Non-discriminated" unions (i.e. untagged unions) are even less supported. TypeScript seems to be the only really popular language that has them.

Quarrelsomeyesterday at 9:42 PM

ok, so what problems do they help me solve that I can't already solve? Is it just that we can make code more concise or am I missing a trick somewhere?

show 2 replies