feat: allow an ApplyConfig argument at constructor tactic (#1319)

This commit is contained in:
Scott Morrison 2022-07-19 14:02:31 +10:00 committed by GitHub
parent 73fce217f6
commit 5c79973300
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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"