Skip to content

Commit 959a3d7

Browse files
committed
simplify
1 parent 94f1c74 commit 959a3d7

File tree

1 file changed

+3
-32
lines changed

1 file changed

+3
-32
lines changed

src/Lean/Elab/Command.lean

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,10 @@ public section
1717

1818
namespace Lean.Elab.Command
1919

20-
structure State where
21-
env : Environment
22-
messages : MessageLog := {}
20+
structure State extends Core.State where
2321
scopes : List Scope := [{ header := "" }]
2422
usedQuotCtxts : NameSet := {}
25-
nextMacroScope : Nat := firstFrontendMacroScope + 1
2623
maxRecDepth : Nat
27-
ngen : NameGenerator := {}
28-
auxDeclNGen : DeclNameGenerator := .ofPrefix .anonymous
29-
infoState : InfoState := {}
30-
traceState : TraceState := {}
31-
snapshotTasks : Array (Language.SnapshotTask Language.SnapshotTree) := #[]
3224
deriving Nonempty
3325

3426
structure Context where
@@ -74,17 +66,6 @@ Remark: see comment at TermElabM
7466
@[always_inline]
7567
instance : Monad CommandElabM := let i := inferInstanceAs (Monad CommandElabM); { pure := i.pure, bind := i.bind }
7668

77-
private def State.updateCore (s : State) (coreS : Core.State) : State :=
78-
{ s with
79-
env := coreS.env
80-
nextMacroScope := coreS.nextMacroScope
81-
ngen := coreS.ngen
82-
auxDeclNGen := coreS.auxDeclNGen
83-
infoState := coreS.infoState
84-
traceState := coreS.traceState
85-
snapshotTasks := coreS.snapshotTasks
86-
messages := coreS.messages }
87-
8869
private def liftCoreMDirect (x : CoreM α) : CommandElabM α := do
8970
let ctx ← read
9071
let s ← get
@@ -103,18 +84,8 @@ private def liftCoreMDirect (x : CoreM α) : CommandElabM α := do
10384
options := scope.opts
10485
cancelTk? := ctx.cancelTk?
10586
suppressElabErrors := ctx.suppressElabErrors }
106-
let coreState := {
107-
env := s.env
108-
ngen := s.ngen
109-
auxDeclNGen := s.auxDeclNGen
110-
nextMacroScope := s.nextMacroScope
111-
infoState := s.infoState
112-
traceState := s.traceState
113-
snapshotTasks := s.snapshotTasks
114-
messages := s.messages
115-
}
116-
let (a, coreS) ← x.run coreCtx coreState
117-
modify (·.updateCore coreS)
87+
let (a, coreS) ← x.run coreCtx s.toState
88+
modify ({ · with toState := coreS })
11889
return a
11990

12091
instance : MonadLift CoreM CommandElabM where

0 commit comments

Comments
 (0)