author | wenzelm |
Wed, 21 Jan 2009 23:21:44 +0100 | |
changeset 29606 | fedb8be05f24 |
parent 29435 | a5f84ac14609 |
child 29858 | c8cee17d7e50 |
permissions | -rw-r--r-- |
21637 | 1 |
(* Title: Pure/ProofGeneral/preferences.ML |
2 |
Author: David Aspinall and Markus Wenzel |
|
3 |
||
4 |
User preferences for Isabelle which are maintained by the interface. |
|
5 |
*) |
|
6 |
||
24329 | 7 |
signature PREFERENCES = |
21637 | 8 |
sig |
28587 | 9 |
type preference = |
10 |
{name: string, |
|
11 |
descr: string, |
|
12 |
default: string, |
|
13 |
pgiptype: PgipTypes.pgiptype, |
|
14 |
get: unit -> string, |
|
15 |
set: string -> unit} |
|
16 |
val generic_pref: ('a -> string) -> (string -> 'a) -> PgipTypes.pgiptype -> |
|
17 |
'a ref -> string -> string -> preference |
|
18 |
val string_pref: string ref -> string -> string -> preference |
|
19 |
val int_pref: int ref -> string -> string -> preference |
|
20 |
val nat_pref: int ref -> string -> string -> preference |
|
21 |
val bool_pref: bool ref -> string -> string -> preference |
|
22 |
type T = (string * preference list) list |
|
23 |
val pure_preferences: T |
|
24 |
val remove: string -> T -> T |
|
25 |
val add: string -> preference -> T -> T |
|
26 |
val set_default: string * string -> T -> T |
|
21637 | 27 |
end |
28 |
||
28587 | 29 |
structure Preferences: PREFERENCES = |
21637 | 30 |
struct |
31 |
||
28587 | 32 |
(* preferences and preference tables *) |
21637 | 33 |
|
28587 | 34 |
type preference = |
35 |
{name: string, |
|
36 |
descr: string, |
|
37 |
default: string, |
|
38 |
pgiptype: PgipTypes.pgiptype, |
|
39 |
get: unit -> string, |
|
40 |
set: string -> unit}; |
|
41 |
||
42 |
fun mkpref raw_get raw_set typ name descr : preference = |
|
43 |
let |
|
44 |
fun get () = CRITICAL raw_get; |
|
45 |
fun set x = CRITICAL (fn () => raw_set x); |
|
46 |
in {name = name, descr = descr, pgiptype = typ, get = get, set = set, default = get ()} end; |
|
21637 | 47 |
|
48 |
||
28587 | 49 |
(* generic preferences *) |
21637 | 50 |
|
28587 | 51 |
fun generic_pref read write typ r = |
52 |
mkpref (fn () => read (! r)) (fn x => r := write x) typ; |
|
53 |
||
54 |
val string_pref = generic_pref I I PgipTypes.Pgipstring; |
|
21637 | 55 |
|
24329 | 56 |
val int_pref = |
28587 | 57 |
generic_pref PgipTypes.int_to_pgstring (PgipTypes.read_pgipint (NONE, NONE)) |
58 |
(PgipTypes.Pgipint (NONE, NONE)); |
|
59 |
||
21637 | 60 |
val nat_pref = |
28587 | 61 |
generic_pref PgipTypes.int_to_pgstring PgipTypes.read_pgipnat PgipTypes.Pgipnat; |
21637 | 62 |
|
63 |
val bool_pref = |
|
28587 | 64 |
generic_pref PgipTypes.bool_to_pgstring PgipTypes.read_pgipbool PgipTypes.Pgipbool; |
65 |
||
66 |
||
67 |
(* preferences of Pure *) |
|
21637 | 68 |
|
69 |
val proof_pref = |
|
28587 | 70 |
let |
71 |
fun get () = PgipTypes.bool_to_pgstring (! Proofterm.proofs >= 2); |
|
72 |
fun set s = Proofterm.proofs := (if PgipTypes.read_pgipbool s then 2 else 1); |
|
73 |
in mkpref get set PgipTypes.Pgipbool "full-proofs" "Record full proof objects internally" end; |
|
21637 | 74 |
|
28587 | 75 |
val thm_depsN = "thm_deps"; |
24329 | 76 |
val thm_deps_pref = |
28587 | 77 |
let |
78 |
fun get () = PgipTypes.bool_to_pgstring (print_mode_active thm_depsN); |
|
79 |
fun set s = |
|
80 |
if PgipTypes.read_pgipbool s then change print_mode (insert (op =) thm_depsN) |
|
81 |
else change print_mode (remove (op =) thm_depsN); |
|
82 |
in |
|
83 |
mkpref get set PgipTypes.Pgipbool "theorem-dependencies" |
|
84 |
"Track theorem dependencies within Proof General" |
|
85 |
end; |
|
21637 | 86 |
|
87 |
val print_depth_pref = |
|
28587 | 88 |
let |
89 |
fun get () = PgipTypes.int_to_pgstring (get_print_depth ()); |
|
90 |
val set = print_depth o PgipTypes.read_pgipnat; |
|
91 |
in mkpref get set PgipTypes.Pgipnat "print-depth" "Setting for the ML print depth" end; |
|
21637 | 92 |
|
93 |
||
24329 | 94 |
val display_preferences = |
28587 | 95 |
[bool_pref show_types |
96 |
"show-types" |
|
97 |
"Include types in display of Isabelle terms", |
|
98 |
bool_pref show_sorts |
|
99 |
"show-sorts" |
|
100 |
"Include sorts in display of Isabelle terms", |
|
101 |
bool_pref show_consts |
|
102 |
"show-consts" |
|
103 |
"Show types of consts in Isabelle goal display", |
|
104 |
bool_pref long_names |
|
105 |
"long-names" |
|
106 |
"Show fully qualified names in Isabelle terms", |
|
107 |
bool_pref show_brackets |
|
108 |
"show-brackets" |
|
109 |
"Show full bracketing in Isabelle terms", |
|
110 |
bool_pref Proof.show_main_goal |
|
111 |
"show-main-goal" |
|
112 |
"Show main goal in proof state display", |
|
113 |
bool_pref Syntax.eta_contract |
|
114 |
"eta-contract" |
|
115 |
"Print terms eta-contracted"]; |
|
21637 | 116 |
|
117 |
val advanced_display_preferences = |
|
28587 | 118 |
[nat_pref goals_limit |
119 |
"goals-limit" |
|
120 |
"Setting for maximum number of goals printed", |
|
121 |
int_pref ProofContext.prems_limit |
|
122 |
"prems-limit" |
|
123 |
"Setting for maximum number of premises printed", |
|
124 |
print_depth_pref, |
|
125 |
bool_pref show_question_marks |
|
126 |
"show-question-marks" |
|
127 |
"Show leading question mark of variable name"]; |
|
21637 | 128 |
|
24329 | 129 |
val tracing_preferences = |
28587 | 130 |
[bool_pref trace_simp |
131 |
"trace-simplifier" |
|
132 |
"Trace simplification rules.", |
|
133 |
nat_pref trace_simp_depth_limit |
|
134 |
"trace-simplifier-depth" |
|
135 |
"Trace simplifier depth limit.", |
|
136 |
bool_pref trace_rules |
|
137 |
"trace-rules" |
|
138 |
"Trace application of the standard rules", |
|
139 |
bool_pref Pattern.trace_unify_fail |
|
140 |
"trace-unification" |
|
141 |
"Output error diagnostics during unification", |
|
142 |
bool_pref Output.timing |
|
143 |
"global-timing" |
|
144 |
"Whether to enable timing in Isabelle.", |
|
145 |
bool_pref Toplevel.debug |
|
146 |
"debugging" |
|
147 |
"Whether to enable debugging.", |
|
148 |
bool_pref Quickcheck.auto |
|
149 |
"auto-quickcheck" |
|
150 |
"Whether to enable quickcheck automatically.", |
|
151 |
nat_pref Quickcheck.auto_time_limit |
|
152 |
"auto-quickcheck-time-limit" |
|
153 |
"Time limit for automatic quickcheck (in milliseconds).", |
|
154 |
thm_deps_pref]; |
|
21637 | 155 |
|
24329 | 156 |
val proof_preferences = |
28587 | 157 |
[bool_pref quick_and_dirty |
158 |
"quick-and-dirty" |
|
159 |
"Take a few short cuts", |
|
160 |
bool_pref Toplevel.skip_proofs |
|
161 |
"skip-proofs" |
|
162 |
"Skip over proofs (interactive-only)", |
|
163 |
proof_pref, |
|
164 |
nat_pref Multithreading.max_threads |
|
165 |
"max-threads" |
|
29435
a5f84ac14609
added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents:
28591
diff
changeset
|
166 |
"Maximum number of threads", |
a5f84ac14609
added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents:
28591
diff
changeset
|
167 |
bool_pref Goal.parallel_proofs |
a5f84ac14609
added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents:
28591
diff
changeset
|
168 |
"parallel-proofs" |
a5f84ac14609
added parallel_proofs flag (default true, cf. usedir option -Q), which can be disabled in low-memory situations;
wenzelm
parents:
28591
diff
changeset
|
169 |
"Check proofs in parallel"]; |
21637 | 170 |
|
28587 | 171 |
val pure_preferences = |
172 |
[("Display", display_preferences), |
|
173 |
("Advanced Display", advanced_display_preferences), |
|
174 |
("Tracing", tracing_preferences), |
|
175 |
("Proof", proof_preferences)]; |
|
21637 | 176 |
|
28587 | 177 |
|
178 |
(* table of categories and preferences; names must be unique *) |
|
179 |
||
180 |
type T = (string * preference list) list; |
|
22214
6e9ab159512f
Add operations on preference tables (remove, set_default).
aspinall
parents:
22130
diff
changeset
|
181 |
|
28587 | 182 |
fun remove name (tab: T) = tab |> map |
183 |
(fn (cat, prefs) => (cat, filter_out (curry op = name o #name) prefs)); |
|
22214
6e9ab159512f
Add operations on preference tables (remove, set_default).
aspinall
parents:
22130
diff
changeset
|
184 |
|
28587 | 185 |
fun set_default (setname, newdefault) (tab: T) = tab |> map |
186 |
(fn (cat, prefs) => |
|
187 |
(cat, prefs |> map (fn (pref as {name, descr, default, pgiptype, get, set}) => |
|
188 |
if name = setname then |
|
189 |
(set newdefault; |
|
190 |
{name =name , descr = descr, default = newdefault, |
|
191 |
pgiptype = pgiptype, get = get, set = set}) |
|
192 |
else pref))); |
|
22214
6e9ab159512f
Add operations on preference tables (remove, set_default).
aspinall
parents:
22130
diff
changeset
|
193 |
|
28587 | 194 |
fun add cname (pref: preference) (tab: T) = tab |> map |
195 |
(fn (cat, prefs) => |
|
196 |
if cat <> cname then (cat, prefs) |
|
197 |
else |
|
198 |
if exists (fn {name, ...} => name = #name pref) prefs |
|
28591 | 199 |
then (warning ("Preference already exists: " ^ quote (#name pref)); (cat, prefs)) |
28587 | 200 |
else (cat, pref :: prefs)); |
28066
611e504c1191
extended interface to preferences to allow adding new ones
nipkow
parents:
25440
diff
changeset
|
201 |
|
28587 | 202 |
end; |