src/Pure/type_infer.ML
changeset 22678 23963361278c
parent 20854 f9cf9e62d11c
child 22688 bbf8835c9f87
equal deleted inserted replaced
22677:b11a9beabe7d 22678:23963361278c
   271       | meet (PTFree (x, S'), S) =
   271       | meet (PTFree (x, S'), S) =
   272           if Type.subsort tsig (S', S) then ()
   272           if Type.subsort tsig (S', S) then ()
   273           else raise NO_UNIFIER (not_of_sort x S' S)
   273           else raise NO_UNIFIER (not_of_sort x S' S)
   274       | meet (PTVar (xi, S'), S) =
   274       | meet (PTVar (xi, S'), S) =
   275           if Type.subsort tsig (S', S) then ()
   275           if Type.subsort tsig (S', S) then ()
   276           else raise NO_UNIFIER (not_of_sort (Syntax.string_of_vname xi) S' S)
   276           else raise NO_UNIFIER (not_of_sort (Term.string_of_vname xi) S' S)
   277       | meet (Param _, _) = sys_error "meet";
   277       | meet (Param _, _) = sys_error "meet";
   278 
   278 
   279 
   279 
   280     (* occurs check and assigment *)
   280     (* occurs check and assigment *)
   281 
   281 
   454       Term.eq_ix (xi, xi') andalso Type.eq_sort tsig (S, S');
   454       Term.eq_ix (xi, xi') andalso Type.eq_sort tsig (S, S');
   455 
   455 
   456     val env = distinct eq (map (apsnd map_sort) raw_env);
   456     val env = distinct eq (map (apsnd map_sort) raw_env);
   457     val _ = (case duplicates (eq_fst (op =)) env of [] => ()
   457     val _ = (case duplicates (eq_fst (op =)) env of [] => ()
   458       | dups => error ("Inconsistent sort constraints for type variable(s) "
   458       | dups => error ("Inconsistent sort constraints for type variable(s) "
   459           ^ commas_quote (map (Syntax.string_of_vname' o fst) dups)));
   459           ^ commas_quote (map (Term.string_of_vname' o fst) dups)));
   460 
   460 
   461     fun get xi =
   461     fun get xi =
   462       (case (AList.lookup (op =) env xi, def_sort xi) of
   462       (case (AList.lookup (op =) env xi, def_sort xi) of
   463         (NONE, NONE) => Type.defaultS tsig
   463         (NONE, NONE) => Type.defaultS tsig
   464       | (NONE, SOME S) => S
   464       | (NONE, SOME S) => S
   465       | (SOME S, NONE) => S
   465       | (SOME S, NONE) => S
   466       | (SOME S, SOME S') =>
   466       | (SOME S, SOME S') =>
   467           if Type.eq_sort tsig (S, S') then S'
   467           if Type.eq_sort tsig (S, S') then S'
   468           else error ("Sort constraint inconsistent with default for type variable " ^
   468           else error ("Sort constraint inconsistent with default for type variable " ^
   469             quote (Syntax.string_of_vname' xi)));
   469             quote (Term.string_of_vname' xi)));
   470   in get end;
   470   in get end;
   471 
   471 
   472 
   472 
   473 (* decode_types -- transform parse tree into raw term *)
   473 (* decode_types -- transform parse tree into raw term *)
   474 
   474