Skip to content

Commit 0646bc5

Browse files
authored
refactor: move Inhabited instances in constant DTreeMap queries (#11448)
This PR moves the `Inhabited` instances in constant `DTreeMap` (and related) queries, such as `Const.get!`, where the `Inhabited` instance can be provided before proving a key.
1 parent 2eca5ca commit 0646bc5

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed

src/Std/Data/DTreeMap/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ def get (t : DTreeMap α β cmp) (a : α) (h : a ∈ t) : β :=
685685
letI : Ord α := ⟨cmp⟩; Impl.Const.get t.inner a h
686686

687687
@[inline, inherit_doc DTreeMap.get!]
688-
def get! (t : DTreeMap α β cmp) (a : α) [Inhabited β] : β :=
688+
def get! [Inhabited β] (t : DTreeMap α β cmp) (a : α) : β :=
689689
letI : Ord α := ⟨cmp⟩; Impl.Const.get! t.inner a
690690

691691
@[inline, inherit_doc DTreeMap.getD]

src/Std/Data/DTreeMap/Internal/Queries.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def get [Ord α] (t : Impl α δ) (k : α) (hlk : t.contains k = true) : δ :=
216216
| .eq => v'
217217

218218
/-- Returns the value for the key `k`, or panics if such a key does not exist. -/
219-
def get! [Ord α] (t : Impl α δ) (k : α) [Inhabited δ] : δ :=
219+
def get! [Ord α] [Inhabited δ] (t : Impl α δ) (k : α) : δ :=
220220
match t with
221221
| .leaf => panic! "Key is not present in map"
222222
| .inner _ k' v' l r =>

src/Std/Data/DTreeMap/Raw/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def get (t : Raw α β cmp) (a : α) (h : a ∈ t) : β :=
433433
letI : Ord α := ⟨cmp⟩; Impl.Const.get t.inner a h
434434

435435
@[inline, inherit_doc DTreeMap.Const.get!]
436-
def get! (t : Raw α β cmp) (a : α) [Inhabited β] : β :=
436+
def get! [Inhabited β] (t : Raw α β cmp) (a : α) : β :=
437437
letI : Ord α := ⟨cmp⟩; Impl.Const.get! t.inner a
438438

439439
@[inline, inherit_doc DTreeMap.Const.getD]

src/Std/Data/ExtDTreeMap/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ def get [TransCmp cmp] (t : ExtDTreeMap α β cmp) (a : α) (h : a ∈ t) : β :
521521
(fun _ _ _ _ h => h.constGet_eq)
522522

523523
@[inline, inherit_doc ExtDTreeMap.get!]
524-
def get! [TransCmp cmp] (t : ExtDTreeMap α β cmp) (a : α) [Inhabited β] : β :=
524+
def get! [TransCmp cmp] [Inhabited β] (t : ExtDTreeMap α β cmp) (a : α) : β :=
525525
t.lift (fun m => DTreeMap.Const.get! m a)
526526
(fun _ _ h => h.constGet!_eq)
527527

src/Std/Data/ExtTreeMap/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def get [TransCmp cmp] (t : ExtTreeMap α β cmp) (a : α) (h : a ∈ t) : β :=
152152
ExtDTreeMap.Const.get t.inner a h
153153

154154
@[inline, inherit_doc ExtDTreeMap.Const.get!]
155-
def get! [TransCmp cmp] (t : ExtTreeMap α β cmp) (a : α) [Inhabited β] : β :=
155+
def get! [TransCmp cmp] [Inhabited β] (t : ExtTreeMap α β cmp) (a : α) : β :=
156156
ExtDTreeMap.Const.get! t.inner a
157157

158158
@[inline, inherit_doc ExtDTreeMap.Const.getD]

src/Std/Data/TreeMap/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def get (t : TreeMap α β cmp) (a : α) (h : a ∈ t) : β :=
155155
DTreeMap.Const.get t.inner a h
156156

157157
@[inline, inherit_doc DTreeMap.Const.get!]
158-
def get! (t : TreeMap α β cmp) (a : α) [Inhabited β] : β :=
158+
def get! [Inhabited β] (t : TreeMap α β cmp) (a : α) : β :=
159159
DTreeMap.Const.get! t.inner a
160160

161161
@[inline, inherit_doc DTreeMap.Const.getD]

src/Std/Data/TreeMap/Raw/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def get (t : Raw α β cmp) (a : α) (h : a ∈ t) : β :=
167167
DTreeMap.Raw.Const.get t.inner a h
168168

169169
@[inline, inherit_doc DTreeMap.Raw.Const.get!]
170-
def get! (t : Raw α β cmp) (a : α) [Inhabited β] : β :=
170+
def get! [Inhabited β] (t : Raw α β cmp) (a : α) : β :=
171171
DTreeMap.Raw.Const.get! t.inner a
172172

173173
@[inline, inherit_doc DTreeMap.Raw.Const.getD]

0 commit comments

Comments
 (0)