Higher-order abstract syntax and a simple inlining pass #965
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 PR adds a very simple version of higher-order abstract syntax, intended to make the construction of lean, easy-to-read ASTs simpler. The idea is to add a new term that semantically is the same as
TmLam, except it's represented by an actual function. This function is allowed to do whatever it wants whenever it's given an argument, with two (necessarily unenforced) restrictions:The PR also contains a simple inlining pass built on these terms, that simply finds all
let-bindings that are referred exactly once and inlines them.However, there are a number of design questions to consider before merging (hence draft):
TempLamandTempFixnodes currently only store their functions. This is enough to construct ASTs, but not to, e.g., calltyTm,infoTm, or any of the related setters. We could implement them by actually calling the functions with fabricated arguments, which is how pretty printing works, but it might mess with the intuition thattyTmandinfoTmare cheap functions.let-bound values may be polymorphic.x?