Having a cake and eating it too Introduction to Typeclasses
summary
Someone builds a small auction domain in Scala, then replaces per-class methods with concrete type class instances for Number, JsonWriter and Evaluator so mean, toJson and evaluate become generic functions driven by implicits. Code compiles, tests pass, and wrapping boilerplate disappears by adding implicit ops that give operators and methods to plain types. The talk demonstrates ad hoc polymorphism for decoupling domain from features, shows instance implementations for Int Double BigDecimal and shows the technique scaling to multiple serializers and evaluators.
AI-written summary · about
chapters (4)
related talks
20mType Classes for the Rest of Us
45mHow to be polymorphic in Scala
43mDon't Fear the Implicits: Everything You Need to Know About Typeclasses
43mMastering Typeclass Induction
48mAcademese to English: A Practical Tour of Scala’s Type System
24mLet the Scala compiler work for you
46mImplicits Inspected and Explained
30mLessons Learned from 15 Years of Scala in the Wild
