Exhaustiveness Checking とは?
exhaustiveness checking は、一連のパターンが照合対象の型の取りうるすべての値をカバーしていることを保証する静的解析で、ケースが漏れているとエラーを報告します。sum type については、すべての variant が処理されていることを確認します。これにより、コードが実行される前に忘れられたケースを検出します。
なぜ重要か
網羅性チェックは「あのケースを処理し忘れた」を、実行時の不意打ちではなくコンパイルエラーに変えます。新しい variant が追加されたときに特に有用で、不完全な match はすべてコンパイルに失敗するようになります。
関連ガイド
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…