View Source cure_pattern_checker (cure v0.7.0)

Summary

Functions

Check if patterns are exhaustive for a given type

Check a match expression for exhaustiveness and redundancy

Check for redundant (unreachable) patterns

Format a diagnostic message for display

Suggest missing patterns for incomplete matches

Types

ast_pattern/0

-type ast_pattern() :: term().

pattern_diagnostic/0

-type pattern_diagnostic() ::
          {exhaustive} |
          {incomplete, [ast_pattern()], string()} |
          {redundant, [integer()], string()} |
          {error, term()}.

Functions

check_exhaustiveness(Patterns, Type)

-spec check_exhaustiveness([ast_pattern()], Type :: term()) -> pattern_diagnostic().

Check if patterns are exhaustive for a given type

check_match(MatchExpr, Env)

-spec check_match(MatchExpr :: term(), Env :: map()) -> pattern_diagnostic().

Check a match expression for exhaustiveness and redundancy

check_redundancy(Patterns, Type)

-spec check_redundancy([ast_pattern()], Type :: term()) -> pattern_diagnostic() | ok.

Check for redundant (unreachable) patterns

format_diagnostic(_)

-spec format_diagnostic(pattern_diagnostic()) -> string().

Format a diagnostic message for display

suggest_missing_patterns(Patterns, Type)

-spec suggest_missing_patterns([ast_pattern()], Type :: term()) -> [ast_pattern()] | {error, term()}.

Suggest missing patterns for incomplete matches