Skip to content


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
<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
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
Jump to Line
Something went wrong with that request. Please try again.