Type Classes for the Rest of Us
summary
Shows how Scala type classes replace ad-hoc serialization patterns by building a compiler-enforced deserialize[A] returning Option that avoids runtime exceptions, migrates per-type boilerplate into implicit type-class instances, and then reduces ceremony with simulacrum while validating laws with discipline and ScalaCheck. Demonstrates a CSV-like parser example, notes runtime hazards of Salat reflection, reports ~33% of the audience had written type classes, and argues the approach works but isn't always better than inheritance.
AI-written summary · about
chapters (12)
- 0:00Introduction and speaker intro
- 1:08Goals of type classes
- 2:51Naive deserialization attempt
- 5:41Adding Option for safety
- 7:53Moving to compile-time checks
- 10:22Discovering type classes
- 11:26Type class structure explained
- 13:16Multiple instances per type
- 14:21Simulacrum and lawfulness
- 15:24Where type classes shine
- 16:29Operator overloading with type classes
- 18:11Where type classes don't fit
related talks
33mTYPE CLASSES FROM THE GROUND UP
58mSeparating Behavior and Data with Type Classes in Scala
43mMastering Typeclass Induction
31mType-Classes (in Scala 3)
31mTYPECLASSES — A TYPE SYSTEM CONSTRUCT
43mDon't Fear the Implicits: Everything You Need to Know About Typeclasses
49mOOP versus Type Classes in Scala
30mHaving a cake and eating it too Introduction to Typeclasses
