package records

  1. Overview
  2. Docs

Dynamic records

Layouts

type 's layout

The representation of record types. 's is usually a phantom type. Two interfaces are provided for creating layouts, in Unsafe and Safe.

exception ModifyingSealedStruct of string

Raised by field or seal if layout has already been sealed.

Records

type 's t = {
  1. layout : 's layout;
  2. content : 's content;
}

The representation of record values.

and 's content
val get_layout : 'a t -> 'a layout

Get the layout of a record.

exception AllocatingUnsealedStruct of string

Raised by make when the corresponding layout has not been sealed.

module Type : sig ... end
module Field : sig ... end
val get : 's t -> ('a, 's) Field.t -> 'a

Get the value of a field.

val set : 's t -> ('a, 's) Field.t -> 'a -> unit

Set the value of a field.

exception UndefinedField of string

Raised by get if the field was not set.

module Polid : sig ... end
module Unsafe : sig ... end
module Safe : sig ... end

Miscellaneous

val to_yojson : 'a t -> Yojson.Safe.t

Convert a record to JSON.

val of_yojson : 'a layout -> Yojson.Safe.t -> ('a t, string) Stdlib.Result.t

Convert a JSON value into a given schema.

module Util : sig ... end
val equal : 'a layout -> 'b layout -> ('a, 'b) Polid.equal

Equality predicate.

OCaml

Innovation. Community. Security.