remove nasty bug in monad injection due to eager evaluation

This commit is contained in:
Thibault Duplessis 2013-05-20 16:13:09 -03:00
parent 2114adafd4
commit b008fd686c

View file

@ -123,7 +123,7 @@ trait WithPlay extends Zeros { self: PackageObject ⇒
def void: Funit = fua map (_ Unit)
def inject[B](b: B): Fu[B] = fua map (_ b)
def inject[B](b: B): Fu[B] = fua map (_ b)
def effectFold(fail: Exception Unit, succ: A Unit) {
fua onComplete {
@ -152,13 +152,6 @@ trait WithPlay extends Zeros { self: PackageObject ⇒
case e: Exception effect(e)
})
def nevermind[A: Zero] = fua recover {
case e: lila.common.LilaException {
logwarn(e.getMessage)
[A]
}
}
def thenPp: Fu[A] = fua ~ {
_.effectFold(
e logwarn("[failure] " + e),
@ -167,6 +160,16 @@ trait WithPlay extends Zeros { self: PackageObject ⇒
}
}
implicit final class LilaPimpedFutureZero[A: Zero](fua: Fu[A]) {
def nevermind = fua recover {
case e: lila.common.LilaException {
logwarn(e.getMessage)
[A]
}
}
}
implicit final class LilaPimpedFutureOption[A](fua: Fu[Option[A]]) {
def flatten(msg: String): Fu[A] = fua flatMap {