Passing a partial list of implicits


Would there be interest from the community to be able to define something like

def f(implicit a: Int, b: String) = ???

and then be able to partly specify the implicit parameters, e.g.

f(b = "value")

and still get the compiler to do its job and try to lookup an implicit value for a?

I think it could seem especially useful to debug calls with a lot of implicits, e.g. shapeless-based methods, without requiring us to write n - 1 times implicitly or needing to worry about the position of each of the other arguments—e.g. f(b = "value", implicitly) doesn’t work.




What would your example do in the following case?

implicit val s: String = "Hello"
val curried_?: (Int)=>Nothing = f()

Basically my question is, should it support currying too (if yes, how, which syntax)?

Your example would not compile, as there is no implicit Int in scope.

This would compile, as it already does now: val curried_? = { implicit i: Int => f }.

I wished this feature existed many times.


@aborg, I agree with @jppellet.

What should maybe also compile in Dotty (haven’t checked, maybe you need def instead of val) is

val curried_? : implicit Int => Nothing = f

because in a definition with an implicit function type, the definition right-hand side is eta-expanded to bind the implicit—here, f is eta-expanded to (implicit i: Int) => f.