我正在使用scala-2.8.1和scalaz-5.0。谁能准确解释为什么PartialApply1Of2
在一种情况下可以推断出 a 在另一种情况下不能推断?
scala> 1.success[String] <|*|> "Bah".fail[Int]
res1: scalaz.Validation[String,(Int, Int)] = Failure(Bah)
即使(如前所述!)该方法<|*|>
具有MA
一个类型参数,而不是两个(如此Validation
),这仍然有效。我无法在我的 IDEA REPL 中使用 unicode,所以这里是:
object testy {
def main(args: Array[String]) {
import scalaz._
import Scalaz._
val ps = NonEmptyList(1.success[String], "Bah".fail[Int])
val res = ps.∘∘((_ : Int) % 2 == 0) //DOES NOT COMPILE
println(res)
}
}
我可以为呼叫提供特定类型,一切都很好。为什么scalac
不能推断这个?
ps.∘∘[PartialApply1Of2[Validation, String]#Apply, Int, Boolean]((_ : Int) % 2 == 0)
在我的 REPL 中,这实际上会导致 scalac 错误,而不是合理的错误消息