Skip to content

Instantly share code, notes, and snippets.

@slouc
slouc / ShapelessGenericTypeClassDerivation.scala
Last active May 2, 2017 19:40
ShapelessGenericTypeClassDerivation
import shapeless._
object Basic {
case class Person(firstName: String, age: Int, married: Boolean)
case class Band(name: String, numOfAlbums: Int, stillActive: Boolean)
def personSerialized(p: Person): List[String] = List(p.firstName, p.age.toString, p.married.toString)
def bandSerialized(b: Band): List[String] = List(b.name, b.numOfAlbums.toString, b.stillActive.toString)