Jsont.Repr
Low level representation (unstable).
This representation may change even between minor versions of the library. It can be used to devise new processors on JSON types.
Processors should be ready to catch the Json.Error
exception when they invoke functional members of the representation.
Processors should also make sure they interpret mappings correctly. In particular:
Number
case represents the sets of JSON numbers and nulls.See the source of Json.decode'
and Jsont.encode'
for a simple example on how to process this representation.
type 'a t' := 'a t
module Type : sig ... end
Type identifiers. Can be removed once we require OCaml 5.1
type 'a t =
| Null : (unit, 'a) base_map -> 'a t
| Bool : (bool, 'a) base_map -> 'a t
| Number : (float, 'a) base_map -> 'a t
| String : (string, 'a) base_map -> 'a t
| Array : ('a, 'elt, 'builder) array_map -> 'a t
| Obj : ('o, 'o) obj_map -> 'o t
| Any : 'a any_map -> 'a t
| Map : ('a, 'b) map -> 'b t
| Rec : 'a t Stdlib.Lazy.t -> 'a t
and ('array, 'elt, 'builder) array_map = {
kind : string;
doc : string;
elt : 'elt t;
dec_empty : Context.t -> 'builder;
dec_skip : Context.t -> int -> 'builder -> bool;
dec_add : Context.t -> int -> 'elt -> 'builder -> 'builder;
dec_finish : Context.t -> Meta.t -> int -> 'builder -> 'array;
enc : 'acc. Context.t ->
('acc -> int -> 'elt -> 'acc) ->
'acc ->
'array ->
'acc;
enc_meta : Context.t -> 'array -> Meta.t;
}
and 'o obj_shape =
| Obj_basic : ('o, 'mems, 'builder) unknown_mems -> 'o obj_shape
| Obj_cases : ('o, 'cases, 'tag) obj_cases -> 'o obj_shape
and ('o, 'mems, 'builder) unknown_mems =
| Unknown_skip : ('o, unit, unit) unknown_mems
| Unknown_error : ('o, unit, unit) unknown_mems
| Unknown_keep : ('mems, 'a, 'builder) mems_map
* ('o ->
'mems) -> ('o, 'mems, 'builder) unknown_mems
and ('mems, 'a, 'builder) mems_map = {
kind : string;
doc : string;
mems_type : 'a t;
id : 'mems Type.Id.t;
dec_empty : Context.t -> 'builder;
dec_add : Context.t -> Meta.t -> string -> 'a -> 'builder -> 'builder;
dec_finish : Context.t -> 'builder -> 'mems;
enc : 'acc. Context.t ->
(Meta.t -> string -> 'a -> 'acc -> 'acc) ->
'mems ->
'acc ->
'acc;
}
and ('o, 'cases, 'tag) obj_cases = {
tag : ('tag, 'tag) mem_map;
tag_compare : 'tag -> 'tag -> int;
id : 'cases Type.Id.t;
cases : ('cases, 'tag) case list;
enc : 'o -> 'cases;
enc_case : Context.t -> 'cases -> ('cases, 'tag) case_value;
}
and ('cases, 'case, 'tag) case_map = {
tag : 'tag;
obj_map : ('case, 'case) obj_map;
dec : 'case -> 'cases;
}
and ('cases, 'tag) case_value =
| Case_value : ('cases, 'case, 'tag) case_map
* 'case -> ('cases, 'tag) case_value
type_error ctx m t
is like Error.kind
but exp
is derived from t
.
val kind : 'a t -> string
kind m
is the kind of definition of m
.
val obj_map_kind : ('o, 'dec) obj_map -> string
obj_map_kind m
is the kind of definition of m
.
val pp_code : string fmt
module Dict : sig ... end
Heterogeneous dictionaries.