Shapely: Super Simple Typeclass Derivation
summary
Shapely provides automatic typeclass derivation for Scala projects by generating a compact abstract representation (case-class/ sealed-trait shapes) and mapping to/from user types with a macro on Scala 2 or native derivation on Scala 3. It targets supports Scala 2.11–3, uses a minimal number of macros, and benchmarks show runtime parity with hand-written instances with only one object allocation per conversion. It divides products and coproducts with AC/DC typeclasses, handles up to 64-field/variant shapes, and is already used to rewrite zio-json encoders/decoders.
AI-written summary · about
chapters (11)
- 0:00Introduction and context
- 1:30Type classes in Scala
- 6:15Abstract data types
- 8:20The problem of derivation
- 14:30Introduction to Shapley
- 18:24AC DC type classes
- 24:30Usage and examples
- 26:42Advanced derivations
- 30:33Library internals
- 36:43Metaprogramming and annotations
- 42:40Handling recursion and lazy types
