Generalizing check_local_application_complete#2818
Merged
Conversation
1fb2284 to
654e74d
Compare
Collaborator
As discussed offline, making this a warning makes things order dependent, so it's best to go back to an error. |
654e74d to
6885bb8
Compare
6885bb8 to
9c965ba
Compare
lukemaurer
pushed a commit
to lukemaurer/flambda-backend
that referenced
this pull request
Oct 23, 2024
This file contains hidden or 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
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.
Background
Consider the example below - what should be the type for
f?Ideally it should be something like
g:(x @ local -> x -> y) -> x -> y. (Bothxandyare both types and variables names, for easier reading). Note thatgcould also be of typex @ local -> (x -> y), but this is undesirable because it has extra parentheses. However, for printing and generatingmli-less.cmifiles, the defaulting will push modes on arrows to legacy (global), giving the undesirable type.The original
check_local_application_completesolves this problem by enforcing currying constraint in a single application. For the above example,xbeinglocalforces the partially-appliedg xto belocalas well.The improvement
This PR does two things:
The function was intended only for the locality axis, for which
mode_fun <= mode_retandmode_arg <= mode_ret. In general we have monadic and comonadic axes, for which the constraints should bepartial_apply mode_fun <= mode_retandclose_over mode_arg <= mode_ret.The constraint is not for soundness but just for better types. Therefore, failed constraints should be warning instead of error.
Please review by commits.