Skip to content

Instantly share code, notes, and snippets.

Avatar

fmc franklinchou

View GitHub Profile
@franklinchou
franklinchou / gist:9d27a92c3cb9537146a16ffe1ba55799
Created Nov 23, 2018 — forked from milessabin/gist:9042788
Boilerplate free conversion from case classes to shapeless records via LabelledGeneric ... coming soon to shapeless 2.0.0.
View gist:9d27a92c3cb9537146a16ffe1ba55799
scala> import shapeless._, record._
import shapeless._
import record._
scala> case class Person(name: String, address: String, age: Int)
defined class Person
scala> val joe = Person("Joe", "Brighton", 33)
joe: Person = Person(Joe,Brighton,33)
View Type_Families_Sealed_Traits_and_Exhaustive_Pattern_Matching_in_Scala.md

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.

You can’t perform that action at this time.