-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a simple exhaustiveness checker 🧐 #47
Conversation
06b137d
to
f785e55
Compare
for (ideal_argument, clause_argument) in ideal_arguments.iter().zip(clause_arguments) { | ||
if let Some(arg_subst) = has_subst(supply, ideal_argument, clause_argument)? { | ||
subst.extend(arg_subst) | ||
} else { | ||
return Ok(None); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note (to self): got stuck on this bit for a while as the typeclass-y Haskell logic wasn't that obvious...
mconcat <$> (sequence (zipWith hasSubst pats1 pats2))
f785e55
to
4662407
Compare
Codecov Report
@@ Coverage Diff @@
## main #47 +/- ##
==========================================
+ Coverage 76.88% 77.70% +0.82%
==========================================
Files 109 111 +2
Lines 6948 7195 +247
==========================================
+ Hits 5342 5591 +249
+ Misses 1606 1604 -2
Continue to review full report at Codecov.
|
4662407
to
2aaf1c2
Compare
Some(coverage::Error::NotCovered(ideal_patterns)) => { | ||
let mut missing_patterns = ideal_patterns | ||
.into_iter() | ||
.map(|ideal_pattern| ideal_pattern.render()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm tempted to surround the rendered pattern in backticks to make it clearer that it's code (rather than prose) but that might be too visually noisy?
9cb45c5
to
0ece521
Compare
More or less a verbatim Rust port of this blog post.
Raises an error for missing patterns, and raises warnings for redundant patterns.
Note that currently the Ditto pattern syntax consists only of constructors and variables:
ditto/crates/ditto-ast/src/expression.rs
Lines 347 to 382 in 2304f8b
But this logic will get more elaborate once we add more pattern variants (e.g. #16).