23827
|
1 |
(* Title: Pure/General/print_mode.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: Makarius
|
|
4 |
|
|
5 |
Generic print mode -- implicit configuration for various output
|
|
6 |
mechanisms.
|
|
7 |
*)
|
|
8 |
|
23934
|
9 |
signature BASIC_PRINT_MODE =
|
23827
|
10 |
sig
|
|
11 |
val print_mode: string list ref
|
|
12 |
val print_mode_active: string -> bool
|
|
13 |
end;
|
|
14 |
|
23934
|
15 |
signature PRINT_MODE =
|
|
16 |
sig
|
|
17 |
include BASIC_PRINT_MODE
|
|
18 |
val with_modes: string list -> ('a -> 'b) -> 'a -> 'b
|
|
19 |
val with_default: ('a -> 'b) -> 'a -> 'b
|
|
20 |
end;
|
|
21 |
|
23827
|
22 |
structure PrintMode: PRINT_MODE =
|
|
23 |
struct
|
|
24 |
|
|
25 |
val print_mode = ref ([]: string list);
|
|
26 |
fun print_mode_active s = member (op =) (! print_mode) s;
|
|
27 |
|
24058
|
28 |
fun with_modes modes f x = NAMED_CRITICAL "print_mode" (fn () =>
|
23934
|
29 |
setmp print_mode (modes @ ! print_mode) f x);
|
|
30 |
|
24058
|
31 |
fun with_default f x = NAMED_CRITICAL "print_mode" (fn () =>
|
|
32 |
setmp print_mode [] f x);
|
23934
|
33 |
|
23827
|
34 |
end;
|
|
35 |
|
23934
|
36 |
structure BasicPrintMode: BASIC_PRINT_MODE = PrintMode;
|
|
37 |
open BasicPrintMode;
|