Hacker News new | past | comments | ask | show | jobs | submit login

sum types are my number one. the frustrating part is that it almost has it with type sets in interfaces, which you can use in function signatures, but you can't use them in definitions of other types.

example, given an interface that is scoped to 4 types:

    type PlayingCardSuit interface {
      Diamond | Spade | Heart | Club
    }
I can use that in a function signature:

    func PrintCardSuit(c PlayingCardSuit) {
     ...
    }
But i can't use it to compose other types:

    type PlayingCard struct {
     Suit PlayingCardSuit // error
     Rank string
    }



Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: