-
-
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 flap function to Apply #2588
Conversation
Add the `flap` function to `Apply` to facilitate combining a function in an `Apply` context with a value which is not. This is similar to `ap`: ``` def ap[A, B](ff: F[A => B])(fa: F[A]): F[B] ``` with the minor change of the value not being in a context: ``` def flap[A, B](ff: F[A => B])(a: A): F[B] ^^^^ ```
Hi @ssanj, thanks for contributing! I don't think |
You're right. This could be moved into Yeah, naming this is hard. I hard a look at some of the Haskell equivalents and the variants I saw were: Another question I had was should this obey any specific Laws? |
When I move the
I've enquired whether this is a Simulcrum issue. I can get this to work if I rewrite
Has anyone seen this issue before? |
How about we call this |
Codecov Report
@@ Coverage Diff @@
## master #2588 +/- ##
==========================================
+ Coverage 95.16% 95.17% +0.01%
==========================================
Files 361 362 +1
Lines 6634 6655 +21
Branches 294 302 +8
==========================================
+ Hits 6313 6334 +21
Misses 321 321
Continue to review full report at Codecov.
|
@@ -31,6 +31,7 @@ trait AllSyntax | |||
with EqSyntax | |||
with FlatMapSyntax | |||
with FoldableSyntax | |||
with Function1Syntax |
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.
due to binary compatibility restrictions, you can't add it to this trait either. However, you can add it to AllSyntaxBinCompat3
which is a new trait that hasn't been released yet.
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. 👍
@kailuowang @LukaJCB does this look ok now? |
I am going to schedule this to 1.5 so that you don't have to change your BinaryCompat trait. |
Add the
flap
function toApply
to facilitate combining a function in anApply
context with a value which is not.This is similar to
ap
:with the minor change of the value not being in a context:
Thank you for contributing to Cats!
This is a kind reminder to run
sbt prePR
and commit the changed files before submitting.