chore: Code cleanup #202

Open
aniva wants to merge 3 commits from chore/cleanup into dev
1 changed files with 6 additions and 9 deletions
Showing only changes of commit 4bb44dd56a - Show all commits

View File

@ -60,7 +60,7 @@ def runCoreM { α } (coreM : CoreM α) : EMainM α := do
Except.ok <$> coreM Except.ok <$> coreM
catch ex => catch ex =>
let desc ← ex.toMessageData.toString let desc ← ex.toMessageData.toString
return Except.error $ ({ error := "exception", desc } : Protocol.InteractionError) return Except.error ({ error := "exception", desc } : Protocol.InteractionError)
finally finally
for {msg, ..} in (← getTraceState).traces do for {msg, ..} in (← getTraceState).traces do
IO.eprintln (← msg.format.toIO) IO.eprintln (← msg.format.toIO)
@ -72,13 +72,12 @@ def runCoreM { α } (coreM : CoreM α) : EMainM α := do
| Except.error (Exception.internal id _) => Protocol.throw $ { error := "internal", desc := (← id.getName).toString } | Except.error (Exception.internal id _) => Protocol.throw $ { error := "internal", desc := (← id.getName).toString }
| Except.ok a => pure a | Except.ok a => pure a
if result matches .ok _ then if result matches .ok _ then
modifyEnv λ _ => state'.env setEnv state'.env
liftExcept result liftExcept result
def runCoreM' { α } (coreM : Protocol.FallibleT CoreM α) : EMainM α := do def runCoreM' { α } (coreM : Protocol.FallibleT CoreM α) : EMainM α := do
liftExcept $ ← runCoreM coreM.run liftExcept $ ← runCoreM coreM.run
def liftMetaM { α } (metaM : MetaM α): EMainM α := def liftMetaM { α } (metaM : MetaM α): EMainM α :=
runCoreM metaM.run' runCoreM metaM.run'
def liftTermElabM { α } (termElabM : Elab.TermElabM α) (levelNames : List Name := []) def liftTermElabM { α } (termElabM : Elab.TermElabM α) (levelNames : List Name := [])
@ -96,7 +95,7 @@ def liftTermElabM { α } (termElabM: Elab.TermElabM α) (levelNames : List Name
section Frontend section Frontend
structure CompilationUnit where structure CompilationUnit where
-- Should be the penultimate environment, but this is ok -- Environment immediately before the unit
env : Environment env : Environment
boundary : Nat × Nat boundary : Nat × Nat
invocations : List Protocol.InvokedTactic invocations : List Protocol.InvokedTactic
@ -104,7 +103,7 @@ structure CompilationUnit where
messages : Array String messages : Array String
newConstants : List Name newConstants : List Name
def frontend_process_inner (args: Protocol.FrontendProcess): EMainM Protocol.FrontendProcessResult := do def frontend_process (args: Protocol.FrontendProcess): EMainM Protocol.FrontendProcessResult := do
let options := (← getMainState).options let options := (← getMainState).options
let (fileName, file) ← match args.fileName?, args.file? with let (fileName, file) ← match args.fileName?, args.file? with
| .some fileName, .none => do | .some fileName, .none => do
@ -400,7 +399,5 @@ def execute (command: Protocol.Command): MainM Json := do
let (goalState, _) ← goalStateUnpickle args.path (← MonadEnv.getEnv) let (goalState, _) ← goalStateUnpickle args.path (← MonadEnv.getEnv)
let id ← newGoalState goalState let id ← newGoalState goalState
return { id } return { id }
frontend_process (args: Protocol.FrontendProcess): EMainM Protocol.FrontendProcessResult := do
frontend_process_inner args
end Pantograph.Repl end Pantograph.Repl