(* Title: Pure/Isar/named_target.ML Author: Makarius Author: Florian Haftmann, TU Muenchen
Targets for theory, locale, class -- at the bottom of the nested structure.
*)
signature NAMED_TARGET = sig val is_theory: local_theory -> bool val locale_of: local_theory -> stringoption val bottom_locale_of: local_theory -> stringoption val class_of: local_theory -> stringoption val init: Bundle.name list -> string -> theory -> local_theory val theory_init: theory -> local_theory val theory_map: (local_theory -> local_theory) -> theory -> theory val theory_map_result: (morphism -> 'a -> 'b) -> (local_theory -> 'a * local_theory) ->
theory -> 'b * theory val setup: (local_theory -> local_theory) -> unit val setup_result: (morphism -> 'a -> 'b) -> (local_theory -> 'a * local_theory) -> 'b val setup_result0: (local_theory -> 'a * local_theory) -> 'a val revoke_reinitializability: local_theory -> local_theory val exit_global_reinitialize: local_theory -> (theory -> local_theory) * theory end;
structure Named_Target: NAMED_TARGET = struct
(* context data *)
datatype target = Theory | Locale ofstring | Class ofstring;
fun target_of_ident _ "" = Theory
| target_of_ident thy ident = if Locale.defined thy ident then (if Class.is_class thy ident then Class else Locale) ident else error ("No such locale: " ^ quote ident);
fun ident_of_target Theory = ""
| ident_of_target (Locale locale) = locale
| ident_of_target (Class class) = class;
fun setup_context Theory = Proof_Context.init_global
| setup_context (Locale locale) = Locale.init locale
| setup_context (Class class) = Class.init class;
fun setup target includes =
setup_context target
#> Data.put (SOME (target, null includes))
#> Bundle.includes includes;
fun init includes ident thy = let val target = target_of_ident thy ident; in
thy
|> Local_Theory.init
{background_naming = Sign.naming_of thy |> Name_Space.mandatory_path (Long_Name.base_name ident),
setup = setup target includes,
conclude = I}
(operations target) end;
val theory_init = init [] "";
fun theory_map g = theory_init #> g #> Local_Theory.exit_global; fun theory_map_result f g = theory_init #> g #> Local_Theory.exit_result_global f;
fun setup g = Context.>> (Context.mapping (theory_map g) g); fun setup_result f g =
Context.>>> (Context.mapping_result (theory_map_result f g) (g #>> f Morphism.identity)); fun setup_result0 g = setup_result (K I) g;
val revoke_reinitializability = (Data.map o Option.map o apsnd) (K false);
fun exit_global_reinitialize lthy = if is_reinitializable lthy then (init [] (ident_of lthy), Local_Theory.exit_global lthy) else error "Non-reinitializable local theory context";
end;
¤ Dauer der Verarbeitung: 0.18 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.