remove nasty bug in monad injection due to eager evaluation
This commit is contained in:
parent
2114adafd4
commit
b008fd686c
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue