diff --git a/src/main/scala/minisql/util/Show.scala b/src/main/scala/minisql/util/Show.scala index b4acc97..3496caf 100644 --- a/src/main/scala/minisql/util/Show.scala +++ b/src/main/scala/minisql/util/Show.scala @@ -1,21 +1,20 @@ package minisql.util -object Show { - trait Show[T] { - def show(v: T): String +trait Show[T] { + extension (v: T) { + def show: String } +} - object Show { - def apply[T](f: T => String) = new Show[T] { - def show(v: T) = f(v) +object Show { + + def apply[T](f: T => String) = new Show[T] { + extension (v: T) { + def show: String = f(v) } } - implicit class Shower[T](v: T)(implicit shower: Show[T]) { - def show = shower.show(v) - } - - implicit def listShow[T](implicit shower: Show[T]): Show[List[T]] = + given listShow[T](using shower: Show[T]): Show[List[T]] = Show[List[T]] { case list => list.map(_.show).mkString(", ") }