package ppx_stable_witness

  1. Overview
  2. Docs
type 'a t
module Export : sig ... end

Stable witnesses for primitive types exported by Core.Core_stable. Code using ppx_stable_witness is expected to start with open Stable_witness.Export.

val of_serializable : 'a t -> ('a -> 'b) -> ('b -> 'a) -> 'b t

This is useful to provide a stable witness on a type that uses another type for serialization.

module type T1 = sig ... end
module Of_serializable1 (Stable_format : T1) (M : T1) : sig ... end
module type T2 = sig ... end
module Of_serializable2 (Stable_format : T2) (M : T2) : sig ... end
module Of_serializable3 (Stable_format : sig ... end) (M : sig ... end) : sig ... end
val assert_stable : _ t

This is an escape hatch. Don't use it unless you have to.

There are two use cases for this:

1. It allows you to assert that a type that you're writing has stable serialization functions, even if the type itself depends on unstable types.

2. It allows you to assert that a type from some other module is stable (and generate a stable witness for it) even if the type doesn't provide one for itself. It is almost always better to get the upstream code to provide a stability guarantee. At the very least, consult with the upstream maintainer to make sure their serializations are stable over time, and document the discussion.

OCaml

Innovation. Community. Security.