From 3acffa86592672cd7cb0b8fedbd8b77f55ee2681 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 8 Jul 2014 00:19:16 +0200 Subject: [PATCH] doc --- core/CCPrint.mli | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/CCPrint.mli b/core/CCPrint.mli index a5d71f9f..31c8de6e 100644 --- a/core/CCPrint.mli +++ b/core/CCPrint.mli @@ -42,6 +42,16 @@ Those combinators work with "%a". For instance to print a Remember that "%a" in this context requires two arguments: - a value of type ['a t] (buffer printer) - a value of type ['a] (value to print) + +To define new printers, one can either use existing ones (e.g. [list int]), +or use {!Printf.bprintf}. For instance a printer for colored points in 2D: + +{[ type point = {x:int; y:int; colors: string list};; + +let pp_point buf p = + Printf.bprintf buf "{x=%d, y=%d, colors=%a}" + p.x p.y CCPrint.(list string) p.colors;; +]} *) type 'a sequence = ('a -> unit) -> unit