나는이 모나드 클래스가 있다고 가정새로운 desugaring 동작 2.10.1
scala> for { (a, b) <- Foo(List(1 -> "x")) } yield a
res0: Foo[Int] = Foo(List(1))
그리고 여기에 2.10에서 같은 일이 :
case class Foo[A](xs: List[A]) {
def map[B](f: A => B) = Foo(xs map f)
def flatMap[B](f: A => Foo[B]) = Foo(xs flatMap f.andThen(_.xs))
def withFilter(p: A => Boolean) = {
println("Filtering!")
Foo(xs filter p)
}
}
다음은 2.10.0 REPL 세션에서입니다 .1 :
scala> for { (a, b) <- Foo(List(1 -> "x")) } yield a
Filtering!
res0: Foo[Int] = Foo(List(1))
이것은 완전히 예상하지 못했던 것이며 (필자에게) 특히 필터링 요청이 추가 제약 조건 (예 : Scalaz의 \/
or EitherT
)이 있습니다.
2.10.1 release notes에서이 변경 사항에 대한 설명을 찾을 수 없습니다. 누군가가이 새로운 desugaring 행동이 도입 된 이유와 이유를 지적 할 수 있습니까?