in the following:

    def expr1: Boolean = ???
    def expr2: Boolean = ???

    val res: Boolean = expr1 || expr2

Then is expr1 is true will not be evaluated. Is there a mechanism `foo`
such that the following (assuming M is a monad) ...

    def expr1: M[Boolean] = ???
    def expr2: M[Boolean] = ???

    val res: M[Boolean] = foo(expr1, expr2)

...will behave similarly ~> that is, expr2 would not be evaluated *at all*
if expr1 is true. This works:

    def foo[M: Monad](expr1: M[Boolean], expr2: M[Boolean]): M[Boolean] =
expr1.ifM(ifTrue = M.pure(true), ifFalse = expr2)

But it feels rather clumsy. Is there a better way?

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"scalaz" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/scalaz.
For more options, visit https://groups.google.com/d/optout.

Reply via email to