From b798ac29c37299b2f761243ae92ab8f7c4c4d7f1 Mon Sep 17 00:00:00 2001 From: Paweł Dybiec Date: Tue, 30 Oct 2018 15:32:56 +0100 Subject: Initial commit --- source/xi_lib/types.ml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 source/xi_lib/types.ml (limited to 'source/xi_lib/types.ml') 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 -- cgit 1.4.1