


Unlike C or Java, Mythryl has type variables.
Mythryl uses single-character upper-case identifiers to name type variables. Type variables are wildcards which may match any concrete type:
List(String) # A list of strings.
List(X) # A list of values of any (single) type.
Type variables are limited in scope to a single type definition, which typically runs a line or less, so usually one to three type variables suffice, which by convention are usually X, Y, Z:
List(X) # A list of values of any (single) type.
Tree(X,Y) # A tree of two unspecified types, one for keys, one for values.
= PAIR (X,Y) # In practice the key type must usually be specified, to allow comparison.
| LEAF
;
Avatar(X,Y,Z) # An record of three unspecified types.
=
AVATAR
{ id: X,
description: Y,
icon: Z
};
Any single upper-case letter will be taken for a type variable. In addition, any single upper-case letter followed by an underbar and a lower-case variable is a legal type variable name:
A B C ... Z
A_icon_type
B_type
C_type
...
Z_best_type_of_all
Finally, Mythryl distinguishes between “equality types”, whose values may be compared for equality, and other types, whose values may not.
If a type variable must represent an equality type, that constraint is indicated by adding a leading underbar to its name:
_X # equality type variable.
_A_icon_type
This is much less common in practice than the use of vanilla type variables.


