diff options
| author | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2000-10-25 23:01:33 +0000 |
|---|---|---|
| committer | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2000-10-25 23:01:33 +0000 |
| commit | 800f0ca969b53c839fa449684f7933e3deaf3382 (patch) | |
| tree | ddea4b21f118bbfc3d248aca987ac855b868a774 | |
| parent | 366b3753355aabf9f085952d9daa36e63d582064 (diff) | |
| download | ocaml-800f0ca969b53c839fa449684f7933e3deaf3382.tar.gz | |
instance_poly
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/poly_meth@3315 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
| -rw-r--r-- | typing/ctype.ml | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/typing/ctype.ml b/typing/ctype.ml index 12179f703f..9fab0bbdc7 100644 --- a/typing/ctype.ml +++ b/typing/ctype.ml @@ -834,6 +834,8 @@ let conflicts free bound = let delayed_copy = ref [] (* copying to do later *) +(* Copy without sharing until there are no free univars left *) +(* all free univars must be included in [visited] *) let rec copy_sep free bound visited ty = let ty = repr ty in let univars = free ty in @@ -847,7 +849,7 @@ let rec copy_sep free bound visited ty = else try let t, bound_t = List.assq ty visited in let dl = diff_list bound bound_t in - if dl <> [] & conflicts univars dl then raise Not_found; + if dl <> [] && conflicts univars dl then raise Not_found; t with Not_found -> begin let t = newvar() in (* Stub *) @@ -888,9 +890,11 @@ let rec copy_sep free bound visited ty = t end -let instance_sep sch = +let instance_poly univars sch = + let vars = List.map (fun _ -> newvar ()) univars in + let pairs = List.map2 (fun u v -> repr u, (v, [])) univars vars in delayed_copy := []; - let ty = copy_sep (compute_univars sch) [] [] sch in + let ty = copy_sep (compute_univars sch) [] pairs sch in List.iter Lazy.force !delayed_copy; delayed_copy := []; cleanup_types (); |
