diff --git a/lib/typeSubstitution.ml b/lib/typeSubstitution.ml index f35a573..5e2aa4a 100644 --- a/lib/typeSubstitution.ml +++ b/lib/typeSubstitution.ml @@ -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 =