Zulip Chat Archive

Stream: lean4

Topic: ppExpr and pp.mvars


Tomas Skrivan (Nov 04 2025 at 11:31):

How do I call ppExpr with pp.mvars option set to false?

This does not work

import Lean

open Lean Meta
run_meta
  let e  mkFreshExprMVar (some (Expr.const ``Nat []))
  let s  withOptions (fun opt => opt.setBool ``pp.mvars false) do ppExpr e
  IO.println s

Floris van Doorn (Nov 04 2025 at 11:44):

I do not quite understand why, but either of these work:

import Lean

open Lean Meta
run_meta
  let e  mkFreshExprMVar (some (Expr.const ``Nat []))
  let s  withOptions (fun opt => opt.setBool `pp.mvars false) do ppExpr e
  withOptions (fun opt => opt.setBool `pp.mvars false) do IO.println s

run_meta
  let e  mkFreshExprMVar (some (Expr.const ``Nat []))
  withOptions (fun opt => opt.setBool `pp.mvars false) do
    let s  ppExpr e
    IO.println s

Tomas Skrivan (Nov 04 2025 at 11:51):

Ohh the original works when you replace

``pp.mvars

with

`pp.mvars

Eric Wieser (Nov 04 2025 at 11:52):

withOptions (fun opt => pp.mvars.set opt false) is the correct spelling


Last updated: Dec 20 2025 at 21:32 UTC