Commit 17127e0
authored
Add 'fromListWithKey' to HashMap (#246)
* Add 'fromListWithKey' to HashMap
Summary:
Test Plan:
Reviewers:
Subscribers:
Tasks:
Tags:
* Define `unsafeInsertWith` using `unsafeInsertWithKey`
See #246 (comment)
for performance numbers.
* Improve documentation of fromListWithKey
Thanks to @emilypi for the suggestions
* Add a test for fromListWithKey
It models the test for fromListWith but makes
sure that values are combined in a way that depends
on the key.
* Clarify the documentation for fromListWithKey
* Improve properties for fromListWith and fromListWithKey
The old properties used associative operators to combine
values when there were duplicate keys.
With this diff we're using a non-commutative and
non-associative operator which can catch more bugs.
* Make sure to return an unboxed tuple in unsafeFromListWithKey
This got lost in a rebase
* Use the free magma to ensure that we preserve the order of operations
* Update fromListWithKey documentation to use non-commutative, non-associative operators
Since the combining function is applied in a way that can be
counter-intuitive it's more pedagical to to use operators which
better illustrate this behaviour.1 parent 0952034 commit 17127e0
File tree
5 files changed
+102
-11
lines changed- Data/HashMap
- Strict
- tests
5 files changed
+102
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| |||
1031 | 1032 | | |
1032 | 1033 | | |
1033 | 1034 | | |
1034 | | - | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
1035 | 1042 | | |
1036 | 1043 | | |
1037 | 1044 | | |
1038 | 1045 | | |
1039 | 1046 | | |
1040 | 1047 | | |
1041 | | - | |
| 1048 | + | |
1042 | 1049 | | |
1043 | 1050 | | |
1044 | 1051 | | |
| |||
1059 | 1066 | | |
1060 | 1067 | | |
1061 | 1068 | | |
1062 | | - | |
| 1069 | + | |
1063 | 1070 | | |
1064 | | - | |
| 1071 | + | |
1065 | 1072 | | |
1066 | 1073 | | |
1067 | 1074 | | |
| |||
1916 | 1923 | | |
1917 | 1924 | | |
1918 | 1925 | | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
1919 | 1954 | | |
1920 | 1955 | | |
1921 | 1956 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| |||
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
112 | | - | |
| 113 | + | |
| 114 | + | |
113 | 115 | | |
114 | 116 | | |
115 | 117 | | |
| |||
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
192 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
193 | 200 | | |
194 | 201 | | |
195 | 202 | | |
196 | 203 | | |
197 | 204 | | |
198 | | - | |
| 205 | + | |
199 | 206 | | |
200 | 207 | | |
201 | 208 | | |
| |||
218 | 225 | | |
219 | 226 | | |
220 | 227 | | |
221 | | - | |
| 228 | + | |
222 | 229 | | |
223 | | - | |
| 230 | + | |
224 | 231 | | |
225 | 232 | | |
226 | 233 | | |
| |||
639 | 646 | | |
640 | 647 | | |
641 | 648 | | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
642 | 677 | | |
643 | 678 | | |
644 | 679 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
366 | 377 | | |
367 | 378 | | |
368 | 379 | | |
369 | 380 | | |
370 | 381 | | |
371 | | - | |
372 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
373 | 391 | | |
374 | 392 | | |
375 | 393 | | |
| |||
467 | 485 | | |
468 | 486 | | |
469 | 487 | | |
| 488 | + | |
470 | 489 | | |
471 | 490 | | |
472 | 491 | | |
| |||
0 commit comments