Created
June 11, 2015 21:06
-
-
Save lancewalton/d8f85659e18bb9fb21c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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