I could see it being used with 3rd party classes + DI to make easy to consume internal classes. or dsls now that i think about it.
class Logger(val name: String) {
fun log(s: String) = println("$name: $s")
}
class NotificationSender {
fun send(s: String) = println("sent: $s")
}
context(Logger, NotificationSender)
fun store(s: String) {
log("Stored: $s")
send("Success")
}
@Inject
data class Storer(val logger: Logger, val ns: NotificationSender) {
fun NotificationSender.log(s: String) = with(logger) { store(s) }
}
fun main() {
val logger = Logger("Main")
val ns = NotificationSender()
val storer = Storer(logger, ns)
storer.log("tacos")
}