package kappa-library

  1. Overview
  2. Docs
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 : Buffer.t -> message -> unit
val print_message : Format.formatter -> message -> unit
val write_t : (Buffer.t -> 'ok -> unit) -> (Buffer.t -> 'error -> unit) -> Buffer.t -> ('ok, 'error) t -> unit

Output a JSON value of type t.

val string_of_t : (Buffer.t -> 'ok -> unit) -> (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.

Input JSON data of type t.

val t_of_string : (Yojson.Safe.lexer_state -> Lexing.lexbuf -> 'ok) -> (Yojson.Safe.lexer_state -> 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
OCaml

Innovation. Community. Security.