1 (* Title: Pure/General/print_mode.ML
5 Generic print mode -- implicit configuration for various output
9 signature BASIC_PRINT_MODE =
11 val print_mode: string list ref
12 val print_mode_value: unit -> string list
13 val print_mode_active: string -> bool
16 signature PRINT_MODE =
18 include BASIC_PRINT_MODE
19 val with_modes: string list -> ('a -> 'b) -> 'a -> 'b
20 val with_default: ('a -> 'b) -> 'a -> 'b
23 structure PrintMode: PRINT_MODE =
26 val print_mode = ref ([]: string list);
28 fun print_mode_value () = NAMED_CRITICAL "print_mode" (fn () => ! print_mode);
29 fun print_mode_active s = member (op =) (print_mode_value ()) s;
31 fun with_modes modes f x = NAMED_CRITICAL "print_mode" (fn () =>
32 setmp print_mode (modes @ ! print_mode) f x);
34 fun with_default f x = NAMED_CRITICAL "print_mode" (fn () =>
35 setmp print_mode [] f x);
39 structure BasicPrintMode: BASIC_PRINT_MODE = PrintMode;