Skip to content

Instantly share code, notes, and snippets.

View mattbarackman's full-sized avatar

Matt Barackman mattbarackman

View GitHub Profile
@mattbarackman
mattbarackman / Type_Families_Sealed_Traits_and_Exhaustive_Pattern_Matching_in_Scala.md
Last active August 25, 2020 01:08
A brief lesson on Type Families, Sealed Traits, and Exhaustive Pattern Matching in Scala

Scala: Type Families, Sealed Traits, and Exhaustive Pattern Matching

By: Matt Barackman

What is a Type Family?

A collection of objects or case classes that share a sealed trait.

In the example below, the type family would be a collection of traffic light colors with Red, Yellow, and Green as member objects.