-
Notifications
You must be signed in to change notification settings - Fork 534
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
feat: remove Decidable instances from GetElem #4560
Conversation
src/Lean/Data/HashMap.lean
Outdated
@@ -222,6 +222,8 @@ def insertIfNew (m : HashMap α β) (a : α) (b : β) : HashMap α β × Option | |||
|
|||
instance : GetElem (HashMap α β) α (Option β) fun _ _ => True where | |||
getElem m k _ := m.find? k | |||
getElem? m k := some (m.find? k) -- Not really sure what should go here. We're meant to be returning an `Option (Option β)`. |
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.
Isn't this a sign that the instance doesn't quite make sense here? I'd expect there to be an Elem
predicate, and that the result of getElem
would not be an Option
.
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 get the pragmatic reason why we don't have that right now, of course)
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.
Yes, @TwoFX will replace this with something more sensible in the big HashMap refactor.
Mathlib CI status (docs):
|
Unfortunately, it doesn't seem to let me leave suggestions for lines that weren't changed. But here's a suggestion for an updated docstring to match the code better:
What do you think? |
Good! Should we exclude |
I agree! |
Thanks, I've adopted the doc-string, with a few minor changes. |
An outstanding issue here is that we no longer provide default implementations of @TwoFX wrote elsewhere:
I propose that we merge as is for now, but keep thinking if there's a clever trick here. Getting these |
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.
Below are a few GetElem
instances that can be removed because of getElemOfDecidable
which I imagine just slipped through.
The rename had already happened, so these are actually the ones that are needed! |
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.
LGTM!
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.
Looks great to me as well!
No description provided.