feat: add #synth command to new frontend

This commit is contained in:
Leonardo de Moura 2020-01-09 09:54:45 -08:00
parent 923bd321ef
commit 2a8e179a64
2 changed files with 25 additions and 0 deletions

View file

@ -497,11 +497,24 @@ fun stx => do
logInfo stx.val (e ++ " : " ++ type);
pure ()
@[builtinCommandElab «synth»] def elabSynth : CommandElab :=
fun stx => do
let ref := stx.val;
let term := stx.getArg 1;
runTermElabM `_synth_cmd $ fun _ => do
inst ← Term.elabTerm term none;
Term.synthesizeSyntheticMVars false;
inst ← Term.instantiateMVars ref inst;
val ← Term.liftMetaM ref $ Meta.synthInstance inst;
logInfo stx.val val;
pure ()
def setOption (ref : Syntax) (optionName : Name) (val : DataValue) : CommandElabM Unit := do
decl ← liftIO ref $ getOptionDecl optionName;
unless (decl.defValue.sameCtor val) $ throwError ref "type mismatch at set_option";
modifyScope $ fun scope => { opts := scope.opts.insert optionName val, .. scope }
@[builtinCommandElab «set_option»] def elabSetOption : CommandElab :=
fun stx => do
let ref := stx.val;

View file

@ -0,0 +1,12 @@
new_frontend
set_option ppOld false
#synth HasToString (Nat × (Nat × Bool))
#synth HasAdd Nat
#synth HasCoe Bool Prop
#synth Decidable (True ∧ 1 = 1)
#synth DecidableEq (Nat × Nat)