tuned check_has_sort;
authorwenzelm
Fri, 18 Apr 1997 11:58:38 +0200
changeset 2991 d9f6299dbf9f
parent 2990 271062b8c461
child 2992 395686b418a4
tuned check_has_sort; fixed norm_typ: also does norm_sort;
src/Pure/type.ML
--- a/src/Pure/type.ML	Fri Apr 18 11:57:51 1997 +0200
+++ b/src/Pure/type.ML	Fri Apr 18 11:58:38 1997 +0200
@@ -269,8 +269,8 @@
 
 
 fun check_has_sort (TySg {classrel, arities, ...}, T, S) =
-  if Sorts.sort_le classrel ((Sorts.least_sort classrel arities T), S) then ()
-  else raise TYPE ("Type not of sort " ^ Sorts.str_of_sort S, [T], []);
+  if Sorts.of_sort classrel arities (T, S) then ()
+  else raise_type ("Type not of sort " ^ Sorts.str_of_sort S) [T] [];
 
 
 (*Instantiation of type variables in types *)
@@ -287,18 +287,19 @@
 
 (* norm_typ *)
 
-fun norm_typ (TySg {abbrs, ...}) ty =
+(*expand abbreviations and normalize sorts*)
+fun norm_typ (tsig as TySg {abbrs, ...}) ty =
   let
     val idx = maxidx_of_typ ty + 1;
 
-    fun expand (Type (a, Ts)) =
+    fun norm (Type (a, Ts)) =
           (case assoc (abbrs, a) of
-            Some (vs, U) =>
-              expand (inst_typ (map (rpair idx) vs ~~ Ts) (incr_tvar idx U))
-          | None => Type (a, map expand Ts))
-      | expand T = T
+            Some (vs, U) => norm (inst_typ (map (rpair idx) vs ~~ Ts) (incr_tvar idx U))
+          | None => Type (a, map norm Ts))
+      | norm (TFree (x, S)) = TFree (x, norm_sort tsig S)
+      | norm (TVar (xi, S)) = TVar (xi, norm_sort tsig S);
   in
-    expand ty
+    norm ty
   end;