Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > ac00cb96767d9c54367b331f839b9a30 > files > 495

ocaml-batteries-2.1-3.mga4.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link rel="previous" href="Batteries.Printexc.html">
<link rel="next" href="Batteries.Queue.html">
<link rel="Up" href="Batteries.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of class methods" rel=Appendix href="index_methods.html">
<link title="Index of classes" rel=Appendix href="index_classes.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="BatArray" rel="Chapter" href="BatArray.html">
<link title="BatAvlTree" rel="Chapter" href="BatAvlTree.html">
<link title="BatBase64" rel="Chapter" href="BatBase64.html">
<link title="BatBig_int" rel="Chapter" href="BatBig_int.html">
<link title="BatBigarray" rel="Chapter" href="BatBigarray.html">
<link title="BatBitSet" rel="Chapter" href="BatBitSet.html">
<link title="BatBool" rel="Chapter" href="BatBool.html">
<link title="BatBounded" rel="Chapter" href="BatBounded.html">
<link title="BatBuffer" rel="Chapter" href="BatBuffer.html">
<link title="BatCache" rel="Chapter" href="BatCache.html">
<link title="BatChar" rel="Chapter" href="BatChar.html">
<link title="BatCharParser" rel="Chapter" href="BatCharParser.html">
<link title="BatComplex" rel="Chapter" href="BatComplex.html">
<link title="BatConcurrent" rel="Chapter" href="BatConcurrent.html">
<link title="BatDeque" rel="Chapter" href="BatDeque.html">
<link title="BatDigest" rel="Chapter" href="BatDigest.html">
<link title="BatDllist" rel="Chapter" href="BatDllist.html">
<link title="BatDynArray" rel="Chapter" href="BatDynArray.html">
<link title="BatEnum" rel="Chapter" href="BatEnum.html">
<link title="BatFile" rel="Chapter" href="BatFile.html">
<link title="BatFingerTree" rel="Chapter" href="BatFingerTree.html">
<link title="BatFloat" rel="Chapter" href="BatFloat.html">
<link title="BatFormat" rel="Chapter" href="BatFormat.html">
<link title="BatGc" rel="Chapter" href="BatGc.html">
<link title="BatGenlex" rel="Chapter" href="BatGenlex.html">
<link title="BatGlobal" rel="Chapter" href="BatGlobal.html">
<link title="BatHashcons" rel="Chapter" href="BatHashcons.html">
<link title="BatHashtbl" rel="Chapter" href="BatHashtbl.html">
<link title="BatHeap" rel="Chapter" href="BatHeap.html">
<link title="BatIMap" rel="Chapter" href="BatIMap.html">
<link title="BatIO" rel="Chapter" href="BatIO.html">
<link title="BatISet" rel="Chapter" href="BatISet.html">
<link title="BatInnerIO" rel="Chapter" href="BatInnerIO.html">
<link title="BatInnerPervasives" rel="Chapter" href="BatInnerPervasives.html">
<link title="BatInnerWeaktbl" rel="Chapter" href="BatInnerWeaktbl.html">
<link title="BatInt" rel="Chapter" href="BatInt.html">
<link title="BatInt32" rel="Chapter" href="BatInt32.html">
<link title="BatInt64" rel="Chapter" href="BatInt64.html">
<link title="BatInterfaces" rel="Chapter" href="BatInterfaces.html">
<link title="BatLazyList" rel="Chapter" href="BatLazyList.html">
<link title="BatLexing" rel="Chapter" href="BatLexing.html">
<link title="BatList" rel="Chapter" href="BatList.html">
<link title="BatLog" rel="Chapter" href="BatLog.html">
<link title="BatLogger" rel="Chapter" href="BatLogger.html">
<link title="BatMap" rel="Chapter" href="BatMap.html">
<link title="BatMarshal" rel="Chapter" href="BatMarshal.html">
<link title="BatMultiMap" rel="Chapter" href="BatMultiMap.html">
<link title="BatMultiPMap" rel="Chapter" href="BatMultiPMap.html">
<link title="BatMutex" rel="Chapter" href="BatMutex.html">
<link title="BatNativeint" rel="Chapter" href="BatNativeint.html">
<link title="BatNum" rel="Chapter" href="BatNum.html">
<link title="BatNumber" rel="Chapter" href="BatNumber.html">
<link title="BatOo" rel="Chapter" href="BatOo.html">
<link title="BatOptParse" rel="Chapter" href="BatOptParse.html">
<link title="BatOption" rel="Chapter" href="BatOption.html">
<link title="BatOrd" rel="Chapter" href="BatOrd.html">
<link title="BatParserCo" rel="Chapter" href="BatParserCo.html">
<link title="BatPathGen" rel="Chapter" href="BatPathGen.html">
<link title="BatPervasives" rel="Chapter" href="BatPervasives.html">
<link title="BatPrintexc" rel="Chapter" href="BatPrintexc.html">
<link title="BatPrintf" rel="Chapter" href="BatPrintf.html">
<link title="BatQueue" rel="Chapter" href="BatQueue.html">
<link title="BatRMutex" rel="Chapter" href="BatRMutex.html">
<link title="BatRandom" rel="Chapter" href="BatRandom.html">
<link title="BatRef" rel="Chapter" href="BatRef.html">
<link title="BatRefList" rel="Chapter" href="BatRefList.html">
<link title="BatResult" rel="Chapter" href="BatResult.html">
<link title="BatReturn" rel="Chapter" href="BatReturn.html">
<link title="BatScanf" rel="Chapter" href="BatScanf.html">
<link title="BatSeq" rel="Chapter" href="BatSeq.html">
<link title="BatSet" rel="Chapter" href="BatSet.html">
<link title="BatSplay" rel="Chapter" href="BatSplay.html">
<link title="BatStack" rel="Chapter" href="BatStack.html">
<link title="BatStream" rel="Chapter" href="BatStream.html">
<link title="BatString" rel="Chapter" href="BatString.html">
<link title="BatSubstring" rel="Chapter" href="BatSubstring.html">
<link title="BatSys" rel="Chapter" href="BatSys.html">
<link title="BatText" rel="Chapter" href="BatText.html">
<link title="BatTuple" rel="Chapter" href="BatTuple.html">
<link title="BatUChar" rel="Chapter" href="BatUChar.html">
<link title="BatUTF8" rel="Chapter" href="BatUTF8.html">
<link title="BatUnit" rel="Chapter" href="BatUnit.html">
<link title="BatUnix" rel="Chapter" href="BatUnix.html">
<link title="BatUref" rel="Chapter" href="BatUref.html">
<link title="BatVect" rel="Chapter" href="BatVect.html">
<link title="Batteries" rel="Chapter" href="Batteries.html">
<link title="BatteriesConfig" rel="Chapter" href="BatteriesConfig.html">
<link title="BatteriesPrint" rel="Chapter" href="BatteriesPrint.html">
<link title="BatteriesThread" rel="Chapter" href="BatteriesThread.html">
<link title="Extlib" rel="Chapter" href="Extlib.html"><link title="General overview" rel="Section" href="#6_Generaloverview">
<link title="Formats" rel="Section" href="#6_Formats">
<link title="Common functions" rel="Section" href="#6_Commonfunctions">
<link title="General functions" rel="Section" href="#6_Generalfunctions">
<link title="Functions with continuations" rel="Section" href="#6_Functionswithcontinuations">
<link title="About formats" rel="Section" href="#6_Aboutformats">
<link title="Format4" rel="Subsection" href="#7_Format4">
<link title="Format" rel="Subsection" href="#7_Format">
<link title="Important" rel="Subsection" href="#7_Important">
<title>Batteries user guide : Batteries.Printf</title>
</head>
<body>
<div class="navbar"><a class="pre" href="Batteries.Printexc.html" title="Batteries.Printexc">Previous</a>
&nbsp;<a class="up" href="Batteries.html" title="Batteries">Up</a>
&nbsp;<a class="post" href="Batteries.Queue.html" title="Batteries.Queue">Next</a>
</div>
<h1>Module <a href="type_Batteries.Printf.html">Batteries.Printf</a></h1>

