add CCFormat.{const_string,opaque}

This commit is contained in:
Simon Cruanes 2021-06-11 12:39:02 -04:00
parent 25660ee2c1
commit 92aad159c8
2 changed files with 15 additions and 2 deletions

View file

@ -8,7 +8,7 @@ type 'a iter = ('a -> unit) -> unit
include Format include Format
type t = Format.formatter type t = Format.formatter
type 'a printer = t -> 'a -> unit type -'a printer = t -> 'a -> unit
(** {2 Combinators} *) (** {2 Combinators} *)
@ -182,6 +182,9 @@ let some pp out = function
| None -> () | None -> ()
| Some x -> pp out x | Some x -> pp out x
let const_string s out _ = string out s
let opaque out _ = string out "opaque"
let lazy_force pp out (lazy x) = pp out x let lazy_force pp out (lazy x) = pp out x
let lazy_or ?(default=return "<lazy>") pp out x = let lazy_or ?(default=return "<lazy>") pp out x =

View file

@ -14,7 +14,7 @@ include module type of struct include Format end
(** {{: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Format.html} Documentation for the standard Format module}*) (** {{: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Format.html} Documentation for the standard Format module}*)
type t = Format.formatter type t = Format.formatter
type 'a printer = t -> 'a -> unit type -'a printer = t -> 'a -> unit
(** {2 Combinators} *) (** {2 Combinators} *)
@ -167,6 +167,16 @@ val some : 'a printer -> 'a option printer
@since 1.0 @since 1.0
*) *)
val const_string : string -> 'a printer
(** [const_string s] is a printer that ignores its input and
always prints [s].
@since NEXT_RELEASE *)
val opaque : 'a printer
(** [opaque] is [const_string "opaque"].
The exact string used is not stable.
@since NEXT_RELEASE *)
val lazy_force : 'a printer -> 'a lazy_t printer val lazy_force : 'a printer -> 'a lazy_t printer
(** [lazy_force pp out x] forces [x] and prints the result with [pp]. (** [lazy_force pp out x] forces [x] and prints the result with [pp].
@since 2.0 *) @since 2.0 *)