diff --git a/src/core/CCFormat.ml b/src/core/CCFormat.ml index ef1c9ca1..9dd8037c 100644 --- a/src/core/CCFormat.ml +++ b/src/core/CCFormat.ml @@ -31,6 +31,9 @@ let break fmt (m, n) = Format.pp_print_break fmt m n let newline = Format.pp_force_newline let substring out (s, i, len) : unit = string out (String.sub s i len) let text = Format.pp_print_text +let option = Format.pp_print_option +let opt = option +let result = Format.pp_print_result let string_lines out (s : string) : unit = fprintf out "@["; @@ -88,11 +91,6 @@ let iter ?(sep = return ",@ ") pp fmt seq = sep fmt (); pp fmt x) -let opt pp fmt x = - match x with - | None -> Format.pp_print_string fmt "none" - | Some x -> Format.fprintf fmt "some %a" pp x - let pair ?(sep = return ",@ ") ppa ppb fmt (a, b) = Format.fprintf fmt "%a%a%a" ppa a sep () ppb b diff --git a/src/core/CCFormat.mli b/src/core/CCFormat.mli index 4426f662..12b1ca81 100644 --- a/src/core/CCFormat.mli +++ b/src/core/CCFormat.mli @@ -99,10 +99,16 @@ val arrayi : ?sep:unit printer -> (int * 'a) printer -> 'a array printer val seq : ?sep:unit printer -> 'a printer -> 'a Seq.t printer val iter : ?sep:unit printer -> 'a printer -> 'a iter printer -val opt : 'a printer -> 'a option printer -(** [opt pp] prints options as follows: - - [Some x] will become "some foo" if [pp x ---> "foo"]. - - [None] will become "none". *) +val option : ?none:unit printer -> 'a printer -> 'a option printer +(** [opt ?none pp] prints options as follows: + - [Some x] will become [pp x] + - [None] will become [none ()] + @since NEXT_RELEASE *) + +val opt : ?none:unit printer -> 'a printer -> 'a option printer +(** Alias of {!option} *) + +val result : ok:'a printer -> error:'e printer -> ('a, 'e) result printer (** In the tuple printers, the [sep] argument is only available. @since 0.17 *)