<@UBD6YCVAR> &gt; Well, the first problem is: If...
# arrow
r
@Leandro Borges Ferreira
Well, the first problem is: If I don’t create a companion object for
Bill
, my code doesn’t compile. That’s easy to workaround, but is it the expected behaviour?
Yes that is the expected behavior you need a companion to expand the reference to the type class instance.
Second: The name of the method I get is
monoid()
. What if I would like to create more than one type of monoid for different types of morphisms?
Ideally there is a single only one valid instance per type. In that case you may want to extend
Monoid
with new type classes
Sum
and
Product
and create instances for those instead