Static Typing Model

Felix uses an ML style static type system with C++ template style compile time polymorphism.

Anonymous Types
Name
Sample Type annotation
Sample Value
Comments
Tuple int * long * double
1,2L,3.0
Categorical product
Unit
1
()
Degenerate product
Variant
int + long
(case 1 of int+long) 2
Categorical sum
Void
0

Degenerate sum
Array
int ^ 3
1,2,3
Special tuple
Function
int -> int
fun (x:int) => x * x
May not have side effects
Procedure
int->void
proc (x:int){ print x; }
Evaluated for side effects

Generative Types
Name
Sample Type Definition Sample Value
Comments
Struct struct X { x:int; y:long; } X(1,2L) Categorical product
Union union U = | Some of int | None; (case 1 of int+long) 2
Categorical sum
Enum
enum E {False; True};
False
Special union