From 4d1e10dff683150b687c413b80e38ae0aba632c5 Mon Sep 17 00:00:00 2001 From: Jon Pretty Date: Mon, 12 Jun 2017 13:11:57 +0200 Subject: Improvements to error reporting --- examples/src/main/scala/example.scala | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'examples') diff --git a/examples/src/main/scala/example.scala b/examples/src/main/scala/example.scala index 5dd1f47..afd202e 100644 --- a/examples/src/main/scala/example.scala +++ b/examples/src/main/scala/example.scala @@ -89,12 +89,22 @@ object `package` { implicit class Showable[T: Show](t: T) { def show: String = implicitly[Show[T]].show(t) } + implicit val showString: Show[String] = identity + implicit val showBool: Show[Boolean] = _.toString + implicit def showList[T: Show]: Show[List[T]] = xs => xs.map { x => s"list:${implicitly[Show[T]].show(x)}" }.mkString(";") + implicit def showSet[T: Show]: Show[Set[T]] = s => "set" } sealed trait Tree case class Branch(left: Tree, right: Tree) extends Tree case class Leaf(value: Int) extends Tree +sealed trait Entity +case class Person(name: String, address: Address) extends Entity +case class Organization(name: String, contacts: Set[Person]) extends Entity +case class Address(lines: List[String], country: Country) +case class Country(name: String, code: String, salesTax: Boolean) + trait Show[T] { def show(t: T): String } object Show extends Show_1 { implicit val showInt: Show[Int] = _.toString -- cgit v1.2.3