Is it possible to "curry" higher-kinded types in Scala?
You mean something like this?
trait QuxWithString[A] extends Qux[A, String]
new Turkle[QuxWithString]{}
This is the analog to partial application for types.
trait Turkle[C[_]]
trait Qux[A,B]
trait Wraps[A] {
type Jkz[X] = Qux[A,X]
trait Baz extends Turkle[Jkz]
}
Jason Zaugg came up with the most succinct way to do this:
trait Baz[A] extends Turkle[({type x[a]=Qux[A, a]})#x]
IntelliJ's Scala plugin will optionally collapse this to:
trait Baz[A] extends Turkle[x[a]=Qux[A, a]]
The compiler plugin kind projector allows this as well:
// Explicit lambda, greek letters
trait Baz[A] extends Turkle[λ[α=>Qux[A,α]]]
// Explicit lambda, normal letters
trait Baz[A] extends Turkle[Lambda[a=>Qux[A,a]]]
// No explicit lambda, ? placeholder
trait Baz[A] extends Turkle[Qux[A,?]]