I try to find out why the call ∅
in scalaz.ListW.<^>
works
def <^>[B: Zero](f: NonEmptyList[A] => B): B = value match {
case Nil => ∅
case h :: t => f(Scalaz.nel(h, t))
}
My minimal theory is:
trait X[T]{
def y : T
}
object X{
implicit object IntX extends X[Int]{
def y = 42
}
implicit object StringX extends X[String]{
def y = "y"
}
}
trait Xs{
def ys[T](implicit x : X[T]) = x.y
}
class A extends Xs{
def z[B](implicit x : X[B]) : B = ys //the call ∅
}
Which produces:
import X._
scala> new A().z[Int]
res0: Int = 42
scala> new A().z[String]
res1: String = y
Is this valid? Can I achieve the same result with fewer steps?