Support.DebugDebug-print library with up to 31 separate categories of information.
Usage:
makeFunctions or makeFunctions': let (dprint, dprnt) = Debug.makeFunctions (Debug.toFlags [...])
let (dprintf, dprint, dprnt) = Debug.makeFunctions' (Debug.toFlags [...])where `...' is the category (or categories) specific to the module.
Then,
dprint takes a thunkdprnt (misspelled) takes a stringdprintf takes a callback receiving formatter, with which you can generate formatted output, including custom indentation.If debugging is turned off, print is more efficient whenever computing the string is at all nontrivial. This actually matters; running the test suite with debug mode enabled takes several times longer.
All functions will add a newline after printing your text.
val makeFunctions : flags -> ((unit -> string) -> unit) * (string -> unit)module Fmt : sig ... endThis submodule defines a record containing a higher-rank polymorphic function. We need this record type so that we can pass a partially-applied Format.fprintf function to client modules. We introduce the submodule so that client modules can selectively open it if they want to use the format-string support provided by Debug; this will bring into scope only the fmt type and the fmt projection for the record.
val toFlags : int list -> flagsRuns the given function with debug printing indented by the given number of spaces. Pass in dprintf obtained by calling makeFunctions'.
Note that the vbox introduced to indent will NOT be closed if the given function raises an exception. This is a trade-off since the alternative would be to reraise the exception, which sadly destroys the backtrace.