package core_kernel

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Module types and utilities for dealing with types that support the bin-io binary encoding.

type bigstring = (Base.Char.t, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t

We copy the definition of the bigstring type here, because we cannot depend on bigstring.ml

module type S = Binable.S

New code should use @@deriving bin_io. These module types (S, S1, and S2) are exported only for backwards compatibility.

module type S_only_functions = Binable.S_only_functions
module type S1 = Binable.S1
module type S2 = Binable.S2
module type S3 = Binable.S3

Of_binable* functors are for when you want the binary representation of one type to be the same as that for some other isomorphic type.

module Of_binable (Binable : Binable.S) (M : sig ... end) : sig ... end
module Of_binable1 (Binable : Binable.S1) (M : sig ... end) : sig ... end
module Of_binable2 (Binable : Binable.S2) (M : sig ... end) : sig ... end
module Of_binable3 (Binable : Binable.S3) (M : sig ... end) : sig ... end
module Of_sexpable (M : Sexpable.S) : sig ... end

Of_sexpable serializes a value using the bin-io of the sexp serialization of the value. This is not as efficient as using @@deriving bin_io. However, it is useful when performance isn't important and there are obstacles to using @@deriving bin_io, e.g., some type missing @@deriving bin_io. Of_sexpable is also useful when one wants to be forgiving about format changes, due to the sexp serialization being more robust to changes like adding or removing a constructor.

module Of_stringable (M : sig ... end) : sig ... end
type 'a m = (module S with type t = 'a)
val of_bigstring : 'a m -> bigstring -> 'a
val to_bigstring : ?prefix_with_length:Base.Bool.t -> 'a m -> 'a -> bigstring
val of_string : 'a m -> Base.String.t -> 'a
val to_string : 'a m -> 'a -> Base.String.t

The following functors preserve stability: if applied to stable types with stable (de)serializations, they will produce stable types with stable (de)serializations.

Note: In all cases, stability of the input (and therefore the output) depends on the semantics of all conversion functions (e.g. to_string, to_sexpable) not changing in the future.

module Stable : sig ... end
OCaml

Innovation. Community. Security.