Automatic type class instance derivation with shapeless
summary
Shows how to use the shapeless library to automatically derive Scala type-class instances (specifically Ordering) for case classes and ADTs by converting them to HLists and Coproducts via shapeless.Generic and composing existing implicit Orderings. Presents concrete code for implicit-driven recursive derivation that builds an Ordering from per-field orderings (including nested fields), and notes practical limits such as failure on recursive types, opaque compiler errors, and increased compilation cost.
AI-written summary · about
chapters (8)
- 0:00Introduction
- 2:07Type classes in Scala
- 7:09Generic representations
- 13:05Automatic instance derivation
- 25:11Recursive types and errors
- 34:22Advanced HList and Coproduct
- 39:19Experience and best practices
- 42:08Q&A
related talks
55mThe Shape of Shapeless (Part 2)
56mThe Shape of Shapeless (Part 1)
54mRoll Your Own Shapeless
57mKittens: Shapeless Typeclass Derivation for Cats
36mShapeless all the things !!
44mType level Computations in Scala
22mTransformation Function Called Higher-Order
37mExpressing Types as Values with Scalaz-Schema
