src/Tools/subtyping.ML
changeset 51248 029de23bb5e8
parent 51246 755562fd2d9d
child 51319 4a92178011e7
equal deleted inserted replaced
51247:064683ba110c 51248:029de23bb5e8
   349                 COVARIANT => (constraint :: cs, tye_idx)
   349                 COVARIANT => (constraint :: cs, tye_idx)
   350               | CONTRAVARIANT => (swap constraint :: cs, tye_idx)
   350               | CONTRAVARIANT => (swap constraint :: cs, tye_idx)
   351               | INVARIANT_TO T => (cs, unify_list [T, fst constraint, snd constraint] tye_idx
   351               | INVARIANT_TO T => (cs, unify_list [T, fst constraint, snd constraint] tye_idx
   352                   handle NO_UNIFIER (msg, _) =>
   352                   handle NO_UNIFIER (msg, _) =>
   353                     err_list ctxt (gen_msg err
   353                     err_list ctxt (gen_msg err
   354                       "failed to unify invariant arguments w.r.t. to the known map function" ^ msg)
   354                       "failed to unify invariant arguments w.r.t. to the known map function\n" ^ msg)
   355                       (fst tye_idx) (T :: Ts))
   355                       (fst tye_idx) (T :: Ts))
   356               | INVARIANT => (cs, strong_unify ctxt constraint tye_idx
   356               | INVARIANT => (cs, strong_unify ctxt constraint tye_idx
   357                   handle NO_UNIFIER (msg, _) =>
   357                   handle NO_UNIFIER (msg, _) =>
   358                     error (gen_msg err ("failed to unify invariant arguments" ^ msg))));
   358                     error (gen_msg err ("failed to unify invariant arguments\n" ^ msg))));
   359             val (new, (tye', idx')) = apfst (fn cs => (cs ~~ replicate (length cs) error_pack))
   359             val (new, (tye', idx')) = apfst (fn cs => (cs ~~ replicate (length cs) error_pack))
   360               (fold new_constraints (arg_var ~~ (Ts ~~ Us)) ([], (tye, idx)));
   360               (fold new_constraints (arg_var ~~ (Ts ~~ Us)) ([], (tye, idx)));
   361             val test_update = is_typeT orf is_freeT orf is_fixedvarT;
   361             val test_update = is_typeT orf is_freeT orf is_fixedvarT;
   362             val (ch, done') =
   362             val (ch, done') =
   363               done
   363               done
   504                   val (tye, idx) =
   504                   val (tye, idx) =
   505                     fold
   505                     fold
   506                       (fn cycle => fn tye_idx' => (unify_list cycle tye_idx'
   506                       (fn cycle => fn tye_idx' => (unify_list cycle tye_idx'
   507                         handle NO_UNIFIER (msg, _) =>
   507                         handle NO_UNIFIER (msg, _) =>
   508                           err_bound ctxt
   508                           err_bound ctxt
   509                             (gen_msg err ("constraint cycle not unifiable" ^ msg)) (fst tye_idx)
   509                             (gen_msg err ("constraint cycle not unifiable\n" ^ msg)) (fst tye_idx)
   510                             (find_cycle_packs cycle)))
   510                             (find_cycle_packs cycle)))
   511                       cycles tye_idx
   511                       cycles tye_idx
   512                 in
   512                 in
   513                   collapse (tye, idx) cycles G
   513                   collapse (tye, idx) cycles G
   514                 end
   514                 end