Generics 如何使用Scalaz标记Generic和使用Generic进行模式匹配
我希望能够做到以下几点Generics 如何使用Scalaz标记Generic和使用Generic进行模式匹配,generics,tags,pattern-matching,match,scalaz,Generics,Tags,Pattern Matching,Match,Scalaz,我希望能够做到以下几点 sealed trait S trait S1 extends S trait S2 extends S case class A[Z <: S](item: URI @@ Z) class SActor extends Actor { def receive = { case A[Z](item) => val item2: URI @@ Z = //do some sort of operation sende
sealed trait S
trait S1 extends S
trait S2 extends S
case class A[Z <: S](item: URI @@ Z)
class SActor extends Actor {
def receive = {
case A[Z](item) =>
val item2: URI @@ Z = //do some sort of operation
sender ! A[Z](item2)
case _ =>
}
}
A需要一个泛型,但我们不知道要分配哪个。我只想用它开始时的哪一个来假设演员遵守那个合同。编译器会说A需要一个泛型,但它要求一个特定的感谢您阅读本文,并特别感谢能够解决此难题的任何人
EitherT((actor ? A(item)).mapTo[A]
//assume actor responds back with an A and the same Tag