Mastering Typeclass Induction
summary
Shows how to derive typeclass instances for type-level lists by giving a concrete base-case and an inductive implicit that composes head and tail instances, using Scala implicit resolution (no macros). Builds a dynamic dispatch that parses heterogeneous event types into a nested Either-in-Option result using available parsers, paying one static object allocation and one method indirection per list step. Uses the technique in production for SoundCloud event routing and reports no discernable overhead while processing two billion events an hour.
AI-written summary · about
chapters (12)
- 0:00Introduction and context
- 2:04The problem: event parsing
- 5:05Outline of the talk
- 5:28Understanding induction
- 8:25Induction in programming
- 11:55What are type classes?
- 14:50Implicit resolution power
- 16:46Type class induction
- 20:26Deriving instances
- 25:25Solving dynamic dispatch
- 30:56Advanced applications
- 32:03Q&A and conclusion
related talks
43mMastering Typeclass Induction
20mType Classes for the Rest of Us
33mTYPE CLASSES FROM THE GROUND UP
41mThe Dialectics of Type-Level Programming
58mSeparating Behavior and Data with Type Classes in Scala
30mHaving a cake and eating it too Introduction to Typeclasses
35mIntroducing Typelevel Scala into an OO environment
49mOOP versus Type Classes in Scala
