Skip to content
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

chore: move Core.withImportModules to Imports.lean #43

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ImportGraph.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ import ImportGraph.Imports
import ImportGraph.CurrentModule
import ImportGraph.Lean.Name
import ImportGraph.RequiredModules
import ImportGraph.UnusedTransitiveImports
6 changes: 6 additions & 0 deletions ImportGraph/Imports.lean
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ def unusedTransitiveImports (amongst : List Name) (verbose : Bool := false) : Co
let unused := (transitiveImports.find? n).getD {} \ (transitivelyRequired.find? n |>.getD {})
amongst.filter (fun m => unused.contains m))

def Core.withImportModules (modules : Array Name) {α} (f : CoreM α) : IO α := do
searchPathRef.set compile_time_search_path%
unsafe Lean.withImportModules (modules.map (fun m => {module := m})) {} (trustLevel := 1024)
fun env => Prod.fst <$> Core.CoreM.toIO
(ctx := { fileName := "<CoreM>", fileMap := default }) (s := { env := env }) do f

/--
Return the redundant imports (i.e. those transitively implied by another import)
of a specified module (or the current module if `none` is specified).
Expand Down
6 changes: 0 additions & 6 deletions ImportGraph/UnusedTransitiveImports.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import ImportGraph.Imports

open Lean

def Core.withImportModules (modules : Array Name) {α} (f : CoreM α) : IO α := do
searchPathRef.set compile_time_search_path%
unsafe Lean.withImportModules (modules.map (fun m => {module := m})) {} (trustLevel := 1024)
fun env => Prod.fst <$> Core.CoreM.toIO
(ctx := { fileName := "<CoreM>", fileMap := default }) (s := { env := env }) do f

/--
`lake exe unused_transitive_imports m1 m2 ...`

Expand Down