What are Scala Type Classes?

What are Scala type classes, what kind of problem do they solve and how are they implemented?

In a nut shell, type classes provide polymorphism without using subtyping, but in a completely type safe way.

Type classes represent some common functionality that can be applied to values of many different types. Moreover, we don’t have to change existing types in order to extend them with the new functionality.

In this post I will describe 5 simple steps for encoding a type class in Scala in an idiomatic way.

Continue reading →