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 -> 'a jsont -> dec_empty:(unit -> 'builder) -> dec_add:(Meta.t -> string -> 'a -> 'builder -> 'builder) -> dec_finish:('builder -> 'mems) -> enc:('mems, 'a) enc -> ('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
  • dec_add meta name v b is used to add a member named name with meta meta with member value v to builder b
  • dec_finish b converts the builder to the final members value.
  • enc f mems acc folds over the elements of mems starting with acc. This function is used to encode the members

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.