This question is for the people who know both Haskell (or any other functional language that supports Higher-kinded Types) and C++...
Is it possible to model higher kinded types using C++ templates? If yes, then how?
EDIT :
From this presentation by Tony Morris:
Higher-order Polymorphism :
Languages such as Java and C# have first-order polymorphism because they allow us to abstract on types. e.g.
List<A>
can have areverse
function that works on any element type (theA
).More practical programming languages and type systems allow us to abstract on type constructors as well.
This feature is called higher-order (or higher-kinded) polymorphism.
Example :
Pseudo-Java with an invented notation for higher-order polymorphism
interface Transformer<X, Y> {
Y transform(X x);
}
interface Monad<M> { // M :: * -> *
<A> M<A> pure(A a);
<A, B> M<B> bind(Transformer<A, M<B>> t, M<A> a);
}