Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If I ever implement a product from scratch again, discriminated unions with compiler enforced exhaustive pattern matching is a hard requirement. It’s too powerful to not have.


Union types are my biggest wish for Dart, but unfortunately it doesn't look like they'll be added any time soon.

They've recently added support for compiler-enforced pattern matching over sealed classes, which I suppose does get you halfway there though.


What languages could fit that description today? I don't really understand what it even means but maybe I could understand better if I could look at examples in languages which have them.



Also Scala


Swift, Typescript depending on your opinion with structural typing, and Rust.

Think Scala, Elm and Haskell have it as well.

Having that and elixirs pattern matching would be insane.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: