|
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|
2 <html> |
|
3 <head> |
|
4 <title>Snippets</title> |
|
5 <style type="text/css"> |
|
6 |
|
7 code { |
|
8 font-family: Courier New, Courier, monospace; |
|
9 font-size: 100% |
|
10 white-space: nowrap; /* pre would be better, but it doesn't work with IE */ |
|
11 } |
|
12 |
|
13 .codedisplay { |
|
14 font-family: Courier New, Courier, monospace; |
|
15 margin: 10px; |
|
16 padding: 10px; |
|
17 border-width: 20px; |
|
18 text-style: center; |
|
19 white-space: pre; |
|
20 color: black; |
|
21 border-color: #A9A9A9; |
|
22 border-width: thin; |
|
23 border-style: solid; |
|
24 background-color: #D3D3D3; |
|
25 background-repeat: no-repeat; |
|
26 background-position: 0 0; |
|
27 background-attachment: fixed; |
|
28 } |
|
29 </style> |
|
30 </head> |
|
31 |
|
32 <body> |
|
33 <h3>How to silence the output produced by other tools?</h3> |
|
34 |
|
35 |
|
36 Jasmin Blanchette wrote: When writing Nitpick, I found the need to silence |
|
37 the other tools upon which Nitpick relies, because their output interfered |
|
38 in bad ways with Nitpick's own output. So I used code like the following: |
|
39 |
|
40 <div class="codedisplay">(* (string -> unit) ref -> ('a -> 'b) -> 'a -> 'b *) |
|
41 fun silence_one out_fn f x = |
|
42 let |
|
43 val old_out_fn = !out_fn |
|
44 val _ = out_fn := K () |
|
45 val y = f x |
|
46 val _ = out_fn := old_out_fn |
|
47 in y end |
|
48 |
|
49 (* ('a -> 'b) -> 'a -> 'b *) |
|
50 fun silence f = |
|
51 fold silence_one |
|
52 [Output.writeln_fn, Output.priority_fn, Output.tracing_fn, |
|
53 Output.warning_fn, Output.error_fn, Output.debug_fn, |
|
54 Output.prompt_fn, Output.status_fn] f |
|
55 </div> |
|
56 |
|
57 <hr> |
|
58 <!-- Created: Thu May 21 21:17:59 CEST 2009 --> |
|
59 <!-- hhmts start --> |
|
60 Last modified: Thu May 21 21:43:15 CEST 2009 |
|
61 <!-- hhmts end --> |
|
62 <a href="http://validator.w3.org/check/referer">[Validate this page.]</a> |
|
63 </body> |
|
64 </html> |