Speaker Deck

Typeclasses from the Ground Up

by Daniel Westheide

Published September 28, 2016 in Programming

When it comes to typeclasses and implicits – the mechanism used for implementing this pattern in Scala – there appears to be a big gulf: They are widely used not only in many popular Scala libraries, but also in the standard library. On the other hand, many Scala developers are not familiar with them or find them too daunting.
Since it is difficult to evade them when writing real world Scala code, I would like to encourage developers adopting Scala to overcome their fear of implicits and instead embrace the typeclass pattern. At the same time, I want to raise awareness of the problems that can arise when you do so too eagerly.
In this talk, as an intermediate Scala developer, you will learn typeclasses from the ground up: What they are good for and how they compare to what you are familiar with from object-oriented languages, when you should and should not use them, how the pattern can be encoded in Scala and how to write your own typeclasses, how to provide instances of typeclasses for your own or existing types, and how to do all of this with minimal boilerplate. Throughout the talk, you will see numerous examples of typeclasses used in the Scala ecosystem and the standard library, and you’ll see that you don’t need to know anything about category theory to benefit from embracing type classes.