Module Async_kernel.Invariant

include module type of Core.Invariant
type ('a : any) t = 'a -> unit
module type S = Base.Invariant.S
module type S1__bits64 = Base.Invariant.S1__bits64
module type S2__bits64__bits64 = Base.Invariant.S2__bits64__bits64
module type S3__bits64__bits64__bits64 = Base.Invariant.S3__bits64__bits64__bits64
module type S3__bits64__bits64__bits32 = Base.Invariant.S3__bits64__bits64__bits32
module type S3__bits64__bits64__word = Base.Invariant.S3__bits64__bits64__word
module type S3__bits64__bits64__float64 = Base.Invariant.S3__bits64__bits64__float64
module type S3__bits64__bits64__float32 = Base.Invariant.S3__bits64__bits64__float32
module type S3__bits64__bits64__value = Base.Invariant.S3__bits64__bits64__value
module type S2__bits64__bits32 = Base.Invariant.S2__bits64__bits32
module type S3__bits64__bits32__bits64 = Base.Invariant.S3__bits64__bits32__bits64
module type S3__bits64__bits32__bits32 = Base.Invariant.S3__bits64__bits32__bits32
module type S3__bits64__bits32__word = Base.Invariant.S3__bits64__bits32__word
module type S3__bits64__bits32__float64 = Base.Invariant.S3__bits64__bits32__float64
module type S3__bits64__bits32__float32 = Base.Invariant.S3__bits64__bits32__float32
module type S3__bits64__bits32__value = Base.Invariant.S3__bits64__bits32__value
module type S2__bits64__word = Base.Invariant.S2__bits64__word
module type S3__bits64__word__bits64 = Base.Invariant.S3__bits64__word__bits64
module type S3__bits64__word__bits32 = Base.Invariant.S3__bits64__word__bits32
module type S3__bits64__word__word = Base.Invariant.S3__bits64__word__word
module type S3__bits64__word__float64 = Base.Invariant.S3__bits64__word__float64
module type S3__bits64__word__float32 = Base.Invariant.S3__bits64__word__float32
module type S3__bits64__word__value = Base.Invariant.S3__bits64__word__value
module type S2__bits64__float64 = Base.Invariant.S2__bits64__float64
module type S3__bits64__float64__bits64 = Base.Invariant.S3__bits64__float64__bits64
module type S3__bits64__float64__bits32 = Base.Invariant.S3__bits64__float64__bits32
module type S3__bits64__float64__word = Base.Invariant.S3__bits64__float64__word
module type S3__bits64__float64__float64 = Base.Invariant.S3__bits64__float64__float64
module type S3__bits64__float64__float32 = Base.Invariant.S3__bits64__float64__float32
module type S3__bits64__float64__value = Base.Invariant.S3__bits64__float64__value
module type S2__bits64__float32 = Base.Invariant.S2__bits64__float32
module type S3__bits64__float32__bits64 = Base.Invariant.S3__bits64__float32__bits64
module type S3__bits64__float32__bits32 = Base.Invariant.S3__bits64__float32__bits32
module type S3__bits64__float32__word = Base.Invariant.S3__bits64__float32__word
module type S3__bits64__float32__float64 = Base.Invariant.S3__bits64__float32__float64
module type S3__bits64__float32__float32 = Base.Invariant.S3__bits64__float32__float32
module type S3__bits64__float32__value = Base.Invariant.S3__bits64__float32__value
module type S2__bits64__value = Base.Invariant.S2__bits64__value
module type S3__bits64__value__bits64 = Base.Invariant.S3__bits64__value__bits64
module type S3__bits64__value__bits32 = Base.Invariant.S3__bits64__value__bits32
module type S3__bits64__value__word = Base.Invariant.S3__bits64__value__word
module type S3__bits64__value__float64 = Base.Invariant.S3__bits64__value__float64
module type S3__bits64__value__float32 = Base.Invariant.S3__bits64__value__float32
module type S3__bits64__value__value = Base.Invariant.S3__bits64__value__value
module type S1__bits32 = Base.Invariant.S1__bits32
module type S2__bits32__bits64 = Base.Invariant.S2__bits32__bits64
module type S3__bits32__bits64__bits64 = Base.Invariant.S3__bits32__bits64__bits64
module type S3__bits32__bits64__bits32 = Base.Invariant.S3__bits32__bits64__bits32
module type S3__bits32__bits64__word = Base.Invariant.S3__bits32__bits64__word
module type S3__bits32__bits64__float64 = Base.Invariant.S3__bits32__bits64__float64
module type S3__bits32__bits64__float32 = Base.Invariant.S3__bits32__bits64__float32
module type S3__bits32__bits64__value = Base.Invariant.S3__bits32__bits64__value
module type S2__bits32__bits32 = Base.Invariant.S2__bits32__bits32
module type S3__bits32__bits32__bits64 = Base.Invariant.S3__bits32__bits32__bits64
module type S3__bits32__bits32__bits32 = Base.Invariant.S3__bits32__bits32__bits32
module type S3__bits32__bits32__word = Base.Invariant.S3__bits32__bits32__word
module type S3__bits32__bits32__float64 = Base.Invariant.S3__bits32__bits32__float64
module type S3__bits32__bits32__float32 = Base.Invariant.S3__bits32__bits32__float32
module type S3__bits32__bits32__value = Base.Invariant.S3__bits32__bits32__value
module type S2__bits32__word = Base.Invariant.S2__bits32__word
module type S3__bits32__word__bits64 = Base.Invariant.S3__bits32__word__bits64
module type S3__bits32__word__bits32 = Base.Invariant.S3__bits32__word__bits32
module type S3__bits32__word__word = Base.Invariant.S3__bits32__word__word
module type S3__bits32__word__float64 = Base.Invariant.S3__bits32__word__float64
module type S3__bits32__word__float32 = Base.Invariant.S3__bits32__word__float32
module type S3__bits32__word__value = Base.Invariant.S3__bits32__word__value
module type S2__bits32__float64 = Base.Invariant.S2__bits32__float64
module type S3__bits32__float64__bits64 = Base.Invariant.S3__bits32__float64__bits64
module type S3__bits32__float64__bits32 = Base.Invariant.S3__bits32__float64__bits32
module type S3__bits32__float64__word = Base.Invariant.S3__bits32__float64__word
module type S3__bits32__float64__float64 = Base.Invariant.S3__bits32__float64__float64
module type S3__bits32__float64__float32 = Base.Invariant.S3__bits32__float64__float32
module type S3__bits32__float64__value = Base.Invariant.S3__bits32__float64__value
module type S2__bits32__float32 = Base.Invariant.S2__bits32__float32
module type S3__bits32__float32__bits64 = Base.Invariant.S3__bits32__float32__bits64
module type S3__bits32__float32__bits32 = Base.Invariant.S3__bits32__float32__bits32
module type S3__bits32__float32__word = Base.Invariant.S3__bits32__float32__word
module type S3__bits32__float32__float64 = Base.Invariant.S3__bits32__float32__float64
module type S3__bits32__float32__float32 = Base.Invariant.S3__bits32__float32__float32
module type S3__bits32__float32__value = Base.Invariant.S3__bits32__float32__value
module type S2__bits32__value = Base.Invariant.S2__bits32__value
module type S3__bits32__value__bits64 = Base.Invariant.S3__bits32__value__bits64
module type S3__bits32__value__bits32 = Base.Invariant.S3__bits32__value__bits32
module type S3__bits32__value__word = Base.Invariant.S3__bits32__value__word
module type S3__bits32__value__float64 = Base.Invariant.S3__bits32__value__float64
module type S3__bits32__value__float32 = Base.Invariant.S3__bits32__value__float32
module type S3__bits32__value__value = Base.Invariant.S3__bits32__value__value
module type S1__word = Base.Invariant.S1__word
module type S2__word__bits64 = Base.Invariant.S2__word__bits64
module type S3__word__bits64__bits64 = Base.Invariant.S3__word__bits64__bits64
module type S3__word__bits64__bits32 = Base.Invariant.S3__word__bits64__bits32
module type S3__word__bits64__word = Base.Invariant.S3__word__bits64__word
module type S3__word__bits64__float64 = Base.Invariant.S3__word__bits64__float64
module type S3__word__bits64__float32 = Base.Invariant.S3__word__bits64__float32
module type S3__word__bits64__value = Base.Invariant.S3__word__bits64__value
module type S2__word__bits32 = Base.Invariant.S2__word__bits32
module type S3__word__bits32__bits64 = Base.Invariant.S3__word__bits32__bits64
module type S3__word__bits32__bits32 = Base.Invariant.S3__word__bits32__bits32
module type S3__word__bits32__word = Base.Invariant.S3__word__bits32__word
module type S3__word__bits32__float64 = Base.Invariant.S3__word__bits32__float64
module type S3__word__bits32__float32 = Base.Invariant.S3__word__bits32__float32
module type S3__word__bits32__value = Base.Invariant.S3__word__bits32__value
module type S2__word__word = Base.Invariant.S2__word__word
module type S3__word__word__bits64 = Base.Invariant.S3__word__word__bits64
module type S3__word__word__bits32 = Base.Invariant.S3__word__word__bits32
module type S3__word__word__word = Base.Invariant.S3__word__word__word
module type S3__word__word__float64 = Base.Invariant.S3__word__word__float64
module type S3__word__word__float32 = Base.Invariant.S3__word__word__float32
module type S3__word__word__value = Base.Invariant.S3__word__word__value
module type S2__word__float64 = Base.Invariant.S2__word__float64
module type S3__word__float64__bits64 = Base.Invariant.S3__word__float64__bits64
module type S3__word__float64__bits32 = Base.Invariant.S3__word__float64__bits32
module type S3__word__float64__word = Base.Invariant.S3__word__float64__word
module type S3__word__float64__float64 = Base.Invariant.S3__word__float64__float64
module type S3__word__float64__float32 = Base.Invariant.S3__word__float64__float32
module type S3__word__float64__value = Base.Invariant.S3__word__float64__value
module type S2__word__float32 = Base.Invariant.S2__word__float32
module type S3__word__float32__bits64 = Base.Invariant.S3__word__float32__bits64
module type S3__word__float32__bits32 = Base.Invariant.S3__word__float32__bits32
module type S3__word__float32__word = Base.Invariant.S3__word__float32__word
module type S3__word__float32__float64 = Base.Invariant.S3__word__float32__float64
module type S3__word__float32__float32 = Base.Invariant.S3__word__float32__float32
module type S3__word__float32__value = Base.Invariant.S3__word__float32__value
module type S2__word__value = Base.Invariant.S2__word__value
module type S3__word__value__bits64 = Base.Invariant.S3__word__value__bits64
module type S3__word__value__bits32 = Base.Invariant.S3__word__value__bits32
module type S3__word__value__word = Base.Invariant.S3__word__value__word
module type S3__word__value__float64 = Base.Invariant.S3__word__value__float64
module type S3__word__value__float32 = Base.Invariant.S3__word__value__float32
module type S3__word__value__value = Base.Invariant.S3__word__value__value
module type S1__float64 = Base.Invariant.S1__float64
module type S2__float64__bits64 = Base.Invariant.S2__float64__bits64
module type S3__float64__bits64__bits64 = Base.Invariant.S3__float64__bits64__bits64
module type S3__float64__bits64__bits32 = Base.Invariant.S3__float64__bits64__bits32
module type S3__float64__bits64__word = Base.Invariant.S3__float64__bits64__word
module type S3__float64__bits64__float64 = Base.Invariant.S3__float64__bits64__float64
module type S3__float64__bits64__float32 = Base.Invariant.S3__float64__bits64__float32
module type S3__float64__bits64__value = Base.Invariant.S3__float64__bits64__value
module type S2__float64__bits32 = Base.Invariant.S2__float64__bits32
module type S3__float64__bits32__bits64 = Base.Invariant.S3__float64__bits32__bits64
module type S3__float64__bits32__bits32 = Base.Invariant.S3__float64__bits32__bits32
module type S3__float64__bits32__word = Base.Invariant.S3__float64__bits32__word
module type S3__float64__bits32__float64 = Base.Invariant.S3__float64__bits32__float64
module type S3__float64__bits32__float32 = Base.Invariant.S3__float64__bits32__float32
module type S3__float64__bits32__value = Base.Invariant.S3__float64__bits32__value
module type S2__float64__word = Base.Invariant.S2__float64__word
module type S3__float64__word__bits64 = Base.Invariant.S3__float64__word__bits64
module type S3__float64__word__bits32 = Base.Invariant.S3__float64__word__bits32
module type S3__float64__word__word = Base.Invariant.S3__float64__word__word
module type S3__float64__word__float64 = Base.Invariant.S3__float64__word__float64
module type S3__float64__word__float32 = Base.Invariant.S3__float64__word__float32
module type S3__float64__word__value = Base.Invariant.S3__float64__word__value
module type S2__float64__float64 = Base.Invariant.S2__float64__float64
module type S3__float64__float64__bits64 = Base.Invariant.S3__float64__float64__bits64
module type S3__float64__float64__bits32 = Base.Invariant.S3__float64__float64__bits32
module type S3__float64__float64__word = Base.Invariant.S3__float64__float64__word
module type S3__float64__float64__float64 = Base.Invariant.S3__float64__float64__float64
module type S3__float64__float64__float32 = Base.Invariant.S3__float64__float64__float32
module type S3__float64__float64__value = Base.Invariant.S3__float64__float64__value
module type S2__float64__float32 = Base.Invariant.S2__float64__float32
module type S3__float64__float32__bits64 = Base.Invariant.S3__float64__float32__bits64
module type S3__float64__float32__bits32 = Base.Invariant.S3__float64__float32__bits32
module type S3__float64__float32__word = Base.Invariant.S3__float64__float32__word
module type S3__float64__float32__float64 = Base.Invariant.S3__float64__float32__float64
module type S3__float64__float32__float32 = Base.Invariant.S3__float64__float32__float32
module type S3__float64__float32__value = Base.Invariant.S3__float64__float32__value
module type S2__float64__value = Base.Invariant.S2__float64__value
module type S3__float64__value__bits64 = Base.Invariant.S3__float64__value__bits64
module type S3__float64__value__bits32 = Base.Invariant.S3__float64__value__bits32
module type S3__float64__value__word = Base.Invariant.S3__float64__value__word
module type S3__float64__value__float64 = Base.Invariant.S3__float64__value__float64
module type S3__float64__value__float32 = Base.Invariant.S3__float64__value__float32
module type S3__float64__value__value = Base.Invariant.S3__float64__value__value
module type S1__float32 = Base.Invariant.S1__float32
module type S2__float32__bits64 = Base.Invariant.S2__float32__bits64
module type S3__float32__bits64__bits64 = Base.Invariant.S3__float32__bits64__bits64
module type S3__float32__bits64__bits32 = Base.Invariant.S3__float32__bits64__bits32
module type S3__float32__bits64__word = Base.Invariant.S3__float32__bits64__word
module type S3__float32__bits64__float64 = Base.Invariant.S3__float32__bits64__float64
module type S3__float32__bits64__float32 = Base.Invariant.S3__float32__bits64__float32
module type S3__float32__bits64__value = Base.Invariant.S3__float32__bits64__value
module type S2__float32__bits32 = Base.Invariant.S2__float32__bits32
module type S3__float32__bits32__bits64 = Base.Invariant.S3__float32__bits32__bits64
module type S3__float32__bits32__bits32 = Base.Invariant.S3__float32__bits32__bits32
module type S3__float32__bits32__word = Base.Invariant.S3__float32__bits32__word
module type S3__float32__bits32__float64 = Base.Invariant.S3__float32__bits32__float64
module type S3__float32__bits32__float32 = Base.Invariant.S3__float32__bits32__float32
module type S3__float32__bits32__value = Base.Invariant.S3__float32__bits32__value
module type S2__float32__word = Base.Invariant.S2__float32__word
module type S3__float32__word__bits64 = Base.Invariant.S3__float32__word__bits64
module type S3__float32__word__bits32 = Base.Invariant.S3__float32__word__bits32
module type S3__float32__word__word = Base.Invariant.S3__float32__word__word
module type S3__float32__word__float64 = Base.Invariant.S3__float32__word__float64
module type S3__float32__word__float32 = Base.Invariant.S3__float32__word__float32
module type S3__float32__word__value = Base.Invariant.S3__float32__word__value
module type S2__float32__float64 = Base.Invariant.S2__float32__float64
module type S3__float32__float64__bits64 = Base.Invariant.S3__float32__float64__bits64
module type S3__float32__float64__bits32 = Base.Invariant.S3__float32__float64__bits32
module type S3__float32__float64__word = Base.Invariant.S3__float32__float64__word
module type S3__float32__float64__float64 = Base.Invariant.S3__float32__float64__float64
module type S3__float32__float64__float32 = Base.Invariant.S3__float32__float64__float32
module type S3__float32__float64__value = Base.Invariant.S3__float32__float64__value
module type S2__float32__float32 = Base.Invariant.S2__float32__float32
module type S3__float32__float32__bits64 = Base.Invariant.S3__float32__float32__bits64
module type S3__float32__float32__bits32 = Base.Invariant.S3__float32__float32__bits32
module type S3__float32__float32__word = Base.Invariant.S3__float32__float32__word
module type S3__float32__float32__float64 = Base.Invariant.S3__float32__float32__float64
module type S3__float32__float32__float32 = Base.Invariant.S3__float32__float32__float32
module type S3__float32__float32__value = Base.Invariant.S3__float32__float32__value
module type S2__float32__value = Base.Invariant.S2__float32__value
module type S3__float32__value__bits64 = Base.Invariant.S3__float32__value__bits64
module type S3__float32__value__bits32 = Base.Invariant.S3__float32__value__bits32
module type S3__float32__value__word = Base.Invariant.S3__float32__value__word
module type S3__float32__value__float64 = Base.Invariant.S3__float32__value__float64
module type S3__float32__value__float32 = Base.Invariant.S3__float32__value__float32
module type S3__float32__value__value = Base.Invariant.S3__float32__value__value
module type S1 = Base.Invariant.S1
module type S2__value__bits64 = Base.Invariant.S2__value__bits64
module type S3__value__bits64__bits64 = Base.Invariant.S3__value__bits64__bits64
module type S3__value__bits64__bits32 = Base.Invariant.S3__value__bits64__bits32
module type S3__value__bits64__word = Base.Invariant.S3__value__bits64__word
module type S3__value__bits64__float64 = Base.Invariant.S3__value__bits64__float64
module type S3__value__bits64__float32 = Base.Invariant.S3__value__bits64__float32
module type S3__value__bits64__value = Base.Invariant.S3__value__bits64__value
module type S2__value__bits32 = Base.Invariant.S2__value__bits32
module type S3__value__bits32__bits64 = Base.Invariant.S3__value__bits32__bits64
module type S3__value__bits32__bits32 = Base.Invariant.S3__value__bits32__bits32
module type S3__value__bits32__word = Base.Invariant.S3__value__bits32__word
module type S3__value__bits32__float64 = Base.Invariant.S3__value__bits32__float64
module type S3__value__bits32__float32 = Base.Invariant.S3__value__bits32__float32
module type S3__value__bits32__value = Base.Invariant.S3__value__bits32__value
module type S2__value__word = Base.Invariant.S2__value__word
module type S3__value__word__bits64 = Base.Invariant.S3__value__word__bits64
module type S3__value__word__bits32 = Base.Invariant.S3__value__word__bits32
module type S3__value__word__word = Base.Invariant.S3__value__word__word
module type S3__value__word__float64 = Base.Invariant.S3__value__word__float64
module type S3__value__word__float32 = Base.Invariant.S3__value__word__float32
module type S3__value__word__value = Base.Invariant.S3__value__word__value
module type S2__value__float64 = Base.Invariant.S2__value__float64
module type S3__value__float64__bits64 = Base.Invariant.S3__value__float64__bits64
module type S3__value__float64__bits32 = Base.Invariant.S3__value__float64__bits32
module type S3__value__float64__word = Base.Invariant.S3__value__float64__word
module type S3__value__float64__float64 = Base.Invariant.S3__value__float64__float64
module type S3__value__float64__float32 = Base.Invariant.S3__value__float64__float32
module type S3__value__float64__value = Base.Invariant.S3__value__float64__value
module type S2__value__float32 = Base.Invariant.S2__value__float32
module type S3__value__float32__bits64 = Base.Invariant.S3__value__float32__bits64
module type S3__value__float32__bits32 = Base.Invariant.S3__value__float32__bits32
module type S3__value__float32__word = Base.Invariant.S3__value__float32__word
module type S3__value__float32__float64 = Base.Invariant.S3__value__float32__float64
module type S3__value__float32__float32 = Base.Invariant.S3__value__float32__float32
module type S3__value__float32__value = Base.Invariant.S3__value__float32__value
module type S2 = Base.Invariant.S2
module type S3__value__value__bits64 = Base.Invariant.S3__value__value__bits64
module type S3__value__value__bits32 = Base.Invariant.S3__value__value__bits32
module type S3__value__value__word = Base.Invariant.S3__value__value__word
module type S3__value__value__float64 = Base.Invariant.S3__value__value__float64
module type S3__value__value__float32 = Base.Invariant.S3__value__value__float32
module type S3 = Base.Invariant.S3
val invariant : here:lexing_position -> 'a -> ('a -> Sexplib0.Sexp.t) @ local -> ((unit -> unit) @ local -> unit) @ local

invariant t sexp_of_t f runs f (), and if f raises, wraps the exception in an Error.t that states "invariant failed" and includes both the exception raised by f, as well as sexp_of_t t. Idiomatic usage looks like:

  invariant t [%sexp_of: t] (fun () ->
    ... check t's invariants ... )

For polymorphic types:

  let invariant check_a t =
    Invariant.invariant t [%sexp_of: _ t] (fun () -> ... )

It's okay to use [%sexp_of: _ t] because the exceptions raised by check_a will show the parts that are opaque at top-level.

val check_field : 'a -> 'b t -> ('a, 'b) Base.Field.t -> unit

check_field is used when checking invariants using Fields.iter. It wraps an exception raised when checking a field with the field's name. Idiomatic usage looks like:

  type t =
    { foo : Foo.t
    ; bar : Bar.t
    }
  [@@deriving fields]

  let invariant t : unit =
    Invariant.invariant t [%sexp_of: t] (fun () ->
      let check f = Invariant.check_field t f in
      Fields.iter ~foo:(check Foo.invariant) ~bar:(check Bar.invariant))
  ;;
module Async : sig ... end