Skip to content
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

chore: Inhabited instances for Std.HashMap #4682

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Std/Data/DHashMap/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ namespace DHashMap
instance [BEq α] [Hashable α] : EmptyCollection (DHashMap α β) where
emptyCollection := empty

instance [BEq α] [Hashable α] : Inhabited (DHashMap α β) where
default := ∅

@[inline, inherit_doc Raw.insert] def insert [BEq α] [Hashable α] (m : DHashMap α β) (a : α)
(b : β a) : DHashMap α β :=
⟨Raw₀.insert ⟨m.1, m.2.size_buckets_pos⟩ a b, .insert₀ m.2⟩
Expand Down
3 changes: 3 additions & 0 deletions src/Std/Data/DHashMap/Raw.lean
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ capacity.
instance : EmptyCollection (Raw α β) where
emptyCollection := empty

instance : Inhabited (Raw α β) where
default := ∅

/--
Inserts the given mapping into the map, replacing an existing mapping for the key if there is one.
-/
Expand Down
3 changes: 3 additions & 0 deletions src/Std/Data/HashMap/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ namespace HashMap
instance [BEq α] [Hashable α] : EmptyCollection (HashMap α β) where
emptyCollection := empty

instance [BEq α] [Hashable α] : Inhabited (HashMap α β) where
default := ∅

@[inline, inherit_doc DHashMap.insert] def insert [BEq α] [Hashable α] (m : HashMap α β) (a : α)
(b : β) : HashMap α β :=
⟨m.inner.insert a b⟩
Expand Down
3 changes: 3 additions & 0 deletions src/Std/Data/HashMap/Raw.lean
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ namespace Raw
instance : EmptyCollection (Raw α β) where
emptyCollection := empty

instance : Inhabited (Raw α β) where
default := ∅

@[inline, inherit_doc DHashMap.Raw.insert] def insert [BEq α] [Hashable α] (m : Raw α β) (a : α)
(b : β) : Raw α β :=
⟨m.inner.insert a b⟩
Expand Down
3 changes: 3 additions & 0 deletions src/Std/Data/HashSet/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ capacity.
instance [BEq α] [Hashable α] : EmptyCollection (HashSet α) where
emptyCollection := empty

instance [BEq α] [Hashable α] : Inhabited (HashSet α) where
default := ∅

/--
Inserts the given element into the set. If the hash set already contains an element that is
equal (with regard to `==`) to the given element, then the hash set is returned unchanged.
Expand Down
3 changes: 3 additions & 0 deletions src/Std/Data/HashSet/Raw.lean
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ the empty collection notations `∅` and `{}` to create an empty hash set with t
instance : EmptyCollection (Raw α) where
emptyCollection := empty

instance : Inhabited (Raw α) where
default := ∅

/--
Inserts the given element into the set. If the hash set already contains an element that is
equal (with regard to `==`) to the given element, then the hash set is returned unchanged.
Expand Down
Loading