feat: allow an ApplyConfig argument at constructor tactic (#1319)
This commit is contained in:
parent
73fce217f6
commit
5c79973300
1 changed files with 6 additions and 2 deletions
|
|
@ -9,7 +9,11 @@ import Lean.Meta.Tactic.Apply
|
|||
|
||||
namespace Lean.Meta
|
||||
|
||||
def constructor (mvarId : MVarId) : MetaM (List MVarId) := do
|
||||
/--
|
||||
When the goal `mvarId` is an inductive datatype,
|
||||
`constructor` calls `apply` with the first matching constructor.
|
||||
-/
|
||||
def constructor (mvarId : MVarId) (cfg : ApplyConfig := {}) : MetaM (List MVarId) := do
|
||||
withMVarContext mvarId do
|
||||
checkNotAssigned mvarId `constructor
|
||||
let target ← getMVarType' mvarId
|
||||
|
|
@ -18,7 +22,7 @@ def constructor (mvarId : MVarId) : MetaM (List MVarId) := do
|
|||
fun ival us => do
|
||||
for ctor in ival.ctors do
|
||||
try
|
||||
return ← apply mvarId (Lean.mkConst ctor us)
|
||||
return ← apply mvarId (Lean.mkConst ctor us) cfg
|
||||
catch _ =>
|
||||
pure ()
|
||||
throwTacticEx `constructor mvarId "no applicable constructor found"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue