Merge functions based on partiality rather than Parmatch.irrefutable#1195
Merged
gasche merged 1 commit intoocaml:trunkfrom Sep 1, 2017
Merged
Merge functions based on partiality rather than Parmatch.irrefutable#1195gasche merged 1 commit intoocaml:trunkfrom
gasche merged 1 commit intoocaml:trunkfrom
Conversation
Contributor
|
Apart from what's mentioned in #1227 this seems like a strict improvement. |
Contributor
|
(of course it would be nice if @maranget could confirm) |
Member
|
(I don't understand why the CI check for Changes entry passes, but I will assume that this does not need a Change entry, add the label, and merge anyway.) |
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.
translcore.mlmerges together nested functions as long as the parameter is "fluid". This is what gives us a 2 parameter function for things like:but the definition of fluid uses
Parmatch.irrefutablewhich does not use type information. So things like:still gives a function of 1 argument returning a function of 1 argument.
Since the partiality of the match (which does use type information) is already available this patch uses it in place of
Parmatch.irrefutable. I think this is strictly more accurate and safe.Note that there are optimizations in later passes (e.g. simplify) that also attempt to merge functions together. However, these can be quite fragile. For instance, the above case was not merged in 4.03, but this was accidentally fixed in 4.04 for
ocamloptby removing some debugging events. An example, which is not merged on trunk isbarbelow (unlikefoowhich is always merged):