-
Notifications
You must be signed in to change notification settings - Fork 481
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
Inline trivial lambda bindings, to beta-reduce later on for smaller scripts #4304
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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.
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.
This needs a note. The decision making here is actually quite complicated. We need to think about two things: saving work, and saving space.
In terms of saving work, I think this is fine. We will create the outermost lambda value at each use site instead of once, but that's a pretty small amount of work that I'm fairly okay with rounding to 0 (but we should document that in a note!). Indeed, several of the other cases also require us to do value creation at each use site, although creating lambda values is probably the most expensive kind (not by much).
In terms of saving space, this is riskier. We will duplicate the whole term at each use site. The other cases all relate to terms which are approximately the same size as a variable (except the constant case! which has a worrying TODO on it...). We could make this much safer by actually doing something more like what the GHC inliner does, and conditionally inlining things at call sites if they're fully applied. But this would be much more complicated...
I think for starters this could do with:
costIsAcceptable
andsizeIsAcceptable
. That way it's clearer what they're checking for and we could in principle use them separately if that's appropriate elsewhere. ThenpostInlineUnconditional
can require that both hold.Suggested implementations: