I'm trying to implement simple type class pattern. It suppose to work similarly to scalaz's typeclasses. Unfortunately I can't get it to work. I have trait Str
trait Str[T] { def str(t: T): String } object Str { def apply[T](implicit instance: Str[T]) : Str[T] = instance } And in my and implicit instance of it.
object Temp extends App { implicit val intStr = new Str[Int] { def str(i: Int) = i.toString } 1.str //error: value str is not a member of Int } I would appreciate any insight.
Str(1).str? You were not defining animplicit class, just anobjectwithapply.