<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="AsciiDoc 8.6.8">
<title>OptionalArguments</title>
<link rel="stylesheet" href="./asciidoc.css" type="text/css">
<link rel="stylesheet" href="./pygments.css" type="text/css">


<script type="text/javascript" src="./asciidoc.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
asciidoc.install();
/*]]>*/
</script>
<link rel="stylesheet" href="./mlton.css" type="text/css"/>
</head>
<body class="article">
<div id="banner">
<div id="banner-home">
<a href="./Home">MLton 20130715</a>
</div>
</div>
<div id="header">
<h1>OptionalArguments</h1>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="paragraph"><p><a href="StandardML">Standard ML</a> does not have built-in support for optional
arguments.  Nevertheless, using <a href="Fold">Fold</a>, it is easy to define
functions that take optional arguments.</p></div>
<div class="paragraph"><p>For example, suppose that we have the following definition of a
function <span class="monospaced">f</span>.</p></div>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span class="k">fun</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="p">,</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="n">s</span><span class="p">)</span><span class="w"> </span><span class="p">=</span><span class="w"></span>
<span class="w">   </span><span class="n">concat</span><span class="w"> </span><span class="p">[</span><span class="n">Int</span><span class="p">.</span><span class="n">toString</span><span class="w"> </span><span class="n">i</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;, &quot;</span><span class="p">,</span><span class="w"> </span><span class="n">Real</span><span class="p">.</span><span class="n">toString</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;, &quot;</span><span class="p">,</span><span class="w"> </span><span class="n">s</span><span class="p">]</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>Using the <span class="monospaced">OptionalArg</span> structure described below, we can define a
function <span class="monospaced">f'</span>, an optionalized version of <span class="monospaced">f</span>, that takes 0, 1, 2, or
3 arguments.  Embedded within <span class="monospaced">f'</span> will be default values for <span class="monospaced">i</span>,
<span class="monospaced">r</span>, and <span class="monospaced">s</span>.  If <span class="monospaced">f'</span> gets no arguments, then all the defaults are
used.  If <span class="monospaced">f'</span> gets one argument, then that will be used for <span class="monospaced">i</span>.  Two
arguments will be used for <span class="monospaced">i</span> and <span class="monospaced">r</span> respectively.  Three arguments
will override all default values.  Calls to <span class="monospaced">f'</span> will look like the
following.</p></div>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span class="n">f&#39;</span><span class="w"> </span><span class="n">$</span><span class="w"></span>
<span class="n">f&#39;</span><span class="w"> </span><span class="n">`</span><span class="mi">2</span><span class="w"> </span><span class="n">$</span><span class="w"></span>
<span class="n">f&#39;</span><span class="w"> </span><span class="n">`</span><span class="mi">2</span><span class="w"> </span><span class="n">`</span><span class="mf">3.0</span><span class="w"> </span><span class="n">$</span><span class="w"></span>
<span class="n">f&#39;</span><span class="w"> </span><span class="n">`</span><span class="mi">2</span><span class="w"> </span><span class="n">`</span><span class="mf">3.0</span><span class="w"> </span><span class="n">`</span><span class="s">&quot;four&quot;</span><span class="w"> </span><span class="n">$</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>The optional argument indicator, <span class="monospaced">&grave;</span>, is not special syntax ---
it is a normal SML value, defined in the <span class="monospaced">OptionalArg</span> structure
below.</p></div>
<div class="paragraph"><p>Here is the definition of <span class="monospaced">f'</span> using the <span class="monospaced">OptionalArg</span> structure, in
particular, <span class="monospaced">OptionalArg.make</span> and <span class="monospaced">OptionalArg.D</span>.</p></div>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span class="k">val</span><span class="w"> </span><span class="n">f&#39;</span><span class="w"> </span><span class="p">=</span><span class="w"></span>
<span class="w">   </span><span class="k">fn</span><span class="w"> </span><span class="n">z</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"></span>
<span class="w">   </span><span class="k">let</span><span class="w"> </span><span class="k">open</span><span class="w"> </span><span class="n">OptionalArg</span><span class="w"> </span><span class="k">in</span><span class="w"></span>
<span class="w">      </span><span class="n">make</span><span class="w"> </span><span class="p">(</span><span class="n">D</span><span class="w"> </span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="p">(</span><span class="n">D</span><span class="w"> </span><span class="mf">2.0</span><span class="p">)</span><span class="w"> </span><span class="p">(</span><span class="n">D</span><span class="w"> </span><span class="s">&quot;three&quot;</span><span class="p">)</span><span class="w"> </span><span class="n">$</span><span class="w"></span>
<span class="w">   </span><span class="k">end</span><span class="w"> </span><span class="p">(</span><span class="k">fn</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="n">&amp;</span><span class="w"> </span><span class="n">r</span><span class="w"> </span><span class="n">&amp;</span><span class="w"> </span><span class="n">s</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="p">,</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="w"> </span><span class="n">s</span><span class="p">))</span><span class="w"></span>
<span class="w">   </span><span class="n">z</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>The definition of <span class="monospaced">f'</span> is eta expanded as with all uses of fold.  A
call to <span class="monospaced">OptionalArg.make</span> is supplied with a variable number of
defaults (in this case, three), the end-of-arguments terminator, <span class="monospaced">$</span>,
and the function to run, taking its arguments as an n-ary
<a href="ProductType">product</a>.  In this case, the function simply converts
the product to an ordinary tuple and calls <span class="monospaced">f</span>.  Often, the function
body will simply be written directly.</p></div>
<div class="paragraph"><p>In general, the definition of an optional-argument function looks like
the following.</p></div>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span class="k">val</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="p">=</span><span class="w"></span>
<span class="w">   </span><span class="k">fn</span><span class="w"> </span><span class="n">z</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"></span>
<span class="w">   </span><span class="k">let</span><span class="w"> </span><span class="k">open</span><span class="w"> </span><span class="n">OptionalArg</span><span class="w"> </span><span class="k">in</span><span class="w"></span>
<span class="w">      </span><span class="n">make</span><span class="w"> </span><span class="p">(</span><span class="n">D</span><span class="w"> </span><span class="n">&lt;default1&gt;</span><span class="p">)</span><span class="w"> </span><span class="p">(</span><span class="n">D</span><span class="w"> </span><span class="n">&lt;default2&gt;</span><span class="p">)</span><span class="w"> </span><span class="p">...</span><span class="w"> </span><span class="p">(</span><span class="n">D</span><span class="w"> </span><span class="n">&lt;defaultn&gt;</span><span class="p">)</span><span class="w"> </span><span class="n">$</span><span class="w"></span>
<span class="w">   </span><span class="k">end</span><span class="w"> </span><span class="p">(</span><span class="k">fn</span><span class="w"> </span><span class="n">x1</span><span class="w"> </span><span class="n">&amp;</span><span class="w"> </span><span class="n">x2</span><span class="w"> </span><span class="n">&amp;</span><span class="w"> </span><span class="p">...</span><span class="w"> </span><span class="n">&amp;</span><span class="w"> </span><span class="n">xn</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"></span>
<span class="w">        </span><span class="n">&lt;function</span><span class="w"> </span><span class="n">code</span><span class="w"> </span><span class="n">goes</span><span class="w"> </span><span class="n">here&gt;</span><span class="p">)</span><span class="w"></span>
<span class="w">   </span><span class="n">z</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>Here is the definition of <span class="monospaced">OptionalArg</span>.</p></div>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span class="k">structure</span><span class="w"> </span><span class="n">OptionalArg</span><span class="w"> </span><span class="p">=</span><span class="w"></span>
<span class="w">   </span><span class="k">struct</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">make</span><span class="w"> </span><span class="p">=</span><span class="w"></span>
<span class="w">         </span><span class="k">fn</span><span class="w"> </span><span class="n">z</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"></span>
<span class="w">         </span><span class="n">Fold</span><span class="p">.</span><span class="n">fold</span><span class="w"></span>
<span class="w">         </span><span class="p">((</span><span class="n">id</span><span class="p">,</span><span class="w"> </span><span class="k">fn</span><span class="w"> </span><span class="p">(</span><span class="n">f</span><span class="p">,</span><span class="w"> </span><span class="n">x</span><span class="p">)</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="n">x</span><span class="p">),</span><span class="w"></span>
<span class="w">          </span><span class="k">fn</span><span class="w"> </span><span class="p">(</span><span class="n">d</span><span class="p">,</span><span class="w"> </span><span class="n">r</span><span class="p">)</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"> </span><span class="k">fn</span><span class="w"> </span><span class="n">func</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"></span>
<span class="w">          </span><span class="n">Fold</span><span class="p">.</span><span class="n">fold</span><span class="w"> </span><span class="p">((</span><span class="n">id</span><span class="p">,</span><span class="w"> </span><span class="n">d</span><span class="w"> </span><span class="p">()),</span><span class="w"> </span><span class="k">fn</span><span class="w"> </span><span class="p">(</span><span class="n">f</span><span class="p">,</span><span class="w"> </span><span class="n">d</span><span class="p">)</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"></span>
<span class="w">                     </span><span class="k">let</span><span class="w"></span>
<span class="w">                        </span><span class="k">val</span><span class="w"> </span><span class="n">d</span><span class="w"> </span><span class="n">&amp;</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">r</span><span class="w"> </span><span class="p">(</span><span class="n">id</span><span class="p">,</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="n">d</span><span class="p">)</span><span class="w"></span>
<span class="w">                     </span><span class="k">in</span><span class="w"></span>
<span class="w">                        </span><span class="n">func</span><span class="w"> </span><span class="n">d</span><span class="w"></span>
<span class="w">                     </span><span class="k">end</span><span class="p">))</span><span class="w"></span>
<span class="w">         </span><span class="n">z</span><span class="w"></span>

