First of all let me congratulate Debasish for this needed book.
I'm trying to understand the so-called explicit dictionary passing technique commented in listing 4.3 for passing appropiate Monoid[Money] instances to maxDebitOnDay and sumBalances but I can't figure out the magic.
I see that we implement a MoneyAdditionMonoid and a MoneyCompareMonoid in Monoid object but I don't understand how each call to maxDebitOnDay or sumBalances will get the correct one being the case that both monoids are in scope and implicit. The fact is that, once tested in the REPL, it works and I don't believe in black magic
It would be nice if someone could elaborate more on this or just point to some resources in the web. The latter will be great also for the book, inside the "Scala Tip" paragraph.
Thank you very much in advance.
Ivan.
|