From e4af7c3090c93a129e99dd75f2a20d5a9d2f6920 Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Fri, 27 Jul 2018 18:50:31 +0100 Subject: Make type annotations abstract in type_check.mli Rather than exporting the implementation of type annotations as type tannot = (Env.t * typ * effect) option we leave it abstract as type tannot Some additional functions have been added to type_check.mli to work with these abstract type annotations. Most use cases where the type was constructed explicitly can be handled by using either mk_tannot or empty_tannot. For pattern matching on a tannot there is a function val destruct_tannot : tannot -> (Env.t * typ * effect) option Note that it is specifically not guaranteed that using mk_tannot on the elements returned by destruct_tannot re-constructs the same tannot, as destruct_tannot is only used to give the old view of a type annotation, and we may add additional information that will not be returned by destruct_tannot. --- src/interpreter.ml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/interpreter.ml') diff --git a/src/interpreter.ml b/src/interpreter.ml index e4f7faf0..9a1d0ed2 100644 --- a/src/interpreter.ml +++ b/src/interpreter.ml @@ -135,7 +135,7 @@ let is_false = function | (E_aux (E_internal_value (V_bool b), _)) -> b == false | _ -> false -let exp_of_value v = (E_aux (E_internal_value v, (Parse_ast.Unknown, None))) +let exp_of_value v = (E_aux (E_internal_value v, (Parse_ast.Unknown, Type_check.empty_tannot))) let value_of_exp = function | (E_aux (E_internal_value v, _)) -> v | _ -> failwith "value_of_exp coerction failed" @@ -589,7 +589,6 @@ and exp_of_lexp (LEXP_aux (lexp_aux, _) as lexp) = | LEXP_field (lexp, id) -> mk_exp (E_field (exp_of_lexp lexp, id)) and pattern_match env (P_aux (p_aux, _) as pat) value = - (* print_endline ("Matching: " ^ string_of_pat pat ^ " with " ^ string_of_value value |> Util.yellow |> Util.clear); *) match p_aux with | P_lit lit -> eq_value (value_of_lit lit) value, Bindings.empty | P_wild -> true, Bindings.empty -- cgit v1.2.3