How to be polymorphic in Scala
summary
Explains concrete Scala features: type classes implemented via implicits with examples for Int and List, a Show instance that either prints numbers or bars, and compiler errors when instances are missing; shows implicit conversions used to extend syntax (custom ternary-like operator, complex number + overload) and how variance, higher-kinded types and predicative limits behave. Demonstrates trait mixins for per-instance behavior, notes compile-time dispatch and runtime performance tradeoffs (slower compilation but zero runtime magic).
AI-written summary · about
chapters (12)
- 0:00Polymorphism introduction
- 1:20Parametric polymorphism
- 5:17Higher-rank polymorphism
- 7:24Variance in Scala
- 13:54Traits and roles
- 17:56Operator overloading
- 21:11Type casting
- 24:02Syntax extension
- 28:17Type Class in Scala
- 35:27Type Class practice
- 37:37Comparison with JavaScript
- 41:15Conclusion
related talks
41mPolymorphism in Scala
42mPolymorphic Function Types in Scala 3
32mUnderstanding the Type System of Scala 3
43mDon't Fear the Implicits: Everything You Need to Know About Typeclasses
43mAdding kind-polymorphism to the Scala programming language
32mAdvanced Features of Scala 3
51mAdding Kind-polymorphism To The Scala Programming Language
40mPolymorphic Function Types in Scala 3
