Module Core_kernel.Debug.Make

Debug.Make produces a debug function used to wrap a function to display arguments before calling and display results after returning. Intended usage is:

      module Foo = struct
        type t = ...
        let invariant = ...
          let bar t x y : Result.t = ...
      end
      module Foo_debug = struct
        open Foo
        include Debug.Make ()
        let debug x = debug invariant ~module_name:"Foo" x
        let bar t x y =
          debug "bar" [t] (t, x, y) <:sexp_of< t * X.t * Y.t >> <:sexp_of< Result.t >>
            (fun () -> bar t x y)
      end

Parameters

Signature

val check_invariant : Core_kernel__.Import.bool Core_kernel__.Import.ref

Whether the invariants are called on each invocation.

val show_messages : Core_kernel__.Import.bool Core_kernel__.Import.ref

If true, you get a message on stderr every time debug is called.

val debug : 't Core_kernel__.Import.Invariant.t ‑> module_name:Core_kernel__.Import.string ‑> Core_kernel__.Import.string ‑> 't Core_kernel__.Import.list ‑> 'args ‑> ('args ‑> Sexp.t) ‑> ('result ‑> Sexp.t) ‑> (Core_kernel__.Import.unit ‑> 'result) ‑> 'result

We avoid labels so that the applications are more concise -- see example above.