<@U88HXKLP3> in the current KEEP proposal we are a...
# arrow-contributors
r
@jacob in the current KEEP proposal we are at a point where we can start with the POC which in its first approach looks like:
Copy code
// type class
interface Monoid<A> {
  fun A.combine(b: A): A
  val empty: A
}
// instance
extension object IntMonoid : Monoid<Int> {
  fun Int.combine(b: Int): Int = this + b
  val empty: Int = 0
}

// polimorphic function or class that depends on `Monoid`
fun <A> add(a: A, b: A, with Monoid<A>): A = a.combine(b)
add(1, 1) // compiles
add("a", "b") // does not compile: No `Monoid<String>` instance defined in scope
add
may desugar to:
Copy code
fun <A> add(a: A, b: A, $ev: Monoid<A>): A = $ev.run { a.combine(b) }