A Tour of Morfa

Templates

A template is a declaration parametrised with some types or values. Templates in Morfa are similar in principle to templates in C++ and D.

You may declare a template for a class, structure or a function, but also for a constant or a variable.

A template may exist in many variants, each applicable to a range of possible template arguments. For each given tuple of arguments, the compiler chooses the best matching variant. This mechanism allows you to use templates for type-level programming.