-
-
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 to Monad ifM example #1546
add to Monad ifM example #1546
Conversation
@@ -112,6 +112,8 @@ statement into the monadic context. | |||
import cats.implicits._ | |||
|
|||
Monad[List].ifM(List(true, false, true))(List(1, 2), List(3, 4)) | |||
|
|||
Monad[List].ifM(List(true, false, false))(List(1, 2), List(3, 4)) |
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.
how about also adding names to parameters?
like
Monad[List].ifM(List(true, false, true))(ifTrue = List(1, 2), ifFalse = List(3, 4))
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.
If we did that I think we could leave out the extra example. I will add parameter names. Do you want me to pull the second example?
6b18fde
to
d8b28fa
Compare
I added param names, left the second example in. happy to adjust further. I did a |
Codecov Report
@@ Coverage Diff @@
## master #1546 +/- ##
=======================================
Coverage 92.48% 92.48%
=======================================
Files 246 246
Lines 3885 3885
Branches 132 132
=======================================
Hits 3593 3593
Misses 292 292 Continue to review full report at Codecov.
|
Monad[List].ifM(List(true, false, true))(List(1, 2), List(3, 4)) | ||
Monad[List].ifM(List(true, false, true))(ifTrue = List(1, 2), ifFalse = List(3, 4)) | ||
|
||
Monad[List].ifM(List(true, false, false))(ifTrue = List(1, 2), ifFalse = List(3, 4)) |
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 agree that with the parameter names, the second example looks redundant.
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.
tend to agree, parameter names make it clear imo
i also was confused by the original example
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.
thanks, i got rid of the extra line
I found this section pretty confusing, but cleared up my misunderstanding quickly in the console. added param names per suggestions on PR.
d8b28fa
to
06cac41
Compare
👍 |
I found this section pretty confusing, but cleared up my misunderstanding quickly in the console.
This extra line in the example might help make it clear to people what is going on.