Zulip Chat Archive
Stream: general
Topic: pretty printer in to_string
Frédéric Le Roux (May 07 2020 at 08:55):
When using to_string expr
in metaprograming, is there a way to force Lean to use the pretty printer?
I would like to get the target into a string in pretty printed format.
Patrick Massot (May 07 2020 at 09:02):
You can use tactic.pp
Patrick Massot (May 07 2020 at 09:10):
Very stupid example:
meta def fred : tactic unit :=
do h ← tactic.get_local `h >>= tactic.pp,
tactic.trace h
example (h : 0 = 1) : false :=
begin
fred,
tauto,
end
Patrick Massot (May 07 2020 at 09:12):
In case you're still afraid of monadic combinators, you can avoid the >>=
by using:
do h ← tactic.get_local `h,
print ← tactic.pp h,
tactic.trace print
Frédéric Le Roux (May 07 2020 at 14:05):
Thanks!
Last updated: Dec 20 2023 at 11:08 UTC