-
Notifications
You must be signed in to change notification settings - Fork 347
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
base: develop
Are you sure you want to change the base?
Conversation
…an be picked based on the monoid implementation
Conflicts: .gitignore
implicit val mapEq = mapEquiv[K,V] | ||
StatefulSummerLaws.sumIsPreserved(sc, mitems) && | ||
StatefulSummerLaws.isFlushedIsConsistent(sc, mitems) | ||
}).fold(true)(_ && _) |
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.
this is equivalent to .reduce(_ && _)
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]. |
The main idea is that depending on the Monoid implementation either calling 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. |
Is there a compelling example right now where not having this makes something else particularly bad or ugly? |
Sorry my bad, git foo on cmd line broke stuff and closed all of these |
|
In particular whether plus or sumOption is more efficient.