Skip to content

Instantly share code, notes, and snippets.

@lancewalton
Created June 11, 2015 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lancewalton/d8f85659e18bb9fb21c2 to your computer and use it in GitHub Desktop.
Save lancewalton/d8f85659e18bb9fb21c2 to your computer and use it in GitHub Desktop.
package foo
object Foo extends App {
case class Tree(label: String, children: List[Tree])
trait Show[T] {
def show(t: T): String
}
implicit def listShow[T : Show]() = new Show[List[T]]{
def show(ts: List[T]) = "(" + ts.map(t => implicitly[Show[T]].show(t)).mkString(" ") + ")"
}
implicit val treeShow = new Show[Tree] {
def show(t: Tree) =
t.label +
listShow[Tree].show(t.children) // doesn't compile
// could not find implicit value for evidence parameter of type foo.Foo.Show[foo.Foo.Tree]
// not enough arguments for method listShow: (implicit evidence$1: foo.Foo.Show[foo.Foo.Tree])foo.Foo.Show[List[foo.Foo.Tree]]. Unspecified value parameter evidence$1.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment