-
-
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 more MonoidK
based folds
#4432
base: main
Are you sure you want to change the base?
Conversation
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.
Wait, is this foldMapM
?
cats/core/src/main/scala/cats/Foldable.scala
Lines 545 to 546 in 14286c9
def foldMapM[G[_], A, B](fa: F[A])(f: A => G[B])(implicit G: Monad[G], B: Monoid[B]): G[B] = | |
foldM(fa, B.empty)((b, a) => G.map(f(a))(B.combine(b, _))) |
@armanbilge oh lol, you are right. So we were only missing the "friends", right? Although, I should have realized it, since I first thought of calling |
Okay, after Arman realized I was reimplementing the wheel with the "traverse" ones. Actually, I just realized we are missing something |
foldTraverse
& friendsMonoidK
based folds
MonoidK
based foldsMonoidK
based folds
I am opening this before adding tests and docs to get feedback and see if it is a worth-it addition or not; or even to confirm this doesn't exist already 😅
I found myself needing
foldSequenceK
today having aList[Resource[IO, HttpRoutes[IO]]
and wanting to get back aResource[IO, HttpRoutes[IO]]
in an easy way.