-
-
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
Follow up to #3233 #3237
Follow up to #3233 #3237
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3237 +/- ##
==========================================
- Coverage 93.38% 93.05% -0.34%
==========================================
Files 372 376 +4
Lines 7226 7413 +187
Branches 185 201 +16
==========================================
+ Hits 6748 6898 +150
- Misses 478 515 +37
Continue to review full report at Codecov.
|
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.
Thank you for persevering on this!
} | ||
|
||
forAll { (i: List[Int], b: Boolean) => | ||
OptionT.whenF[List, Int](b)(i).value should ===(when(b, i).sequence) |
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'm unsure whether I'd ever reason about code by this property, but I noticed it when I thought about the types and it seems to pass. I'm curious whether others think this one is actually useful.
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.
The test case is very interesting to me, but certainly less obvious that it universally holds (not only in the case when F = List).
Added abd798b to remove it for now.
👍 to restore it if someone knows a good explanation about it.
forAll { (li: List[Int], b: Boolean) => | ||
OptionT.whenF(b)(li).value should ===(li.map(when(b, _))) | ||
test("OptionT.whenF[F, A] consistent with Option.when") { | ||
def when[A]: (Boolean, A) => Option[A] = (c: Boolean, a: A) => if (c) Some(a) else None |
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.
Not a blocker, but since the property refers to Option.when
, it might be helpful to future readers to comment why it's inlined here (e.g., that it's not available before 2.13).
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.
LGTM. Thank you @strong-zero!
A follow up to #3233 based on the helpful comments by @fthomas and @rossabaker:
OptionT.{whenF, unlessF}
should returnOptionT.none
when the given condition isfalse
.