diff options
Diffstat (limited to 'source/xi_lib/types.ml')
-rw-r--r-- | source/xi_lib/types.ml | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/source/xi_lib/types.ml b/source/xi_lib/types.ml new file mode 100644 index 0000000..14809cc --- /dev/null +++ b/source/xi_lib/types.ml @@ -0,0 +1,31 @@ + +type normal_type + = TP_Int + | TP_Bool + | TP_Array of normal_type + +let rec string_of_normal_type = function + | TP_Int -> "int" + | TP_Bool -> "bool" + | TP_Array el -> string_of_normal_type el ^ "[]" + +type extended_type = normal_type list + +let string_of_extended_type xs = + String.concat ", " @@ List.map string_of_normal_type xs + +type result_type + = RT_Unit + | RT_Void + +type env_type + = ENVTP_Var of normal_type + | ENVTP_Fn of extended_type * extended_type + +let string_of_env_type = function + | ENVTP_Var t -> string_of_normal_type t + | ENVTP_Fn (xs, []) -> Format.sprintf "fn(%s)" + (string_of_extended_type xs) + | ENVTP_Fn (xs, rs) -> Format.sprintf "fn(%s) -> (%s)" + (string_of_extended_type xs) + (string_of_extended_type rs) \ No newline at end of file |