logoalt Hacker News

Quarrelsomeyesterday at 9:56 PM2 repliesview on HN

Ok. I'm just trying to understand what code I'm replacing with them. Like I wanna see the before and after in order to gain the same level of excitment as other people seem to have for them.

Often the explanations just seem rather abstract which makes it harder to appreciate the win, versus the hideous sort of code that might appear when they're misused.


Replies

airstrikeyesterday at 10:05 PM

They are so fundamental to the way I write code I can't imagine ever using a language that does not support them.

"Make invalid states unrepresentable."

show 1 reply
speed_spreadyesterday at 10:32 PM

The value is realized when you have both discriminated union types _and_ language pattern matching (not regex). Then it's not just a way to structure data but a way to think about how to process it.