Zulip Chat Archive
Stream: general
Topic: Definition dependencies public
Martin Dvořák (Jun 23 2025 at 14:08):
What is the easiest way to check that a specific important (public) definition doesn't depend on any private definition? I mean both def and abbrev by "definition" in the previous sentence.
Eric Wieser (Jun 23 2025 at 14:40):
Why do you care?
Martin Dvořák (Jun 23 2025 at 14:47):
API consistency?
Ruben Van de Velde (Jun 23 2025 at 14:54):
I think you'll need to expand on that
Eric Wieser (Jun 23 2025 at 15:00):
Maybe I should ask what you mean by "depend on"?
Eric Wieser (Jun 23 2025 at 15:00):
Indeed def foo : Bar := _ where private structure Bar is probably problematic, but def foo : Nat := bar where private def bar is not
Martin Dvořák (Jun 23 2025 at 15:16):
I would like to detect both (anti)patterns:
private def Foo : Type := Fin 37
def zeroFoo : Foo := ⟨0, by decide⟩
private def bar : Char := 'b'
def baz : Char := bar
The latter is less problematic, but I'd like to avoid both of them.
Kenny Lau (Jun 23 2025 at 16:26):
the latter is fine as long as there is API
Martin Dvořák (Jun 23 2025 at 17:23):
Speaking of the former problem, is the following catch known?
private def Foo : Type := Fin 37
private theorem Foo.eq_self (x : Foo) : x = x := rfl
theorem break_me (x : Foo) : x = x := x.eq_self
Removing private from Foo.eq_self breaks the proof of the subsequent theorem.
Aaron Liu (Jun 23 2025 at 19:42):
It because of macro scopes but I can see why it would be confusing if you didn't know the reason
Robin Arnez (Jun 23 2025 at 20:01):
It's not macro scopes but the fact that private is a name prefix, similar to namespaces
Robin Arnez (Jun 23 2025 at 20:02):
private Foo is actually _private.My.Module.Path.0.Foo and then it obviously expected _private.My.Module.Path.0.Foo.eq_self for dot notation
Aaron Liu (Jun 23 2025 at 20:07):
Robin Arnez said:
private Foois actually_private.My.Module.Path.0.Fooand then it obviously expected_private.My.Module.Path.0.Foo.eq_selffor dot notation
Oh I thought those were macro scopes but I guess not (they seemed really similar)
Robin Arnez (Jun 23 2025 at 20:19):
It's similar but _private is a deterministic prefix (only based on module name) and macro scopes are suffixes with random (technically deterministic but ever-changing) numbers
Robin Arnez (Jun 23 2025 at 20:20):
or well, _hyg vs _private
Martin Dvořák (Jun 24 2025 at 06:56):
Robin Arnez said:
It's not macro scopes but the fact that
privateis a name prefix, similar to namespaces
Would it be reasonable to open a RFC about changing this behavior?
Joachim Breitner (Jun 24 2025 at 07:05):
Martin Dvořák schrieb:
I would like to detect both (anti)patterns:
private def Foo : Type := Fin 37 def zeroFoo : Foo := ⟨0, by decide⟩ private def bar : Char := 'b' def baz : Char := barThe latter is less problematic, but I'd like to avoid both of them.
I think the upcoming module system will prevent the former, and also the latter if the definition is exposed. So maybe just wait for that?
Martin Dvořák (Jun 24 2025 at 08:58):
Martin Dvořák said:
Speaking of the former problem, is the following catch known?
private def Foo : Type := Fin 37 private theorem Foo.eq_self (x : Foo) : x = x := rfl theorem break_me (x : Foo) : x = x := x.eq_selfRemoving
privatefromFoo.eq_selfbreaks the proof of the subsequent theorem.
The suggested potential RFC was about this behavior.
Last updated: Dec 20 2025 at 21:32 UTC