src/Pure/display.ML
changeset 6846 f2380295d4dd
parent 6390 5d58c100ca3f
child 6889 adcf91ad5add
equal deleted inserted replaced
6845:598d2f32d452 6846:f2380295d4dd
   148     fun prt_cls c = Sign.pretty_sort sg [c];
   148     fun prt_cls c = Sign.pretty_sort sg [c];
   149     fun prt_sort S = Sign.pretty_sort sg S;
   149     fun prt_sort S = Sign.pretty_sort sg S;
   150     fun prt_arity t (c, Ss) = Sign.pretty_arity sg (t, Ss, [c]);
   150     fun prt_arity t (c, Ss) = Sign.pretty_arity sg (t, Ss, [c]);
   151     fun prt_typ ty = Pretty.quote (Sign.pretty_typ sg ty);
   151     fun prt_typ ty = Pretty.quote (Sign.pretty_typ sg ty);
   152 
   152 
   153     val ext_class = Sign.cond_extern sg Sign.classK;
       
   154     val ext_tycon = Sign.cond_extern sg Sign.typeK;
       
   155     val ext_const = Sign.cond_extern sg Sign.constK;
       
   156 
       
   157 
   153 
   158     fun pretty_classes cs = Pretty.block
   154     fun pretty_classes cs = Pretty.block
   159       (Pretty.breaks (Pretty.str "classes:" :: map prt_cls cs));
   155       (Pretty.breaks (Pretty.str "classes:" :: map prt_cls cs));
   160 
   156 
   161     fun pretty_classrel (c, cs) = Pretty.block
   157     fun pretty_classrel (c, cs) = Pretty.block
   164 
   160 
   165     fun pretty_default S = Pretty.block
   161     fun pretty_default S = Pretty.block
   166       [Pretty.str "default:", Pretty.brk 1, prt_sort S];
   162       [Pretty.str "default:", Pretty.brk 1, prt_sort S];
   167 
   163 
   168     fun pretty_ty (t, n) = Pretty.block
   164     fun pretty_ty (t, n) = Pretty.block
   169       [Pretty.str (ext_tycon t), Pretty.spc 1, Pretty.str (string_of_int n)];
   165       [Pretty.str (Sign.cond_extern sg Sign.typeK t), Pretty.spc 1, Pretty.str (string_of_int n)];
   170 
   166 
   171     fun pretty_abbr (t, (vs, rhs)) = Pretty.block
   167     fun pretty_abbr (t, (vs, rhs)) = Pretty.block
   172       [prt_typ (Type (t, map (fn v => TVar ((v, 0), [])) vs)),
   168       [prt_typ (Type (t, map (fn v => TVar ((v, 0), [])) vs)),
   173         Pretty.str " =", Pretty.brk 1, prt_typ rhs];
   169         Pretty.str " =", Pretty.brk 1, prt_typ rhs];
   174 
   170 
   176 
   172 
   177     fun pretty_const (c, ty) = Pretty.block
   173     fun pretty_const (c, ty) = Pretty.block
   178       [Pretty.str c, Pretty.str " ::", Pretty.brk 1, prt_typ ty];
   174       [Pretty.str c, Pretty.str " ::", Pretty.brk 1, prt_typ ty];
   179 
   175 
   180     val {self = _, tsig, const_tab, syn = _, path, spaces, data} = Sign.rep_sg sg;
   176     val {self = _, tsig, const_tab, syn = _, path, spaces, data} = Sign.rep_sg sg;
   181     val spaces' = sort_wrt fst spaces;
   177     val spaces' = Library.sort_wrt fst spaces;
   182     val {classes, classrel, default, tycons, abbrs, arities} =
   178     val {classes, classrel, default, tycons, abbrs, arities} =
   183       Type.rep_tsig tsig;
   179       Type.rep_tsig tsig;
   184     val consts = sort_wrt fst (map (apfst ext_const) (Symtab.dest const_tab));
   180     val consts = Sign.cond_extern_table sg Sign.constK const_tab;
   185   in
   181   in
   186     Pretty.writeln (Pretty.strs ("stamps:" :: Sign.stamp_names_of sg));
   182     Pretty.writeln (Pretty.strs ("stamps:" :: Sign.stamp_names_of sg));
   187     Pretty.writeln (Pretty.strs ("data:" :: Sign.data_kinds data));
   183     Pretty.writeln (Pretty.strs ("data:" :: Sign.data_kinds data));
   188     Pretty.writeln (Pretty.strs ["name prefix:", NameSpace.pack path]);
   184     Pretty.writeln (Pretty.strs ["name prefix:", NameSpace.pack path]);
   189     Pretty.writeln (Pretty.big_list "name spaces:" (map pretty_name_space spaces'));
   185     Pretty.writeln (Pretty.big_list "name spaces:" (map pretty_name_space spaces'));
   200 (* print axioms, oracles, theorems *)
   196 (* print axioms, oracles, theorems *)
   201 
   197 
   202 fun print_thy thy =
   198 fun print_thy thy =
   203   let
   199   let
   204     val {sign, axioms, oracles, ...} = Theory.rep_theory thy;
   200     val {sign, axioms, oracles, ...} = Theory.rep_theory thy;
   205     val axioms = Symtab.dest axioms;
   201     fun cond_externs kind = Sign.cond_extern_table sign kind;
   206     val oras = map fst (Symtab.dest oracles);
       
   207 
   202 
   208     fun prt_axm (a, t) = Pretty.block
   203     fun prt_axm (a, t) = Pretty.block
   209       [Pretty.str (Sign.cond_extern sign Theory.axiomK a ^ ":"), Pretty.brk 1,
   204       [Pretty.str (a ^ ":"), Pretty.brk 1, Pretty.quote (Sign.pretty_term sign t)];
   210         Pretty.quote (Sign.pretty_term sign t)];
       
   211   in
   205   in
   212     Pretty.writeln (Pretty.big_list "axioms:" (map prt_axm axioms));
   206     Pretty.writeln (Pretty.big_list "axioms:" (map prt_axm (cond_externs Theory.axiomK axioms)));
   213     Pretty.writeln (Pretty.strs ("oracles:" :: oras))
   207     Pretty.writeln (Pretty.strs ("oracles:" :: (map #1 (cond_externs Theory.oracleK oracles))))
   214   end;
   208   end;
   215 
   209 
   216 fun print_theory thy = (print_sign (Theory.sign_of thy); print_thy thy);
   210 fun print_theory thy = (print_sign (Theory.sign_of thy); print_thy thy);
   217 
   211 
   218 (*also show consts in case of showing types?*)
   212 (*also show consts in case of showing types?*)