module Type: sig
.. end
Type converters
type 'a
t
How to convert a type to and from JSON.
val name : 'a t -> string
val of_yojson : 'a t -> Yojson.Safe.json -> ('a, string) Result.result
val to_yojson : 'a t -> 'a -> Yojson.Safe.json
val make : name:string ->
to_yojson:('a -> Yojson.Safe.json) ->
of_yojson:(Yojson.Safe.json -> ('a, string) Result.result) ->
unit -> 'a t
Declare a new type.
val make_string : name:string ->
to_string:('a -> string) ->
of_string:(string -> ('a, string) Result.result) -> unit -> 'a t
Declare a new type that marshal/unmarshal to strings.
val exn : exn t
How to represent exceptions.
exception UnserializedException of string
Raised by exn.of_json
val unit : unit t
How to represent unit
.
val string : string t
How to represent string
.
val int : int t
How to represent int
.
val int32 : int32 t
How to represent int32
.
val int64 : int64 t
How to represent int64
.
val list : 'a t -> 'a list t
Build a representation of a list.
val product_2 : string ->
'a t -> string -> 'b t -> ('a * 'b) t
Build a representation of a couple.
The labels identify the elements, not their types.
val result : 'a t -> 'b t -> ('a, 'b) Result.result t
Build a representation of a result
.
val view : name:string ->
read:('a -> ('b, string) Result.result) ->
write:('b -> 'a) -> 'a t -> 'b t
Build a 'b
type which has the same JSON encoding as the 'a
type from
conversion functions read
and write
.