Skip to content

refactor: move core API extensions to their own files - #176

Open
josaum wants to merge 1 commit into
leanprover-community:mainfrom
josaum:refactor/lean-extension-files
Open

josaum wants to merge 1 commit into
leanprover-community:mainfrom
josaum:refactor/lean-extension-files

Conversation

@josaum

@josaum josaum commented Oct 13, 2026 •

Copy link
Copy Markdown

Fixes #144.

ImportGraph/Shake/EnvExtension.lean contained two private declarations extending core API, which were dead code (only self-references) precisely because they were private:

  • List.prependWithoutDuplicating — essentially (as ++ bs).deleteDuplicatesRev, keeping later-occurring elements
  • Lean.PHashSet.union — inserts the elements of the first set into the second unless present

This PR moves them to their own public modules under the existing ImportGraph/Lean/ layout, as suggested in the issue:

  • ImportGraph/Lean/List.lean provides List.prependWithoutDuplicating (root List namespace, so dot notation works on any list)
  • ImportGraph/Lean/PersistentHashSet.lean provides Lean.PersistentHashSet.union (PHashSet is an abbrev for PersistentHashSet, so dot notation on PHashSet values keeps working)

Neither file is imported by the umbrella ImportGraph.lean, per the issue description; users opt in with an explicit import.

Regression tests for both functions were added as ImportGraphTest/Lean/List.lean and ImportGraphTest/Lean/PersistentHashSet.lean (following the repo's #guard_msgs in #eval style) and registered in ImportGraphTest.lean.

Verified locally against the pinned toolchain (leanprover/lean4:v4.35.0): lake build and lake exe graph pass, and lake build ImportGraphTest passes for every target except the pre-existing ImportGraphTest.AnotherFileWithTransitiveImports, which exceeds my local sandbox's 3 GiB memory cgroup (OOM-kill, exit 137) identically on unmodified main, so it is unrelated to this change. No sorry/admit anywhere.

…munity#144)

Move the two private declarations extending core API out of
`ImportGraph/Shake/EnvExtension.lean` into their own public modules,
following the existing `ImportGraph/Lean/` layout:

- `List.prependWithoutDuplicating` moves to `ImportGraph/Lean/List.lean`
  (root `List` namespace, so dot notation works on any list).
- `Lean.PHashSet.union` moves to `ImportGraph/Lean/PersistentHashSet.lean`
  as `Lean.PersistentHashSet.union` (`PHashSet` is an abbrev of
  `PersistentHashSet`, so dot notation keeps working).

Both were dead code as `private` declarations; they are now public API.
The new files are intentionally not imported by the umbrella
`ImportGraph.lean`. Regression tests added under `ImportGraphTest/Lean/`
and registered in `ImportGraphTest.lean`.

Fixes leanprover-community#144
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: move Lean extension functions to their own file

1 participant