diff --git a/src/core/CCError.ml b/src/core/CCError.ml index ab9af226..3b6486c8 100644 --- a/src/core/CCError.ml +++ b/src/core/CCError.ml @@ -260,6 +260,14 @@ let pp pp_x buf e = match e with | `Ok x -> Printf.bprintf buf "ok(%a)" pp_x x | `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 | `Ok x -> Format.fprintf fmt "@[ok(@,%a)@]" pp_x x | `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 diff --git a/src/core/CCError.mli b/src/core/CCError.mli index 64bbf525..c0cbef2e 100644 --- a/src/core/CCError.mli +++ b/src/core/CCError.mli @@ -190,8 +190,16 @@ val to_seq : ('a, _) t -> 'a sequence 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 -> 'e formatter -> ('a, 'e) t formatter +(** Printer that is generic on the error type + @since NEXT_RELEASE *) + (** {2 Global Exception Printers} One can register exception printers here, so they will be used by {!guard}, diff --git a/src/core/CCResult.ml b/src/core/CCResult.ml index da374da6..0da2eb95 100644 --- a/src/core/CCResult.ml +++ b/src/core/CCResult.ml @@ -261,6 +261,14 @@ let pp pp_x buf e = match e with | Ok x -> Printf.bprintf buf "ok(%a)" pp_x x | 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 | Ok x -> Format.fprintf fmt "@[ok(@,%a)@]" pp_x x | 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 diff --git a/src/core/CCResult.mli b/src/core/CCResult.mli index 78f15010..20a21fb8 100644 --- a/src/core/CCResult.mli +++ b/src/core/CCResult.mli @@ -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 -> '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 -> 'e formatter -> ('a, 'e) t formatter +(** Printer that is generic on the error type + @since NEXT_RELEASE *) +