Skip to content

Commit

Permalink
try ord
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjbest committed Jan 4, 2024
1 parent 744403b commit 3c1f998
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Leaff/Diff.lean
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ def summarize (diffs : List Diff) : MessageData := Id.run do
if diffs == [] then return "No differences found."
let mut out : MessageData := "Found differences:" ++ Format.line
let mut diffs := diffs.toArray
diffs := diffs.qsort (fun a b => a.prio < b.prio)
let _inst : Ord Name := ⟨Name.quickCmp⟩
let _inst : Ord (Nat × Name) := lexOrd
let _inst : LT (Nat × Name) := ltOfOrd
diffs := diffs.qsort (fun a b => (a.prio, a.mod) < (b.prio, b.mod))
let mut oldmod : Name := Name.anonymous
for d in diffs do
let mod := d.mod
Expand All @@ -245,6 +248,7 @@ def summarize (diffs : List Diff) : MessageData := Id.run do
out := out ++ m!"@@ {mod} @@\n"
out := out ++ (match d with
-- TODO add expr to all of these
-- TODO see if universe printing can be disabled
| .added const _ => m!"+ added {Expr.const const.name (const.levelParams.map mkLevelParam)}"
| .removed name _ => m!"- removed {Expr.const name []}"
| .renamed oldName newName true _ => m!"! renamed {oldName} → {newName} (changed namespace)"
Expand Down Expand Up @@ -669,12 +673,15 @@ def summarizeDiffImports (oldImports newImports : Array Import) (old new : Searc
searchPathRef.set old
let opts := Options.empty
let trustLevel := 1024 -- TODO actually think about this value
withImportModules oldImports opts trustLevel fun oldEnv => do
-- TODO could be really clever here instead of passing search paths around and try and swap the envs in place
-- to reduce the need for multiple checkouts, but that seems complicated
searchPathRef.set new
withImportModules newImports opts trustLevel fun newEnv => do
IO.println <| ← (Diff.summarize (← oldEnv.diff newEnv)).format
try
withImportModules oldImports opts trustLevel fun oldEnv => do
-- TODO could be really clever here instead of passing search paths around and try and swap the envs in place
-- to reduce the need for multiple checkouts, but that seems complicated
searchPathRef.set new
withImportModules newImports opts trustLevel fun newEnv => do
IO.println <| ← (Diff.summarize (← oldEnv.diff newEnv)).format
catch ex => do
throw <| IO.userError s!"Exception: {← ex.toMessageData.toString}"

section cmd

Expand Down

0 comments on commit 3c1f998

Please sign in to comment.