Leandro Borges Ferreira
07/16/2018, 2:57 PM@instance(Bill::class)
interface BillMonoid : Monoid<Bill> {
override fun empty(): Bill = Bill(0.0, LocalDate.MIN)
override fun Bill.combine(b: Bill): Bill = Bill(this.amount + b.amount, this.dueDate)
}
I get the extension function:
fun domain.Bill.Companion.monoid(): BillMonoid =
object : BillMonoid {
}
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?
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? Like one for sums, another one for multiplication, another subtractions... It would be good to be able to control the names that are generated, WDYT?