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
|
24613
|
12 |
val print_mode_value: unit -> string list
|
23827
|
13 |
val print_mode_active: string -> bool
|
|
14 |
end;
|
|
15 |
|
23934
|
16 |
signature PRINT_MODE =
|
|
17 |
sig
|
|
18 |
include BASIC_PRINT_MODE
|
24634
|
19 |
val setmp: string list -> ('a -> 'b) -> 'a -> 'b
|
23934
|
20 |
val with_modes: string list -> ('a -> 'b) -> 'a -> 'b
|
|
21 |
end;
|
|
22 |
|
23827
|
23 |
structure PrintMode: PRINT_MODE =
|
|
24 |
struct
|
|
25 |
|
|
26 |
val print_mode = ref ([]: string list);
|
24613
|
27 |
|
|
28 |
fun print_mode_value () = NAMED_CRITICAL "print_mode" (fn () => ! print_mode);
|
|
29 |
fun print_mode_active s = member (op =) (print_mode_value ()) s;
|
23827
|
30 |
|
24634
|
31 |
fun setmp modes f x = NAMED_CRITICAL "print_mode" (fn () => Library.setmp print_mode modes f x);
|
|
32 |
fun with_modes modes f x = NAMED_CRITICAL "print_mode" (fn () => setmp (modes @ ! print_mode) f x);
|
23934
|
33 |
|
23827
|
34 |
end;
|
|
35 |
|
23934
|
36 |
structure BasicPrintMode: BASIC_PRINT_MODE = PrintMode;
|
|
37 |
open BasicPrintMode;
|