Zulip Chat Archive

Stream: lean4

Topic: expand all members within a type class


lexuan (Sep 27 2024 at 13:04):

In Lean 4, is there a way to view all the fields contained in a type class, including all the fields defined by it and all the fields of the inheriting classes (this means, all fields including the fields of inheritances of inheritances)? If there is no ready-made statement that can achieve this, how then should one write a program to achieve this functionality? GitHub Copilot has not been able to solve this difficulty, using a lot of erroneous code.

Floris van Doorn (Sep 27 2024 at 13:25):

If it's in Mathlib/Batteries/Core, then you can just look at the generated docs, e.g. docs#Field

lexuan (Sep 27 2024 at 14:58):

Thank you for sharing, this method is very helpful. However, how should I proceed if I want to implement this in VSCode? Is there a syntax similar to #check?

Floris van Doorn (Sep 27 2024 at 15:57):

You should be able to get this with metaprogramming quite quickly, probably by looking at the doc-gen code that generates this list.

lexuan (Sep 27 2024 at 16:08):

Understood, thank you for the answer.


Last updated: May 02 2025 at 03:31 UTC