package topkg

  1. Overview
  2. Docs

Result value combinators.

Errors

val reword_error : ('b -> 'c) -> ('a, 'b) r -> ('a, 'c) r

reword_error reword r is:

  • r if r = Ok v
  • Error (reword e) if r = Error e

Error messages

type msg = [
  1. | `Msg of string
]

The type for (error) messages.

val error_msg : string -> ('b, [> msg ]) r

error_msg s is Error (`Msg s).

val error_msgf : ('a, Format.formatter, unit, ('b, [> msg ]) r) format4 -> 'a

error_msgf fmt ... is an error formatted according to fmt.

val reword_error_msg : ?replace:bool -> (string -> msg) -> ('a, msg) r -> ('a, [> msg ]) r

reword_error_msg ~replace reword r is like reword_error except if replace is false (default), the result of reword old_msg is concatened, on a new line to the old message.

OCaml

Innovation. Community. Security.