From 8da92a7541c2039ad4d9e8be49eee1b2f6c8bf4c Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 8 Jul 2014 00:12:08 +0200 Subject: [PATCH] doc --- core/CCPrint.mli | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/CCPrint.mli b/core/CCPrint.mli index 47adea83..a5d71f9f 100644 --- a/core/CCPrint.mli +++ b/core/CCPrint.mli @@ -29,6 +29,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This module provides combinators to build printers for user-defined types. It doesn't try to do {b pretty}-printing (see for instance Pprint for this), but a simple way to print complicated values without writing a lot of code. + +Those combinators work with "%a". For instance to print a +[(int * bool) list list] and a [float array], one can write: +{[ + CCPrint.(printf "int: %d list: %a, array: %a\n" + 42 + (list (list (pair int bool))) [[1, true; 2, false]; [4, true]] + (array float) [| 1. ; 2. ; 3e18 |] ;; +]} + +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) *) type 'a sequence = ('a -> unit) -> unit