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

The irony is that Go actually does have sum types, but only for generics!

type A interface { Foo | Bar | Baz }

Can't use this anywhere but in generic type signatures though :(



There's a proposal [0] by Ian Lance Taylor that proposes extending the type parameter constrains union of types to non-generic interfaces too. Indeed, there are some issues with the implementation details, but I'm hoping they get ironed out.

[0] https://github.com/golang/go/issues/57644




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

Search: