Skip to content

Commit 2da4769

Browse files
committed
deprecate List.*Assoc functions towards the use of Map
1 parent 6560ea7 commit 2da4769

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

runtime/List.res

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ let rec has = (xs, x, eq) =>
709709
| list{a, ...l} => eq(a, x) || has(l, x, eq)
710710
}
711711

712+
@deprecated("Use a `Map` instead")
712713
let rec getAssoc = (xs, x, eq) =>
713714
switch xs {
714715
| list{} => None
@@ -720,12 +721,14 @@ let rec getAssoc = (xs, x, eq) =>
720721
}
721722
}
722723

724+
@deprecated("Use a `Map` instead")
723725
let rec hasAssoc = (xs, x, eq) =>
724726
switch xs {
725727
| list{} => false
726728
| list{(a, _), ...l} => eq(a, x) || hasAssoc(l, x, eq)
727729
}
728730

731+
@deprecated("Use a `Map` instead")
729732
let removeAssoc = (xs, x, eq) =>
730733
switch xs {
731734
| list{} => list{}
@@ -743,6 +746,7 @@ let removeAssoc = (xs, x, eq) =>
743746
}
744747
}
745748

749+
@deprecated("Use a `Map` instead")
746750
let setAssoc = (xs, x, k, eq) =>
747751
switch xs {
748752
| list{} => list{(x, k)}

runtime/List.resi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ list{(9, "morning"), (15, "afternoon"), (22, "night")}
827827
// Some("afternoon")
828828
```
829829
*/
830+
@deprecated("Use a `Map` instead")
830831
let getAssoc: (list<('a, 'c)>, 'b, ('a, 'b) => bool) => option<'c>
831832

832833
/**
@@ -842,6 +843,7 @@ list{(9, "morning"), (15, "afternoon"), (22, "night")}
842843
->List.hasAssoc(25, (k, item) => k /* 25 */ == item /* 9, 5, 22 */) // false
843844
```
844845
*/
846+
@deprecated("Use a `Map` instead")
845847
let hasAssoc: (list<('a, 'c)>, 'b, ('a, 'b) => bool) => bool
846848

847849
/**
@@ -859,6 +861,7 @@ list{(9, "morning"), (15, "afternoon"), (22, "night")}
859861
// list{(15, "afternoon"), (22, "night")}
860862
```
861863
*/
864+
@deprecated("Use a `Map` instead")
862865
let removeAssoc: (list<('a, 'c)>, 'b, ('a, 'b) => bool) => list<('a, 'c)>
863866

864867
/**
@@ -882,6 +885,7 @@ list{(9, "morning"), (3, "morning?!"), (22, "night")}
882885
**Please note**: In the last example, since: `15 mod 12` equals `3 mod 12`. Both
883886
the key _and_ the value are replaced in the list.
884887
*/
888+
@deprecated("Use a `Map` instead")
885889
let setAssoc: (list<('a, 'c)>, 'a, 'c, ('a, 'a) => bool) => list<('a, 'c)>
886890

887891
/**

0 commit comments

Comments
 (0)