package ppx_stable_witness

  1. Overview
  2. Docs
Ppx extension for deriving a witness that a type is intended to be stable. In this context, stable means that the serialization format will never change. This allows programs running at different versions of the code to safely communicate.

Install

Dune Dependency

Authors

Maintainers

Sources

v0.17.0.tar.gz
sha256=052db5d52ccacaab30ead1a4192ad021ee00c235a73c09b7918acabcee4a0cda

doc/ppx_stable_witness.stable_witness/Stable_witness/index.html

Module Stable_witnessSource

Sourcetype 'a t
Sourcemodule 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.

Sourceval 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.

Sourcemodule type T1 = sig ... end
Sourcemodule Of_serializable1 (Stable_format : T1) (M : T1) : sig ... end
Sourcemodule type T2 = sig ... end
Sourcemodule Of_serializable2 (Stable_format : T2) (M : T2) : sig ... end
Sourcemodule Of_serializable3 (Stable_format : sig ... end) (M : sig ... end) : sig ... end
Sourceval 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.