What Is Exhaustiveness Checking?
Exhaustiveness checking is a static analysis that ensures a set of patterns covers all possible values of the type being matched, reporting an error when a case is left out. For a sum type, it confirms every variant is handled. This catches forgotten cases before the code runs.
Why it matters
Exhaustiveness checks turn "I forgot to handle that case" into a compile error rather than a runtime surprise. They are especially valuable when a new variant is added, since every incomplete match then fails to compile.
Related guides
What Is Pattern Matching?Pattern matching inspects a value against a set of shapes, selecting a branch and binding parts of the value…
What Is a Sum Type?A sum type holds a value that is exactly one of several named alternatives, each potentially carrying differe…
What Is an Algebraic Data Type?An algebraic data type composes types as combinations of fields and alternatives, modeling data as products a…