Exceptions play an important role in the system of static and dynamic checks that make SML a safe language.
Exceptions may cause an evaluation to be interrupted or aborted. (Think of division by 0.)
One simple use of exceptions is to signal that invariants are violated or exceptional boundary cases are encountered.
Exceptions can sometimes also be used in backtracking search procedures or other patterns of control flow where a computation needs to be partially undone. We demonstrated this with an n-Queens implementation. We also showed an implementation of n-Queens based on continuations and another implementation based on options. The code file below contains further variations of these three perspectives.