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

> Sum types in general are missing from Go

Not quite. It doesn't have tagged unions, which is what I expect you are thinking of, but it does have sum types.

 help



Only by abusing interface {}. The result is horrible.

Go doesn’t have sum types as a first class primitive.


Using interface as it was designed to be used offers first-class sum types. Although not all interface use equates to sum types.

But they're not tagged unions. I expect that is still where your confusion lies. Tagged unions and sum types are not equivalent. Tagged unions are a subset of sum types.




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

Search: