-
Notifications
You must be signed in to change notification settings - Fork 52
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
Case expression exhaustiveness & redundancy checking #1114
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Conflicts: # INSTALL.md # src/haz3lcore/dynamics/Builtins.re # src/haz3lcore/dynamics/Builtins.rei # src/haz3lcore/dynamics/DH.re # src/haz3lcore/dynamics/Elaborator.re # src/haz3lcore/dynamics/Evaluator.re # src/haz3lcore/dynamics/EvaluatorPost.re # src/haz3lcore/dynamics/InvalidOperationError.rei # src/haz3lcore/lang/Form.re # src/haz3lcore/statics/Ctx.re # src/haz3lcore/statics/Info.re # src/haz3lcore/statics/MakeTerm.re # src/haz3lcore/statics/Mode.re # src/haz3lcore/statics/Self.re # src/haz3lcore/statics/Statics.re # src/haz3lcore/statics/Term.re # src/haz3lcore/statics/Typ.re # src/haz3lcore/statics/TypBase.re # src/haz3lcore/tiles/Segment.re # src/haz3lweb/Init.ml # src/haz3lweb/Keyboard.re # src/haz3lweb/Log.re # src/haz3lweb/Store.re # src/haz3lweb/Update.re # src/haz3lweb/UpdateAction.re # src/haz3lweb/view/CtxInspector.re # src/haz3lweb/view/CursorInspector.re # src/haz3lweb/view/EditorModeView.re # src/haz3lweb/view/ScratchMode.re # src/haz3lweb/view/Type.re # src/haz3lweb/view/dhcode/DHCode.re # src/haz3lweb/www/style.css
cyrus-
reviewed
May 14, 2024
src/haz3lcore/statics/TypBase.re
Outdated
id: Id.t, | ||
typ: Typ.t, | ||
/* Temporary variables. Better implementation is a TO-DO. */ | ||
nth: int, |
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.
same here
cyrus-
approved these changes
May 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request aims to implement the exhaustiveness checking feature mentioned in Live Pattern Matching with Typed Holes.
If a
case
expression is necessarily inexhaustive (i.e.: the expression will necessarily fail to match all values of the type of its scrutinee), the expression will be wrapped with an error hole like in Fig. 2b in the paper. This is planned to be done by introducing a newerror_exp
calledInexhaustiveMatch
(tentative), which behaves uniquely when supplied toCursorInspector.re
. Like discussed in #1059, we probably need a correspondingSelf.exp
for the new expression error.Self.match()
might be modified accordingly.Exhaustiveness checking on a
case
expression relies on whether the final constraint for the rules can be entailed from truth (i.e.: all expressions of the type of thecase
expression’s scrutinee “determinately or indeterminately match any of the branches”). This final constraint for the rules is discovered in the process of typing the rules of the match expression, which is to be implemented by applying the sequence of rules to a type generator calledruls_to_info_map
(tentative). It corresponds to the judgment TRules in the paper (ideally).ruls_to_info_map
is going to be based on the list schemeList.fold_left
instead ofList.map
since the info of rules will be dependent on each other in the redundancy checking.The entailment check itself has already been implemented in #1094 as the functionIncon.is_exhaustive
.After checking the exhaustiveness, the branches are yet to be checked for type consistency (should they be in sequential order? Or should two errors show up in the cursor inspector at the same time?) So the output of
ruls_to_info_map
probably contains a list of expression types for branches and the final constraint for the rules.(Karan Anand got involved in editing the proposal)