The Shape(less) of Type Class Derivation in Scala 3
summary
Scala 3 adds three concrete primitives—Mirror, derives clause and a companion-driven derived hook—that let libraries synthesize typeclass instances with minimal runtime cost; shapeless3 is a poly-kinded rewrite that implements a poly-kinded Generic as a refinement of Mirror, uses tuples instead of HLists, and provides a compact kernel plus per-kind veneers for products, coproducts and higher-kinded functors. The preview on GitHub generates derived instances in companions (cached, low bytecode footprint), handles higher-kinded mapping and record transforms, and can be back-ported to Scala 2.13/2.14.
AI-written summary · about
chapters (14)
- 0:00Introduction
- 4:13What is type class derivation
- 10:21The mirror type
- 15:09The mirror monotype
- 20:27Examples
- 26:58Derived Clause
- 35:44Question Marks
- 36:59Shapeless to
- 41:17Generic to
- 42:31Kind Star
- 43:20Generic
- 45:11Instances
- 46:39Products
- 46:58Signatures
related talks
31mType-Classes (in Scala 3)
31mShapeless? - Easy!
49mRoll Your Own Shapeless
57mKittens: Shapeless Typeclass Derivation for Cats
42mPolymorphic Function Types in Scala 3
51mAdding Kind-polymorphism To The Scala Programming Language
43mAdding kind-polymorphism to the Scala programming language
24mLet the Scala compiler work for you
