src/Tools/code/code_thingol.ML
changeset 24969 b38527eefb3b
parent 24918 22013215eece
child 25042 a33b78d63114
equal deleted inserted replaced
24968:f9bafc868847 24969:b38527eefb3b
   344 (* translation kernel *)
   344 (* translation kernel *)
   345 
   345 
   346 fun ensure_class thy (algbr as ((_, algebra), _)) funcgr class =
   346 fun ensure_class thy (algbr as ((_, algebra), _)) funcgr class =
   347   let
   347   let
   348     val superclasses = (Sorts.certify_sort algebra o Sorts.super_classes algebra) class;
   348     val superclasses = (Sorts.certify_sort algebra o Sorts.super_classes algebra) class;
   349     val (v, cs) = AxClass.params_of_class thy class;
   349     val cs = #params (AxClass.get_info thy class);
   350     val class' = CodeName.class thy class;
   350     val class' = CodeName.class thy class;
   351     val stmt_class =
   351     val stmt_class =
   352       fold_map (fn superclass => ensure_class thy algbr funcgr superclass
   352       fold_map (fn superclass => ensure_class thy algbr funcgr superclass
   353         ##>> ensure_classrel thy algbr funcgr (class, superclass)) superclasses
   353         ##>> ensure_classrel thy algbr funcgr (class, superclass)) superclasses
   354       ##>> fold_map (fn (c, ty) => ensure_const thy algbr funcgr c
   354       ##>> fold_map (fn (c, ty) => ensure_const thy algbr funcgr c
   355         ##>> exprgen_typ thy algbr funcgr ty) cs
   355         ##>> exprgen_typ thy algbr funcgr ty) cs
   356       #>> (fn info => Class (unprefix "'" v, info))
   356       #>> (fn info => Class (unprefix "'" Name.aT, info))
   357   in
   357   in
   358     ensure_stmt stmt_class class'
   358     ensure_stmt stmt_class class'
   359   end
   359   end
   360 and ensure_classrel thy algbr funcgr (subclass, superclass) =
   360 and ensure_classrel thy algbr funcgr (subclass, superclass) =
   361   let
   361   let
   443     #>> rpair thm
   443     #>> rpair thm
   444   end
   444   end
   445 and ensure_inst thy (algbr as ((_, algebra), _)) funcgr (class, tyco) =
   445 and ensure_inst thy (algbr as ((_, algebra), _)) funcgr (class, tyco) =
   446   let
   446   let
   447     val superclasses = (Sorts.certify_sort algebra o Sorts.super_classes algebra) class;
   447     val superclasses = (Sorts.certify_sort algebra o Sorts.super_classes algebra) class;
   448     val (var, classparams) = try (AxClass.params_of_class thy) class |> the_default ("'a", [])
   448     val classparams = these (try (#params o AxClass.get_info thy) class);
   449     val vs = Name.names Name.context "'a" (Sorts.mg_domain algebra tyco [class]);
   449     val vs = Name.names Name.context "'a" (Sorts.mg_domain algebra tyco [class]);
   450     val sorts' = Sorts.mg_domain (Sign.classes_of thy) tyco [class];
   450     val sorts' = Sorts.mg_domain (Sign.classes_of thy) tyco [class];
   451     val vs' = map2 (fn (v, sort1) => fn sort2 => (v,
   451     val vs' = map2 (fn (v, sort1) => fn sort2 => (v,
   452       Sorts.inter_sort (Sign.classes_of thy) (sort1, sort2))) vs sorts';
   452       Sorts.inter_sort (Sign.classes_of thy) (sort1, sort2))) vs sorts';
   453     val arity_typ = Type (tyco, map TFree vs);
   453     val arity_typ = Type (tyco, map TFree vs);