I'm studying LEAN4 internals and I want to see the result of Lean.readModuleData function, however, I cannot print it (its type is ModuleData × CompactedRegion) and I cannot derive ToString for it also. In situation like this, how do you print objects? I think implementing printing function for every types is really painful.
I think implementing printing function for every types is really painful.
In the same boat at present.
What is somewhat helpful but only for the simpler types is using an LLM. Currently find some success with simpler types using Claude and/or Mistral but have not tried all LLMs, e.g.
One caveat I found with toJson is that a Lean list, ( ['a','b','c'] ) and a Lean array ( #['a','b','c']) will both be converted to a JSON array as there is no JSON list. (JSON syntax)
My lean file for experimenting with toString and toJson.
Had to cut off much of it to meet the posting length. :frown:
That's a standard markdown feature I believe. When you want to enclose something that contains n consecutive backticks, you can use n + 1 consecutive backticks
@lunuy There are objects of unknown (to lean) type stored inside ModuleData. CompactedRegion you can ignore, it's not really a piece of data itself but rather a handle to the region which stores the ModuleData, and which can be used (unsafely) to deallocate it. You can view arbitrary lean objects using the structure that the garbage collector uses to do its job; this is implemented in the oleandump library, invented precisely for being able to inspect the module data in .olean files