diff --git a/src/Std/Data/DHashMap/Basic.lean b/src/Std/Data/DHashMap/Basic.lean index b51e76776b8e..7a3e6a3a3239 100644 --- a/src/Std/Data/DHashMap/Basic.lean +++ b/src/Std/Data/DHashMap/Basic.lean @@ -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⟩ diff --git a/src/Std/Data/DHashMap/Raw.lean b/src/Std/Data/DHashMap/Raw.lean index c38602d7f5a5..f3c9c027a634 100644 --- a/src/Std/Data/DHashMap/Raw.lean +++ b/src/Std/Data/DHashMap/Raw.lean @@ -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. -/ diff --git a/src/Std/Data/HashMap/Basic.lean b/src/Std/Data/HashMap/Basic.lean index b05098cc1eab..ba499c34a622 100644 --- a/src/Std/Data/HashMap/Basic.lean +++ b/src/Std/Data/HashMap/Basic.lean @@ -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⟩ diff --git a/src/Std/Data/HashMap/Raw.lean b/src/Std/Data/HashMap/Raw.lean index 9cd4118efda1..174df4126265 100644 --- a/src/Std/Data/HashMap/Raw.lean +++ b/src/Std/Data/HashMap/Raw.lean @@ -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⟩ diff --git a/src/Std/Data/HashSet/Basic.lean b/src/Std/Data/HashSet/Basic.lean index ee840b92f10a..34d9c7168ac6 100644 --- a/src/Std/Data/HashSet/Basic.lean +++ b/src/Std/Data/HashSet/Basic.lean @@ -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. diff --git a/src/Std/Data/HashSet/Raw.lean b/src/Std/Data/HashSet/Raw.lean index 8ec894022634..299542f9f132 100644 --- a/src/Std/Data/HashSet/Raw.lean +++ b/src/Std/Data/HashSet/Raw.lean @@ -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.