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/state.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/state.ml') diff --git a/src/state.ml b/src/state.ml index 245d450c..70e53a52 100644 --- a/src/state.ml +++ b/src/state.ml @@ -69,9 +69,9 @@ let find_registers defs = List.fold_left (fun acc def -> match def with - | DEF_reg_dec (DEC_aux(DEC_reg (typ, id), annot)) -> - let env = match annot with - | (_, Some (env, _, _)) -> env + | DEF_reg_dec (DEC_aux(DEC_reg (typ, id), (_, tannot))) -> + let env = match destruct_tannot tannot with + | Some (env, _, _) -> env | _ -> Env.empty in (Env.expand_synonyms env typ, id) :: acc -- cgit v1.2.3