logoalt Hacker News

josephgyesterday at 7:18 PM1 replyview on HN

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

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


Replies

9rxyesterday at 7:27 PM

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.

show 2 replies