feat(library/init/meta/tactic): more general trace_fmt

This commit is contained in:
Leonardo de Moura 2016-06-22 14:14:33 -07:00
parent 61de427699
commit 1e005e185a
3 changed files with 6 additions and 6 deletions

View file

@ -50,8 +50,8 @@ do s ← read,
meta_definition trace (s : string) : tactic unit :=
return (_root_.trace s (λ u, ()))
meta_definition trace_fmt (fmt : format) : tactic unit :=
return (_root_.trace_fmt fmt (λ u, ()))
meta_definition trace_fmt {A : Type} [has_to_format A] (a : A) : tactic unit :=
return (_root_.trace_fmt (to_fmt a) (λ u, ()))
/- Trace expression with respect to the main goal -/
meta_definition trace_expr (e : expr) : tactic unit :=

View file

@ -3,9 +3,9 @@ open tactic
example (a : nat) : true :=
by do
trace "ite information:",
mk_const "ite" >>= get_fun_info >>= trace_fmt ∘ to_fmt,
mk_const "ite" >>= get_fun_info >>= trace_fmt,
trace "eq.rec information:",
mk_const ("eq" <.> "rec") >>= get_fun_info >>= trace_fmt ∘ to_fmt,
mk_const ("eq" <.> "rec") >>= get_fun_info >>= trace_fmt,
trace "and.intro information:",
mk_const ("and" <.> "intro") >>= get_fun_info >>= trace_fmt ∘ to_fmt,
mk_const ("and" <.> "intro") >>= get_fun_info >>= trace_fmt,
mk_const "trivial" >>= exact

View file

@ -14,7 +14,7 @@ by do
do t ← infer_type e,
fmt₁ ← format_expr e,
fmt₂ ← format_expr t,
trace_fmt (fmt₁ + to_fmt " : " + fmt₂)),
trace_fmt $ fmt₁ + to_fmt " : " + fmt₂),
trace "----------",
trace ("num: " + to_string n),
trace_state,