Type Class Derivation
Automatic instances.
What is Derivation?
Type class derivation generates instances automatically from a type's structure, so you do not hand-write boilerplate for every case class. The compiler builds the instance from its fields.
The Boilerplate Problem
Without derivation, every new case class needs a manual instance. For a Show over twenty case classes, that is twenty near-identical definitions. Derivation removes that repetition.
All lessons in this course
- The Type Class Pattern
- Defining Instances
- Common Type Classes
- Type Class Derivation