src/Pure/Isar/locale.ML
changeset 66333 30c1639a343a
parent 66188 bd841164592f
child 66581 72bb0eefd148
equal deleted inserted replaced
66332:489667636064 66333:30c1639a343a
    86   val hyp_spec_of: theory -> string -> Element.context_i list
    86   val hyp_spec_of: theory -> string -> Element.context_i list
    87   val print_locales: bool -> theory -> unit
    87   val print_locales: bool -> theory -> unit
    88   val print_locale: theory -> bool -> xstring * Position.T -> unit
    88   val print_locale: theory -> bool -> xstring * Position.T -> unit
    89   val print_registrations: Proof.context -> xstring * Position.T -> unit
    89   val print_registrations: Proof.context -> xstring * Position.T -> unit
    90   val print_dependencies: Proof.context -> bool -> morphism -> (string * morphism) list -> unit
    90   val print_dependencies: Proof.context -> bool -> morphism -> (string * morphism) list -> unit
       
    91   val pretty_locale: theory -> bool -> string -> Pretty.T list
    91   val pretty_locale_deps: theory -> {name: string, parents: string list, body: Pretty.T} list
    92   val pretty_locale_deps: theory -> {name: string, parents: string list, body: Pretty.T} list
    92 end;
    93 end;
    93 
    94 
    94 structure Locale: LOCALE =
    95 structure Locale: LOCALE =
    95 struct
    96 struct
   697       | cons_elem elem = cons elem;
   698       | cons_elem elem = cons elem;
   698     val elems =
   699     val elems =
   699       activate_all name thy cons_elem (K (Morphism.transfer_morphism thy)) (empty_idents, [])
   700       activate_all name thy cons_elem (K (Morphism.transfer_morphism thy)) (empty_idents, [])
   700       |> snd |> rev;
   701       |> snd |> rev;
   701   in
   702   in
   702     Pretty.block
   703     Pretty.keyword1 "locale" :: Pretty.brk 1 :: pretty_name locale_ctxt name ::
   703       (Pretty.keyword1 "locale" :: Pretty.brk 1 :: pretty_name locale_ctxt name ::
   704       maps (fn elem => [Pretty.fbrk, Pretty.chunks (Element.pretty_ctxt locale_ctxt elem)]) elems
   704         maps (fn elem => [Pretty.fbrk, Pretty.chunks (Element.pretty_ctxt locale_ctxt elem)]) elems)
       
   705   end;
   705   end;
   706 
   706 
   707 fun print_locale thy show_facts raw_name =
   707 fun print_locale thy show_facts raw_name =
   708   Pretty.writeln (pretty_locale thy show_facts (check thy raw_name));
   708   Pretty.writeln (Pretty.block (pretty_locale thy show_facts (check thy raw_name)));
   709 
   709 
   710 fun print_registrations ctxt raw_name =
   710 fun print_registrations ctxt raw_name =
   711   let
   711   let
   712     val thy = Proof_Context.theory_of ctxt;
   712     val thy = Proof_Context.theory_of ctxt;
   713     val name = check thy raw_name;
   713     val name = check thy raw_name;
   730 fun pretty_locale_deps thy =
   730 fun pretty_locale_deps thy =
   731   let
   731   let
   732     fun make_node name =
   732     fun make_node name =
   733      {name = name,
   733      {name = name,
   734       parents = map (fst o fst) (dependencies_of thy name),
   734       parents = map (fst o fst) (dependencies_of thy name),
   735       body = pretty_locale thy false name};
   735       body = Pretty.block (pretty_locale thy false name)};
   736     val names = sort_strings (Name_Space.fold_table (cons o #1) (Locales.get thy) []);
   736     val names = sort_strings (Name_Space.fold_table (cons o #1) (Locales.get thy) []);
   737   in map make_node names end;
   737   in map make_node names end;
   738 
   738 
   739 end;
   739 end;