1Stdlib.Format(3)                 OCaml library                Stdlib.Format(3)
2
3
4

NAME

6       Stdlib.Format - no description
7

Module

9       Module   Stdlib.Format
10

Documentation

12       Module Format
13        : (module Stdlib__format)
14
15
16
17
18
19
20
21
22
23   Introduction
24       For a gentle introduction to the basics of pretty-printing using Format
25       , read http://caml.inria.fr/resources/doc/guides/format.en.html.
26
27       You may consider this module as providing an extension  to  the  printf
28       facility   to   provide  automatic  line  splitting.  The  addition  of
29       pretty-printing annotations to your regular printf format strings gives
30       you fancy indentation and line breaks.  Pretty-printing annotations are
31       described below in the documentation of the function Format.fprintf .
32
33       You may also use the explicit pretty-printing box management and print‐
34       ing  functions  provided  by  this module. This style is more basic but
35       more verbose than the concise fprintf format strings.
36
37       For instance, the sequence open_box 0; print_string x =  ;  print_space
38       ();  print_int  1;  close_box  ();  print_newline  () that prints x = 1
39       within a pretty-printing box, can be abbreviated as printf @[%s@ %i@]@.
40       x = 1 , or even shorter printf @[x =@ %i@]@. 1 .
41
42       Rule of thumb for casual users of this library:
43
44       -use simple pretty-printing boxes (as obtained by open_box 0 );
45
46       -use simple break hints as obtained by print_cut () that outputs a sim‐
47       ple break hint, or by print_space () that outputs a space indicating  a
48       break hint;
49
50       -once  a  pretty-printing  box is open, display its material with basic
51       printing functions (e. g.  print_int and print_string );
52
53       -when the material for a pretty-printing box  has  been  printed,  call
54       close_box () to close the box;
55
56       -at the end of pretty-printing, flush the pretty-printer to display all
57       the remaining material, e.g. evaluate print_newline () .
58
59       The behavior of pretty-printing commands is unspecified if there is  no
60       open pretty-printing box. Each box opened by one of the open_ functions
61       below must be closed using close_box for proper formatting.  Otherwise,
62       some  of the material printed in the boxes may not be output, or may be
63       formatted incorrectly.
64
65       In case of interactive use, each phrase  is  executed  in  the  initial
66       state  of the standard pretty-printer: after each phrase execution, the
67       interactive system closes all open pretty-printing boxes,  flushes  all
68       pending text, and resets the standard pretty-printer.
69
70       Warning:  mixing calls to pretty-printing functions of this module with
71       calls to Stdlib low level output functions is error prone.
72
73       The pretty-printing functions output material that is  delayed  in  the
74       pretty-printer  queue and stacks in order to compute proper line split‐
75       ting. In contrast, basic I/O output functions write directly  in  their
76       output device. As a consequence, the output of a basic I/O function may
77       appear before the output of a pretty-printing function  that  has  been
78       called   before.   For   instance,   Stdlib.print_string   <   ;   For‐
79       mat.print_string PRETTY ; Stdlib.print_string >  ;  Format.print_string
80       TEXT ; leads to output <>PRETTYTEXT .
81
82       type formatter
83
84
85       Abstract  data corresponding to a pretty-printer (also called a format‐
86       ter) and all its machinery. See also Format.formatter .
87
88
89
90
91   Pretty-printing boxes
92       The pretty-printing engine uses the concepts of pretty-printing box and
93       break  hint  to  drive  indentation  and line splitting behavior of the
94       pretty-printer.
95
96       Each different pretty-printing box  kind  introduces  a  specific  line
97       splitting policy:
98
99
100       -within  an  horizontal  box, break hints never split the line (but the
101       line may be split in a box nested deeper),
102
103       -within a vertical box, break hints always split the line,
104
105       -within an horizontal/vertical box, if the box fits on the current line
106       then  break  hints  never  split  the line, otherwise break hint always
107       split the line,
108
109       -within a compacting box, a break hint never splits  the  line,  unless
110       there is no more room on the current line.
111
112       Note  that  line  splitting policy is box specific: the policy of a box
113       does not rule the policy of inner boxes. For instance,  if  a  vertical
114       box is nested in an horizontal box, all break hints within the vertical
115       box will split the line.
116
117       val pp_open_box : formatter -> int -> unit
118
119
120
121
122       val open_box : int -> unit
123
124
125       pp_open_box ppf d opens a new compacting pretty-printing box with  off‐
126       set d in the formatter ppf .
127
128       Within this box, the pretty-printer prints as much as possible material
129       on every line.
130
131       A break hint splits the line if there is no more room on  the  line  to
132       print the remainder of the box.
133
134       Within  this  box,  the  pretty-printer emphasizes the box structure: a
135       break hint also splits the line if the splitting ``moves to the  left''
136       (i.e. the new line gets an indentation smaller than the one of the cur‐
137       rent line).
138
139       This box is the general purpose pretty-printing box.
140
141       If the pretty-printer splits the line in the box, offset d is added  to
142       the current indentation.
143
144
145
146       val pp_close_box : formatter -> unit -> unit
147
148
149
150
151       val close_box : unit -> unit
152
153       Closes the most recently open pretty-printing box.
154
155
156
157       val pp_open_hbox : formatter -> unit -> unit
158
159
160
161
162       val open_hbox : unit -> unit
163
164
165       pp_open_hbox ppf () opens a new 'horizontal' pretty-printing box.
166
167       This box prints material on a single line.
168
169       Break  hints in a horizontal box never split the line.  (Line splitting
170       may still occur inside boxes nested deeper).
171
172
173
174       val pp_open_vbox : formatter -> int -> unit
175
176
177
178
179       val open_vbox : int -> unit
180
181
182       pp_open_vbox ppf d opens a new 'vertical' pretty-printing box with off‐
183       set d .
184
185       This box prints material on as many lines as break hints in the box.
186
187       Every break hint in a vertical box splits the line.
188
189       If  the  pretty-printer  splits  the line in the box, d is added to the
190       current indentation.
191
192
193
194       val pp_open_hvbox : formatter -> int -> unit
195
196
197
198
199       val open_hvbox : int -> unit
200
201
202       pp_open_hvbox ppf d opens a new  'horizontal/vertical'  pretty-printing
203       box with offset d .
204
205       This box behaves as an horizontal box if it fits on a single line, oth‐
206       erwise it behaves as a vertical box.
207
208       If the pretty-printer splits the line in the box, d  is  added  to  the
209       current indentation.
210
211
212
213       val pp_open_hovbox : formatter -> int -> unit
214
215
216
217
218       val open_hovbox : int -> unit
219
220
221       pp_open_hovbox ppf d opens a new 'horizontal-or-vertical' pretty-print‐
222       ing box with offset d .
223
224       This box prints material as much as possible on every line.
225
226       A break hint splits the line if there is no more room on  the  line  to
227       print the remainder of the box.
228
229       If  the  pretty-printer  splits  the line in the box, d is added to the
230       current indentation.
231
232
233
234
235   Formatting functions
236       val pp_print_string : formatter -> string -> unit
237
238
239
240
241       val print_string : string -> unit
242
243
244       pp_print_string ppf s prints s in the current pretty-printing box.
245
246
247
248       val pp_print_as : formatter -> int -> string -> unit
249
250
251
252
253       val print_as : int -> string -> unit
254
255
256       pp_print_as ppf len s prints s in the current pretty-printing box.  The
257       pretty-printer formats s as if it were of length len .
258
259
260
261       val pp_print_int : formatter -> int -> unit
262
263
264
265
266       val print_int : int -> unit
267
268       Print an integer in the current pretty-printing box.
269
270
271
272       val pp_print_float : formatter -> float -> unit
273
274
275
276
277       val print_float : float -> unit
278
279       Print a floating point number in the current pretty-printing box.
280
281
282
283       val pp_print_char : formatter -> char -> unit
284
285
286
287
288       val print_char : char -> unit
289
290       Print a character in the current pretty-printing box.
291
292
293
294       val pp_print_bool : formatter -> bool -> unit
295
296
297
298
299       val print_bool : bool -> unit
300
301       Print a boolean in the current pretty-printing box.
302
303
304
305
306   Break hints
307       A  'break  hint' tells the pretty-printer to output some space or split
308       the line whichever way is more appropriate to the current pretty-print‐
309       ing box splitting rules.
310
311       Break  hints  are  used to separate printing items and are mandatory to
312       let the pretty-printer correctly split lines and indent items.
313
314       Simple break hints are:
315
316       -the 'space': output a space or split the line if appropriate,
317
318       -the 'cut': split the line if appropriate.
319
320       Note: the notions of space and line  splitting  are  abstract  for  the
321       pretty-printing engine, since those notions can be completely redefined
322       by the programmer.  However, in  the  pretty-printer  default  setting,
323       ``output  a space'' simply means printing a space character (ASCII code
324       32) and ``split the line'' means printing a  newline  character  (ASCII
325       code 10).
326
327       val pp_print_space : formatter -> unit -> unit
328
329
330
331
332       val print_space : unit -> unit
333
334
335       pp_print_space  ppf  ()  emits a 'space' break hint: the pretty-printer
336       may split the line at this point, otherwise it prints one space.
337
338
339       pp_print_space ppf () is equivalent to pp_print_break ppf 1 0 .
340
341
342
343       val pp_print_cut : formatter -> unit -> unit
344
345
346
347
348       val print_cut : unit -> unit
349
350
351       pp_print_cut ppf () emits a 'cut' break hint:  the  pretty-printer  may
352       split the line at this point, otherwise it prints nothing.
353
354
355       pp_print_cut ppf () is equivalent to pp_print_break ppf 0 0 .
356
357
358
359       val pp_print_break : formatter -> int -> int -> unit
360
361
362
363
364       val print_break : int -> int -> unit
365
366
367       pp_print_break  ppf  nspaces  offset  emits  a  'full'  break hint: the
368       pretty-printer may split the line at this point,  otherwise  it  prints
369       nspaces spaces.
370
371       If  the  pretty-printer splits the line, offset is added to the current
372       indentation.
373
374
375
376       val pp_print_custom_break : formatter -> fits:string * int * string  ->
377       breaks:string * int * string -> unit
378
379
380       pp_print_custom_break ppf ~fits:(s1, n, s2) ~breaks:(s3, m, s4) emits a
381       custom break hint: the pretty-printer may split the line at this point.
382
383       If it does not split the line, then the s1 is emitted, then  n  spaces,
384       then s2 .
385
386       If  it  splits  the  line,  then it emits the s3 string, then an indent
387       (according to the box rules), then an offset of m spaces, then  the  s4
388       string.
389
390       While  n  and m are handled by formatter_out_functions.out_indent , the
391       strings will be handled by  formatter_out_functions.out_string  .  This
392       allows  for a custom formatter that handles indentation distinctly, for
393       example, outputs <br/> tags or &nbsp; entities.
394
395       The custom break  is  useful  if  you  want  to  change  which  visible
396       (non-whitespace)  characters  are printed in case of break or no break.
397       For example, when printing a list [a; b; c] , you might want to  add  a
398       trailing semicolon when it is printed vertically:
399
400
401       [ a; b; c; ]
402
403       You   can   do   this   as   follows:   printf   @[<v   0>[@;<0  2>@[<v
404       0>a;@,b;@,c@]%t]@]@\n   (pp_print_custom_break   ~fits:("",    0,     )
405       ~breaks:(";", 0,  ))
406
407
408
409       Since 4.08.0
410
411
412
413       val pp_force_newline : formatter -> unit -> unit
414
415
416
417
418       val force_newline : unit -> unit
419
420       Force a new line in the current pretty-printing box.
421
422       The pretty-printer must split the line at this point,
423
424       Not  the normal way of pretty-printing, since imperative line splitting
425       may interfere with current line  counters  and  box  size  calculation.
426       Using break hints within an enclosing vertical box is a better alterna‐
427       tive.
428
429
430
431       val pp_print_if_newline : formatter -> unit -> unit
432
433
434
435
436       val print_if_newline : unit -> unit
437
438       Execute the next formatting command if the preceding line has just been
439       split. Otherwise, ignore the next formatting command.
440
441
442
443
444   Pretty-printing termination
445       val pp_print_flush : formatter -> unit -> unit
446
447
448
449
450       val print_flush : unit -> unit
451
452       End of pretty-printing: resets the pretty-printer to initial state.
453
454       All open pretty-printing boxes are closed, all pending text is printed.
455       In addition, the pretty-printer low level output device is  flushed  to
456       ensure that all pending text is really displayed.
457
458       Note:  never  use print_flush in the normal course of a pretty-printing
459       routine, since the pretty-printer uses a complex buffering machinery to
460       properly  indent  the output; manually flushing those buffers at random
461       would conflict with the pretty-printer strategy and result to poor ren‐
462       dering.
463
464       Only consider using print_flush when displaying all pending material is
465       mandatory (for instance in case of interactive use when  you  want  the
466       user  to  read  some  text) and when resetting the pretty-printer state
467       will not disturb further pretty-printing.
468
469       Warning: If the output device of the pretty-printer is an output  chan‐
470       nel,  repeated  calls  to  print_flush means repeated calls to flush to
471       flush the out channel;  these  explicit  flush  calls  could  foil  the
472       buffering  strategy  of  output  channels and could dramatically impact
473       efficiency.
474
475
476
477       val pp_print_newline : formatter -> unit -> unit
478
479
480
481
482       val print_newline : unit -> unit
483
484       End of pretty-printing: resets the pretty-printer to initial state.
485
486       All open pretty-printing boxes are closed, all pending text is printed.
487
488       Equivalent to Format.print_flush followed by a new  line.   See  corre‐
489       sponding words of caution for Format.print_flush .
490
491       Note:  this  is  not the normal way to output a new line; the preferred
492       method is using break hints within a vertical pretty-printing box.
493
494
495
496
497   Margin
498       val pp_set_margin : formatter -> int -> unit
499
500
501
502
503       val set_margin : int -> unit
504
505
506       pp_set_margin ppf d sets the right margin to  d  (in  characters):  the
507       pretty-printer splits lines that overflow the right margin according to
508       the break hints given.  Nothing happens if d is smaller than 2.   If  d
509       is  too  large, the right margin is set to the maximum admissible value
510       (which is greater than 10 ^ 9 ).  If d is less than the current maximum
511       indentation  limit,  the  maximum  indentation limit is decreased while
512       trying to preserve a minimal ratio max_indent/margin>=50% and if possi‐
513       ble the current difference margin - max_indent .
514
515       See also Format.pp_set_geometry .
516
517
518
519       val pp_get_margin : formatter -> unit -> int
520
521
522
523
524       val get_margin : unit -> int
525
526       Returns the position of the right margin.
527
528
529
530
531   Maximum indentation limit
532       val pp_set_max_indent : formatter -> int -> unit
533
534
535
536
537       val set_max_indent : int -> unit
538
539
540       pp_set_max_indent  ppf d sets the maximum indentation limit of lines to
541       d (in characters): once this  limit  is  reached,  new  pretty-printing
542       boxes  are rejected to the left, unless the enclosing box fully fits on
543       the current line.  As an illustration, set_margin 10; set_max_indent 5;
544       printf  @[123456@[7@]89A@]@.  yields 123456 789A because the nested box
545       @[7@] is opened after the maximum indentation limit (  7>5  )  and  its
546       parent  box  does  not  fit on the current line.  Either decreasing the
547       length  of  the  parent  box  to  make  it  fit  on  a   line:   printf
548       @[123456@[7@]89@]@.   or opening an intermediary box before the maximum
549       indentation   limit   which   fits   on   the   current   line   printf
550       @[123@[456@[7@]89@]A@]@.  avoids the rejection to the left of the inner
551       boxes and print respectively 123456789 and 123456789A .  Note also that
552       vertical  boxes  never  fit  on  a line whereas horizontal boxes always
553       fully fit on the current line.
554
555       Nothing happens if d is smaller than 2.
556
557       If d is too large, the limit is set to  the  maximum  admissible  value
558       (which is greater than 10 ^ 9 ).
559
560       If  d  is  greater or equal than the current margin, it is ignored, and
561       the current maximum indentation limit is kept.
562
563       See also Format.pp_set_geometry .
564
565
566
567       val pp_get_max_indent : formatter -> unit -> int
568
569
570
571
572       val get_max_indent : unit -> int
573
574       Return the maximum indentation limit (in characters).
575
576
577
578
579   Geometry
580       Geometric functions can be used to manipulate simultaneously  the  cou‐
581       pled variables, margin and maxixum indentation limit.
582
583       type geometry = {
584        max_indent : int ;
585        margin : int ;
586        }
587
588
589
590
591
592       val check_geometry : geometry -> bool
593
594       Check if the formatter geometry is valid: 1 < max_indent < margin
595
596
597
598
599       val pp_set_geometry : formatter -> max_indent:int -> margin:int -> unit
600
601
602
603
604       val set_geometry : max_indent:int -> margin:int -> unit
605
606
607
608
609       val pp_safe_set_geometry : formatter -> max_indent:int -> margin:int ->
610       unit
611
612
613
614
615       val safe_set_geometry : max_indent:int -> margin:int -> unit
616
617
618       pp_set_geometry ppf ~max_indent ~margin sets both the margin and  maxi‐
619       mum indentation limit for ppf .
620
621       When  1 < max_indent < margin , pp_set_geometry ppf ~max_indent ~margin
622       is  equivalent  to  pp_set_margin  ppf  margin;  pp_set_max_indent  ppf
623       max_indent  ;  and  avoids  the  subtly incorrect pp_set_max_indent ppf
624       max_indent; pp_set_margin ppf margin ;
625
626       Outside of this domain,  pp_set_geometry  raises  an  invalid  argument
627       exception whereas pp_safe_set_geometry does nothing.
628
629
630       Since 4.08.0
631
632
633
634       val pp_get_geometry : formatter -> unit -> geometry
635
636
637
638
639       val get_geometry : unit -> geometry
640
641       Return the current geometry of the formatter
642
643
644       Since 4.08.0
645
646
647
648
649   Maximum formatting depth
650       The  maximum  formatting depth is the maximum number of pretty-printing
651       boxes simultaneously open.
652
653       Material inside boxes nested deeper is printed  as  an  ellipsis  (more
654       precisely as the text returned by Format.get_ellipsis_text () ).
655
656       val pp_set_max_boxes : formatter -> int -> unit
657
658
659
660
661       val set_max_boxes : int -> unit
662
663
664       pp_set_max_boxes  ppf  max  sets  the maximum number of pretty-printing
665       boxes simultaneously open.
666
667       Material inside boxes nested deeper is printed  as  an  ellipsis  (more
668       precisely as the text returned by Format.get_ellipsis_text () ).
669
670       Nothing happens if max is smaller than 2.
671
672
673
674       val pp_get_max_boxes : formatter -> unit -> int
675
676
677
678
679       val get_max_boxes : unit -> int
680
681       Returns  the  maximum  number  of  pretty-printing boxes allowed before
682       ellipsis.
683
684
685
686       val pp_over_max_boxes : formatter -> unit -> bool
687
688
689
690
691       val over_max_boxes : unit -> bool
692
693       Tests if the maximum  number  of  pretty-printing  boxes  allowed  have
694       already been opened.
695
696
697
698
699   Tabulation boxes
700       A  tabulation  box prints material on lines divided into cells of fixed
701       length. A tabulation box provides a simple way to display vertical col‐
702       umns of left adjusted text.
703
704       This  box  features command set_tab to define cell boundaries, and com‐
705       mand print_tab to move from cell to cell and split the line when  there
706       is no more cells to print on the line.
707
708       Note:  printing  within  tabulation  box is line directed, so arbitrary
709       line splitting inside a tabulation box leads to  poor  rendering.  Yet,
710       controlled  use  of  tabulation boxes allows simple printing of columns
711       within module Format .
712
713       val pp_open_tbox : formatter -> unit -> unit
714
715
716
717
718       val open_tbox : unit -> unit
719
720
721       open_tbox () opens a new tabulation box.
722
723       This box prints lines separated into cells of fixed width.
724
725       Inside a tabulation box, special tabulation markers defines  points  of
726       interest  on the line (for instance to delimit cell boundaries).  Func‐
727       tion Format.set_tab sets a tabulation marker at insertion point.
728
729       A tabulation box features specific tabulation breaks to  move  to  next
730       tabulation  marker  or  split  the  line.  Function Format.print_tbreak
731       prints a tabulation break.
732
733
734
735       val pp_close_tbox : formatter -> unit -> unit
736
737
738
739
740       val close_tbox : unit -> unit
741
742       Closes the most recently opened tabulation box.
743
744
745
746       val pp_set_tab : formatter -> unit -> unit
747
748
749
750
751       val set_tab : unit -> unit
752
753       Sets a tabulation marker at current insertion point.
754
755
756
757       val pp_print_tab : formatter -> unit -> unit
758
759
760
761
762       val print_tab : unit -> unit
763
764
765       print_tab () emits a 'next' tabulation break hint: if not  already  set
766       on  a tabulation marker, the insertion point moves to the first tabula‐
767       tion marker on the right, or the pretty-printer  splits  the  line  and
768       insertion point moves to the leftmost tabulation marker.
769
770       It is equivalent to print_tbreak 0 0 .
771
772
773
774       val pp_print_tbreak : formatter -> int -> int -> unit
775
776
777
778
779       val print_tbreak : int -> int -> unit
780
781
782       print_tbreak nspaces offset emits a 'full' tabulation break hint.
783
784       If not already set on a tabulation marker, the insertion point moves to
785       the first tabulation marker on the right and the pretty-printer  prints
786       nspaces spaces.
787
788       If  there is no next tabulation marker on the right, the pretty-printer
789       splits the line at this point, then insertion point moves to the  left‐
790       most tabulation marker of the box.
791
792       If  the  pretty-printer splits the line, offset is added to the current
793       indentation.
794
795
796
797
798   Ellipsis
799       val pp_set_ellipsis_text : formatter -> string -> unit
800
801
802
803
804       val set_ellipsis_text : string -> unit
805
806       Set the text of the ellipsis  printed  when  too  many  pretty-printing
807       boxes are open (a single dot, .  , by default).
808
809
810
811       val pp_get_ellipsis_text : formatter -> unit -> string
812
813
814
815
816       val get_ellipsis_text : unit -> string
817
818       Return the text of the ellipsis.
819
820
821
822
823   Semantic tags
824       type stag = ..
825
826
827       Semantic  tags (or simply tags) are user's defined annotations to asso‐
828       ciate user's specific operations to printed entities.
829
830       Common usage of semantic tags is text decoration to get  specific  font
831       or text size rendering for a display device, or marking delimitation of
832       entities (e.g. HTML or TeX  elements  or  terminal  escape  sequences).
833       More  sophisticated usage of semantic tags could handle dynamic modifi‐
834       cation of the pretty-printer behavior to properly  print  the  material
835       within some specific tags.  For instance, we can define an RGB tag like
836       so: type stag += RGB of {r:int;g:int;b:int}
837
838       In order to properly delimit printed entities, a semantic tag  must  be
839       opened  before and closed after the entity. Semantic tags must be prop‐
840       erly  nested  like  parentheses  using  Format.pp_open_stag  and   For‐
841       mat.pp_close_stag .
842
843       Tag  specific  operations  occur any time a tag is opened or closed, At
844       each occurrence, two kinds of operations are performed tag-marking  and
845       tag-printing:
846
847       -The  tag-marking  operation  is the simpler tag specific operation: it
848       simply writes a tag specific string into the output device of the  for‐
849       matter. Tag-marking does not interfere with line-splitting computation.
850
851       -The  tag-printing  operation  is the more involved tag specific opera‐
852       tion: it can print arbitrary material to the formatter. Tag-printing is
853       tightly linked to the current pretty-printer operations.
854
855       Roughly  speaking, tag-marking is commonly used to get a better render‐
856       ing of texts in the rendering device, while  tag-printing  allows  fine
857       tuning  of  printing  routines  to  print  the  same entity differently
858       according to the semantic tags (i.e. print additional material or  even
859       omit parts of the output).
860
861       More  precisely:  when a semantic tag is opened or closed then both and
862       successive 'tag-printing' and 'tag-marking' operations occur:
863
864       -Tag-printing a semantic tag means calling the formatter specific func‐
865       tion  print_open_stag  (resp.   print_close_stag ) with the name of the
866       tag as argument: that tag-printing function can then print any  regular
867       material  to  the formatter (so that this material is enqueued as usual
868       in the formatter queue for further line splitting computation).
869
870       -Tag-marking a semantic tag means calling the formatter specific  func‐
871       tion  mark_open_stag (resp.  mark_close_stag ) with the name of the tag
872       as argument: that tag-marking function can then return the 'tag-opening
873       marker'  (resp. `tag-closing marker') for direct output into the output
874       device of the formatter.
875
876       Being written directly into the output device of the formatter,  seman‐
877       tic tag marker strings are not considered as part of the printing mate‐
878       rial that drives line splitting (in other  words,  the  length  of  the
879       strings  corresponding  to  tag  markers is considered as zero for line
880       splitting).
881
882       Thus,  semantic  tag  handling  is  in  some   sense   transparent   to
883       pretty-printing and does not interfere with usual indentation. Hence, a
884       single pretty-printing routine can output both simple 'verbatim'  mate‐
885       rial  or richer decorated output depending on the treatment of tags. By
886       default, tags are not active, hence the output is  not  decorated  with
887       tag  information.  Once  set_tags  is  set to true , the pretty-printer
888       engine honors tags and decorates the output accordingly.
889
890       Default tag-marking functions  behave  the  HTML  way:  Format.tag  are
891       enclosed  in  "<"  and ">" while other tags are ignored; hence, opening
892       marker for tag string t is <t> and closing marker is </t> .
893
894       Default tag-printing functions just do nothing.
895
896       Tag-marking and tag-printing functions are user definable  and  can  be
897       set by calling Format.set_formatter_stag_functions .
898
899       Semantic  tag  operations  may  be set on or off with Format.set_tags .
900       Tag-marking operations may be set on or off with Format.set_mark_tags .
901       Tag-printing operations may be set on or off with Format.set_print_tags
902       .
903
904
905       type tag = string
906
907
908
909
910       type Format.stag +=
911        | String_tag of tag  (* String_tag s is a string tag s .  String  tags
912       can  be  inserted either by explicitly using the constructor String_tag
913       or by using the dedicated format syntax @{<s> ... @} .
914        *)
915
916
917
918
919
920       val pp_open_stag : formatter -> stag -> unit
921
922
923
924
925       val open_stag : stag -> unit
926
927
928       pp_open_stag ppf t opens the semantic tag named t .
929
930       The print_open_stag tag-printing function of the  formatter  is  called
931       with  t  as  argument;  then the opening tag marker for t , as given by
932       mark_open_stag t , is written into the output device of the formatter.
933
934
935
936       val pp_close_stag : formatter -> unit -> unit
937
938
939
940
941       val close_stag : unit -> unit
942
943
944       pp_close_stag ppf () closes the most recently opened semantic tag t .
945
946       The closing tag marker, as given by mark_close_stag t , is written into
947       the   output   device  of  the  formatter;  then  the  print_close_stag
948       tag-printing function of the formatter is called with t as argument.
949
950
951
952       val pp_set_tags : formatter -> bool -> unit
953
954
955
956
957       val set_tags : bool -> unit
958
959
960       pp_set_tags ppf b turns on  or  off  the  treatment  of  semantic  tags
961       (default is off).
962
963
964
965       val pp_set_print_tags : formatter -> bool -> unit
966
967
968
969
970       val set_print_tags : bool -> unit
971
972
973       pp_set_print_tags ppf b turns on or off the tag-printing operations.
974
975
976
977       val pp_set_mark_tags : formatter -> bool -> unit
978
979
980
981
982       val set_mark_tags : bool -> unit
983
984
985       pp_set_mark_tags ppf b turns on or off the tag-marking operations.
986
987
988
989       val pp_get_print_tags : formatter -> unit -> bool
990
991
992
993
994       val get_print_tags : unit -> bool
995
996       Return the current status of tag-printing operations.
997
998
999
1000       val pp_get_mark_tags : formatter -> unit -> bool
1001
1002
1003
1004
1005       val get_mark_tags : unit -> bool
1006
1007       Return the current status of tag-marking operations.
1008
1009
1010
1011       val pp_set_formatter_out_channel : formatter -> out_channel -> unit
1012
1013
1014   Redirecting the standard formatter output
1015       val set_formatter_out_channel : out_channel -> unit
1016
1017       Redirect the standard pretty-printer output to the given channel.  (All
1018       the output functions of the standard formatter are set to  the  default
1019       output functions printing to the given channel.)
1020
1021
1022       set_formatter_out_channel   is   equivalent   to  Format.pp_set_format‐
1023       ter_out_channel std_formatter .
1024
1025
1026
1027       val pp_set_formatter_output_functions : formatter -> (string -> int  ->
1028       int -> unit) -> (unit -> unit) -> unit
1029
1030
1031
1032
1033       val  set_formatter_output_functions : (string -> int -> int -> unit) ->
1034       (unit -> unit) -> unit
1035
1036
1037       pp_set_formatter_output_functions ppf out flush redirects the  standard
1038       pretty-printer output functions to the functions out and flush .
1039
1040       The  out function performs all the pretty-printer string output.  It is
1041       called with a string s , a start position p , and a number  of  charac‐
1042       ters n ; it is supposed to output characters p to p + n - 1 of s .
1043
1044       The  flush  function  is  called whenever the pretty-printer is flushed
1045       (via conversion %!  , or pretty-printing indications @?  or  @.   ,  or
1046       using low level functions print_flush or print_newline ).
1047
1048
1049
1050       val pp_get_formatter_output_functions : formatter -> unit -> (string ->
1051       int -> int -> unit) * (unit -> unit)
1052
1053
1054
1055
1056       val get_formatter_output_functions : unit -> (string -> int ->  int  ->
1057       unit) * (unit -> unit)
1058
1059       Return the current output functions of the standard pretty-printer.
1060
1061
1062
1063
1064   Redefining formatter output
1065       The  Format  module  is versatile enough to let you completely redefine
1066       the meaning of pretty-printing output: you may provide your  own  func‐
1067       tions  to  define  how  to handle indentation, line splitting, and even
1068       printing of all the characters that have to be printed!
1069
1070   Redefining output functions
1071       type formatter_out_functions = {
1072        out_string : string -> int -> int -> unit ;
1073        out_flush : unit -> unit ;
1074        out_newline : unit -> unit ;
1075        out_spaces : int -> unit ;
1076        out_indent : int -> unit ;
1077        }
1078
1079
1080       The set of output functions specific to a formatter:
1081
1082       -the out_string function performs all the pretty-printer string output.
1083       It  is  called  with  a string s , a start position p , and a number of
1084       characters n ; it is supposed to output characters p to p + n - 1 of  s
1085       .
1086
1087       -the out_flush function flushes the pretty-printer output device.
1088
1089       -  out_newline  is  called  to  open a new line when the pretty-printer
1090       splits the line.
1091
1092       -the out_spaces function outputs spaces when a break hint leads to spa‐
1093       ces  instead of a line split. It is called with the number of spaces to
1094       output.
1095
1096       -the  out_indent  function  performs  new  line  indentation  when  the
1097       pretty-printer splits the line. It is called with the indentation value
1098       of the new line.
1099
1100       By default:
1101
1102       -fields out_string and out_flush  are  output  device  specific;  (e.g.
1103       output_string  and  flush  for a out_channel device, or Buffer.add_sub‐
1104       string and ignore for a Buffer.t output device),
1105
1106       -field out_newline is equivalent to out_string \n 0 1 ;
1107
1108       -fields  out_spaces  and  out_indent  are  equivalent   to   out_string
1109       (String.make n ' ') 0 n .
1110
1111
1112
1113       Since 4.01.0
1114
1115
1116
1117       val  pp_set_formatter_out_functions  : formatter -> formatter_out_func‐
1118       tions -> unit
1119
1120
1121
1122
1123       val set_formatter_out_functions : formatter_out_functions -> unit
1124
1125
1126       pp_set_formatter_out_functions ppf out_funs Set all the  pretty-printer
1127       output functions of ppf to those of argument out_funs ,
1128
1129       This way, you can change the meaning of indentation (which can be some‐
1130       thing else than just printing space characters) and the meaning of  new
1131       lines opening (which can be connected to any other action needed by the
1132       application at hand).
1133
1134       Reasonable  defaults  for  functions  out_spaces  and  out_newline  are
1135       respectively   out_funs.out_string   (String.make   n  '  ')  0  n  and
1136       out_funs.out_string \n 0 1 .
1137
1138
1139       Since 4.01.0
1140
1141
1142
1143       val pp_get_formatter_out_functions  :  formatter  ->  unit  ->  format‐
1144       ter_out_functions
1145
1146
1147
1148
1149       val get_formatter_out_functions : unit -> formatter_out_functions
1150
1151       Return  the  current  output functions of the pretty-printer, including
1152       line splitting and indentation functions. Useful to record the  current
1153       setting and restore it afterwards.
1154
1155
1156       Since 4.01.0
1157
1158
1159
1160
1161   Redefining semantic tag operations
1162       type formatter_stag_functions = {
1163        mark_open_stag : stag -> string ;
1164        mark_close_stag : stag -> string ;
1165        print_open_stag : stag -> unit ;
1166        print_close_stag : stag -> unit ;
1167        }
1168
1169
1170       The  semantic tag handling functions specific to a formatter: mark ver‐
1171       sions are the 'tag-marking' functions that associate a string marker to
1172       a tag in order for the pretty-printing engine to write those markers as
1173       0 length tokens in the output device of the formatter.  print  versions
1174       are the 'tag-printing' functions that can perform regular printing when
1175       a tag is closed or opened.
1176
1177
1178
1179       val pp_set_formatter_stag_functions : formatter -> formatter_stag_func‐
1180       tions -> unit
1181
1182
1183
1184
1185       val set_formatter_stag_functions : formatter_stag_functions -> unit
1186
1187
1188       pp_set_formatter_stag_functions  ppf  tag_funs  changes  the meaning of
1189       opening and closing semantic tag operations to  use  the  functions  in
1190       tag_funs when printing on ppf .
1191
1192       When opening a semantic tag with name t , the string t is passed to the
1193       opening tag-marking function (the mark_open_stag field  of  the  record
1194       tag_funs ), that must return the opening tag marker for that name. When
1195       the next call to close_stag () happens, the semantic tag name t is sent
1196       back  to the closing tag-marking function (the mark_close_stag field of
1197       record tag_funs ), that must return a closing tag marker for that name.
1198
1199       The print_ field of the record contains the tag-printing functions that
1200       are called at tag opening and tag closing time, to output regular mate‐
1201       rial in the pretty-printer queue.
1202
1203
1204
1205       val pp_get_formatter_stag_functions :  formatter  ->  unit  ->  format‐
1206       ter_stag_functions
1207
1208
1209
1210
1211       val get_formatter_stag_functions : unit -> formatter_stag_functions
1212
1213       Return  the  current  semantic  tag operation functions of the standard
1214       pretty-printer.
1215
1216
1217
1218
1219   Defining formatters
1220       Defining new formatters permits unrelated output of material in  paral‐
1221       lel  on  several output devices.  All the parameters of a formatter are
1222       local to the formatter: right margin, maximum indentation limit,  maxi‐
1223       mum  number of pretty-printing boxes simultaneously open, ellipsis, and
1224       so on, are specific to each formatter and may be fixed independently.
1225
1226       For instance, given a Buffer.t buffer b , Format.formatter_of_buffer  b
1227       returns  a  new  formatter  using buffer b as its output device.  Simi‐
1228       larly,  given  a  out_channel  output  channel  oc   ,   Format.format‐
1229       ter_of_out_channel  oc  returns a new formatter using channel oc as its
1230       output device.
1231
1232       Alternatively, given out_funs , a complete set of output functions  for
1233       a formatter, then Format.formatter_of_out_functions out_funs computes a
1234       new formatter using those functions for output.
1235
1236       val formatter_of_out_channel : out_channel -> formatter
1237
1238
1239       formatter_of_out_channel oc returns a new formatter writing to the cor‐
1240       responding output channel oc .
1241
1242
1243
1244       val std_formatter : formatter
1245
1246       The standard formatter to write to standard output.
1247
1248       It is defined as Format.formatter_of_out_channel stdout .
1249
1250
1251
1252       val err_formatter : formatter
1253
1254       A formatter to write to standard error.
1255
1256       It is defined as Format.formatter_of_out_channel stderr .
1257
1258
1259
1260       val formatter_of_buffer : Buffer.t -> formatter
1261
1262
1263       formatter_of_buffer  b returns a new formatter writing to buffer b . At
1264       the end of pretty-printing, the formatter must be  flushed  using  For‐
1265       mat.pp_print_flush  or Format.pp_print_newline , to print all the pend‐
1266       ing material into the buffer.
1267
1268
1269
1270       val stdbuf : Buffer.t
1271
1272       The string buffer in which str_formatter writes.
1273
1274
1275
1276       val str_formatter : formatter
1277
1278       A formatter to output to the Format.stdbuf string buffer.
1279
1280
1281       str_formatter is defined as Format.formatter_of_buffer Format.stdbuf .
1282
1283
1284
1285       val flush_str_formatter : unit -> string
1286
1287       Returns the material printed with str_formatter , flushes the formatter
1288       and resets the corresponding buffer.
1289
1290
1291
1292       val  make_formatter  : (string -> int -> int -> unit) -> (unit -> unit)
1293       -> formatter
1294
1295
1296       make_formatter out flush returns a  new  formatter  that  outputs  with
1297       function out , and flushes with function flush .
1298
1299       For instance, make_formatter (Stdlib.output oc) (fun () -> Stdlib.flush
1300       oc) returns a formatter to the out_channel oc .
1301
1302
1303
1304       val formatter_of_out_functions : formatter_out_functions -> formatter
1305
1306
1307       formatter_of_out_functions out_funs returns a new formatter that writes
1308       with the set of output functions out_funs .
1309
1310       See  definition  of type Format.formatter_out_functions for the meaning
1311       of argument out_funs .
1312
1313
1314       Since 4.06.0
1315
1316
1317
1318
1319   Symbolic pretty-printing
1320       Symbolic pretty-printing is pretty-printing using a symbolic formatter,
1321       i.e. a formatter that outputs symbolic pretty-printing items.
1322
1323       When using a symbolic formatter, all regular pretty-printing activities
1324       occur but output material is symbolic and stored in a buffer of  output
1325       items.   At  the  end  of  pretty-printing,  flushing the output buffer
1326       allows post-processing of symbolic output before performing  low  level
1327       output operations.
1328
1329       In practice, first define a symbolic output buffer b using:
1330
1331       -  let  sob  = make_symbolic_output_buffer () .  Then define a symbolic
1332       formatter with:
1333
1334       - let ppf = formatter_of_symbolic_output_buffer sob
1335
1336       Use symbolic formatter ppf as usual, and retrieve symbolic items at end
1337       of pretty-printing by flushing symbolic output buffer sob with:
1338
1339       - flush_symbolic_output_buffer sob .
1340
1341
1342       type symbolic_output_item =
1343        | Output_flush  (* symbolic flush command
1344        *)
1345        | Output_newline  (* symbolic newline command
1346        *)
1347        | Output_string of string
1348         (* Output_string s : symbolic output for string s
1349
1350        *)
1351        | Output_spaces of int
1352         (* Output_spaces n : symbolic command to output n spaces
1353        *)
1354        | Output_indent of int
1355         (* Output_indent i : symbolic indentation of size i
1356
1357        *)
1358
1359
1360       Items produced by symbolic pretty-printers
1361
1362
1363       Since 4.06.0
1364
1365
1366       type symbolic_output_buffer
1367
1368
1369       The output buffer of a symbolic pretty-printer.
1370
1371
1372       Since 4.06.0
1373
1374
1375
1376       val make_symbolic_output_buffer : unit -> symbolic_output_buffer
1377
1378
1379       make_symbolic_output_buffer () returns a fresh buffer for symbolic out‐
1380       put.
1381
1382
1383       Since 4.06.0
1384
1385
1386
1387       val clear_symbolic_output_buffer : symbolic_output_buffer -> unit
1388
1389
1390       clear_symbolic_output_buffer sob resets buffer sob .
1391
1392
1393       Since 4.06.0
1394
1395
1396
1397       val  get_symbolic_output_buffer  :   symbolic_output_buffer   ->   sym‐
1398       bolic_output_item list
1399
1400
1401       get_symbolic_output_buffer sob returns the contents of buffer sob .
1402
1403
1404       Since 4.06.0
1405
1406
1407
1408       val   flush_symbolic_output_buffer  :  symbolic_output_buffer  ->  sym‐
1409       bolic_output_item list
1410
1411
1412       flush_symbolic_output_buffer sob returns the contents of buffer sob and
1413       resets  buffer sob .  flush_symbolic_output_buffer sob is equivalent to
1414       let  items  =  get_symbolic_output_buffer  sob  in  clear_symbolic_out‐
1415       put_buffer sob; items
1416
1417
1418
1419       Since 4.06.0
1420
1421
1422
1423       val  add_symbolic_output_item : symbolic_output_buffer -> symbolic_out‐
1424       put_item -> unit
1425
1426
1427       add_symbolic_output_item sob itm adds item itm to buffer sob .
1428
1429
1430       Since 4.06.0
1431
1432
1433
1434       val  formatter_of_symbolic_output_buffer  :  symbolic_output_buffer  ->
1435       formatter
1436
1437
1438       formatter_of_symbolic_output_buffer  sob  returns  a symbolic formatter
1439       that outputs to symbolic_output_buffer sob .
1440
1441
1442       Since 4.06.0
1443
1444
1445
1446
1447   Convenience formatting functions.
1448       val pp_print_list : ?pp_sep:(formatter -> unit -> unit)  ->  (formatter
1449       -> 'a -> unit) -> formatter -> 'a list -> unit
1450
1451
1452       pp_print_list ?pp_sep pp_v ppf l prints items of list l , using pp_v to
1453       print each item, and calling pp_sep between items ( pp_sep defaults  to
1454       Format.pp_print_cut .  Does nothing on empty lists.
1455
1456
1457       Since 4.02.0
1458
1459
1460
1461       val pp_print_text : formatter -> string -> unit
1462
1463
1464       pp_print_text  ppf  s  prints  s  with spaces and newlines respectively
1465       printed using Format.pp_print_space and Format.pp_force_newline .
1466
1467
1468       Since 4.02.0
1469
1470
1471
1472       val pp_print_option : ?none:(formatter -> unit -> unit)  ->  (formatter
1473       -> 'a -> unit) -> formatter -> 'a option -> unit
1474
1475
1476       pp_print_option  ?none  pp_v  ppf  o prints o on ppf using pp_v if o is
1477       Some v and none if it is None .  none prints nothing by default.
1478
1479
1480       Since 4.08
1481
1482
1483
1484       val pp_print_result : ok:(formatter -> 'a -> unit) ->  error:(formatter
1485       -> 'e -> unit) -> formatter -> ('a, 'e) result -> unit
1486
1487
1488       pp_print_result  ~ok ~error ppf r prints r on ppf using ok if r is Ok _
1489       and error if r is Error _ .
1490
1491
1492       Since 4.08
1493
1494
1495
1496
1497   Formatted pretty-printing
1498       Module Format provides a complete set  of  printf  like  functions  for
1499       pretty-printing using format string specifications.
1500
1501       Specific  annotations  may  be  added  in  the  format  strings to give
1502       pretty-printing commands to the pretty-printing engine.
1503
1504       Those annotations are introduced in the  format  strings  using  the  @
1505       character.  For  instance,  @  means  a space break, @, means a cut, @[
1506       opens a new box, and @] closes the last open box.
1507
1508       val fprintf : formatter -> ('a, formatter, unit) format -> 'a
1509
1510
1511
1512
1513
1514       fprintf ff fmt arg1 ... argN formats the arguments arg1 to argN accord‐
1515       ing  to the format string fmt , and outputs the resulting string on the
1516       formatter ff .
1517
1518       The format string fmt is a character string which contains three  types
1519       of objects: plain characters and conversion specifications as specified
1520       in the Printf module, and pretty-printing indications specific  to  the
1521       Format module.
1522
1523       The pretty-printing indication characters are introduced by a @ charac‐
1524       ter, and their meanings are:
1525
1526       - @[ : open a pretty-printing box. The type and offset of the  box  may
1527       be  optionally  specified  with  the following syntax: the < character,
1528       followed by an optional box type indication, then an  optional  integer
1529       offset,  and  the closing > character.  Pretty-printing box type is one
1530       of h , v , hv , b , or  hov  .   '  h  '  stands  for  an  'horizontal'
1531       pretty-printing box, ' v ' stands for a 'vertical' pretty-printing box,
1532       ' hv ' stands for an 'horizontal/vertical' pretty-printing box, '  b  '
1533       stands  for an 'horizontal-or-vertical' pretty-printing box demonstrat‐
1534       ing indentation, '  hov  '  stands  a  simple  'horizontal-or-vertical'
1535       pretty-printing  box.   For  instance,  @[<hov  2>  opens  an 'horizon‐
1536       tal-or-vertical' pretty-printing box with  indentation  2  as  obtained
1537       with open_hovbox 2 .  For more details about pretty-printing boxes, see
1538       the various box opening functions open_*box .
1539
1540       - @] : close the most recently opened pretty-printing box.
1541
1542       - @, : output a 'cut' break hint, as with print_cut () .
1543
1544       - @ : output a 'space' break hint, as with print_space () .
1545
1546       - @; : output a 'full' break hint as with print_break . The nspaces and
1547       offset  parameters  of  the break hint may be optionally specified with
1548       the following syntax: the < character, followed by an  integer  nspaces
1549       value,  then  an  integer  offset  ,  and a closing > character.  If no
1550       parameters are provided, the good break defaults  to  a  'space'  break
1551       hint.
1552
1553       - @.  : flush the pretty-printer and split the line, as with print_new‐
1554       line () .
1555
1556       - @<n> : print the following item as if it were of length n  .   Hence,
1557       printf  @<0>%s  arg prints arg as a zero length string.  If @<n> is not
1558       followed by a conversion specification, then the following character of
1559       the format is printed as if it were of length n .
1560
1561       - @{ : open a semantic tag. The name of the tag may be optionally spec‐
1562       ified with the following  syntax:  the  <  character,  followed  by  an
1563       optional  string specification, and the closing > character. The string
1564       specification is any character string that does not contain the closing
1565       character  '>' . If omitted, the tag name defaults to the empty string.
1566       For  more  details  about  semantic  tags,  see  the   functions   For‐
1567       mat.open_stag and Format.close_stag .
1568
1569       - @} : close the most recently opened semantic tag.
1570
1571       -  @?   :  flush  the  pretty-printer as with print_flush () .  This is
1572       equivalent to the conversion %!  .
1573
1574       - @\n : force a newline, as with force_newline () , not the normal  way
1575       of pretty-printing, you should prefer using break hints inside a verti‐
1576       cal pretty-printing box.
1577
1578       Note: To prevent the interpretation of a @ character as a pretty-print‐
1579       ing indication, escape it with a % character.  Old quotation mode @@ is
1580       deprecated since it is not compatible with formatted input  interpreta‐
1581       tion of character '@' .
1582
1583       Example:  printf  @[%s@  %d@]@.  x  =  1  is equivalent to open_box ();
1584       print_string  x  =  ;  print_space  ();  print_int  1;  close_box   ();
1585       print_newline  () .  It prints x = 1 within a pretty-printing 'horizon‐
1586       tal-or-vertical' box.
1587
1588       val printf : ('a, formatter, unit) format -> 'a
1589
1590       Same as fprintf above, but output on std_formatter .
1591
1592
1593
1594       val eprintf : ('a, formatter, unit) format -> 'a
1595
1596       Same as fprintf above, but output on err_formatter .
1597
1598
1599
1600       val sprintf : ('a, unit, string) format -> 'a
1601
1602       Same as printf above, but instead of printing on a formatter, returns a
1603       string  containing  the  result of formatting the arguments.  Note that
1604       the pretty-printer queue is flushed at the end of each call to  sprintf
1605       .
1606
1607       In  case of multiple and related calls to sprintf to output material on
1608       a single string, you should consider using fprintf with the  predefined
1609       formatter  str_formatter  and  call  flush_str_formatter  () to get the
1610       final result.
1611
1612       Alternatively, you can use Format.fprintf with a formatter writing to a
1613       buffer of your own: flushing the formatter and the buffer at the end of
1614       pretty-printing returns the desired string.
1615
1616
1617
1618       val asprintf : ('a, formatter, unit, string) format4 -> 'a
1619
1620       Same as printf above, but instead of printing on a formatter, returns a
1621       string  containing the result of formatting the arguments.  The type of
1622       asprintf is general enough to interact nicely with %a conversions.
1623
1624
1625       Since 4.01.0
1626
1627
1628
1629       val dprintf : ('a, formatter, unit, formatter -> unit) format4 -> 'a
1630
1631       Same as Format.fprintf , except the formatter  is  the  last  argument.
1632       dprintf  ... a b c is a function of type formatter -> unit which can be
1633       given to a format specifier %t .
1634
1635       This can be used as a replacement for Format.asprintf to delay  format‐
1636       ting  decisions. Using the string returned by Format.asprintf in a for‐
1637       matting context forces formatting decisions to be taken  in  isolation,
1638       and the final string may be created prematurely.  Format.dprintf allows
1639       delay of formatting decisions until the  final  formatting  context  is
1640       known.   For  example:  let  t = Format.dprintf %i@ %i@ %i 1 2 3 in ...
1641       Format.printf @[<v>%t@] t
1642
1643
1644
1645       Since 4.08.0
1646
1647
1648
1649       val ifprintf : formatter -> ('a, formatter, unit) format -> 'a
1650
1651       Same as fprintf above, but does not print anything.  Useful  to  ignore
1652       some material when conditionally printing.
1653
1654
1655       Since 3.10.0
1656
1657
1658
1659
1660       Formatted Pretty-Printing with continuations.
1661
1662       val  kfprintf : (formatter -> 'a) -> formatter -> ('b, formatter, unit,
1663       'a) format4 -> 'b
1664
1665       Same as fprintf above, but instead of returning immediately, passes the
1666       formatter to its first argument at the end of printing.
1667
1668
1669
1670       val kdprintf : ((formatter -> unit) -> 'a) -> ('b, formatter, unit, 'a)
1671       format4 -> 'b
1672
1673       Same as Format.dprintf above, but  instead  of  returning  immediately,
1674       passes the suspended printer to its first argument at the end of print‐
1675       ing.
1676
1677
1678       Since 4.08.0
1679
1680
1681
1682       val ikfprintf : (formatter -> 'a) -> formatter -> ('b, formatter, unit,
1683       'a) format4 -> 'b
1684
1685       Same  as kfprintf above, but does not print anything.  Useful to ignore
1686       some material when conditionally printing.
1687
1688
1689       Since 3.12.0
1690
1691
1692
1693       val ksprintf : (string -> 'a) -> ('b, unit, string, 'a) format4 -> 'b
1694
1695       Same as sprintf above, but instead of returning the string,  passes  it
1696       to the first argument.
1697
1698
1699
1700       val  kasprintf : (string -> 'a) -> ('b, formatter, unit, 'a) format4 ->
1701       'b
1702
1703       Same as asprintf above, but instead of returning the string, passes  it
1704       to the first argument.
1705
1706
1707       Since 4.03
1708
1709
1710
1711
1712   Deprecated
1713       val bprintf : Buffer.t -> ('a, formatter, unit) format -> 'a
1714
1715       Deprecated.   This  function is error prone. Do not use it.  This func‐
1716       tion is neither compositional nor incremental,  since  it  flushes  the
1717       pretty-printer queue at each call.
1718
1719       If you need to print to some buffer b , you must first define a format‐
1720       ter writing to b , using let to_b = formatter_of_buffer b  ;  then  use
1721       regular calls to Format.fprintf with formatter to_b .
1722
1723
1724
1725       val kprintf : (string -> 'a) -> ('b, unit, string, 'a) format4 -> 'b
1726
1727       Deprecated.  An alias for ksprintf .
1728
1729
1730
1731       val  set_all_formatter_output_functions  : out:(string -> int -> int ->
1732       unit) -> flush:(unit -> unit) -> newline:(unit -> unit) ->  spaces:(int
1733       -> unit) -> unit
1734
1735       Deprecated.  Subsumed by set_formatter_out_functions .
1736
1737
1738
1739       val  get_all_formatter_output_functions : unit -> (string -> int -> int
1740       -> unit) * (unit -> unit) * (unit -> unit) * (int -> unit)
1741
1742       Deprecated.  Subsumed by get_formatter_out_functions .
1743
1744
1745
1746       val pp_set_all_formatter_output_functions : formatter -> out:(string ->
1747       int  ->  int -> unit) -> flush:(unit -> unit) -> newline:(unit -> unit)
1748       -> spaces:(int -> unit) -> unit
1749
1750       Deprecated.  Subsumed by pp_set_formatter_out_functions .
1751
1752
1753
1754       val  pp_get_all_formatter_output_functions  :  formatter  ->  unit   ->
1755       (string -> int -> int -> unit) * (unit -> unit) * (unit -> unit) * (int
1756       -> unit)
1757
1758       Deprecated.  Subsumed by pp_get_formatter_out_functions .
1759
1760
1761
1762
1763   String tags
1764       val pp_open_tag : formatter -> tag -> unit
1765
1766       Deprecated.  Subsumed by Format.pp_open_stag .
1767
1768
1769
1770       val open_tag : tag -> unit
1771
1772       Deprecated.  Subsumed by Format.open_stag .
1773
1774
1775
1776       val pp_close_tag : formatter -> unit -> unit
1777
1778       Deprecated.  Subsumed by Format.pp_close_stag .
1779
1780
1781
1782       val close_tag : unit -> unit
1783
1784       Deprecated.  Subsumed by Format.close_stag .
1785
1786
1787       type formatter_tag_functions = {
1788        mark_open_tag : tag -> string ;
1789        mark_close_tag : tag -> string ;
1790        print_open_tag : tag -> unit ;
1791        print_close_tag : tag -> unit ;
1792        }
1793
1794
1795       Deprecated.  Subsumed by Format.formatter_stag_functions .
1796
1797
1798
1799       val pp_set_formatter_tag_functions : formatter  ->  formatter_tag_func‐
1800       tions -> unit
1801
1802       Deprecated.  Subsumed by Format.pp_set_formatter_stag_functions .
1803
1804
1805       This function will erase non-string tag formatting functions.
1806
1807
1808
1809       val set_formatter_tag_functions : formatter_tag_functions -> unit
1810
1811       Deprecated.  Subsumed by Format.set_formatter_stag_functions .
1812
1813
1814
1815       val  pp_get_formatter_tag_functions  :  formatter  ->  unit  -> format‐
1816       ter_tag_functions
1817
1818       Deprecated.  Subsumed by Format.pp_get_formatter_stag_functions .
1819
1820
1821
1822       val get_formatter_tag_functions : unit -> formatter_tag_functions
1823
1824       Deprecated.  Subsumed by Format.get_formatter_stag_functions .
1825
1826
1827
1828
1829
1830OCamldoc                          2019-07-30                  Stdlib.Format(3)
Impressum