Skip to content

Conversation

@johnynek
Copy link
Contributor

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

LukaJCB
LukaJCB previously approved these changes Jul 11, 2020
@codecov-commenter
Copy link

codecov-commenter commented Jul 12, 2020

Codecov Report

Merging #3515 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           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           

() => (fa(), fb())

override def ap[A, B](f: () => A => B)(fa: () => A): () => B =
() => f().apply(fa())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was that .apply here in the first place? does () => f()(fa()) work on dotty, maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it starts to look like a soup of parens, so I didn't write it that way.


override def ap[A, B](f: () => A => B)(fa: () => A): () => B =
() => {
val fnAB = f()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@johnynek johnynek merged commit 8ca1096 into master Jul 13, 2020
@travisbrown travisbrown added this to the 2.2.0-RC2 milestone Jul 17, 2020
@larsrh larsrh deleted the oscar/function_methods branch September 19, 2020 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants