Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
Kostarrr
on April 25, 2022
|
parent
|
context
|
favorite
| on:
Crimes with Go Generics
Actually, go generics can do sum types, it’s just not well known or advertised.
tsimionescu
on April 25, 2022
[–]
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
on April 25, 2022
|
parent
[–]
> not actual runtime variables/parameters/return types/struct fields.
Is it possible to church-encode these with Go generics?
tsimionescu
on April 25, 2022
|
root
|
parent
[–]
Yes, 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.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: