TYPE CLASSES FROM THE GROUND UP
summary
Builds a CSV parser then a decoding library that turns rows of strings into business types by defining CellDecoder and RowDecoder type classes and registering instances as implicits. Shows how implicit resolution composes instances (lists, options, either, tuples) to decode nested and mixed columns automatically, demonstrates the implicit-conversion pitfall, reproduces the same pattern in Java with explicit dictionaries, previews nicer Scala 3 extension syntax, and challenges the Haskell uniqueness claim with a counterexample that still compiles and produces duplicated set entries.
AI-written summary · about
chapters (25)
- 0:00Intro
- 1:23CSV data
- 1:34Parsing CSV
- 2:20Decoding to Int
- 3:45Generic decoding
- 5:24Decoding with implicits
- 6:08The dangers of implicits
- 8:12Implicit decoder
- 10:23Subclassing
- 12:14Explicit dictionary
- 13:29Key takeaways
- 14:02Heterogenous types
- 14:38RowDecoder type class
- 15:32(Int, String) decoder
- 16:37Implicit resolution revisited
- 17:54(A, B) decoder
- 18:48Collections of values
- 19:43Optional cells
- 20:56Cells with multiple types
- 22:10Going nuts
- 23:57Context bounds
- 24:47Instance summoning
- 26:13Scala 3 extension methods
- 27:14If you only remember 1 slide...
- 29:58Global uniqueness
related talks
20mType Classes for the Rest of Us
18mDiscovering Types (from Strings) with Cats and Shapeless
43mMastering Typeclass Induction
43mDon't Fear the Implicits: Everything You Need to Know About Typeclasses
31mTYPECLASSES — A TYPE SYSTEM CONSTRUCT
35mMastering Typeclass Induction
24mLet the Scala compiler work for you
46mImplicits Inspected and Explained
