Hacker News new | past | comments | ask | show | jobs | submit login

> That feels like quite an awkward way to squash tagged unions into a class structure... But maybe it will work.

It's what Scala and Kotlin do and I think it's a fairly natural mapping. (Swift takes a different approach with their enums).

> defining an entire class for each variant does not sound like fun!

If you come at it expecting the brevity of ML, yes, it's not. But if you accept that those variants are real classes and may also have their instance methods, documentation comments on the fields, etc. then the overhead starts to feel less onerous.




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

Search: