-
Notifications
You must be signed in to change notification settings - Fork 597
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 foldMap
alternative that uses scan
, scanMonoid
#1184
Comments
As mentioned in the gitter channel, I'll gladly implement these ;) |
@kubukoz Do you still want to implement these? The signatures look good to me. |
Yeah, I haven't had much time lately so if someone wants to do them soon
I'm good with that, but hopefully I'll have some time after the weekend, in
case nobody picks this up :)
…On Thu, Sep 6, 2018, 14:05 Michael Pilquist ***@***.***> wrote:
@kubukoz <https://github.com/kubukoz> Do you still want to implement
these? The signatures look good to me.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1184 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA2npBxc3gJKJOXRlFGSLkMeBCDiO0Zeks5uYQ-EgaJpZM4VbUOv>
.
|
Sounds good to me. Looking forward to it. |
I'm on it! Should be done this week. I saw that What I'd be looking for now is: def evalScanMonoid[F2[x] >: F[x], O2](f: O => F2[O2])(implicit O2: Monoid[O2],
F: Functor[F2]): Stream[F2, O2] =
evalScan[F2, O2](O2.empty) { (acc, o) =>
f(o).map(O2.combine(acc, _))
} Maybe Edit: Now that I think about it, I think having the |
I couldn't find that method in the code base, only from old commits from 2013, seems it didn't make it at the end. So I defined it myself like: def scanMap[O2](f: O => O2)(implicit O2: Monoid[O2]): Stream[F, O2] =
self.scan(O2.empty)((acc, el) => acc |+| f(el))
def scanMonoid(implicit O: Monoid[O]): Stream[F, O] =
self.scanMap(identity) Happy to PR the snippet above if it's useful to others. |
@tabdulradi Sounds good, PR is definitely welcome! |
Something along the lines of:
Not sure about the naming of it, could be
evalScanMonoid
or something like that, but it looks similar tofoldMap
to me (apart from theFunctor[F]
requirement). Maybe it's possible to write it withpull
and without the Functor bound?Also,
scanMonoid
resemblingfoldMonoid
:The text was updated successfully, but these errors were encountered: