2 ms·
No, they can't. Or more precisely, only generic type parameters can be sum types, not actual runtime variables/parameters/return types/struct fields.
by tsimionescu 5y ago
No, they can't. Or more precisely, only generic type parameters can be sum types, not actual runtime variables/parameters/return types/struct fields.
- chombier 5y ago> not actual runtime variables/parameters/return types/struct fields. Is it possible to church-encode these with Go generics?
- tsimionescu 5y agoYes, probably, but I'm not sure that would be very ergonomic (I don't think you'd want to use it for something like Optional), if I understand correctly how it would work.