I'm learning ML, can somebody please explain what does it mean exhaustive patterns?
A pattern match is exhaustive if it can not fail. I.e. all cases that could possibly occur are covered by a pattern.
For example the following pattern match is not exhaustive because it doesn't cover the case that the list is empty:
fun sum (x::xs) = x + sum xs
The following is exhaustive because both cases are covered:
fun sum (x::xs) = x + sum xs
| sum [] = 0
Generally a pattern match on an algebraic data type is exhaustive if and only if there is a default case or there is a case for all constructors and the match for each sub-pattern is exhaustive.