-
-
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 toNested to OptionT and XorT. #1172
Conversation
Nice @peterneyens. And thank you for the detailed explanation of the inconsistent
Since this is such a trivial method, I'm not really concerned about testing it. Maybe you could add a simple doctest example so the code coverage doesn't drop? Actually the examples you gave in this PR along with comments about potential |
Current coverage is 88.80%@@ master #1172 diff @@
==========================================
Files 233 233
Lines 3079 3081 +2
Methods 3025 3029 +4
Messages 0 0
Branches 51 49 -2
==========================================
+ Hits 2734 2736 +2
Misses 345 345
Partials 0 0
|
0a880e9
to
281cb44
Compare
281cb44
to
80be15f
Compare
I have added the I am not sure which part of the diff codecov is complaining about ? |
👍 looks great to me. Thanks for the detailed examples @peterneyens.
The "patch" code coverage stats often seem kind of bogus to me, though I'm sure this is just me not understanding what they represent. The overall project code coverage has gone up with this PR, so that's enough to make me happy. |
@adelbertc as our resident |
LGTM 👍 Some questions:
|
I am not sure if these |
What's here looks really good to me and has a couple 👍 already, so I'm going to go ahead and merge it. It sounds like there are some potential followups that could be addressed in later PRs. I agree with @peterneyens that |
I have added
toNested
toOptionT
andXorT
like I mentioned in #1107.This among other things makes it possible to use the "applicative
ap
" (calledapp
in Scalaz) which is inconsistent theap
it gets from the monad instances ofOptionT
orXorT
(see #1106).The
toNested
forXorT
is currently not that useful because we are not able to get the implicits forNested[F, A Xor ?, B]
, but it works with the SI-2712 fix :In #1107 I also suggested that we could simplify some functions like
foldLeft
by using the one fromNested
, but I benchmarkedoptiont.foldLeft(0)(_ + _)
(the current implementation) vsoptiont.toNested.foldLeft(0)(_ + _)
and the one usingtoNested
is quite a bit slower :Even though a
foldLeft
implementation withtoNested
would like slightly nicer, I am not sure it's worth the performance hit ? (This doesn't feel that important, but if someone wants to voice their opinion ...)F.compose(optionInstance).foldLeft(value, b)(f) toNested.foldLeft(value, b)(f)
I am not sure which tests to add (I could check for consistency for
map
,traverse
, ... ?)