Generics Unconstrained!
summary
Claim: prefer unconstrained type parameters combined with existing Go features because they produce simpler, more general APIs. Shows concrete rewrites: strings.Join becomes generic by passing a toString mapping function instead of a Stringer constraint; a directed-graph API drops mutually recursive Node/Edge constraints in favor of a generic interface to encapsulate recursive relationships; and outer containers drop type parameters via type erasure using a non-generic interface. Notes Min/Max still needs a constrained ordered set.
AI-written summary · about
chapters (14)
- 0:00Intro
- 0:26Overview
- 1:12The type parameters proposal
- 1:44Type parameters 101
- 5:41Existing polymorphism
- 6:28Type parameterised polymorphism
- 8:55Where does the complexity of the spec come from?
- 12:46Stringer Join
- 15:04Unconstrained Join in practice
- 16:28Example 2: Directed graph traversal
- 20:29Unconstrained graph implementation
- 24:47Hiding type parameters
- 25:04Type erasure
- 27:11Conclusion








