-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add convenience wrapper for Xor.fromOption in XorT #1078
Conversation
Seems like you are missing an implicit parameter here. |
Japp, pushed fix now. |
Current coverage is 88.32%
@@ master #1078 diff @@
==========================================
Files 224 223 -1
Lines 2842 2809 -33
Methods 2785 2753 -32
Messages 0 0
Branches 52 51 -1
==========================================
- Hits 2505 2481 -24
+ Misses 337 328 -9
Partials 0 0
|
With the current val foo: Option[Int] = ???
XorT.fromOption[Future, String, Int](foo, "Couldn't find foo") Maybe you could create a The code above could then look like : XorT.fromOption[Future](foo, "Couldn't find foo") |
Good idea, updated like that. Btw, do you know if fromOptionT[F, _] also should be added, or is it supported somehow else? |
|
Ajapp, those are probably best to use. |
@mkotsbak I'm wondering if a more general solution might be to add a |
Well, yes, I suppose that is the same as fromXor just in the opposite direction, but possibly requiring specifying less types explicit, almost like typing this manually:
Maybe we could have both available. |
I can see the following ways how we can do this at the moment (without this PR): XorT.fromXor[Future](1.some.toRightXor("kamboom"))
OptionT.fromOption[Future](1.some).toRight("kamboom") I don't think the first one is much worse than @ceedubs Your |
@peterneyens yeah, I guess you are right that my I tend to agree with @peterneyens that it's not that much more verbose to use the existing methods in cats. I'm hesitant to add this, because it seems like if we are adding edit: oops it looks like |
It seems there already is an |
Ok, so now with the other PR we have: with workaround:
so then I think we don't need fromOption so I close this PR. |
Hmm, but there is still no myOption.toRightXor? Yes, it is if |
No description provided.