Module Kappa_data_structures.Result_util

type status = [
  1. | `OK
  2. | `Accepted
  3. | `Created
  4. | `Bad_request
  5. | `Conflict
  6. | `Not_found
  7. | `Request_timeout
]

The subset of Cohttp.Code.status we need

type message = {
  1. severity : Logs.level;
  2. text : string;
  3. range : Loc.t option;
}
type ('a, 'b) t = {
  1. value : ('a, 'b) Result.result;
  2. status : status;
}
val write_message : Stdlib.Buffer.t -> message -> unit
val read_message : Yojson.Safe.lexer_state -> Stdlib.Lexing.lexbuf -> message
val print_message : Stdlib.Format.formatter -> message -> unit
val write_t : (Stdlib.Buffer.t -> 'ok -> unit) -> (Stdlib.Buffer.t -> 'error -> unit) -> Stdlib.Buffer.t -> ('ok, 'error) t -> unit

Output a JSON value of type t.

val string_of_t : (Stdlib.Buffer.t -> 'ok -> unit) -> (Stdlib.Buffer.t -> 'error -> unit) -> ?len:int -> ('ok, 'error) t -> string

Serialize a value of type t into a JSON string.

  • parameter len

    specifies the initial length of the buffer used internally. Default: 1024.

val read_t : (Yojson.Safe.lexer_state -> Stdlib.Lexing.lexbuf -> 'ok) -> (Yojson.Safe.lexer_state -> Stdlib.Lexing.lexbuf -> 'error) -> Yojson.Safe.lexer_state -> Stdlib.Lexing.lexbuf -> ('ok, 'error) t

Input JSON data of type t.

val t_of_string : (Yojson.Safe.lexer_state -> Stdlib.Lexing.lexbuf -> 'ok) -> (Yojson.Safe.lexer_state -> Stdlib.Lexing.lexbuf -> 'error) -> string -> ('ok, 'error) t

Deserialize JSON data of type t.

val lift : ?ok_status:status -> ?error_status:status -> ('a, 'b) Result.result -> ('a, 'b) t
val fold : ok:('ok -> 'a) -> error:('error -> 'a) -> ('ok, 'error) t -> 'a
val bind : ?overwrite_status:status -> ?error_status:status -> ('ok -> ('a, 'error) Result.result) -> ('ok, 'error) t -> ('a, 'error) t
val map : ('ok -> 'a) -> ('ok, 'error) t -> ('a, 'error) t
val map2 : ('a -> 'b -> 'ok) -> ('a, 'error) t -> ('b, 'error) t -> ('ok, 'error) t
val error : ?status:status -> 'error -> ('ok, 'error) t
val ok : ?status:status -> 'ok -> ('ok, 'error) t