jon.recoil.org

Module Bin_prot.ShapeSource

include module type of struct include Bin_shape end

Shape.t are constructed by the bin_shape syntax extension from OCaml type definitions & expressions.

There is a direct mapping from ocaml type definition syntax to the corresponding Shape.group and from ocaml type expression syntax to the corresponding Shape.t.

Tid.t & Vid.t are identifiers for type-constructors & type-vars. i.e. Given type 'a t = ...

Sourcemodule Tid = Bin_shape.Tid
Sourcemodule Vid = Bin_shape.Vid
Sourcemodule Location = Bin_shape.Location

Location.t is required when constructing shapes for which evaluation might fail.

Sourcemodule Uuid = Bin_shape.Uuid

Uuid.t is used by basetype and annotate.

group of mutually recursive type definitions

This function is generative; repeated calls create distinct groups

Sourceval record : (string * Bin_prot.Shape.t) list -> Bin_prot.Shape.t
Sourceval variant : (string * Bin_prot.Shape.t list) list -> Bin_prot.Shape.t
Sourcetype poly_variant_row = Bin_shape.poly_variant_row

recursive apps within the current group

apps from outside the group

Built-in types and types with custom serialization: i.e. int,list,... To avoid accidental protocol compatibility, pass a UUID as the string argument

a = annotate s t creates a shape a distinguished, but dependent on shape t. Very much as record [(s,t)] does. But with annotate the ocaml record type does not exist.

Sourcemodule Stable = Bin_shape.Stable

Shape.Canonical.t is the result of evaluating a shape to a canonical form, and represents the shape of OCaml types w.r.t. bin_io serialization.

The idea is that de-serialization is safe if the canonical-shape for the type produced by de-serialization is equivalent to the canonical-shape of the serialized type.

The representation is canonical, so equivalence is structural equality.

Canonical.t also provides a useful human level description of a type.

A Canonical.t can be `digested' to a Digest.t, and except for nearly impossible hash collisions, equality of the digests implies equality of canonical-shapes and hence equivalence at the Shape.t level.

Canonical.t may also be constructed with various functions: annotate, basetype, tuple, record, variant, poly_variant, fix, recurse, .. which might be used when setting up unit tests or expected shapes.

Sourcemodule Digest = Bin_shape.Digest
Sourcemodule Expert = Bin_shape.Expert
Sourcemodule Canonical = Bin_shape.Canonical

eval t returns the canonical-shape for a shape-expression Shape.t. Type aliases are expanded, so that no Tid.t or Vid.t have significance in the resulting canonical-shape. Type-recursion, including non-regular recursion, is translated to the de-bruijn representation used in canonical-shapes.

Sourceval eval_to_digest : Bin_prot.Shape.t -> Digest.t

eval_to_digest t returns a hash-value direct from the Shape.t, potentially avoiding the intermediate Canonical.t from being constructed. This is important as the size of a canonical-shape might be exponential in terms of the size of the shape expression. The following holds: Digest.(eval_to_digest exp = Canonical.to_digest (eval exp))

Sourceval eval_to_digest_string : Bin_prot.Shape.t -> string

eval_to_digest_string t == Digest.to_hex (eval_to_digest t) Convenience function useful for writing unit tests.

Sourcemodule For_typerep = Bin_shape.For_typerep
Sourceval bin_shape_unit : Bin_prot.Shape.t
Sourceval bin_shape_bool : Bin_prot.Shape.t
Sourceval bin_shape_string : Bin_prot.Shape.t
Sourceval bin_shape_bytes : Bin_prot.Shape.t
Sourceval bin_shape_char : Bin_prot.Shape.t
Sourceval bin_shape_float : Bin_prot.Shape.t
Sourceval bin_shape_int : Bin_prot.Shape.t
Sourceval bin_shape_int32 : Bin_prot.Shape.t
Sourceval bin_shape_int63 : Bin_prot.Shape.t
Sourceval bin_shape_int64 : Bin_prot.Shape.t
Sourceval bin_shape_nativeint : Bin_prot.Shape.t
Sourceval bin_shape_nat0 : Bin_prot.Shape.t
Sourceval bin_shape_digest : Bin_prot.Shape.t
Sourceval bin_shape_float32_vec : Bin_prot.Shape.t
Sourceval bin_shape_float64_vec : Bin_prot.Shape.t
Sourceval bin_shape_vec : Bin_prot.Shape.t
Sourceval bin_shape_float32_mat : Bin_prot.Shape.t
Sourceval bin_shape_float64_mat : Bin_prot.Shape.t
Sourceval bin_shape_mat : Bin_prot.Shape.t
Sourceval bin_shape_bigstring : Bin_prot.Shape.t
Sourceval bin_shape_floatarray : Bin_prot.Shape.t
Sourceval bin_shape_variant_int : Bin_prot.Shape.t
Sourceval bin_shape_int_8bit : Bin_prot.Shape.t
Sourceval bin_shape_int_16bit : Bin_prot.Shape.t
Sourceval bin_shape_int_32bit : Bin_prot.Shape.t
Sourceval bin_shape_int_64bit : Bin_prot.Shape.t
Sourceval bin_shape_int64_bits : Bin_prot.Shape.t
Sourceval bin_shape_network16_int : Bin_prot.Shape.t
Sourceval bin_shape_network32_int : Bin_prot.Shape.t
Sourceval bin_shape_network32_int32 : Bin_prot.Shape.t
Sourceval bin_shape_network64_int : Bin_prot.Shape.t
Sourceval bin_shape_network64_int64 : Bin_prot.Shape.t
Sourceval bin_shape_option : Bin_prot.Shape.t -> Bin_prot.Shape.t
Sourceval bin_shape_array : Bin_prot.Shape.t -> Bin_prot.Shape.t