mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add more generic printers for CCError and CCResult (close #73)
This commit is contained in:
parent
103dfb8c73
commit
c573f447bc
4 changed files with 33 additions and 0 deletions
|
|
@ -260,6 +260,14 @@ let pp pp_x buf e = match e with
|
||||||
| `Ok x -> Printf.bprintf buf "ok(%a)" pp_x x
|
| `Ok x -> Printf.bprintf buf "ok(%a)" pp_x x
|
||||||
| `Error s -> Printf.bprintf buf "error(%s)" s
|
| `Error s -> Printf.bprintf buf "error(%s)" s
|
||||||
|
|
||||||
|
let pp' pp_x pp_e buf e = match e with
|
||||||
|
| `Ok x -> Printf.bprintf buf "ok(%a)" pp_x x
|
||||||
|
| `Error s -> Printf.bprintf buf "error(%a)" pp_e s
|
||||||
|
|
||||||
let print pp_x fmt e = match e with
|
let print pp_x fmt e = match e with
|
||||||
| `Ok x -> Format.fprintf fmt "@[ok(@,%a)@]" pp_x x
|
| `Ok x -> Format.fprintf fmt "@[ok(@,%a)@]" pp_x x
|
||||||
| `Error s -> Format.fprintf fmt "@[error(@,%s)@]" s
|
| `Error s -> Format.fprintf fmt "@[error(@,%s)@]" s
|
||||||
|
|
||||||
|
let print' pp_x pp_e fmt e = match e with
|
||||||
|
| `Ok x -> Format.fprintf fmt "@[ok(@,%a)@]" pp_x x
|
||||||
|
| `Error s -> Format.fprintf fmt "@[error(@,%a)@]" pp_e s
|
||||||
|
|
|
||||||
|
|
@ -190,8 +190,16 @@ val to_seq : ('a, _) t -> 'a sequence
|
||||||
|
|
||||||
val pp : 'a printer -> ('a, string) t printer
|
val pp : 'a printer -> ('a, string) t printer
|
||||||
|
|
||||||
|
val pp': 'a printer -> 'e printer -> ('a, 'e) t printer
|
||||||
|
(** Printer that is generic on the error type
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val print : 'a formatter -> ('a, string) t formatter
|
val print : 'a formatter -> ('a, string) t formatter
|
||||||
|
|
||||||
|
val print' : 'a formatter -> 'e formatter -> ('a, 'e) t formatter
|
||||||
|
(** Printer that is generic on the error type
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
(** {2 Global Exception Printers}
|
(** {2 Global Exception Printers}
|
||||||
|
|
||||||
One can register exception printers here, so they will be used by {!guard},
|
One can register exception printers here, so they will be used by {!guard},
|
||||||
|
|
|
||||||
|
|
@ -261,6 +261,14 @@ let pp pp_x buf e = match e with
|
||||||
| Ok x -> Printf.bprintf buf "ok(%a)" pp_x x
|
| Ok x -> Printf.bprintf buf "ok(%a)" pp_x x
|
||||||
| Error s -> Printf.bprintf buf "error(%s)" s
|
| Error s -> Printf.bprintf buf "error(%s)" s
|
||||||
|
|
||||||
|
let pp' pp_x pp_e buf e = match e with
|
||||||
|
| Ok x -> Printf.bprintf buf "ok(%a)" pp_x x
|
||||||
|
| Error s -> Printf.bprintf buf "error(%a)" pp_e s
|
||||||
|
|
||||||
let print pp_x fmt e = match e with
|
let print pp_x fmt e = match e with
|
||||||
| Ok x -> Format.fprintf fmt "@[ok(@,%a)@]" pp_x x
|
| Ok x -> Format.fprintf fmt "@[ok(@,%a)@]" pp_x x
|
||||||
| Error s -> Format.fprintf fmt "@[error(@,%s)@]" s
|
| Error s -> Format.fprintf fmt "@[error(@,%s)@]" s
|
||||||
|
|
||||||
|
let print' pp_x pp_e fmt e = match e with
|
||||||
|
| Ok x -> Format.fprintf fmt "@[ok(@,%a)@]" pp_x x
|
||||||
|
| Error s -> Format.fprintf fmt "@[error(@,%a)@]" pp_e s
|
||||||
|
|
|
||||||
|
|
@ -193,4 +193,13 @@ val to_err : ('a, 'b) t -> ('a, 'b) error
|
||||||
|
|
||||||
val pp : 'a printer -> ('a, string) t printer
|
val pp : 'a printer -> ('a, string) t printer
|
||||||
|
|
||||||
|
val pp': 'a printer -> 'e printer -> ('a, 'e) t printer
|
||||||
|
(** Printer that is generic on the error type
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val print : 'a formatter -> ('a, string) t formatter
|
val print : 'a formatter -> ('a, string) t formatter
|
||||||
|
|
||||||
|
val print' : 'a formatter -> 'e formatter -> ('a, 'e) t formatter
|
||||||
|
(** Printer that is generic on the error type
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue