<?xml version="1.0" encoding='utf-8'?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Standard ML - Page 14 - Wikipedia">
<p>
<a accesskey="1" href="page.php?w=Standard_ML&amp;p=13">1.Previous</a><br />
<a accesskey="3" href="page.php?w=Standard_ML&amp;p=15">3.Next</a>
</p>
<p>are defined as patterns, is merely <a href="page.php?w=syntactic_sugar">syntactic sugar</a> for a case expression:</p>

<p><syntaxhighlight lang="sml">fun area shape = case shape of    Circle (_, r) => Math.pi * square r  | Square (_, s) => square s  | Triangle p => heron p</syntaxhighlight></p>

<p><big>Exhaustiveness checking</big></p>
<p>Pattern-exhaustiveness checking will make sure that each constructor of the datatype is matched by at least one pattern. </p>

<p>The following pattern is not exhaustive:</p>

<p><syntaxhighlight lang="sml">fun center (Circle (c, _)) = c  | center (Square ((x, y), s)) = (x + s / 2.0, y + s / 2.0)</syntaxhighlight></p><p>
<a accesskey="1" href="page.php?w=Standard_ML&amp;p=13">1.Previous</a><br />
<a accesskey="3" href="page.php?w=Standard_ML&amp;p=15">3.Next</a>
</p>

<do type="prev" label="Search">
        <go href="search.wml"/>
</do>

</card>
</wml>
