src/Pure/config.ML
author wenzelm
Tue, 01 Sep 2020 18:03:17 +0200
changeset 72235 a5bf0b69c22a
parent 69576 cfac69e7b962
child 74561 8e6c973003c8
permissions -rw-r--r--
discontinue export_document --- always enabled (reverting f0f83ce0badd);
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/config.ML
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
     3
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
     4
Configuration options as values within the local context.
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
     5
*)
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
     6
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
     7
signature CONFIG =
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
     8
sig
40291
012ed4426fda support for real valued configuration options;
wenzelm
parents: 39163
diff changeset
     9
  datatype value = Bool of bool | Int of int | Real of real | String of string
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    10
  val print_value: value -> string
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    11
  val print_type: value -> string
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    12
  type 'a T
69575
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    13
  val name_of: 'a T -> string
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    14
  val pos_of: 'a T -> Position.T
69576
cfac69e7b962 tuned signature;
wenzelm
parents: 69575
diff changeset
    15
  val apply: 'a T -> Proof.context -> 'a
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    16
  val get: Proof.context -> 'a T -> 'a
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    17
  val map: 'a T -> ('a -> 'a) -> Proof.context -> Proof.context
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    18
  val put: 'a T -> 'a -> Proof.context -> Proof.context
68827
1286ca9dfd26 tuned signature;
wenzelm
parents: 63806
diff changeset
    19
  val restore: 'a T -> Proof.context -> Proof.context -> Proof.context
69576
cfac69e7b962 tuned signature;
wenzelm
parents: 69575
diff changeset
    20
  val apply_global: 'a T -> theory -> 'a
36787
f60e4dd6d76f renamed Config.get_thy to Config.get_global etc. to indicate that this is not the real thing;
wenzelm
parents: 36002
diff changeset
    21
  val get_global: theory -> 'a T -> 'a
f60e4dd6d76f renamed Config.get_thy to Config.get_global etc. to indicate that this is not the real thing;
wenzelm
parents: 36002
diff changeset
    22
  val map_global: 'a T -> ('a -> 'a) -> theory -> theory
f60e4dd6d76f renamed Config.get_thy to Config.get_global etc. to indicate that this is not the real thing;
wenzelm
parents: 36002
diff changeset
    23
  val put_global: 'a T -> 'a -> theory -> theory
68827
1286ca9dfd26 tuned signature;
wenzelm
parents: 63806
diff changeset
    24
  val restore_global: 'a T -> theory -> theory -> theory
69576
cfac69e7b962 tuned signature;
wenzelm
parents: 69575
diff changeset
    25
  val apply_generic: 'a T -> Context.generic -> 'a
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    26
  val get_generic: Context.generic -> 'a T -> 'a
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    27
  val map_generic: 'a T -> ('a -> 'a) -> Context.generic -> Context.generic
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    28
  val put_generic: 'a T -> 'a -> Context.generic -> Context.generic
68827
1286ca9dfd26 tuned signature;
wenzelm
parents: 63806
diff changeset
    29
  val restore_generic: 'a T -> Context.generic -> Context.generic -> Context.generic
69575
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    30
  val bool: value T -> bool T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    31
  val bool_value: bool T -> value T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    32
  val int: value T -> int T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    33
  val int_value: int T -> value T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    34
  val real: value T -> real T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    35
  val real_value: real T -> value T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    36
  val string: value T -> string T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    37
  val string_value: string T -> value T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    38
  val declare: string * Position.T -> (Context.generic -> value) -> value T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    39
  val declare_bool: string * Position.T -> (Context.generic -> bool) -> bool T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    40
  val declare_int: string * Position.T -> (Context.generic -> int) -> int T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    41
  val declare_real: string * Position.T -> (Context.generic -> real) -> real T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    42
  val declare_string: string * Position.T -> (Context.generic -> string) -> string T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    43
  val declare_option: string * Position.T -> value T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    44
  val declare_option_bool: string * Position.T -> bool T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    45
  val declare_option_int: string * Position.T -> int T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    46
  val declare_option_real: string * Position.T -> real T
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    47
  val declare_option_string: string * Position.T -> string T
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    48
end;
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    49
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    50
structure Config: CONFIG =
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    51
struct
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    52
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    53
(* simple values *)
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    54
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    55
datatype value =
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    56
  Bool of bool |
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    57
  Int of int |
