0Pricing
Scala for Backend Engineering & Functional Programming · Lesson

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

  1. The Type Class Pattern
  2. Defining Instances
  3. Common Type Classes
  4. Type Class Derivation
← Back to Scala for Backend Engineering & Functional Programming