src/Pure/config.ML
changeset 39116 f14735a88886
parent 38804 99cc7e748ab4
child 39163 4d701c0388c3
equal deleted inserted replaced
39115:a00da1674c1c 39116:f14735a88886
    20   val map_global: 'a T -> ('a -> 'a) -> theory -> theory
    20   val map_global: 'a T -> ('a -> 'a) -> theory -> theory
    21   val put_global: 'a T -> 'a -> theory -> theory
    21   val put_global: 'a T -> 'a -> theory -> theory
    22   val get_generic: Context.generic -> 'a T -> 'a
    22   val get_generic: Context.generic -> 'a T -> 'a
    23   val map_generic: 'a T -> ('a -> 'a) -> Context.generic -> Context.generic
    23   val map_generic: 'a T -> ('a -> 'a) -> Context.generic -> Context.generic
    24   val put_generic: 'a T -> 'a -> Context.generic -> Context.generic
    24   val put_generic: 'a T -> 'a -> Context.generic -> Context.generic
    25   val declare: bool -> string -> (Context.generic -> value) -> value T
    25   val declare_generic: {global: bool} -> string -> (Context.generic -> value) -> value T
       
    26   val declare_global: string -> (Context.generic -> value) -> value T
       
    27   val declare: string -> (Context.generic -> value) -> value T
    26   val name_of: 'a T -> string
    28   val name_of: 'a T -> string
    27 end;
    29 end;
    28 
    30 
    29 structure Config: CONFIG =
    31 structure Config: CONFIG =
    30 struct
    32 struct
    96   val empty = Inttab.empty;
    98   val empty = Inttab.empty;
    97   val extend = I;
    99   val extend = I;
    98   fun merge data = Inttab.merge (K true) data;
   100   fun merge data = Inttab.merge (K true) data;
    99 );
   101 );
   100 
   102 
   101 fun declare global name default =
   103 fun declare_generic {global} name default =
   102   let
   104   let
   103     val id = serial ();
   105     val id = serial ();
   104 
   106 
   105     fun get_value context =
   107     fun get_value context =
   106       (case Inttab.lookup (Value.get context) id of
   108       (case Inttab.lookup (Value.get context) id of
   118             else context'
   120             else context'
   119           end
   121           end
   120       | map_value f context = update_value f context;
   122       | map_value f context = update_value f context;
   121   in Config {name = name, get_value = get_value, map_value = map_value} end;
   123   in Config {name = name, get_value = get_value, map_value = map_value} end;
   122 
   124 
       
   125 val declare_global = declare_generic {global = true};
       
   126 val declare = declare_generic {global = false};
       
   127 
   123 fun name_of (Config {name, ...}) = name;
   128 fun name_of (Config {name, ...}) = name;
   124 
   129 
   125 
   130 
   126 (*final declarations of this structure!*)
   131 (*final declarations of this structure!*)
   127 val get = get_ctxt;
   132 val get = get_ctxt;