Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sirthias
Copy link
Contributor

@sirthias sirthias commented Apr 2, 2020

in the spirit of filter/filterNot, doUntil/doWhile, retryUntil/retryWhile and the like.

@CLAassistant
Copy link

CLAassistant commented Apr 2, 2020

CLA assistant check
All committers have signed the CLA.

@sirthias
Copy link
Contributor Author

sirthias commented Apr 2, 2020

unlessM is especially useful since negating the condition for use with when is more clunky on the "lifted" level than it is on the value level:

val zio: ZIO[..., ..., ...] = ...

val cond: Boolean = ...
val when = zio.when(cond)
val unless0 = zio.when(!cond) // negation is easy
val unless1 = zio.unless(cond) // maybe clearer

val condM: UIO[Boolean] = ...
val whenM = zio.whenM(cond)
val unlessM0 = zio.whenM(cond.map(!_)) // negation is more clunky
val unlessM1 = zio.unlessM(cond) // clearer and more concise

@adamgfraser
Copy link
Contributor

Yes. There is a little danger here that we have another different set of ways to do very similar things but I am inclined to think this makes sense.

Copy link
Contributor

@adamgfraser adamgfraser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@adamgfraser adamgfraser merged commit 5d9ee02 into zio:master Apr 2, 2020
@sirthias sirthias deleted the sirthias/unless branch April 2, 2020 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants