feat: FFI interface for `evaluate` tactic
This commit is contained in:
parent
7acf1ffdf1
commit
2d2ff24017
|
@ -186,7 +186,15 @@ protected def GoalState.tryHave (state: GoalState) (goalId: Nat) (binderName: St
|
||||||
| .error error => return .parseError error
|
| .error error => return .parseError error
|
||||||
runTermElabM do
|
runTermElabM do
|
||||||
state.restoreElabM
|
state.restoreElabM
|
||||||
state.execute goalId (Tactic.have_t binderName.toName type)
|
state.execute goalId (Tactic.«have» binderName.toName type)
|
||||||
|
@[export pantograph_goal_evaluate_m]
|
||||||
|
protected def GoalState.tryEvaluate (state: GoalState) (goalId: Nat) (binderName: String) (type: String): CoreM TacticResult := do
|
||||||
|
let type ← match (← Compile.parseTermM type) with
|
||||||
|
| .ok syn => pure syn
|
||||||
|
| .error error => return .parseError error
|
||||||
|
runTermElabM do
|
||||||
|
state.restoreElabM
|
||||||
|
state.execute goalId (Tactic.evaluate binderName.toName type)
|
||||||
@[export pantograph_goal_let_m]
|
@[export pantograph_goal_let_m]
|
||||||
def goalLet (state: GoalState) (goalId: Nat) (binderName: String) (type: String): CoreM TacticResult :=
|
def goalLet (state: GoalState) (goalId: Nat) (binderName: String) (type: String): CoreM TacticResult :=
|
||||||
runTermElabM <| state.tryLet goalId binderName type
|
runTermElabM <| state.tryLet goalId binderName type
|
||||||
|
|
|
@ -19,7 +19,7 @@ def evaluate (binderName: Name) (expr: Syntax): Elab.Tactic.TacticM Unit := do
|
||||||
pure [mvarUpstream.mvarId!]
|
pure [mvarUpstream.mvarId!]
|
||||||
Elab.Tactic.setGoals nextGoals
|
Elab.Tactic.setGoals nextGoals
|
||||||
|
|
||||||
def have_t (binderName: Name) (type: Syntax): Elab.Tactic.TacticM Unit := do
|
def «have» (binderName: Name) (type: Syntax): Elab.Tactic.TacticM Unit := do
|
||||||
let goal ← Elab.Tactic.getMainGoal
|
let goal ← Elab.Tactic.getMainGoal
|
||||||
let nextGoals: List MVarId ← goal.withContext do
|
let nextGoals: List MVarId ← goal.withContext do
|
||||||
let type ← Elab.Term.elabType (stx := type)
|
let type ← Elab.Term.elabType (stx := type)
|
||||||
|
|
Loading…
Reference in New Issue