40291
012ed4426fda support for real valued configuration options;
wenzelm
parents: 39163
diff changeset
    58
  Real of real |
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    59
  String of string;
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    60
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    61
fun print_value (Bool true) = "true"
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    62
  | print_value (Bool false) = "false"
69574
wenzelm
parents: 68827
diff changeset
    63
  | print_value (Int i) = Value.print_int i
63806
c54a53ef1873 clarified modules;
wenzelm
parents: 58951
diff changeset
    64
  | print_value (Real x) = Value.print_real x
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    65
  | print_value (String s) = quote s;
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    66
38804
99cc7e748ab4 tuned printed type names, according to ML;
wenzelm
parents: 36787
diff changeset
    67
fun print_type (Bool _) = "bool"
99cc7e748ab4 tuned printed type names, according to ML;
wenzelm
parents: 36787
diff changeset
    68
  | print_type (Int _) = "int"
40291
012ed4426fda support for real valued configuration options;
wenzelm
parents: 39163
diff changeset
    69
  | print_type (Real _) = "real"
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    70
  | print_type (String _) = "string";
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    71
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    72
fun same_type (Bool _) (Bool _) = true
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    73
  | same_type (Int _) (Int _) = true
40291
012ed4426fda support for real valued configuration options;
wenzelm
parents: 39163
diff changeset
    74
  | same_type (Real _) (Real _) = true
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    75
  | same_type (String _) (String _) = true
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    76
  | same_type _ _ = false;
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    77
56438
7f6b2634d853 more source positions;
wenzelm
parents: 56294
diff changeset
    78
fun type_check (name, pos) f value =
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    79
  let
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    80
    val value' = f value;
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    81
    val _ = same_type value value' orelse
