Please refer to the source code below. All source code is defined in the same package. When I define all of the code within a single source file ShowMain.scala
There's a rule that implicit has to be defined earlier in the compilation unit.
So, move object Show to the top and it compiles.
Alternatively,
object Show {
//implicit object StringShow extends Show[String] {
implicit val x: Show[String] = new Show[String] {
def show(s: String) = s"[String: $s]"
}
}
see the explanation about the type:
https://stackoverflow.com/a/2731285/1296806