Crdt.Value
crdt · API reference
Value types including JSON and CBOR extensions
Value types including JSON and CBOR extensions.
This module defines the internal value type supporting JSON values plus CBOR extensions (bytes, undefined).
type t =
| Null
| Undefined (* CBOR extension - not in standard JSON *)
| Bool of bool
| Int of int (* 53-bit safe integer *)
| Float of float
| String of string
| Bytes of bytes (* CBOR extension - not in standard JSON *)
| Array of t list
| Object of (string * t) list
| Timestamp_ref of int * int (* Reference to another node as (sid, time) *)The value type supporting JSON + CBOR extensions
val equal : t -> t -> boolequal a b returns true if values are structurally equal
val compare : t -> t -> intcompare a b provides total ordering for values
val null : tnull is the JSON null value
val undefined : tundefined is the CBOR undefined value
val bool : bool -> tbool b creates a boolean value
val int : int -> tint i creates an integer value
val float : float -> tfloat f creates a float value
val string : string -> tstring s creates a string value
val bytes : bytes -> tbytes b creates a bytes value (CBOR extension)
val array : t list -> tarray vs creates an array value
val obj : (string * t) list -> tobj pairs creates an object value
val timestamp_ref : int -> int -> ttimestamp_ref sid time creates a timestamp reference
val is_null : t -> boolis_null v returns true if the value is null
val is_undefined : t -> boolis_undefined v returns true if the value is undefined
val is_bool : t -> boolis_bool v returns true if the value is a boolean
val is_int : t -> boolis_int v returns true if the value is an integer
val is_float : t -> boolis_float v returns true if the value is a float
val is_string : t -> boolis_string v returns true if the value is a string
val is_bytes : t -> boolis_bytes v returns true if the value is bytes
val is_array : t -> boolis_array v returns true if the value is an array
val is_object : t -> boolis_object v returns true if the value is an object
val is_timestamp_ref : t -> boolis_timestamp_ref v returns true if the value is a timestamp reference
val to_bool : t -> bool optionto_bool v extracts a boolean, or None if not a boolean
val to_int : t -> int optionto_int v extracts an integer, or None if not an integer
val to_float : t -> float optionto_float v extracts a float, or None if not a float
val to_string_opt : t -> string optionto_string_opt v extracts a string, or None if not a string
val to_bytes : t -> bytes optionto_bytes v extracts bytes, or None if not bytes
val to_array : t -> t list optionto_array v extracts an array, or None if not an array
val to_object : t -> (string * t) list optionto_object v extracts an object, or None if not an object
val to_timestamp_ref : t -> (int * int) optionto_timestamp_ref v extracts a timestamp reference, or None
val pp : Format.formatter -> t -> unitpp fmt v pretty-prints a value
val to_string : t -> stringto_string v converts a value to a string representation
val type_name : t -> stringtype_name v returns the type name of the value