Higher kinded types?

Ricky Clarkson ricky.clarkson at gmail.com
Wed Jan 16 20:07:03 PST 2013

This is surely outside the scope of the lambda effort, though possibly
would help the lambda effort.  I wondered whether any serious consideration
has been given to adding higher kinded types to Java.  For instance, I
cannot write this in Java (the ? is nonsense in that position):

interface Functor<F<?>> {
    public <A, B> F<B> map(Function<A, B>, F<A> fa);


public <M<?>, A> M<List<A>> sequence(List<M<A>> list)

That one would need at least one more parameter anyway so that the method
would 'know' how to create an M, but the point is that the signature itself
can't be typed as is.

I'm not a type wizard but I have a reasonable eye for spec/compiler
complexity and ambiguities and I would rate this as being simpler to spec,
implement and understand than Java 5 wildcards, the abandoned idea of
function types and autoboxing/autounboxing.

This doesn't come up all that often, but when it does it's a killer not to
have the feature, and there isn't even an approximation that comes close.
 It does come up more in functional code than imperative, and abstract code
more than direct code, so it would be a more marginal feature for Java at
least by today's standards.  Has it already been proposed by anybody?

More information about the lambda-dev mailing list