scala-with-cats icon indicating copy to clipboard operation
scala-with-cats copied to clipboard

CRDT excercise confusion

Open oker1 opened this issue 8 years ago • 2 comments

I'm not sure if this is worth a clarification, but I've had a bit of head scratching with this one.

If you create the BoundedSemiLattice[Int] instance in a worksheet outside the BoundedSemiLattice companion object, it'll get picked up as Monoid[Int] by the increment method. The increment method will not work properly. While I really liked this excercise, it can be a bit confusing since it requires a Monoid[Int] with the add behavior for increment and it requires a BoundedSemiLattice[Int] (which happens to be also a Monoid[Int]) with the max behavior for the merge operation.

oker1 avatar Dec 05 '17 10:12 oker1

Hey Zsolt,

Thanks for the issue. I agree that the case study needs some work.

@noelwelsh has a bunch of changes incoming that will hopefully address the problems!

Cheers, Dave

On Tue, Dec 5, 2017 at 10:58 AM Zsolt Takács [email protected] wrote:

I'm not sure if this is worth a clarification, but I've had a bit of head scratching with this one.

If you create the BoundedSemiLattice[Int] instance in a worksheet outside the BoundedSemiLattice companion object, it'll get picked up as Monoid[Int] by the increment method. The increment method will not work properly. While I really liked this excercise, it can be a bit confusing since it requires a Monoid[Int] with the add behavior for increment and it requires a BoundedSemiLattice[Int] (which happens to be also a Monoid[Int]) with the max behavior for the merge operation.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/underscoreio/advanced-scala/issues/100, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOI5_rpecgIamZly2V6XQvf-Nak435wks5s9SHlgaJpZM4Q2Gkd .

davegurnell avatar Dec 05 '17 11:12 davegurnell

Hi everyone.

Any idea if we can change the signatures such that the BoundedSemiLattice instance for Int is picked up for merge and the Monoid instance for increment and total?

ioanluca avatar Mar 29 '20 10:03 ioanluca