Materialize Typeclasses with Magnolia
summary
Shows how Magnolia derives typeclasses at compile time to auto-generate Json/Avro/BigQuery/Protobuf converters for case classes and sealed traits, replacing hand-written instances and shapeless macros. Demonstrates a tiny jsonify implementation and avro/generic-record converters that perform successful round-trips, and reports significantly faster compile times versus shapeless for arbitrary/converter derivation. Mentions Spotify’s magnolify project and practical limitations (dispatch for some unions, handling multi-parameter typeclasses) and workarounds.
AI-written summary · about
chapters (20)
- 0:00Introduction and agenda
- 1:05What are type classes
- 3:34Designing a type class
- 5:41JSONify library overview
- 8:55Deriving type classes manually
- 11:03Magnolia introduction
- 13:09Using Magnolia for JSONify
- 17:45Deriving type class for products
- 18:27Deriving type class for coproducts
- 20:34Putting it all together
- 22:19Magnolia limitations and workarounds
- 23:25Type class variance in Magnolia
- 24:31Magnolia in Spotify's Shio
- 25:16Magnolia in testing and cats
- 25:38Converters in Spotify
- 27:05Avro field type class
- 29:52Future support for coproducts
- 30:13Type class in action demo
- 31:58Benchmark results
- 32:41Magnolia improvements and references
related talks
25mMagnolia: Generic Derivation 2.0
01h 12mDeriving pleasure
20mType Classes for the Rest of Us
23mCASE STUDY FOR A REAL-WORLD TYPE-LEVEL PROGRAMMING
29mADVENTURES IN META-PROGRAMMING
40mUnshaped Protos Beyond Code Generation for Protocol Buffers
30mHaving a cake and eating it too Introduction to Typeclasses
24mLet the Scala compiler work for you
