mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-10 21:23:57 -05:00
change boxing in CCFormat.Dump; add example/doc
This commit is contained in:
parent
9045fcca0b
commit
af4c3fc195
2 changed files with 15 additions and 8 deletions
|
|
@ -334,8 +334,8 @@ module Dump = struct
|
||||||
let int32 = int32
|
let int32 = int32
|
||||||
let int64 = int64
|
let int64 = int64
|
||||||
let nativeint = nativeint
|
let nativeint = nativeint
|
||||||
let list pp = hovbox (list ~start:"[" ~stop:"]" ~sep:";" pp)
|
let list pp = within "[" "]" (hovbox (list ~sep:";" pp))
|
||||||
let array pp = hovbox (array ~start:"[|" ~stop:"|]" ~sep:";" pp)
|
let array pp = within "[|" "|]" (hovbox (array ~sep:";" pp))
|
||||||
let option pp out x = match x with
|
let option pp out x = match x with
|
||||||
| None -> Format.pp_print_string out "None"
|
| None -> Format.pp_print_string out "None"
|
||||||
| Some x -> Format.fprintf out "Some %a" pp x
|
| Some x -> Format.fprintf out "Some %a" pp x
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,15 @@ val to_file : string -> ('a, t, unit, unit) format4 -> 'a
|
||||||
(** {2 Dump}
|
(** {2 Dump}
|
||||||
|
|
||||||
Print structures as OCaml values, so that they can be parsed back
|
Print structures as OCaml values, so that they can be parsed back
|
||||||
by OCaml (typically, in the toplevel, for debugging)
|
by OCaml (typically, in the toplevel, for debugging).
|
||||||
|
|
||||||
|
Example:
|
||||||
|
{[
|
||||||
|
Format.printf "%a@." CCFormat.Dump.(list int) CCList.(1 -- 200);;
|
||||||
|
|
||||||
|
Format.printf "%a@." CCFormat.Dump.(array (list (pair int bool)))
|
||||||
|
[| [1, true; 2, false]; []; [42, false] |];;
|
||||||
|
]}
|
||||||
|
|
||||||
@since NEXT_RELEASE *)
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
|
|
@ -215,11 +223,10 @@ module Dump : sig
|
||||||
val string : string t
|
val string : string t
|
||||||
val bool : bool t
|
val bool : bool t
|
||||||
val float : float t
|
val float : float t
|
||||||
val char : char t (** @since 0.14 *)
|
val char : char t
|
||||||
val int32 : int32 t (** @since 0.14 *)
|
val int32 : int32 t
|
||||||
val int64 : int64 t (** @since 0.14 *)
|
val int64 : int64 t
|
||||||
val nativeint : nativeint t (** @since 0.14 *)
|
val nativeint : nativeint t
|
||||||
|
|
||||||
val list : 'a t -> 'a list t
|
val list : 'a t -> 'a list t
|
||||||
val array : 'a t -> 'a array t
|
val array : 'a t -> 'a array t
|
||||||
val option : 'a t -> 'a option t
|
val option : 'a t -> 'a option t
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue