Skip to content

Commit b8bca10

Browse files
committed
deprecate List.*Assoc functions towards the use of Map
1 parent 6f0e444 commit b8bca10

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

runtime/Stdlib_List.res

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

692+
@deprecated("Use a `Map` instead")
692693
let rec getAssoc = (xs, x, eq) =>
693694
switch xs {
694695
| list{} => None
@@ -700,12 +701,14 @@ let rec getAssoc = (xs, x, eq) =>
700701
}
701702
}
702703

704+
@deprecated("Use a `Map` instead")
703705
let rec hasAssoc = (xs, x, eq) =>
704706
switch xs {
705707
| list{} => false
706708
| list{(a, _), ...l} => eq(a, x) || hasAssoc(l, x, eq)
707709
}
708710

711+
@deprecated("Use a `Map` instead")
709712
let removeAssoc = (xs, x, eq) =>
710713
switch xs {
711714
| list{} => list{}
@@ -723,6 +726,7 @@ let removeAssoc = (xs, x, eq) =>
723726
}
724727
}
725728

729+
@deprecated("Use a `Map` instead")
726730
let setAssoc = (xs, x, k, eq) =>
727731
switch xs {
728732
| list{} => list{(x, k)}

runtime/Stdlib_List.resi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@ list{(9, "morning"), (15, "afternoon"), (22, "night")}
822822
// Some("afternoon")
823823
```
824824
*/
825+
@deprecated("Use a `Map` instead")
825826
let getAssoc: (list<('a, 'c)>, 'b, ('a, 'b) => bool) => option<'c>
826827

827828
/**
@@ -837,6 +838,7 @@ list{(9, "morning"), (15, "afternoon"), (22, "night")}
837838
->List.hasAssoc(25, (k, item) => k /* 25 */ == item /* 9, 5, 22 */) // false
838839
```
839840
*/
841+
@deprecated("Use a `Map` instead")
840842
let hasAssoc: (list<('a, 'c)>, 'b, ('a, 'b) => bool) => bool
841843

842844
/**
@@ -854,6 +856,7 @@ list{(9, "morning"), (15, "afternoon"), (22, "night")}
854856
// list{(15, "afternoon"), (22, "night")}
855857
```
856858
*/
859+
@deprecated("Use a `Map` instead")
857860
let removeAssoc: (list<('a, 'c)>, 'b, ('a, 'b) => bool) => list<('a, 'c)>
858861

859862
/**
@@ -877,6 +880,7 @@ list{(9, "morning"), (3, "morning?!"), (22, "night")}
877880
**Please note**: In the last example, since: `15 mod 12` equals `3 mod 12`. Both
878881
the key _and_ the value are replaced in the list.
879882
*/
883+
@deprecated("Use a `Map` instead")
880884
let setAssoc: (list<('a, 'c)>, 'a, 'c, ('a, 'a) => bool) => list<('a, 'c)>
881885

882886
/**

0 commit comments

Comments
 (0)