-
Notifications
You must be signed in to change notification settings - Fork 61
Baby Modules #2104
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
Draft
disconcision
wants to merge
76
commits into
dev
Choose a base branch
from
sorted-insertion-modules
base: dev
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.
Draft
Baby Modules #2104
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
Re-add features that were simplified for probemoar merge: Debug/profiling (for development): - WorkerServer.re: Eval timing logging - ScratchMode.re: Round-trip timing - CodeEditable.re: Probe perf profiling UI features: - NutMenu.re: probe_all toggle enabled - ProbeSidebar.re: Full feature set - Probearium/Printarium mode toggle - sketch_view settings panel with all toggles - Full Dynamic Cursor with opacity for items after index - Sample displays in probe list - indicated-call red outline 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
The fold projector's hover view was always rendering code as single-line because simple_code hardcoded is_single_line=true. Now view_seg accepts an optional ~single_line parameter (default false) so FoldProj gets multiline display while ProbeProj and TypeProj explicitly use single-line. Changes: - ProjectorBase.re: Add ~single_line to View.seg type - ProjectorView.re: Pass ~single_line through flex_code and mk_view - ProbeProj.re: Create view_seg_single_line wrapper for probe displays - TypeProj.re: Add ~single_line=true for type display - ProbeSidebar.re: Add ~single_line=true for sidebar displays 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Each legend item now shows an explanatory tooltip on hover, positioned below the legend panel. Also cleans up Language module prefixes in ProbeSidebar. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
When a sample has no environment bindings to display, the context menu actions (Pin/Step into) now stack vertically like a traditional menu instead of horizontally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Merges latest dev changes and resolves conflicts: - ZipperBase.re: Use dev's extracted Refractor module pattern - Editor.re: Keep dev's comment, add auto_def probe handling - Refractors.re (root): Deleted, functionality moved to ProbePerform.re Adds auto_def field to zipper/Refractors.re for auto-probe-follows-cursor feature, which automatically places an auto-probe on the body of whichever top-level definition the cursor is currently inside. Fixes data flow issue where probes would appear but show no samples until an edit was made. The fix detects ephemeral probe changes in CodeWithStatics and triggers statics recalculation, which updates evaluation targets. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
When the cursor is on a secondary (whitespace/comment), the indicated piece has no statics info, causing toplevel_def_body_id to return None. Fix: Fall back to using the parent tile's ID from the zipper's ancestors, which is guaranteed to be a real tile with statics info. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Two new auto-probe behaviors: 1. Test forms: When cursor is inside a test, auto-probe the entire test body. This overrides let behavior, so `test let a = 1 in a pass` with cursor on `a` probes the full test body, not just the let definition. 2. Let delimiter/pattern: When cursor is on the let keyword itself or inside the pattern (not in body), auto-probe the definition. Implementation: - StaticsBase.toplevel_def_body_id: Check for Test/HintedTest as current term or ancestor (priority over Let). Changed Let condition from "cursor in def" to "cursor NOT in body". - ProbePerform.target_subterm_ids: Don't redirect Let→definition when the Let is the body of a Test (so we see test result, not just def). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Rewrote toplevel_def_body_id with a cleaner top-down algorithm: - Walk ancestors from outermost to innermost - For each let, check if child-toward-cursor is the body - If child == body: skip (cursor in body, let doesn't apply) - Otherwise: return that let's def (cursor in def/pattern/on-delimiter) Key insight: the ONLY way to not probe a let's def is if cursor is in its body. Being on the delimiter, pattern, or def all qualify. Fixed edge case: when cursor is directly on a top-level let (no containing let exists), return that let's def as the auto-probe target. Also moved toplevel_def_body_id from StaticsBase.re to ProbePerform.re since it's probe-specific logic, not general statics. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Brings in: - Auto-probe for test forms and let delimiters/patterns - Fix auto-probe disappearing on whitespace/comments - Top-down algorithm for toplevel_def_body_id - Move toplevel_def_body_id from StaticsBase to ProbePerform
…toprobe when active. manual run more for printarium / console log
When a probe (manual or auto) is added, the sample cursor now automatically points to an appropriate sample from that probe once evaluation completes. Uses pending_probe_cursor field to defer until async worker returns results. Picks the lexically first probe with samples and uses closest_to_cursor for conservative sample selection. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- TyDi: min 2-char prefix before showing completions; prioritize keywords over context vars when expected type is unknown - AutoProbe: soft-reject function types (probe if no better alternative) - Elaborator: elaborate first pattern in MultiHole([Pat(p1), ...]) - Abbreviate: show <function> and builtin name instead of <> 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
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]>
When moving to a function definition with auto-probe mode enabled,
the sample cursor wasn't being set correctly - samples appeared blue
until another action was performed.
Fixes:
- CellEditor: Pass ~auto_probe_mode to second pass in calculate to
prevent clear_auto_def from removing the probe
- CellEditor: Force recalculation when pending_probe_cursor is set
during ResultAction handling
- Editor: Call resolve_pending_probe_cursor after update_auto_def_probe
since editor_effects runs before it
Also:
- ProbeSidebar: Shorten toggle labels ("Auto"/"Manual" -> "A"/"M")
- Test: Fix arrow syntax in recursive test case
- TODO: Commented out profiling code in CodeEditable, WorkerServer,
ScratchMode (to be deleted later)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
- New ClosureCursorBar component shows call stack as breadcrumbs - Appears below top bar when probes are active - Click entries to jump to syntax location - Add RecordStackFrame to built-in function applications - Fix grid layout for 4-row structure with sidebars Co-Authored-By: Claude Opus 4.5 <[email protected]>
- plans/modules-phase-1.md: Detailed implementation plan for Phase 1 modules - claude.md: Worktree session tracking for parallel development Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add Mod sort for module-level items - Add module forms: ModBody, ModSeq, ModLet, ModType - Add mk_pre' helper for heterogeneous prefix forms (body sort differs from out) - Add MakeTerm parsing for modules with semicolon sequence flattening - Add remold_mod function with Exp fallback for bare expressions - Add CSS styling for Mod sort (greenish color) - Add Module(list(Mod.t)) to exp_term for module expressions - Add stubs in dynamics/statics for Module expression type Co-Authored-By: Claude Opus 4.5 <[email protected]>
- In Insert.re: When in Mod context and no Mod expansion exists, try Exp (allows if/test/etc forms to expand inside module bodies) - Updated modules-phase-1.md with comprehensive implementation notes: - Heterogeneous prefix forms (mk_pre') - Mod→Exp fallback pattern for remolding and expansion - Sort disambiguation at heterogeneous boundaries - Decision table for sort resolution - Future considerations (universal semicolon, removing CellJoin) - Removed plans/sort-disambiguation-phase-1.1.1.md (content integrated) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Phase 1.2: Module expansion and semantics (ExpandModule.re, Statics, Elaborator) - Phase 1.3: Menhir parser support - Phase 1.4: Comprehensive testing (parsing, statics, dynamics, grammar factory) - Phase 1.5: Polish and exploration (empty module, ExplainThis, other systems) - Phase 1.6: Final report documentation Co-Authored-By: Claude Opus 4.5 <[email protected]>
Module expansion: - ExpandModule.re: Transform module syntax into nested let/type + labeled tuple - Statics.re: Type-check modules by expanding and checking expanded form - Elaborator.re: Elaborate modules directly to expanded form Menhir parser: - AST.re: Add Module and mod_item types - Lexer.mll: Add OPEN_CURLY and CLOSE_CURLY tokens - Parser.mly: Add modItem rule and module expression grammar - Conversion.re: Add ModItem conversion functions - Grammar.re: Add mod_ type alias for Factory module Also includes formatting fixes from dune fmt. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Statics tests: - Empty module - Single and multiple bindings - Shadowing behavior - Type aliases - Bare expressions - Module access via dot notation - Module as labeled tuple Evaluator tests: - Module evaluation to labeled tuple - Access via dot notation - Sequential bindings - Type aliases - Shadowing 2 tests skipped for features not yet fully working: - Nested modules - Module with function binding access All 1446 tests pass. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Mark all implemented phases as complete: - Phase 1.1: Syntax foundation ✅ - Phase 1.2: Module expansion & semantics ✅ - Phase 1.3: Menhir parser ✅ - Phase 1.4: Testing ✅ All 1446 tests pass. 2 tests skipped for features not yet fully working. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Fixes:
- Empty module atomic form: {} now creates atomic EmptyModule token
(like () and []) instead of compound form with hole. Added {} to
Token.is_potential_token and EmptyModule to Form.re atomic forms.
- Singleton labeled tuple pattern bug: Fixed incorrect elaboration
when Var pattern has Unknown synth type. Now only elaborates
(destructures) if pattern name matches the tuple label.
e.g., `let m = (y=1) in m` now correctly has type (y=Int), not Int.
Documentation:
- Added detailed Menhir parser section explaining semicolon ambiguity
(shift-reduce conflict between Seq and module item separator) and
potential fix options (grammar duplication, GLR, lexer hack, etc.)
- Replaced incomplete "Capitalized Names in Patterns" section with
comprehensive "Capitalized Module Names: Design Considerations"
covering both pattern/binding AND expression/reference sides,
with analysis of 5 options and trade-offs. Decision deferred.
Tests:
- All 1461 tests pass
- Added nested module tests to Test_MakeTerm.re
- Expanded statics and evaluator module tests
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Added section explaining why cursor inspector does not work for module items (fresh IDs in expansion) and the solution: preserve Mod item IDs on wrapper Let/TyAlias expressions using IdTagged.mk_internal. This also unifies Statics and Elaborator since both can use the same deterministic expansion. Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit enables cursor inspector support for module constructs by: 1. Preserving IDs on wrapper expressions during module expansion: - ModLet ID → wrapper Let expression - ModType ID → wrapper TyAlias expression - ModExp uses fresh ID (synthetic, inner expr has its own IDs) 2. Absorbing semicolon IDs in MakeTerm (like ListLit absorbs comma IDs): - Module expression now includes semicolon IDs from inner Mod sequence - Enables cursor inspector to show info for both braces and semicolons 3. Using fresh IDs for the final labeled tuple: - Prevents overwriting Module statics map entry - Avoids infinite loops in Elaborator Key insight: ModExp differs from ModLet/ModType - it wraps an existing expression that already has its own IDs. The synthetic let _ = e wrapper needs a fresh ID to avoid conflicts. Co-Authored-By: Claude Opus 4.5 <[email protected]>
MakeTerm changes: - Use is_mod_seq to handle any number of semicolons (not just 2 items) - Only absorb IDs when body is MultiHole (avoids duplicating single-item IDs) - Fixes infinite loop that occurred with single-item modules Known limitation documented in plan: - Only first semicolon has cursor info due to nested Skel structure - Inner semicolon IDs are buried in nested MultiHole annotations - flatten_mod flattens terms but not IDs - Documented potential solutions: modify Skel, collect IDs during flatten, or accept limitation Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add semicolons to is_chainable when both tiles have mold.out == Sort.Mod. This produces flat Bin structures for module semicolons (like commas do for tuples), instead of nested binary structures. CellJoin (Exp-sort semicolons) is unaffected due to the Sort.Mod guard. Flat structure means is_mod_seq in MakeTerm sees all semicolons at once, which is prerequisite for collecting all semicolon IDs for cursor inspector. Co-Authored-By: Claude Opus 4.5 <[email protected]>
With flat Skel structure (from previous commit), body.annotation.ids now contains ALL semicolon IDs for multi-item modules. The existing MultiHole absorption path in MakeTerm naturally handles this - no additional ID collection logic needed. Updated comments to reflect the new reality. Plan updates: - Documented Skel fix resolving the nested semicolon ID issue - Added near-term item: module semicolon decoration is visually noisy (arms drawn between all semicolons), consider custom decoration Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add signature (Sig) sort for module type annotations:
- Sig sort infrastructure parallel to Mod (Sort, Grammar, Form,
Segment, Skel, Arms, Insert, MakeTerm)
- Sig as Typ variant with desugar_sig bridge to labeled tuples
- Type-directed module expansion for error attribution
- Cursor inspector integration (Mod/Sig cls, colors, bolding)
- Menhir parser support for Sig syntax
- ExpToSegment: full Module and Sig pretty-printing with whitespace
- Sig pretty_print in Typ.re for cursor inspector display
- Module abbreviation in Abbreviate.re
Tests added across 8 test files (1502 total, all pass):
- 14 statics, 11 evaluator, 4 elaboration, 6 ExpToSegment roundtrip,
4 editing, 2 abbreviation, 5 Menhir Sig roundtrip tests
Bug fixes:
- ExpToSegment: wrap mod/sig items with secondary for whitespace
- ExpToSegment: ModType mk_form children count (1 inner sort, not 2)
- Typ.re: Sig pretty_print renders { let x : Int } not {sig}
- Abbreviate.re: recursive module item abbreviation
Docs and plans consolidated.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Module width mismatches (sig wider/narrower than module) now produce
type errors. The fix builds the actual Prod type from the module's
exported bindings rather than using expanded_info.ty, which masked
width errors via fixed_typ_exp.
Empty module signatures ({} in type position) now parse correctly
as Sig([]) by adding a Typ mold to the EmptyModule atomic form.
Adds 16 new statics tests covering sig annotations, width errors,
and module/tuple equivalence limitations. Updates modules doc slide.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev #2104 +/- ##
==========================================
- Coverage 50.40% 50.03% -0.37%
==========================================
Files 230 233 +3
Lines 25365 26466 +1101
==========================================
+ Hits 12784 13243 +459
- Misses 12581 13223 +642
🚀 New features to boost your workflow:
|
In Mod/Sig sort context, concave grout now uses mod_seq precedence (very loose) instead of concave_grout (tight). This means deleting a semicolon between module items leaves them as separate items rather than absorbing everything into one broken expression body. Threaded via optional ~sort parameter on Skel.mk and Segment.skel, defaulting to Exp. MakeTerm passes the child sort from tile molds. Also makes flatten_mod/flatten_sig handle non-Mod/Sig children in multi-holes by wrapping them as module items, isolating parse breakage. Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.
Potemkin modules. Cargo modules. I can believe theyre not modules. Subsumes #2075.