-
Couldn't load subscription status.
- Fork 1.4k
Add a new fromOptionError operator
#3813
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
|
I think this is definitely interesting. Have you explored using |
|
I find this vastly more useful than the current fromOption, FWIW. |
|
Yes. I wonder if we just move everything over. |
I'm ok with moving everything over to this. I use this extension locally in most of my projects because I wanted a drop in replacement for Also I'd prefer to move, because the naming of this operator is somewhat confusing, it would be better for it to just be the defacto. |
|
Agreed
…On 16 Jun 2020, 9:39 +0300, Paul Daniels ***@***.***>, wrote:
> Yes. I wonder if we just move everything over.
I'm ok with moving everything over to this. I use this extension locally in most of my projects because I wanted a drop in replacement for OptionT. I don't think I have any current instances of fromOption because they always require mapError or asError directly after them to make them work with other operators.
Also I'd prefer to move, because the naming of this operator is somewhat confusing, it would be better for it to just be the defacto.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
docs/overview/creating_effects.md
Outdated
| val zoption: IO[Option[Nothing], Int] = ZIO.fromOption(Some(2)) | ||
| ``` | ||
|
|
||
| The error type of the resulting effect is `Unit`, because the `None` case of `Option` provides no information on why the value is not there. You can change the `Unit` into a more specific error type using `ZIO#mapError`: |
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.
Does this paragraph need to be updated in lieu of the error channel now being defined as Option[Nothing] instead of Unit?
|
Agree to use |
| You can also readily compose it with other operators while preserving the optional nature of the result (similar to an `OptionT`) | ||
|
|
||
| ```scala mdoc:silent | ||
| val maybeId: IO[Option[Nothing], String] = ZIO.fromOption(Some("abc123")) |
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.
Really nice example!
|
@paulpdaniels Made a few comments but looks really good! Let me know when it's ready & tests are passing. Thank you for your work on this! |
|
@jdegoes comments addressed! |
1 similar comment
|
@jdegoes comments addressed! |
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!
Adds a new
fromOptionErroroperator which has better composability with the existingsome/optional/asSomeErrorcombinators.