Skip to content

Commit 1518aa8

Browse files
committed
chore: add test case with bad grind pattern
1 parent 4694aaa commit 1518aa8

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import Std.Data.HashMap
2+
import Std.Data.TreeMap
3+
4+
open Std
5+
6+
/--
7+
info: Std.DTreeMap.contains_iff_mem.{u, v} {α : Type u} {β : α → Type v} {cmp : α → α → Ordering} {t : DTreeMap α β cmp}
8+
{k : α} : t.contains k = true ↔ k ∈ t
9+
-/
10+
#guard_msgs in
11+
#check DTreeMap.contains_iff_mem
12+
13+
-- I like what `[grind _=_]` does here!
14+
/--
15+
info: DTreeMap.contains_iff_mem: [@DTreeMap.contains #4 #3 #2 #1 #0, true]
16+
---
17+
info: DTreeMap.contains_iff_mem: [@Membership.mem #4 (@DTreeMap _ #3 #2) _ #1 #0]
18+
-/
19+
#guard_msgs in
20+
attribute [grind? _=_] DTreeMap.contains_iff_mem
21+
22+
-- Similarly for every other `contains_iff_mem` we encounter (`List`, `Array`, `Vector`, `HashSet`, `HashMap`, etc.)
23+
24+
-- But:
25+
26+
/--
27+
info: Std.DHashMap.contains_iff_mem.{u, v} {α : Type u} {β : α → Type v} {x✝ : BEq α} {x✝¹ : Hashable α} {m : DHashMap α β}
28+
{a : α} : m.contains a = true ↔ a ∈ m
29+
-/
30+
#guard_msgs in
31+
#check DHashMap.contains_iff_mem
32+
33+
-- Here the reverse direction of `[grind _=_]` gives a pattern than matches too often: `@Membership.mem #5 _ _ #1 #0`.
34+
/--
35+
info: DHashMap.contains_iff_mem: [@DHashMap.contains #5 #4 #3 #2 #1 #0, true]
36+
---
37+
info: DHashMap.contains_iff_mem: [@Membership.mem #5 _ _ #1 #0]
38+
-/
39+
#guard_msgs in
40+
attribute [grind? _=_] DHashMap.contains_iff_mem
41+
42+
-- We can do this manually with
43+
grind_pattern DHashMap.contains_iff_mem => @Membership.mem α (DHashMap α β) _ m a

0 commit comments

Comments
 (0)