<pre><span class="keyword">module</span> Printf: <code class="type">BatPrintf</code></pre><hr width="100%">
<br>
Formatted output functions (also known as unparsing).<br>
<br>
<h6 id="6_Generaloverview">General overview</h6>
<p>

   The functions of this module produce output according to a
   <code class="code"><span class="constructor">Pervasives</span>.format</code>, as described below. Some functions write to
   the standard output (i.e. the screen), some to error channels,
   some to strings or to buffers, or some to abstract outputs.
<p>

   <b>Note</b> The types used in this module are confusing at first.
   If you are a beginner, you should probably ignore them in a
   first time and concentrate on formats.
<p>

   For a first explanation, we will concentrate on function <a href="BatPrintf.html#VALprintf"><code class="code"><span class="constructor">BatPrintf</span>.printf</code></a>.
   As all the functions in this module, the behavior of <a href="BatPrintf.html#VALprintf"><code class="code"><span class="constructor">BatPrintf</span>.printf</code></a> is
   dictated by a <code class="code">format</code>. This format is a string, composed of
   regular text and directives, and which dictates how to interpret
   the other arguments passed to the function. Every directive starts
   with character <code class="code">%</code>.  The most common directive is <code class="code">%s</code>, which
   serves to display a string, something quite useful for
   pretty-printing or translation.  Anther common directive is <code class="code">%i</code>,
   which serves to display an integer.
