-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - refactor(tactic/lint/type_classes): change inhabited linter to nonempty linter #15542
Conversation
…ty linter The `inhabited` typeclass is intended to be a default value (and computable, if one is programming) but many times it is filled in with a junk (and perhaps noncomputable) value to satisfy the inhabited linter. This switches to pushing contributors to supply a `nonempty` instance. The linter still accepts `inhabited` and `unique` instances.
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
#1898 is where the @gebner I think I still don't fully understand the inhabited instance linter, and it might be because the corners of mathlib I'm familiar with don't tend to need
There are a number of places in mathlib where there are arbitrary values (like Maybe it would be better to have the linter itself suggest adding a nolint if there are no good default values? Or extend it to be satisfied with a |
My original intention with the For many types in mathlib, requiring But to my surprise, some people actually took the linter's advice in an unexpected and different direction. Instead of adding general instances, they added particular examples of the type in the question (such as the 37 you refer to). This is certainly valuable information (and a sneaky way to get around mathlib's "no examples" policy), but not really what the In general, making these noncanonical inhabitants nonempty rather than inhabited seems like a good change to me. Maybe we also need a more explicit and officially sanctioned way to include examples (I have no data on how common this abuse of inhabited is). There is one notable use of |
I am personally more in favor of retiring this linter (and removing a bunch of |
I think pushing for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm enough of an intuitionist to think that we should push inhabited
as much as possible, but I guess the consensus in this thread overrules me.
I'd still like the documentation to push the user a bit further towards inhabited
or unique
if appropriate, otherwise this looks good to me.
Could you merge master before handing the PR over to bors?
bors d+
✌️ kmill can now approve this pull request. To approve and merge a pull request, simply reply with |
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
…-community/mathlib into kmill_nonempty_linter
bors r+ |
…ty linter (#15542) The `inhabited` typeclass is intended to be a default value (and computable, if one is writing programs) but many times it is filled in with a junk (and perhaps noncomputable) value to satisfy the `has_inhabited_instance` linter. This commit switches to a `has_nonempty_instance` linter to push contributors toward supplying a `nonempty` instance instead. The linter still accepts `inhabited` and `unique` instances, which should be preferred over `nonempty` when appropriate.
Pull request successfully merged into master. Build succeeded: |
Why are there junk |
…ty linter (leanprover-community#15542) The `inhabited` typeclass is intended to be a default value (and computable, if one is writing programs) but many times it is filled in with a junk (and perhaps noncomputable) value to satisfy the `has_inhabited_instance` linter. This commit switches to a `has_nonempty_instance` linter to push contributors toward supplying a `nonempty` instance instead. The linter still accepts `inhabited` and `unique` instances, which should be preferred over `nonempty` when appropriate.
…ty linter (#15542) The `inhabited` typeclass is intended to be a default value (and computable, if one is writing programs) but many times it is filled in with a junk (and perhaps noncomputable) value to satisfy the `has_inhabited_instance` linter. This commit switches to a `has_nonempty_instance` linter to push contributors toward supplying a `nonempty` instance instead. The linter still accepts `inhabited` and `unique` instances, which should be preferred over `nonempty` when appropriate.
…ty linter (#15542) The `inhabited` typeclass is intended to be a default value (and computable, if one is writing programs) but many times it is filled in with a junk (and perhaps noncomputable) value to satisfy the `has_inhabited_instance` linter. This commit switches to a `has_nonempty_instance` linter to push contributors toward supplying a `nonempty` instance instead. The linter still accepts `inhabited` and `unique` instances, which should be preferred over `nonempty` when appropriate.
The
inhabited
typeclass is intended to be a default value (and computable, if one is writing programs) but many times it is filled in with a junk (and perhaps noncomputable) value to satisfy thehas_inhabited_instance
linter. This commit switches to ahas_nonempty_instance
linter to push contributors toward supplying anonempty
instance instead. The linter still acceptsinhabited
andunique
instances, which should be preferred overnonempty
when appropriate.