How to solve the “PartiallyApplied” problem?

I’d like to make another case for multiple type parameter lists. The following already works:

def fromFunction[M[_], R](using app: Applicative[M])[A](f: R => A): Kleisli[M, R, A] =
  Kleisli(r => app.pure(f(r)))

fromFunction[List, Int](_ * 2)

The bytecode works out nicely too, properly being Kleisli fromFunction(Applicative, Function1) rather than what would happen with def fromFunction[M[_], R]: [A] => (R => A) => Applicative[M] ?=> ...

In other situations where the types explicitly specified are not to be bound with implicit parameters, using DummyImplicit (or using erased DummyImplicit under -language:experimental.erasedDefinitions) has the desired behavior as well.

So my thoughts are: why not just cut out the need middle parameter list entirely?

9 Likes