Add some more implementations to Function0 and Function1 Monads#3515
Merged
Conversation
LukaJCB
previously approved these changes
Jul 11, 2020
Codecov Report
@@ Coverage Diff @@
## master #3515 +/- ##
=======================================
Coverage 91.54% 91.54%
=======================================
Files 386 386
Lines 8476 8483 +7
Branches 217 246 +29
=======================================
+ Hits 7759 7766 +7
Misses 717 717 |
ritschwumm
reviewed
Jul 12, 2020
| () => (fa(), fb()) | ||
|
|
||
| override def ap[A, B](f: () => A => B)(fa: () => A): () => B = | ||
| () => f().apply(fa()) |
There was a problem hiding this comment.
why was that .apply here in the first place? does () => f()(fa()) work on dotty, maybe?
Contributor
Author
There was a problem hiding this comment.
I think it starts to look like a soup of parens, so I didn't write it that way.
travisbrown
reviewed
Jul 12, 2020
|
|
||
| override def ap[A, B](f: () => A => B)(fa: () => A): () => B = | ||
| () => { | ||
| val fnAB = f() |
Contributor
There was a problem hiding this comment.
You can write this as either f.apply.apply(fa()) or f()(fa()) on Dotty, both of which are I think a little nicer than the extra val.
barambani
approved these changes
Jul 13, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is just filling out some methods on these Monads that were left to default implementations. I think implementing them by hand slightly reduces the stack depth we are at when calling these