Module Object.Mems

Uniform members.

Maps

type 'a jsont := 'a t
type ('mems, 'a) enc = {
  1. enc : 'acc. (Meta.t -> string -> 'a -> 'acc -> 'acc) -> 'mems -> 'acc -> 'acc;
}

The type for specifying unknown members encoding function. A function to fold over unknown members of uniform type 'a stored in a value of type 'mems.

type ('mems, 'a, 'builder) map

The type for mapping members of uniform type 'a to values of type 'mems using a builder of type 'builder.

val map : ?kind:string -> ?doc:string -> ?dec_empty:(unit -> 'builder) -> ?dec_add:(Meta.t -> string -> 'a -> 'builder -> 'builder) -> ?dec_finish:(Meta.t -> 'builder -> 'mems) -> ?enc:('mems, 'a) enc -> 'a jsont -> ('mems, 'a, 'builder) map

map type' maps unknown members of uniform type 'a to values of type 'mems built with type 'builder.

  • kind names the entities represented by the map and doc documents them. Both default to "".
  • dec_empty is used to create a builder for the members. Can be omitted if the map is only used for encoding, the default unconditionally errors.
  • dec_add meta name v b is used to add a member named name with meta meta with member value v to builder b. Can be omitted if the map is only used for encoding, the default unconditionally errors.
  • dec_finish meta b converts the builder to the final members value. meta is the metadata of the object in which they were found. Can be omitted if the map is only used for encoding, the default unconditionally errors.
  • enc f mems acc folds over the elements of mems starting with acc. This function is used to encode the members. Can be omitted if the map is only used for decoding, the default unconditionally errors.

See keep_unknown.

val string_map : ?kind:string -> ?doc:string -> 'a jsont -> ('a Stdlib.Map.Make(Stdlib.String).t, 'a, 'a Stdlib.Map.Make(Stdlib.String).t) map

string_map t collects unknown member by name and types their values with t. See keep_unknown and as_string_map.