2 ms·
One problem beyond the technical "How" is that culturally Go didn't have Sum types, so there are existing APIs where, if a Sum type was possible that's what you
by tialaramex 5y ago
One problem beyond the technical "How" is that culturally Go didn't have Sum types, so there are existing APIs where, if a Sum type was possible that's what you'd do, but it wasn't, so they didn't.
This isn't so different from the problem Generics introduce (why isn't this API generic, oh, it pre-dates that feature). And it might similarly be worth it for Sum types, but it's certainly an extra consideration.
On the technical side, Sum types kinda suck unless you have niches. If your Optional sum type is always actually bigger than the Some type it is wrapping then why even bother? So then you're also adding promises about niches in your implementation.