Zulip Chat Archive
Stream: metaprogramming / tactics
Topic: withImportModules + `#check`/`#print`
Yury G. Kudryashov (May 25 2025 at 03:53):
How do I (a) #check; (b) #print (to a string or to stdout) a declaration from withImportModules? #xy: I have something like
unsafe def main (_ : List String) : IO Unit := do
initSearchPath (← findSysroot)
withImportModules #[{module := `Mathlib}] {} (trustLevel := 1024) fun env => do
let names : Array String := (env.constants.fold · #[]) fun ar c _ ↦
if isAutoDecl env c then ar else ar.push c.toString -- here `isAutoDecl` is a pure version of Batteries' function
for name in names.qsortOrd do
IO.println name
but I want to pretty print the type of the theorem named name instead.
Damiano Testa (May 25 2025 at 05:59):
You could try using docs#Lean.MessageData.signature, maybe?
Last updated: Dec 20 2025 at 21:32 UTC