module C = Common module V = Value module Mv = struct type t = C.meta let compare (C.Mv i1) (C.Mv i2) = Stdlib.compare i1 i2 end module MvMap = Map.Make(Mv) type mentry = Unsolved of V.value (* type *) | Solved of (V.value * V.value) (* solution : type *) let metaEntries : mentry MvMap.t ref = ref MvMap.empty let getMetaEntry (m : C.meta) = MvMap.find m !metaEntries let modMetaEntry (f : mentry MvMap.t -> mentry MvMap.t) = metaEntries.contents <- f !metaEntries (* TODO: if not found then insert new meta for the type somehow *) let getMetaType (m : C.meta) = match getMetaEntry m with | Unsolved ty -> ty | Solved (_, ty) -> ty let resolveMeta (m : C.meta) = match getMetaEntry m with | Unsolved ty -> V.Stuck (V.Meta m, ty) | Solved (tr, _) -> tr