<p>

   For instance, <code class="code"><span class="string">"foobar"</span></code> is a format with no directive. Calling
   <code class="code">printf <span class="string">"foobar"</span></code> prints <code class="code"><span class="string">"foobar"</span></code> on the screen and returns
   <code class="code">()</code>. On the other hand, <code class="code"><span class="string">"%s"</span></code> is a format with one directive for
   printing strings. <code class="code">printf <span class="string">"%s"</span></code> does nothing yet but returns a
   function with type <code class="code">string <span class="keywordsign">-&gt;</span> unit</code>. In turn, <code class="code">printf <span class="string">"%s"</span>
   <span class="string">"foobar"</span></code> prints <code class="code"><span class="string">"foobar"</span></code> on the screen and returns <code class="code">()</code>. The
   main interest of this module is that directives may be combined
   together and with text, to allow more complex printing. For instance
   <code class="code">printf <span class="string">"(%s)\n"</span></code> is a function with type <code class="code">string <span class="keywordsign">-&gt;</span> unit</code> which,
   when passed string <code class="code"><span class="string">"foobar"</span></code> prints <code class="code"><span class="string">"(foobar)"</span></code> and ends the
   line. Similarly, <code class="code">printf <span class="string">"Here's the result: %s.\n\tComputation
   took %i seconds.\n"</span> <span class="string">"foobar"</span> 5</code> prints
   <pre class="codepre"><code class="code"><span class="constructor">Here's</span>&nbsp;the&nbsp;result:&nbsp;foobar<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="constructor">Computation</span>&nbsp;took&nbsp;5&nbsp;seconds.</code></pre>
<p>

   Note that <code class="code">\n</code> (the newline character) and <code class="code">\t</code> (the tabulation)
   are not specific to this module but rather part of the conventions
   on characters strings in OCaml.
<p>

   Other directives and functions make this module extremely useful
   for printing, pretty-printing and translation of messages to
   the user's language. For more information, see the documentation
   of <code class="code">format</code> and the various functions.<br>
<br>
<h6 id="6_Formats">Formats</h6><br>

<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type">('a, 'b, 'c)</code> t</span> = <code class="type">('a, 'b, 'c) Pervasives.format</code> </pre>
<div class="info ">
The format to use for displaying the various arguments passed to the function.
<p>

   Syntactically, the format is a character string which contains two types
   of objects: plain characters, which are simply copied, and directives,
   each of which causes the conversion and printing of arguments.
<p>

   <div class="h7" id="7_Simpledirectives">Simple directives</div>
<p>

   All directives start with the <code class="code">%</code> character. In their simplest form,
   a directive is <code class="code">%</code> followed by exactly one character:
<p>
<ul>
<li><code class="code">%d</code>, <code class="code">%i</code>, <code class="code">%n</code>, <code class="code">%l</code>, <code class="code">%<span class="constructor">L</span></code>, or <code class="code">%<span class="constructor">N</span></code>: convert an integer argument to
     signed decimal.</li>
<li><code class="code">%u</code>: convert an integer argument to unsigned decimal.</li>
<li><code class="code">%x</code>: convert an integer argument to unsigned hexadecimal,
     using lowercase letters.</li>
<li><code class="code">%<span class="constructor">X</span></code>: convert an integer argument to unsigned hexadecimal,
     using uppercase letters.</li>
