package records

  1. Overview
  2. Docs

Module Record.TypeSource

Type converters

Sourcetype 'a t

How to convert a type to and from JSON.

Sourceval name : 'a t -> string
Sourceval of_yojson : 'a t -> Yojson.Safe.json -> ('a, string) Result.result
Sourceval to_yojson : 'a t -> 'a -> Yojson.Safe.json
Sourceval 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.

Sourceval 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.

Sourceval exn : exn t

How to represent exceptions.

Sourceexception UnserializedException of string

Raised by exn.of_json

Sourceval unit : unit t

How to represent unit.

Sourceval string : string t

How to represent string.

Sourceval int : int t

How to represent int.

Sourceval int32 : int32 t

How to represent int32.

Sourceval int64 : int64 t

How to represent int64.

Sourceval list : 'a t -> 'a list t

Build a representation of a list.

  • deprecated Please use ppx_deriving_yojson instead
Sourceval 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.

  • deprecated Please use ppx_deriving_yojson instead
Sourceval result : 'a t -> 'b t -> ('a, 'b) Result.result t

Build a representation of a result.

Sourceval 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.