Module Tpf_json.Enc
Generic JSON encoder.
Records are represented as JSON objects, and constant constructors are represented as JSON strings.
The representation of variants is determined by the ~sum
argument (default arr
).
Generic function
type sum
= string -> json list -> json
Sum-formatting functions.
f name args
is the JSON encoding of constructor namedname
, with argumentsargs
.
val arr : sum
Formats
K (a0, a1, ...)
as["K", a0, a1, ...]
.
val obj : ?tag:string -> ?values:string -> sum
Formats
K (a0, a1, ...)
as{ tag: "K", values: [a0, a1, ...]}
.tag
defaults to"tag"
andvalues
defaults to"values"
.
data
interface
val data0 : ?sum:sum -> 'x Tpf.data0 -> 'x e
val data1 : ?sum:sum -> ('a, 'x) Tpf.data1 -> 'a e -> 'x e
val data2 : ?sum:sum -> ('a, 'b, 'x) Tpf.data2 -> 'a e -> 'b e -> 'x e
val data3 : ?sum:sum -> ('a, 'b, 'c, 'x) Tpf.data3 -> 'a e -> 'b e -> 'c e -> 'x e
val data4 : ?sum:sum -> ('a, 'b, 'c, 'd, 'x) Tpf.data4 -> 'a e -> 'b e -> 'c e -> 'd e -> 'x e
val data5 : ?sum:sum -> ('a, 'b, 'c, 'd, 'e, 'x) Tpf.data5 -> 'a e -> 'b e -> 'c e -> 'd e -> 'e e -> 'x e
val data6 : ?sum:sum -> ('a, 'b, 'c, 'd, 'e, 'f, 'x) Tpf.data6 -> 'a e -> 'b e -> 'c e -> 'd e -> 'e e -> 'f e -> 'x e
val data7 : ?sum:sum -> ('a, 'b, 'c, 'd, 'e, 'f, 'g, 'x) Tpf.data7 -> 'a e -> 'b e -> 'c e -> 'd e -> 'e e -> 'f e -> 'g e -> 'x e
val data8 : ?sum:sum -> ('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'x) Tpf.data8 -> 'a e -> 'b e -> 'c e -> 'd e -> 'e e -> 'f e -> 'g e -> 'h e -> 'x e
val data9 : ?sum:sum -> ('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'x) Tpf.data9 -> 'a e -> 'b e -> 'c e -> 'd e -> 'e e -> 'f e -> 'g e -> 'h e -> 'i e -> 'x e