<li><code class="code">%o</code>: convert an integer argument to unsigned octal.</li>
<li><code class="code">%s</code>: insert a string argument.</li>
<li><code class="code">%<span class="constructor">S</span></code>: insert a string argument in OCaml syntax (double quotes, escapes).</li>
<li><code class="code">%c</code>: insert a character argument.</li>
<li><code class="code">%<span class="constructor">C</span></code>: insert a character argument in OCaml syntax (single quotes, escapes).</li>
<li><code class="code">%f</code>: convert a floating-point argument to decimal notation,
     in the style <code class="code">dddd.ddd</code>.</li>
<li><code class="code">%<span class="constructor">F</span></code>: convert a floating-point argument to OCaml syntax (<code class="code">dddd.</code>
     or <code class="code">dddd.ddd</code> or <code class="code">d.ddd e+-dd</code>).</li>
<li><code class="code">%e</code> or <code class="code">%<span class="constructor">E</span></code>: convert a floating-point argument to decimal notation,
     in the style <code class="code">d.ddd e+-dd</code> (mantissa and exponent).</li>
<li><code class="code">%g</code> or <code class="code">%<span class="constructor">G</span></code>: convert a floating-point argument to decimal notation,
     in style <code class="code">%f</code> or <code class="code">%e</code>, <code class="code"><span class="constructor">E</span></code> (whichever is more compact).</li>
<li><code class="code">%<span class="constructor">B</span></code>: convert a boolean argument to the string <code class="code"><span class="keyword">true</span></code> or <code class="code"><span class="keyword">false</span></code></li>
<li><code class="code">%b</code>: convert a boolean argument (for backward compatibility; do not
     use in new programs).</li>
<li><code class="code">%ld</code>, <code class="code">%li</code>, <code class="code">%lu</code>, <code class="code">%lx</code>, <code class="code">%lX</code>, <code class="code">%lo</code>: convert an <code class="code">int32</code> argument to
     the format specified by the second letter (decimal, hexadecimal, etc).</li>
<li><code class="code">%nd</code>, <code class="code">%ni</code>, <code class="code">%nu</code>, <code class="code">%nx</code>, <code class="code">%nX</code>, <code class="code">%no</code>: convert a <code class="code">nativeint</code> argument to
     the format specified by the second letter.</li>
<li><code class="code">%<span class="constructor">Ld</span></code>, <code class="code">%<span class="constructor">Li</span></code>, <code class="code">%<span class="constructor">Lu</span></code>, <code class="code">%<span class="constructor">Lx</span></code>, <code class="code">%<span class="constructor">LX</span></code>, <code class="code">%<span class="constructor">Lo</span></code>: convert an <code class="code">int64</code> argument to
     the format specified by the second letter.</li>
<li><code class="code">!</code>: take no argument and flush the output.</li>
<li><code class="code">%</code>: take no argument and output one <code class="code">%</code> character.</li>
<li><code class="code">,</code>: the no-op delimiter for conversion specifications</li>
</ul>

   <div class="h7" id="7_Unparsers">Unparsers</div>
