1
0
Fork 0

useless application

This commit is contained in:
Mylloon 2024-04-27 12:33:58 +02:00
parent cc709fb5b3
commit fd68a06c08
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -22,20 +22,25 @@ let rec apply subst = function
| Type.Arrow (ty1, ty2) -> Type.Arrow (apply subst ty1, apply subst ty2)
;;
(** Compose two substitutions *)
(** Compose two substitutions, last with priority *)
let compose s2 s1 =
IdentifierMap.merge
(fun _ ty1 ty2 ->
match ty1, ty2 with
(* If we have 2, we pick one of them *)
| Some ty1', Some _ -> Some (apply s2 ty1')
(* If we have 1, we pick the one we have *)
| Some ty1', None -> Some (apply s2 ty1')
| None, Some ty2' -> Some (apply s2 ty2')
(* If we have 0, we return nothing *)
| None, None -> None)
s1
s2
let merger =
IdentifierMap.merge
(* ID type_s1 type_s2 *)
(fun _ ty1 ty2 ->
match ty1, ty2 with
(* Dans ce cas, on donne la priorité à s1 *)
| Some ty1', Some _ -> Some ty1'
(* Utilisation de la substitution que l'on à déjà *)
| Some ty1', None -> Some ty1'
| None, Some ty2' -> Some ty2'
(* Variable untyped *)
| None, None -> None)
s1
s2
in
print_endline "wow!";
merger
;;
let to_string map =