Skip to content

Commit c1d6de5

Browse files
authored
feat: add Insert instances for NameMap/NameSet (#14153)
This PR adds `Insert` instances for `NameMap` and `NameSet`.
1 parent d14ff0b commit c1d6de5

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/Lean/Data/NameMap/Basic.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ def contains (m : NameMap α) (n : Name) : Bool := Std.TreeMap.contains m n
3535

3636
def find? (m : NameMap α) (n : Name) : Option α := Std.TreeMap.get? m n
3737

38+
instance : Insert (Name × α) (NameMap α) where
39+
insert e s := s.insert e.1 e.2
40+
3841
instance [Monad m] : ForIn m (NameMap α) (Name × α) :=
3942
inferInstanceAs (ForIn _ (Std.TreeMap _ _ _) ..)
4043

@@ -52,6 +55,8 @@ instance : EmptyCollection NameSet := ⟨empty⟩
5255
instance : Inhabited NameSet := ⟨empty⟩
5356
def insert (s : NameSet) (n : Name) : NameSet := Std.TreeSet.insert s n
5457
def contains (s : NameSet) (n : Name) : Bool := Std.TreeSet.contains s n
58+
instance : Insert Name NameSet where
59+
insert n s := s.insert n
5560
instance [Monad m] : ForIn m NameSet Name :=
5661
inferInstanceAs (ForIn _ (Std.TreeSet _ _) ..)
5762

0 commit comments

Comments
 (0)