<p>
<ul>
<li><code class="code">%a</code>: user-defined printer. Typically, this printer corresponds to two
     arguments: a printing function <code class="code">f</code>, with type <code class="code"><span class="keywordsign">'</span>a output <span class="keywordsign">-&gt;</span> <span class="keywordsign">'</span>c <span class="keywordsign">-&gt;</span> unit</code>
     and the item <code class="code">x</code> you want to print, with type <code class="code"><span class="keywordsign">'</span>c</code>. Item <code class="code">x</code> will
     be printing by calling <code class="code">f out x</code>, where <code class="code">out</code> is the output you are
     currently using -- if you are calling <a href="BatPrintf.html#VALprintf"><code class="code"><span class="constructor">BatPrintf</span>.printf</code></a>, this output is
     the standard output (i.e. the screen), if you are calling <a href="BatPrintf.html#VALeprintf"><code class="code"><span class="constructor">BatPrintf</span>.eprintf</code></a>,
     this will be the error channel, if you are calling <a href="BatPrintf.html#VALfprintf"><code class="code"><span class="constructor">BatPrintf</span>.fprintf</code></a>, this
     will be the output you provided yourself, etc. More generally, if your
     <code class="code">format</code> has type <code class="code">(<span class="keywordsign">'</span>a, <span class="keywordsign">'</span>b, <span class="keywordsign">'</span>d) format</code> or <code class="code">(<span class="keywordsign">'</span>a, <span class="keywordsign">'</span>b, <span class="keywordsign">'</span>d, <span class="keywordsign">'</span>e) format4</code>,
     the printing function <code class="code">f</code> must have type <code class="code"><span class="keywordsign">'</span>b <span class="keywordsign">-&gt;</span> <span class="keywordsign">'</span>c <span class="keywordsign">-&gt;</span> <span class="keywordsign">'</span>d</code>, where
     <code class="code">x</code> has type <code class="code"><span class="keywordsign">'</span>d</code>.</li>
<li><code class="code">%t</code>: same as <code class="code">%a</code> but takes only a printing function <code class="code">f</code>,
     without an item. If your <code class="code">format</code> has type <code class="code">(<span class="keywordsign">'</span>a, <span class="keywordsign">'</span>b, <span class="keywordsign">'</span>d) format</code>
     or <code class="code">(<span class="keywordsign">'</span>a, <span class="keywordsign">'</span>b, <span class="keywordsign">'</span>d, <span class="keywordsign">'</span>e) format4</code>, function <code class="code">f</code> must have type
     <code class="code"><span class="keywordsign">'</span>b <span class="keywordsign">-&gt;</span> <span class="keywordsign">'</span>d</code>.</li>
</ul>

   <div class="h7" id="7_Formattingformats">Formatting formats</div><ul>
<li><code class="code">%{ fmt %}</code>: convert a <code class="code">format</code> to a string. The format argument
     must have the same type as the internal format string <code class="code">fmt</code>.
     In other words, <code class="code">printf <span class="string">"%{ %s %}"</span></code> accepts an argument
     whose type must be the same as that of format <code class="code"><span class="string">"%s"</span></code>, and
     prints that format argument as if it were a character string.</li>
<li><code class="code">%( fmt %)</code>: format string substitution. Takes a format string
     argument and substitutes it to the internal format string <code class="code">fmt</code>
     to print following arguments. The argument must have the same
     type as <code class="code">fmt</code>. <code class="code">printf <span class="string">"%{ %s %}"</span></code> accepts an argument
     whose type must be the same as that of format <code class="code"><span class="string">"%s"</span></code>, and
     uses that argument to print the following arguments.</li>
</ul>

   <div class="h7" id="7_Additionaloptions">Additional options</div>
   The general format of directives is
<p>

   <code class="code">% [flags] [width] [.precision] <span class="keyword">type</span></code>
<p>

   <code class="code"><span class="keyword">type</span></code> is one of <code class="code">d</code>, <code class="code">i</code>, <code class="code">n</code>, <code class="code">l</code>, <code class="code"><span class="constructor">L</span></code>, <code class="code"><span class="constructor">N</span></code>, <code class="code">u</code>, <code class="code">x</code> ...,
   <code class="code">( fmt %)</code> and behaves as explained above.
<p>

   The optional <code class="code">flags</code> are:<ul>
<li><code class="code">-</code>: left-justify the output (default is right justification).</li>
<li><code class="code">0</code>: for numerical conversions, pad with zeroes instead of spaces.</li>
<li><code class="code">+</code>: for numerical conversions, prefix number with a <code class="code">+</code> sign if positive.</li>
<li>space: for numerical conversions, prefix number with a space if positive.</li>
<li><code class="code"><span class="keywordsign">#</span></code>: request an alternate formatting style for numbers.</li>
</ul>

   The optional <code class="code">width</code> is an integer indicating the minimal
   width of the result. For instance, <code class="code">%6d</code> prints an integer,
   prefixing it with spaces to fill at least 6 characters.
<p>

   The optional <code class="code">precision</code> is a dot <code class="code">.</code> followed by an integer
   indicating how many digits follow the decimal point in the <code class="code">%f</code>,
   <code class="code">%e</code>, and <code class="code">%<span class="constructor">E</span></code> conversions. For instance, <code class="code">%.4f</code> prints a <code class="code">float</code> with
   4 fractional digits.
<p>

   The integer in a <code class="code">width</code> or <code class="code">precision</code> can also be specified as
   <code class="code">*</code>, in which case an extra integer argument is taken to specify
   the corresponding <code class="code">width</code> or <code class="code">precision</code>. This integer argument
   precedes immediately the argument to print.
   For instance, <code class="code">%.*f</code> prints a <code class="code">float</code> with as many fractional
   digits as the value of the argument given before the float.<br>
</div>

<br>
<h6 id="6_Commonfunctions">Common functions</h6><br>

<pre><span id="VALprintf"><span class="keyword">val</span> printf</span> : <code class="type">('b, 'a <a href="BatInnerIO.html#TYPEoutput">BatInnerIO.output</a>, unit) <a href="BatPrintf.html#TYPEt">t</a> -> 'b</code></pre><div class="info ">
The usual <code class="code">printf</code> function, prints to the standard output <code class="code">stdout</code>, i.e. normally
   to the screen. If you are lost, this is probably the function you're looking for.<br>
</div>

<pre><span id="VALeprintf"><span class="keyword">val</span> eprintf</span> : <code class="type">('b, 'a <a href="BatInnerIO.html#TYPEoutput">BatInnerIO.output</a>, unit) <a href="BatPrintf.html#TYPEt">t</a> -> 'b</code></pre><div class="info ">
The usual <code class="code">eprintf</code> function, prints to the standard error output <code class="code">stderr</code>, used
   to display warnings and errors. Otherwise identical to <a href="BatPrintf.html#VALprintf"><code class="code"><span class="constructor">BatPrintf</span>.printf</code></a>.<br>
</div>

<pre><span id="VALsprintf"><span class="keyword">val</span> sprintf</span> : <code class="type">('a, unit, string) <a href="BatPrintf.html#TYPEt">t</a> -> 'a</code></pre><div class="info ">
A function which doesn't print its result but returns it as a string. Useful
    for building messages, for translation purposes or for display in a window,
    for instance.
<p>

    While this function is quite convenient, don't abuse it to create very large
    strings such as files, that's not its role. For this kind of usage, prefer
    the more modular and usually faster <a href="BatPrintf.html#VALfprintf"><code class="code"><span class="constructor">BatPrintf</span>.fprintf</code></a>.
<p>

    Note that any function called with <code class="code">%a</code> should return strings, i.e.
    should have type <code class="code">unit <span class="keywordsign">-&gt;</span> string</code>.<br>
</div>

<pre><span id="VALsprintf2"><span class="keyword">val</span> sprintf2</span> : <code class="type">('a, 'b <a href="BatInnerIO.html#TYPEoutput">BatInnerIO.output</a>, unit, string) Pervasives.format4 -> 'a</code></pre><div class="info ">
A function which doesn't print its result but returns it as a string. Useful
    for building messages, for translation purposes or for display in a window,
    for instance.
<p>

    While this function is quite convenient, don't abuse it to create very large
    strings such as files, that's not its role. For this kind of usage, prefer
    the more modular and usually faster <a href="BatPrintf.html#VALfprintf"><code class="code"><span class="constructor">BatPrintf</span>.fprintf</code></a>.
    Note that any function called with <code class="code">%a</code> should be able to print its result,
    i.e. should have type <code class="code"><span class="keywordsign">'</span>b output <span class="keywordsign">-&gt;</span> unit</code>.<br>
</div>
<br>
<h6 id="6_Generalfunctions">General functions</h6><br>

<pre><span id="VALfprintf"><span class="keyword">val</span> fprintf</span> : <code class="type">'a <a href="BatInnerIO.html#TYPEoutput">BatInnerIO.output</a> -> ('b, 'a <a href="BatInnerIO.html#TYPEoutput">BatInnerIO.output</a>, unit) <a href="BatPrintf.html#TYPEt">t</a> -> 'b</code></pre><div class="info ">
General function. This function prints to any output. Typically,
   if you are attempting to build a large output such as a file,
   this is probably the function you are looking for. If you are
   writing a pretty-printer, this is probably the function you are
   looking for. If you are you are looking for a function to use for
   argument <code class="code">%a</code> with <a href="BatPrintf.html#VALprintf"><code class="code"><span class="constructor">BatPrintf</span>.printf</code></a>, <a href="BatPrintf.html#VALeprintf"><code class="code"><span class="constructor">BatPrintf</span>.eprintf</code></a>, <a href="BatPrintf.html#VALsprintf2"><code class="code"><span class="constructor">BatPrintf</span>.sprintf2</code></a>,
   <a href="BatPrintf.html#VALifprintf"><code class="code"><span class="constructor">BatPrintf</span>.ifprintf</code></a>, <a href="BatPrintf.html#VALbprintf2"><code class="code"><span class="constructor">BatPrintf</span>.bprintf2</code></a>, <a href="BatPrintf.html#VALkfprintf"><code class="code"><span class="constructor">BatPrintf</span>.kfprintf</code></a>, <a href="BatPrintf.html#VALksprintf2"><code class="code"><span class="constructor">BatPrintf</span>.ksprintf2</code></a>, <a href="BatPrintf.html#VALkbprintf2"><code class="code"><span class="constructor">BatPrintf</span>.kbprintf2</code></a>
   or any other function with type <code class="code">(_, _ output, unit) format</code> or
   <code class="code">(_, _ output, unit, _) format4</code>, this is also probably the
   function you are looking for.<br>
</div>

<pre><span id="VALifprintf"><span class="keyword">val</span> ifprintf</span> : <code class="type">'c -> ('b, 'a <a href="BatInnerIO.html#TYPEoutput">BatInnerIO.output</a>, unit) <a href="BatPrintf.html#TYPEt">t</a> -> 'b</code></pre><div class="info ">
As <a href="BatPrintf.html#VALfprintf"><code class="code"><span class="constructor">BatPrintf</span>.fprintf</code></a> but doesn't actually print anything.
   Sometimes useful for debugging.<br>
</div>

<pre><span id="VALbprintf"><span class="keyword">val</span> bprintf</span> : <code class="type">Buffer.t -> ('a, Buffer.t, unit) <a href="BatPrintf.html#TYPEt">t</a> -> 'a</code></pre><div class="info ">
As <a href="BatPrintf.html#VALfprintf"><code class="code"><span class="constructor">BatPrintf</span>.fprintf</code></a>, but with buffers instead of outputs.
   In particular, any unparser called with <code class="code">%a</code> should
   write to a buffer rather than to an output<br>
</div>

<pre><span id="VALbprintf2"><span class="keyword">val</span> bprintf2</span> : <code class="type">Buffer.t -> ('b, 'a <a href="BatInnerIO.html#TYPEoutput">BatInnerIO.output</a>, unit) <a href="BatPrintf.html#TYPEt">t</a> -> 'b</code></pre><div class="info ">
As <a href="BatPrintf.html#VALprintf"><code class="code"><span class="constructor">BatPrintf</span>.printf</code></a> but writes to a buffer instead
   of printing to the output. By opposition to
   <a href="BatPrintf.html#VALbprintf"><code class="code"><span class="constructor">BatPrintf</span>.bprintf</code></a>, only the result is changed with
   respect to <a href="BatPrintf.html#VALprintf"><code class="code"><span class="constructor">BatPrintf</span>.printf</code></a>, not the inner workings.<br>
</div>
<br>
<h6 id="6_Functionswithcontinuations">Functions with continuations</h6><br>

<pre><span id="VALkfprintf"><span class="keyword">val</span> kfprintf</span> : <code class="type">('a <a href="BatInnerIO.html#TYPEoutput">BatInnerIO.output</a> -> 'b) -><br>       'a <a href="BatInnerIO.html#TYPEoutput">BatInnerIO.output</a> -><br>       ('c, 'a <a href="BatInnerIO.html#TYPEoutput">BatInnerIO.output</a>, unit, 'b) Pervasives.format4 -> 'c</code></pre><div class="info ">
Same as <code class="code">fprintf</code>, but instead of returning immediately, passes the <code class="code">output</code> to its first
   argument at the end of printing.<br>
</div>

<pre><span id="VALksprintf"><span class="keyword">val</span> ksprintf</span> : <code class="type">(string -> 'a) -> ('b, unit, string, 'a) Pervasives.format4 -> 'b</code></pre><div class="info ">
Same as <code class="code">sprintf</code> above, but instead of returning the string,
    passes it to the first argument.<br>
</div>

<pre><span id="VALksprintf2"><span class="keyword">val</span> ksprintf2</span> : <code class="type">(string -> 'b) -><br>       ('c, 'a <a href="BatInnerIO.html#TYPEoutput">BatInnerIO.output</a>, unit, 'b) Pervasives.format4 -> 'c</code></pre><div class="info ">
Same as <code class="code">sprintf2</code> above, but instead of returning the string,
    passes it to the first argument.<br>
</div>

<pre><span id="VALkbprintf"><span class="keyword">val</span> kbprintf</span> : <code class="type">(Buffer.t -> 'a) -><br>       Buffer.t -> ('b, Buffer.t, unit, 'a) Pervasives.format4 -> 'b</code></pre><div class="info ">
Same as <code class="code">bprintf</code>, but instead of returning immediately,
    passes the buffer to its first argument at the end of printing.<br>
</div>

<pre><span id="VALkbprintf2"><span class="keyword">val</span> kbprintf2</span> : <code class="type">(Buffer.t -> 'b) -><br>       Buffer.t -> ('c, 'a <a href="BatInnerIO.html#TYPEoutput">BatInnerIO.output</a>, unit, 'b) Pervasives.format4 -> 'c</code></pre><div class="info ">
Same as <code class="code">bprintf2</code>, but instead of returning immediately,
    passes the buffer to its first argument at the end of printing.<br>
</div>

<pre><span id="VALkprintf"><span class="keyword">val</span> kprintf</span> : <code class="type">(string -> 'a) -> ('b, unit, string, 'a) Pervasives.format4 -> 'b</code></pre><div class="info ">
<span class="warning">Deprecated.</span>This is a deprecated synonym for <code class="code">ksprintf</code>.<br>
</div>
<br>
<h6 id="6_Aboutformats">About formats</h6>
<p>

   You only need to read this if you intend to create your new printf-like functions,
   which happens generally by toying with <code class="code">mkprintf</code>.
<p>

   <div class="h7" id="7_Format4">Format4</div>
<p>

   <code class="code">(<span class="keywordsign">'</span>a, <span class="keywordsign">'</span>b, <span class="keywordsign">'</span>c, <span class="keywordsign">'</span>d) format4</code> is the type of arguments for
   <code class="code">printf</code>-style functions such that<ul>
<li><code class="code"><span class="keywordsign">'</span>a</code> is the type of arguments, with a return type of <code class="code"><span class="keywordsign">'</span>d</code>
   <ul>
<li>if your format looks like <code class="code"><span class="string">"%s"</span></code>, <code class="code"><span class="keywordsign">'</span>a</code> is <code class="code">string <span class="keywordsign">-&gt;</span> <span class="keywordsign">'</span>d</code></li>
<li>if your format looks like <code class="code"><span class="string">"%s%s"</span></code>, <code class="code"><span class="keywordsign">'</span>a</code> is <code class="code">string <span class="keywordsign">-&gt;</span> string <span class="keywordsign">-&gt;</span> <span class="keywordsign">'</span>d</code></li>
<li>...</li>
</ul>
</li>
<li><code class="code"><span class="keywordsign">'</span>b</code> is the type of the first argument given to unparsers
   (i.e. functions introduced with <code class="code">%a</code> or <code class="code">%t</code>)
   <ul>
<li>if your unparsers take a <code class="code">unit</code> argument, <code class="code"><span class="keywordsign">'</span>b</code> should be
   <code class="code">unit</code></li>
<li>if your unparsers take a <code class="code">string output</code>, <code class="code"><span class="keywordsign">'</span>b</code> should be
   <code class="code">string output</code></li>
<li>...</li>
</ul>
</li>
<li><code class="code"><span class="keywordsign">'</span>c</code> is the <b>final</b> return type of unparsers
   <ul>
<li>if you have an unparser introduced with <code class="code">%t</code> and its result
   has type <code class="code">unit</code>, <code class="code"><span class="keywordsign">'</span>c</code> should be <code class="code">unit</code></li>
<li>if you have an unparser introduced with <code class="code">%a</code> and its type is
   <code class="code">string output <span class="keywordsign">-&gt;</span> string <span class="keywordsign">-&gt;</span> unit</code>, <code class="code"><span class="keywordsign">'</span>c</code> should be <code class="code">unit</code></li>
<li>...</li>
</ul>
</li>
<li><code class="code"><span class="keywordsign">'</span>d</code> is the final return value of the function once all
   arguments have been printed</li>
</ul>

   <div class="h7" id="7_Format">Format</div>
   <code class="code">(<span class="keywordsign">'</span>a, <span class="keywordsign">'</span>b, <span class="keywordsign">'</span>c) format</code> or <code class="code">(<span class="keywordsign">'</span>a, <span class="keywordsign">'</span>b, <span class="keywordsign">'</span>c) t</code> is just a shortcut for <code class="code">(<span class="keywordsign">'</span>a, <span class="keywordsign">'</span>b, <span class="keywordsign">'</span>c, <span class="keywordsign">'</span>c) format4</code>.
<p>

   <div class="h7" id="7_Important">Important</div>
   Note that <code class="code"><span class="constructor">Obj</span>.magic</code> is involved behind this, so be careful.<br>
</body></html>