I would like to have a higher order function that takes in parameter a function that accepts a specific implicit parameter.
To be more precise, I am trying to make a
The problem is that foo
is a method, not a function, and eta-expansion (which converts methods to functions) is not attempted until after implicit application. See section 6.26.2 of the language specification for the details, and this issue for additional discussion.
One workaround would be to write something like this:
provideCtx((ctx: ExecutionContext) => (a: Int) => foo(a)(ctx))
I'm not sure a more generic solution is possible (at least without some kind of reflection, etc.), since we can't even refer to foo
(except in a method call, of course) without an implicit in scope.