Beyond Types in Swift
summary
Defines algebraic protocols in Swift (magma → semigroup → monoid → commutative monoid → bounded semi‑lattice) and shows concrete gains: wrapping Int into Sum/Max, deriving an average via paired (sum,count) monoids, and a parallel fold that drops span from O(n) to O(log n) for large inputs (he mentions 40 billion integers). Uses protocol inheritance, DispatchQueue for parallel reduce, and a UDP‑style relaxed delivery for distributed folds; stronger protocol conformance picks the faster fold implementation automatically.
AI-written summary · about
chapters (25)
- 0:00Introduction
- 0:23API design goals
- 2:11Composable APIs
- 3:59Folding explained
- 5:04Magma protocol
- 6:30Mathematical naming
- 7:33Why this matters
- 9:00Associativity law
- 10:28Semigroup protocol
- 11:52Expressive power
- 13:16Parallel folding
- 14:18Non-associative example
- 15:01Identity law
- 16:26Monoid protocol
- 17:49Two sums example
- 18:56Simplified fold API
- 19:37Commutativity law
- 21:22Idempotence law
- 22:27Bounded semilattice
- 23:56Distributed folding
- 25:03Generalizing the process
- 27:14Animation API
- 28:39Names matter
- 29:43Key takeaways
- 31:35Q&A
