Blog

August 5, 2014

Activator Template: Type Classes

@dickwall
August 5, 2014

At Scaladays this year I presented a talk called Unsung Heroes, with some of my favorite Scala patterns and practices summarized in it. The talk can be found on Parleys. I felt that several of the patterns presented deserved a little more detail, and nothing adds detail like running code.

With that in mind, I am starting to put the patterns into a series of Activator templates and the first of these is now available. This template is called typeclass-tips and covers some of the ideas that are useful like:

  • Using type classes to provide serialization for domain objects
  • Boilerplate busting with companion objects
  • Making a companion object into its own type class
  • Taking advantage of the nature of case classes for easier serialization
  • Swapping serialization implementations in a few lines by swapping implicits

and more...


The template is available on github and is described on the Typesafe Activator templates site. You can most easily get it by downloading Activator (if you don’t have it already) and then searching for typeclass in the templates (the full description is Tricks and Tips with Type Classes in Scala). If you haven’t tried Activator before, this is a great opportunity to give it a whirl - it’s an excellent tool for learning.

comments powered by Disqus
Browse Recent Blog Posts