-
Couldn't load subscription status.
- Fork 1.4k
Implement noneOrFail #4841 #4851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5904030 to
195011e
Compare
| * If the option is empty it succeeds with Unit. | ||
| * If the option is defined it fails with an error adapted with f. | ||
| */ | ||
| def noneOrFail[E, O](o: Option[O], f: O => E): IO[E, Unit] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think noneOrFail would fail with O and noneOrFailWith would allow specifying a function to transform the error type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the code. Now the 2 methods are available.
|
makes sense, I'll try that tomorrow
…On Tue, Mar 30, 2021 at 2:57 PM Adam Fraser ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In core/shared/src/main/scala/zio/ZIO.scala
<#4851 (comment)>:
> @@ -3649,6 +3649,14 @@ object ZIO extends ZIOCompanionPlatformSpecific {
*/
val none: UIO[Option[Nothing]] = succeedNow(None)
+ /**
+ * Lifts an Option into a IO.
+ * If the option is empty it succeeds with Unit.
+ * If the option is defined it fails with an error adapted with f.
+ */
+ def noneOrFail[E, O](o: Option[O], f: O => E): IO[E, Unit] =
I would think noneOrFail would fail with O and noneOrFailWith would allow
specifying a function to transform the error type.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4851 (review)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFK6ZDIHMKTCMMZ7MIE2DTTGHCUVANCNFSM4Z76GMQA>
.
|
16d0378 to
ef675fa
Compare
|
hey @adamgfraser , anything still needed before the merge ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! A couple of minor comments. Could you also pull in the latest upstream changes? We've had some changes to our CI infrastructure recently so want to make sure everything is running. Thanks again for your work on this!
|
Thanks for the review ! I'll have a look at the changes you requested, I think they all make sense. I don't know when I can handle these, this week is going to be quite busy. |
|
I rebased from master branch, currified, and added an alias in RIO and Task. The Task alias really makes sense ! Anything else @adamgfraser ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
No description provided.