Skip to content

make SummingCache a trait and provide multiple implementations that can be picked based on the monoid implementation #312

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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

julienledem
Copy link
Contributor

In particular whether plus or sumOption is more efficient.

implicit val mapEq = mapEquiv[K,V]
StatefulSummerLaws.sumIsPreserved(sc, mitems) &&
StatefulSummerLaws.isFlushedIsConsistent(sc, mitems)
}).fold(true)(_ && _)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is equivalent to .reduce(_ && _)

@jcoveney
Copy link
Contributor

I do not love this approach. I don't like the idea that all monoids have to now tag themselves with anything that might be useful to caching...I would vastly prefer for these two to be decoupled. It IS possible to do this with typeclass, but the syntax gets pretty nasty when you want to do it on Semigroup[T].

@julienledem
Copy link
Contributor Author

The main idea is that depending on the Monoid implementation either calling plus or sumOption will be more efficient and that's a characteristic of the Monoid.
I'm trying to find a good way for the Monoid to advertise this property. Suggestions welcome.

Another simpler option is to add a method in Semigroup which will return plus as the preferred summing mechanism. Monoids implementing sumOption or sum could override it and indicate sumOption is prefered instead.

@jcoveney
Copy link
Contributor

Is there a compelling example right now where not having this makes something else particularly bad or ugly?

@ianoc ianoc closed this Aug 4, 2015
@ianoc
Copy link
Collaborator

ianoc commented Aug 4, 2015

Sorry my bad, git foo on cmd line broke stuff and closed all of these

@ianoc ianoc reopened this Aug 4, 2015
@CLAassistant
Copy link

CLAassistant commented Jul 18, 2019

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants