Dave Gurnell

Workshop: Type Class Derivation with Shapeless

Functional Programmer and Synthesizer Enthusiast

Workshop: Type Class Derivation with Shapeless

In this workshop we will dive into generic programming in Scala using shapeless. We will start by discussing how to use shapeless to automatically create instances of type classes ("JSON encoder", "Equals", "Show", and so on) for any algebraic data type (case class or sealed trait). Once we have experience with the basic techniques, we will discuss the "lemma pattern", which allows us to bundle shapeless code into re-usable building blocks that we can combine at ever more powerful levels of abstraction. We will ground this theory by splitting into groups and developing several complete worked examples.

The workshop is aimed at established Scala developers who haven't yet got to grips with shapeless. It will use material from Dave's book "The Type Astronaut's Guide to Shapeless", which you can download for free from the Underscore web site, http://underscore.io/books/shapeless-guide. You will need: a laptop, a copy of Scala, and a clone of the exercises repo. http://github.com/underscoreio/shapeless-guide-code. Setup instructions are in the README on Github. Please grab the book and code before the workshop to avoid unexpected last minute technical problems.

Tutorial Objectives:

  • Learn how to eliminate Scala boilerplate using generic programming.
  • Demystify one of the most powerful libraries in the Scala ecosystem.
  • Amaze your friends with a new-found mastery of Scala's type system.


About Dave

Dave is a Scala consultant and developer working for Underscore in London, UK. He is the author and co-author of several books on Scala including the Type Astronaut's Guide to Shapeless and Advanced Scala with Cats. He has spoken on Scala and functional programming at numerous conferences worldwide, including Scala World, Scala Days, Scala Exchange, and ICFP.

Github: davegurnell

Twitter: @davegurnell

Back to conference page