In my code base, I found useful having such combinator:
def not[R, E](effect: ZIO[R, E, Boolean]) =
effect.map(result => !result)
e.g., if you have method activated(foo), it's quite concise to write not(activated(foo)).
It's quite easy to add it, so I can do it myself. Though, I'd like to have approval from core contributors to do it, in order to avoid doing wasteful work.
I think this makes sense. I might suggest making it a method on the trait itself since it involves a single value and calling it negate to match a couple of other combinators we have in various places in ZIO that do the same thing. So it would be:
trait ZIO[-R, +E, +A] { self =>
def negate(implicit ev: A <:< Boolean): ZIO[R, E, Boolean] =
map(a => !ev(a))
}
Then it could be used like activated(foo).negate.
Could also have the not variant on the companion object if we wanted.
consider doing #3635 too 馃槃
Most helpful comment
I think this makes sense. I might suggest making it a method on the trait itself since it involves a single value and calling it
negateto match a couple of other combinators we have in various places in ZIO that do the same thing. So it would be:Then it could be used like
activated(foo).negate.Could also have the
notvariant on the companion object if we wanted.