Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 86f8d60c78
Fetching contributors…

Cannot retrieve contributors at this time

23 lines (17 sloc) 0.625 kb
<h3>Exhaustiveness</h3>
<p>One of the benefit of pattern-matching is the exhaustiveness check
done by the compiler statically. Indeed, the OCaml compiler can
verify that all the cases are handled. For instance, when
pattern-matching on a list, the compiler will warn
the user if she forgets to handle the empty list case:
<pre><code>let head_partial = function
| h::_ -> h
</code></pre>
Moreover, the compiler will also warm the user when a case is handled
multiple times or when a case is unused:
<pre><code>let head = function
| [] -> failwith "empty list"
| h::_ -> h
| [h] -> h
</code></pre>
</p>
Jump to Line
Something went wrong with that request. Please try again.