<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Snippets</title><style type="text/css">code { font-family: Courier New, Courier, monospace; font-size: 100% white-space: nowrap; /* pre would be better, but it doesn't work with IE */}.codedisplay { font-family: Courier New, Courier, monospace; margin: 10px; padding: 10px; border-width: 20px; text-style: center; white-space: pre; color: black; border-color: #A9A9A9; border-width: thin; border-style: solid; background-color: #D3D3D3; background-repeat: no-repeat; background-position: 0 0; background-attachment: fixed;}</style></head><body><h3>How to silence the output produced by other tools?</h3>Jasmin Blanchette wrote: When writing Nitpick, I found the need to silence the other tools upon which Nitpick relies, because their output interfered in bad ways with Nitpick's own output. So I used code like the following:<div class="codedisplay">(* (string -> unit) ref -> ('a -> 'b) -> 'a -> 'b *)fun silence_one out_fn f x =let val old_out_fn = !out_fn val _ = out_fn := K () val y = f x val _ = out_fn := old_out_fnin y end(* ('a -> 'b) -> 'a -> 'b *)fun silence f = fold silence_one [Output.writeln_fn, Output.priority_fn, Output.tracing_fn, Output.warning_fn, Output.error_fn, Output.debug_fn, Output.prompt_fn, Output.status_fn] f</div><hr> <!-- Created: Thu May 21 21:17:59 CEST 2009 --><!-- hhmts start -->Last modified: Thu May 21 21:43:15 CEST 2009<!-- hhmts end --><a href="http://validator.w3.org/check/referer">[Validate this page.]</a> </body></html>