<span class="w">      </span><span class="k">fun</span><span class="w"> </span><span class="n">D</span><span class="w"> </span><span class="n">d</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">Fold</span><span class="p">.</span><span class="n">step0</span><span class="w"> </span><span class="p">(</span><span class="k">fn</span><span class="w"> </span><span class="p">(</span><span class="n">f</span><span class="p">,</span><span class="w"> </span><span class="n">r</span><span class="p">)</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"></span>
<span class="w">                            </span><span class="p">(</span><span class="k">fn</span><span class="w"> </span><span class="n">ds</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="p">(</span><span class="n">d</span><span class="w"> </span><span class="n">&amp;</span><span class="w"> </span><span class="n">ds</span><span class="p">),</span><span class="w"></span>
<span class="w">                             </span><span class="k">fn</span><span class="w"> </span><span class="p">(</span><span class="n">f</span><span class="p">,</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="n">&amp;</span><span class="w"> </span><span class="n">b</span><span class="p">)</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"> </span><span class="n">r</span><span class="w"> </span><span class="p">(</span><span class="k">fn</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="n">&amp;</span><span class="w"> </span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="p">)))</span><span class="w"></span>

<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">`</span><span class="w"> </span><span class="p">=</span><span class="w"></span>
<span class="w">         </span><span class="k">fn</span><span class="w"> </span><span class="n">z</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"></span>
<span class="w">         </span><span class="n">Fold</span><span class="p">.</span><span class="n">step1</span><span class="w"> </span><span class="p">(</span><span class="k">fn</span><span class="w"> </span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="n">f</span><span class="p">,</span><span class="w"> </span><span class="p">_</span><span class="w"> </span><span class="n">&amp;</span><span class="w"> </span><span class="n">d</span><span class="p">))</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"> </span><span class="p">(</span><span class="k">fn</span><span class="w"> </span><span class="n">d</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="p">(</span><span class="n">x</span><span class="w"> </span><span class="n">&amp;</span><span class="w"> </span><span class="n">d</span><span class="p">),</span><span class="w"> </span><span class="n">d</span><span class="p">))</span><span class="w"></span>
<span class="w">         </span><span class="n">z</span><span class="w"></span>
<span class="w">   </span><span class="k">end</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p><span class="monospaced">OptionalArg.make</span> uses a nested fold.  The first <span class="monospaced">fold</span> accumulates
the default values in a product, associated to the right, and a
reversal function that converts a product (of the same arity as the
number of defaults) from right associativity to left associativity.
The accumulated defaults are used by the second fold, which recurs
over the product, replacing the appropriate component as it encounters
optional arguments.  The second fold also constructs a "fill"
function, <span class="monospaced">f</span>, that is used to reconstruct the product once the
end-of-arguments is reached.  Finally, the finisher reconstructs the
product and uses the reversal function to convert the product from
right associative to left associative, at which point it is passed to
the user-supplied function.</p></div>
<div class="paragraph"><p>Much of the complexity comes from the fact that while recurring over a
product from left to right, one wants it to be right-associative,
e.g., look like</p></div>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span class="n">a</span><span class="w"> </span><span class="n">&amp;</span><span class="w"> </span><span class="p">(</span><span class="n">b</span><span class="w"> </span><span class="n">&amp;</span><span class="w"> </span><span class="p">(</span><span class="n">c</span><span class="w"> </span><span class="n">&amp;</span><span class="w"> </span><span class="n">d</span><span class="p">))</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>but the user function in the end wants the product to be left
associative, so that the product argument pattern can be written
without parentheses (since <span class="monospaced">&amp;</span> is left associative).</p></div>
</div>
</div>
<div class="sect1">
<h2 id="_labelled_optional_arguments">Labelled optional arguments</h2>
<div class="sectionbody">
<div class="paragraph"><p>In addition to the positional optional arguments described above, it
is sometimes useful to have labelled optional arguments.  These allow
one to define a function, <span class="monospaced">f</span>, with defaults, say <span class="monospaced">a</span> and <span class="monospaced">b</span>.  Then,
a caller of <span class="monospaced">f</span> can supply values for <span class="monospaced">a</span> and <span class="monospaced">b</span> by name.  If no
value is supplied then the default is used.</p></div>
<div class="paragraph"><p>Labelled optional arguments are a simple extension of
<a href="FunctionalRecordUpdate">FunctionalRecordUpdate</a> using post composition.  Suppose, for
example, that one wants a function <span class="monospaced">f</span> with labelled optional
arguments <span class="monospaced">a</span> and <span class="monospaced">b</span> with default values <span class="monospaced">0</span> and <span class="monospaced">0.0</span> respectively.
If one has a functional-record-update function <span class="monospaced">updateAB</span> for records
with <span class="monospaced">a</span> and <span class="monospaced">b</span> fields, then one can define <span class="monospaced">f</span> in the following way.</p></div>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span class="k">val</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="p">=</span><span class="w"></span>
<span class="w">   </span><span class="k">fn</span><span class="w"> </span><span class="n">z</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"></span>
<span class="w">   </span><span class="n">Fold</span><span class="p">.</span><span class="n">post</span><span class="w"></span>
<span class="w">   </span><span class="p">(</span><span class="n">updateAB</span><span class="w"> </span><span class="p">{</span><span class="n">a</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="mf">0.0</span><span class="p">},</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span><span class="w"> </span><span class="p">{</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="p">}</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"> </span><span class="n">print</span><span class="w"> </span><span class="p">(</span><span class="n">concat</span><span class="w"> </span><span class="p">[</span><span class="n">Int</span><span class="p">.</span><span class="n">toString</span><span class="w"> </span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="s">&quot; &quot;</span><span class="p">,</span><span class="w"></span>
<span class="w">                                </span><span class="n">Real</span><span class="p">.</span><span class="n">toString</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">]))</span><span class="w"></span>
<span class="w">   </span><span class="n">z</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>The idea is that <span class="monospaced">f</span> is the post composition (using <span class="monospaced">Fold.post</span>) of
the actual code for the function with a functional-record updater that
starts with the defaults.</p></div>
<div class="paragraph"><p>Here are some example calls to <span class="monospaced">f</span>.</p></div>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span class="k">val</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="n">$</span><span class="w"></span>
<span class="k">val</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="p">(</span><span class="n">U</span><span class="p">#</span><span class="n">a</span><span class="w"> </span><span class="mi">13</span><span class="p">)</span><span class="w"> </span><span class="n">$</span><span class="w"></span>
<span class="k">val</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="p">(</span><span class="n">U</span><span class="p">#</span><span class="n">a</span><span class="w"> </span><span class="mi">13</span><span class="p">)</span><span class="w"> </span><span class="p">(</span><span class="n">U</span><span class="p">#</span><span class="n">b</span><span class="w"> </span><span class="mf">17.5</span><span class="p">)</span><span class="w"> </span><span class="n">$</span><span class="w"></span>
<span class="k">val</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="p">(</span><span class="n">U</span><span class="p">#</span><span class="n">b</span><span class="w"> </span><span class="mf">17.5</span><span class="p">)</span><span class="w"> </span><span class="p">(</span><span class="n">U</span><span class="p">#</span><span class="n">a</span><span class="w"> </span><span class="mi">13</span><span class="p">)</span><span class="w"> </span><span class="n">$</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>Notice that a caller can supply neither of the arguments, either of
the arguments, or both of the arguments, and in either order.  All
that matter is that the arguments be labelled correctly (and of the
right type, of course).</p></div>
<div class="paragraph"><p>Here is another example.</p></div>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span class="k">val</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="p">=</span><span class="w"></span>
<span class="w">   </span><span class="k">fn</span><span class="w"> </span><span class="n">z</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"></span>
<span class="w">   </span><span class="n">Fold</span><span class="p">.</span><span class="n">post</span><span class="w"></span>
<span class="w">   </span><span class="p">(</span><span class="n">updateBCD</span><span class="w"> </span><span class="p">{</span><span class="n">b</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="mf">0.0</span><span class="p">,</span><span class="w"> </span><span class="n">d</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="s">&quot;&lt;&gt;&quot;</span><span class="p">},</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span><span class="w"> </span><span class="p">{</span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="n">c</span><span class="p">,</span><span class="w"> </span><span class="n">d</span><span class="p">}</span><span class="w"> </span><span class="p">=&gt;</span><span class="w"></span>
<span class="w">    </span><span class="n">print</span><span class="w"> </span><span class="p">(</span><span class="n">concat</span><span class="w"> </span><span class="p">[</span><span class="n">Int</span><span class="p">.</span><span class="n">toString</span><span class="w"> </span><span class="n">b</span><span class="p">,</span><span class="w"> </span><span class="s">&quot; &quot;</span><span class="p">,</span><span class="w"></span>
<span class="w">                   </span><span class="n">Real</span><span class="p">.</span><span class="n">toString</span><span class="w"> </span><span class="n">c</span><span class="p">,</span><span class="w"> </span><span class="s">&quot; &quot;</span><span class="p">,</span><span class="w"></span>
<span class="w">                   </span><span class="n">d</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">]))</span><span class="w"></span>
<span class="w">   </span><span class="n">z</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>Here are some example calls.</p></div>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span class="k">val</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="n">$</span><span class="w"></span>
<span class="k">val</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="p">(</span><span class="n">U</span><span class="p">#</span><span class="n">d</span><span class="w"> </span><span class="s">&quot;goodbye&quot;</span><span class="p">)</span><span class="w"> </span><span class="n">$</span><span class="w"></span>
<span class="k">val</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">=</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="p">(</span><span class="n">U</span><span class="p">#</span><span class="n">d</span><span class="w"> </span><span class="s">&quot;hello&quot;</span><span class="p">)</span><span class="w"> </span><span class="p">(</span><span class="n">U</span><span class="p">#</span><span class="n">b</span><span class="w"> </span><span class="mi">17</span><span class="p">)</span><span class="w"> </span><span class="p">(</span><span class="n">U</span><span class="p">#</span><span class="n">c</span><span class="w"> </span><span class="mf">19.3</span><span class="p">)</span><span class="w"> </span><span class="n">$</span><span class="w"></span>
</pre></div></div></div>
</div>
</div>
</div>
<div id="footnotes"><hr></div>
<div id="footer">
<div id="footer-text">
</div>
<div id="footer-badges">
</div>
</div>
</body>
</html>
