Type-Classes (in Scala 3)
summary
Scala 3 treats type classes as an officially supported pattern with givens and extension methods, opaque types and mirrors and saner macros for automatic derivation. The compiler proves constraints so the CanEqual multiversal equality enforces type-safe comparisons unless an instance is supplied. Implicit scope still finds instances in companions (put instances in the right roots) and Scala 3.7 flips prioritization so supertypes win over subtypes, avoiding many conflicts. Example: a working JSON codec is generated in about one hour using derivation and it works.
AI-written summary · about
chapters (14)
- 0:00Introduction
- 1:51Object-oriented programming in Scala
- 4:41Subtyping limitations
- 6:05Type classes in Scala 2
- 8:35Type classes in Scala 3
- 11:28Type classes vs OOP
- 13:13Multiversal equality
- 16:04Type classes and proving
- 18:52Design challenges
- 21:24Implicit scope rules
- 22:30Given prioritization in 3.7
- 25:40Avoiding inheritance
- 27:51Macros and derivation
- 29:39Compile-time vs reflection