56438
7f6b2634d853 more source positions;
wenzelm
parents: 56294
diff changeset
    82
      error ("Ill-typed configuration option " ^ quote name ^ Position.here pos ^ ": " ^
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    83
        print_type value ^ " expected,\nbut " ^ print_type value' ^ " was found");
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    84
  in value' end;
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    85
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    86
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    87
(* abstract configuration options *)
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    88
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    89
datatype 'a T = Config of
24125
454a0c895735 added name_of;
wenzelm
parents: 24114
diff changeset
    90
 {name: string,
56438
7f6b2634d853 more source positions;
wenzelm
parents: 56294
diff changeset
    91
  pos: Position.T,
24125
454a0c895735 added name_of;
wenzelm
parents: 24114
diff changeset
    92
  get_value: Context.generic -> 'a,
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    93
  map_value: ('a -> 'a) -> Context.generic -> Context.generic};
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    94
69575
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    95
fun name_of (Config {name, ...}) = name;
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
    96
fun pos_of (Config {pos, ...}) = pos;
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
    97
69576
cfac69e7b962 tuned signature;
wenzelm
parents: 69575
diff changeset
    98
fun apply_generic (Config {get_value, ...}) = get_value;
cfac69e7b962 tuned signature;
wenzelm
parents: 69575
diff changeset
    99
fun get_generic context config = apply_generic config context;
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   100
fun map_generic (Config {map_value, ...}) f context = map_value f context;
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   101
fun put_generic config value = map_generic config (K value);
69576
cfac69e7b962 tuned signature;
wenzelm
parents: 69575
diff changeset
   102
fun restore_generic config = put_generic config o apply_generic config;
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   103
69576
cfac69e7b962 tuned signature;
wenzelm
parents: 69575
diff changeset
   104
fun apply_ctxt config = apply_generic config o Context.Proof;
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   105
fun get_ctxt ctxt = get_generic (Context.Proof ctxt);
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   106
fun map_ctxt config f = Context.proof_map (map_generic config f);
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   107
fun put_ctxt config value = map_ctxt config (K value);
69576
cfac69e7b962 tuned signature;
wenzelm
parents: 69575
diff changeset
   108
fun restore_ctxt config = put_ctxt config o apply_ctxt config;
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   109
69576
cfac69e7b962 tuned signature;
wenzelm
parents: 69575
diff changeset
   110
fun apply_global config = apply_generic config o Context.Theory;
36787
f60e4dd6d76f renamed Config.get_thy to Config.get_global etc. to indicate that this is not the real thing;
wenzelm
parents: 36002
diff changeset
   111
fun get_global thy = get_generic (Context.Theory thy);
f60e4dd6d76f renamed Config.get_thy to Config.get_global etc. to indicate that this is not the real thing;
wenzelm
parents: 36002
diff changeset
   112
fun map_global config f = Context.theory_map (map_generic config f);
f60e4dd6d76f renamed Config.get_thy to Config.get_global etc. to indicate that this is not the real thing;
wenzelm
parents: 36002
diff changeset
   113
fun put_global config value = map_global config (K value);
69576
cfac69e7b962 tuned signature;
wenzelm
parents: 69575
diff changeset
   114
fun restore_global config = put_global config o apply_global config;
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   115
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   116
69575
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   117
(* coerce type *)
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   118
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   119
fun coerce make dest (Config {name, pos, get_value, map_value}) = Config
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   120
 {name = name,
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   121
  pos = pos,
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   122
  get_value = dest o get_value,
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   123
  map_value = fn f => map_value (make o f o dest)};
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   124
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   125
fun coerce_pair make dest = (coerce make dest, coerce dest make);
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   126
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   127
val (bool, bool_value) = coerce_pair Bool (fn Bool b => b);
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   128
val (int, int_value) = coerce_pair Int (fn Int i => i);
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   129
val (real, real_value) = coerce_pair Real (fn Real x => x);
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   130
val (string, string_value) = coerce_pair String (fn String s => s);
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   131
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   132
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   133
(* context data *)
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   134
63806
c54a53ef1873 clarified modules;
wenzelm
parents: 58951
diff changeset
   135
structure Data = Generic_Data
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   136
(
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   137
  type T = value Inttab.table;
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   138
  val empty = Inttab.empty;
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   139
  val extend = I;
33519
e31a85f92ce9 adapted Generic_Data, Proof_Data;
wenzelm
parents: 29606
diff changeset
   140
  fun merge data = Inttab.merge (K true) data;
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   141
);
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   142
58951
8b7caf447357 removed obsolete global-only options, which did not work out anyway (due to complexity of local_theory sandwich);
wenzelm
parents: 57858
diff changeset
   143
fun declare (name, pos) default =
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   144
  let
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   145
    val id = serial ();
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   146
36000
5560b2437789 configuration options admit dynamic default values;
wenzelm
parents: 33519
diff changeset
   147
    fun get_value context =
63806
c54a53ef1873 clarified modules;
wenzelm
parents: 58951
diff changeset
   148
      (case Inttab.lookup (Data.get context) id of
36000
5560b2437789 configuration options admit dynamic default values;
wenzelm
parents: 33519
diff changeset
   149
        SOME value => value
36002
f4f343500249 pass raw Context.generic, to avoid wasteful Context.proof_of -- Config.get_thy is often used in performance critical spots like unify.ML;
wenzelm
parents: 36000
diff changeset
   150
      | NONE => default context);
36000
5560b2437789 configuration options admit dynamic default values;
wenzelm
parents: 33519
diff changeset
   151
58951
8b7caf447357 removed obsolete global-only options, which did not work out anyway (due to complexity of local_theory sandwich);
wenzelm
parents: 57858
diff changeset
   152
    fun map_value f context =
63806
c54a53ef1873 clarified modules;
wenzelm
parents: 58951
diff changeset
   153
      Data.map (Inttab.update (id, type_check (name, pos) f (get_value context))) context;
58951
8b7caf447357 removed obsolete global-only options, which did not work out anyway (due to complexity of local_theory sandwich);
wenzelm
parents: 57858
diff changeset
   154
  in
8b7caf447357 removed obsolete global-only options, which did not work out anyway (due to complexity of local_theory sandwich);
wenzelm
parents: 57858
diff changeset
   155
    Config {name = name, pos = pos, get_value = get_value, map_value = map_value}
8b7caf447357 removed obsolete global-only options, which did not work out anyway (due to complexity of local_theory sandwich);
wenzelm
parents: 57858
diff changeset
   156
  end;
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   157
69575
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   158
fun declare_bool name default = bool (declare name (Bool o default));
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   159
fun declare_int name default = int (declare name (Int o default));
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   160
fun declare_real name default = real (declare name (Real o default));
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   161
fun declare_string name default = string (declare name (String o default));
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   162
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   163
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   164
(* system options *)
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   165
58951
8b7caf447357 removed obsolete global-only options, which did not work out anyway (due to complexity of local_theory sandwich);
wenzelm
parents: 57858
diff changeset
   166
fun declare_option (name, pos) =
51947
3301612c4893 support for system options as context-sensitive config options;
wenzelm
parents: 47814
diff changeset
   167
  let
3301612c4893 support for system options as context-sensitive config options;
wenzelm
parents: 47814
diff changeset
   168
    val typ = Options.default_typ name;
3301612c4893 support for system options as context-sensitive config options;
wenzelm
parents: 47814
diff changeset
   169
    val default =
3301612c4893 support for system options as context-sensitive config options;
wenzelm
parents: 47814
diff changeset
   170
      if typ = Options.boolT then fn _ => Bool (Options.default_bool name)
3301612c4893 support for system options as context-sensitive config options;
wenzelm
parents: 47814
diff changeset
   171
      else if typ = Options.intT then fn _ => Int (Options.default_int name)
3301612c4893 support for system options as context-sensitive config options;
wenzelm
parents: 47814
diff changeset
   172
      else if typ = Options.realT then fn _ => Real (Options.default_real name)
3301612c4893 support for system options as context-sensitive config options;
wenzelm
parents: 47814
diff changeset
   173
      else if typ = Options.stringT then fn _ => String (Options.default_string name)
56438
7f6b2634d853 more source positions;
wenzelm
parents: 56294
diff changeset
   174
      else error ("Unknown type for option " ^ quote name ^ Position.here pos ^ " : " ^ quote typ);
58951
8b7caf447357 removed obsolete global-only options, which did not work out anyway (due to complexity of local_theory sandwich);
wenzelm
parents: 57858
diff changeset
   175
  in declare (name, pos) default end;
51947
3301612c4893 support for system options as context-sensitive config options;
wenzelm
parents: 47814
diff changeset
   176
69575
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   177
val declare_option_bool = bool o declare_option;
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   178
val declare_option_int = int o declare_option;
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   179
val declare_option_real = real o declare_option;
f77cc54f6d47 clarified signature: more types;
wenzelm
parents: 69574
diff changeset
   180
val declare_option_string = string o declare_option;
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   181
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   182
(*final declarations of this structure!*)
69576
cfac69e7b962 tuned signature;
wenzelm
parents: 69575
diff changeset
   183
val apply = apply_ctxt;
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   184
val get = get_ctxt;
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   185
val map = map_ctxt;
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   186
val put = put_ctxt;
68827
1286ca9dfd26 tuned signature;
wenzelm
parents: 63806
diff changeset
   187
val restore = restore_ctxt;
24114
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   188
1b0bc10019a5 renamed config_option.ML to config.ML;
wenzelm
parents:
diff changeset
   189
end;