-
-
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 FlatMap#flatTap, a more principled version of the kestrel combinator. #1958
Conversation
core/src/main/scala/cats/Monad.scala
Outdated
* res3: List[Int] = List(4, 4, 4, 4) | ||
* }}} | ||
*/ | ||
def tapM[A, B](fa: F[A])(f: A => F[B]): F[A] = |
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.
can't this be on FlatMap
not Monad
?
Oh. Yeah, I guess it can. Thanks!
|
Codecov Report
@@ Coverage Diff @@
## master #1958 +/- ##
==========================================
+ Coverage 96.14% 96.14% +<.01%
==========================================
Files 273 273
Lines 4535 4536 +1
Branches 114 119 +5
==========================================
+ Hits 4360 4361 +1
Misses 175 175
Continue to review full report at Codecov.
|
I vote for |
* res1: Char = 'a' | ||
* }}} | ||
* */ | ||
def forEffect[A, B](fa: F[A])(fb: F[B]): F[A] = tapM(fa)(_ => fb) |
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.
There is another PR in flight to move this to a Apply. I don’t think we need tapM here. Can we revert this change?
…tor. It's a useful way of adding side-effects (as in, effects on the side) of a monadic (flatMappish?) computation.
Cool. That's two for the |
It's a useful way of adding side-effects (as in, effects on the side) of a monadic computation.
I almost called it
flatTap
; I welcome opinions for or against either name.