let instantiate ~generalized def =
let subst =
(* Levels don't matter since we're never going to generalize. *)
List.map
(fun (i,c) -> (i,c), T.fresh ~level:0 ~constraints:c ~pos:None)
generalized
in
if generalized=[] then def else
V.map_types
(fun bound t ->
let subst =
List.filter (fun (x,_) -> not (List.mem x bound)) subst
in
T.copy_with subst t)
[]
def