equal
deleted
inserted
replaced
706 val varifyT = varifyT midx; |
706 val varifyT = varifyT midx; |
707 val vartypes = map varifyT types; |
707 val vartypes = map varifyT types; |
708 |
708 |
709 val subst = Type.raw_matches (vartypes, argtypes) Vartab.empty |
709 val subst = Type.raw_matches (vartypes, argtypes) Vartab.empty |
710 handle Type.TYPE_MATCH => err "type is no proper record (extension)"; |
710 handle Type.TYPE_MATCH => err "type is no proper record (extension)"; |
711 val term_of_typ = Syntax_Phases.term_of_typ (Config.get ctxt show_sorts); |
|
712 val alphas' = |
711 val alphas' = |
713 map (term_of_typ o Envir.norm_type subst o varifyT) (#1 (split_last alphas)); |
712 map (Syntax_Phases.term_of_typ ctxt o Envir.norm_type subst o varifyT) |
|
713 (#1 (split_last alphas)); |
714 |
714 |
715 val more' = mk_ext rest; |
715 val more' = mk_ext rest; |
716 in |
716 in |
717 list_comb |
717 list_comb |
718 (Syntax.const (Syntax.mark_type (suffix ext_typeN ext)), alphas' @ [more']) |
718 (Syntax.const (Syntax.mark_type (suffix ext_typeN ext)), alphas' @ [more']) |
816 let |
816 let |
817 val thy = ProofContext.theory_of ctxt; |
817 val thy = ProofContext.theory_of ctxt; |
818 |
818 |
819 val T = decode_type thy t; |
819 val T = decode_type thy t; |
820 val varifyT = varifyT (Term.maxidx_of_typ T); |
820 val varifyT = varifyT (Term.maxidx_of_typ T); |
821 |
|
822 val term_of_type = Syntax_Phases.term_of_typ (Config.get ctxt show_sorts); |
|
823 |
821 |
824 fun strip_fields T = |
822 fun strip_fields T = |
825 (case T of |
823 (case T of |
826 Type (ext, args as _ :: _) => |
824 Type (ext, args as _ :: _) => |
827 (case try (unsuffix ext_typeN) ext of |
825 (case try (unsuffix ext_typeN) ext of |
845 | _ => [("", T)]) |
843 | _ => [("", T)]) |
846 | _ => [("", T)]); |
844 | _ => [("", T)]); |
847 |
845 |
848 val (fields, (_, moreT)) = split_last (strip_fields T); |
846 val (fields, (_, moreT)) = split_last (strip_fields T); |
849 val _ = null fields andalso raise Match; |
847 val _ = null fields andalso raise Match; |
850 val u = foldr1 field_types_tr' (map (field_type_tr' o apsnd term_of_type) fields); |
848 val u = |
|
849 foldr1 field_types_tr' |
|
850 (map (field_type_tr' o apsnd (Syntax_Phases.term_of_typ ctxt)) fields); |
851 in |
851 in |
852 if not (! print_type_as_fields) orelse null fields then raise Match |
852 if not (! print_type_as_fields) orelse null fields then raise Match |
853 else if moreT = HOLogic.unitT then Syntax.const @{syntax_const "_record_type"} $ u |
853 else if moreT = HOLogic.unitT then Syntax.const @{syntax_const "_record_type"} $ u |
854 else Syntax.const @{syntax_const "_record_type_scheme"} $ u $ term_of_type moreT |
854 else |
|
855 Syntax.const @{syntax_const "_record_type_scheme"} $ u $ |
|
856 Syntax_Phases.term_of_typ ctxt moreT |
855 end; |
857 end; |
856 |
858 |
857 (*try to reconstruct the record name type abbreviation from |
859 (*try to reconstruct the record name type abbreviation from |
858 the (nested) extension types*) |
860 the (nested) extension types*) |
859 fun record_type_abbr_tr' abbr alphas zeta last_ext schemeT ctxt tm = |
861 fun record_type_abbr_tr' abbr alphas zeta last_ext schemeT ctxt tm = |
863 val midx = maxidx_of_typ T; |
865 val midx = maxidx_of_typ T; |
864 val varifyT = varifyT midx; |
866 val varifyT = varifyT midx; |
865 |
867 |
866 fun mk_type_abbr subst name args = |
868 fun mk_type_abbr subst name args = |
867 let val abbrT = Type (name, map (varifyT o TFree) args) |
869 let val abbrT = Type (name, map (varifyT o TFree) args) |
868 in Syntax_Phases.term_of_typ (Config.get ctxt show_sorts) (Envir.norm_type subst abbrT) end; |
870 in Syntax_Phases.term_of_typ ctxt (Envir.norm_type subst abbrT) end; |
869 |
871 |
870 fun match rT T = Type.raw_match (varifyT rT, T) Vartab.empty; |
872 fun match rT T = Type.raw_match (varifyT rT, T) Vartab.empty; |
871 in |
873 in |
872 if ! print_type_abbr then |
874 if ! print_type_abbr then |
873 (case last_extT T of |
875 (case last_extT T of |