Sort-dependent expansion for Modules #2075
Open
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 implemented sort-dependent expansion. Multi-delimiter forms now only expand when inserted in an appropriate sort context. This is a slightly subtle notion; it currently means that the nearest leftward non-secondary piece has a nib of the appropriate sort. This has a complex but well-tested special case around case rules.
The new functionality is demonstrated below by creating four new forms of pattern sort. They are patterns because I didn't want to bother creating a new sort, but are intended to be representative of what we'd need to implement module syntax. The
letandtypeforms below reuseExpkeywords, but now in a pattern context they expand different.;is an infix operator below, not a trailing delimiter. AFAICT this suffices to implement module syntax; see appendix below.Appendix:
Example of module syntax which the above enables:
Required for modules: 2 new sorts:
ModandSigand 8 new forms:Remaining issues:
letinto a regularletor vice versa you'll need to delete all delimiters. Getting this to work is a larger change; I'm not sure on a good approach. Copy-paste could be hacked to work somewhat straightforwardly though (just skip the clipboard cache for segments containing forms with multiple expansions)