-
Notifications
You must be signed in to change notification settings - Fork 61
Sort-dependent expansion for Modules #2075
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
Open
disconcision
wants to merge
13
commits into
probe-III
Choose a base branch
from
sorted-insertion
base: probe-III
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+192
−103
Conversation
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
When inserting a tile, select a mold appropriate for the local sort context rather than just taking the first available mold. This prevents wrong-sort molds (e.g., Exp mold for `-` in a Pat context) from being assigned during insertion. - Form.Molds: split into get_base, try_get (strict), try_get_permissive, and get (with fallback). Strict filtering for remolding, permissive for insertion (allows wrong-sort multi-delimiter forms to expand) - Relatives.sort: compute local sort at insertion point from left sibling's right nib (handles heterogeneous infix like `:`) - Insert.re: use sort-aware Form.Molds.get - Segment.remold_tile: use strict try_get - Ancestor.re: remove unused functions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Expansion now considers sort context when deciding how to expand delimiters. This prevents wrong-sort expansions (e.g., `let` expanding in Pat context) and enables sort-specific forms (e.g., `[` expanding to ListLitPat vs ListLitExp based on context). Key changes: - Form.re: Register expansions using nib sort (the context you're typing in) rather than mold.out (what the form produces). Rul context is permissive and falls back to any expansion since rules contain Exp/Pat operands but have no operand forms of their own. - Insert.re: Handle `|` entirely here when inside case expressions, bypassing sort-specific lookup. This is needed because ascriptions (expr : Type) have Typ right nib even though they produce Exp. - TyDiForms.re: Pass sort to Form.Expansion.get. See plans/sort-specific-expansion.md for detailed analysis of the case/rule structure and known limitations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## probe-III #2075 +/- ##
=============================================
+ Coverage 50.08% 50.24% +0.15%
=============================================
Files 229 229
Lines 25437 25455 +18
=============================================
+ Hits 12741 12789 +48
+ Misses 12696 12666 -30
🚀 New features to boost your workflow:
|
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Draft
Member
Author
|
Subsumed by #2075. |
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.
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)