equal
deleted
inserted
replaced
4 |
4 |
5 Generic print mode -- implicit configuration for various output |
5 Generic print mode -- implicit configuration for various output |
6 mechanisms. |
6 mechanisms. |
7 *) |
7 *) |
8 |
8 |
9 signature PRINT_MODE = |
9 signature BASIC_PRINT_MODE = |
10 sig |
10 sig |
11 val print_mode: string list ref |
11 val print_mode: string list ref |
12 val print_mode_active: string -> bool |
12 val print_mode_active: string -> bool |
|
13 end; |
|
14 |
|
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 |
13 end; |
20 end; |
14 |
21 |
15 structure PrintMode: PRINT_MODE = |
22 structure PrintMode: PRINT_MODE = |
16 struct |
23 struct |
17 |
24 |
18 val print_mode = ref ([]: string list); |
25 val print_mode = ref ([]: string list); |
19 fun print_mode_active s = member (op =) (! print_mode) s; |
26 fun print_mode_active s = member (op =) (! print_mode) s; |
20 |
27 |
|
28 fun with_modes modes f x = CRITICAL (fn () => |
|
29 setmp print_mode (modes @ ! print_mode) f x); |
|
30 |
|
31 fun with_default f x = setmp print_mode [] f x; |
|
32 |
21 end; |
33 end; |
22 |
34 |
23 open PrintMode; |
35 structure BasicPrintMode: BASIC_PRINT_MODE = PrintMode; |
|
36 open BasicPrintMode; |