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

Genuine question—why would you need a sum type in a self-describing data format?



Well, there are already sumtypes, just only specific builtin ones, not custom ones. E.g. booleans are sumtypes (true | false). Everything else that is nullable is also a sumtype (e.g. number | null).

I think it should be pretty obvious how these are helpful and why they are needed no?


Yeah, but it’s a schema-less, self-describing data format. It’s not like a specific position in a data stream has a requirement to be a specific type.

I can see why sum types would be useful in a schema or for the elements of a collection that is required to be homogeneous (ie. List<Foo|Bar>).

For what use case would one use custom sum types in a schema-less data format?




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: