Figuring out how to abstract over typeclasses in Scala.