diff --git a/src/VendoredArray.rei b/src/VendoredArray.rei index 958f9f6..2c6686e 100644 --- a/src/VendoredArray.rei +++ b/src/VendoredArray.rei @@ -16,10 +16,10 @@ Utililites for Array functions */; -/** [length xs] return the size of the array */ +[@dead "length"] /** [length xs] return the size of the array */ external length: array('a) => int = "%array_length"; -/** {b See} {!length} */ external size: array('a) => int = "%array_length"; +[@dead "size"] /** {b See} {!length} */ external size: array('a) => int = "%array_length"; /** [get arr i] @@ -36,14 +36,14 @@ external length: array('a) => int = "%array_length"; let get: (array('a), int) => option('a); -/** [getExn arr i] +[@dead "getExn"] /** [getExn arr i] {b raise} an exception if [i] is out of range;otherwise return the value at index [i] in [arr] */ let getExn: (array('a), int) => 'a; -/** [getUnsafe arr i] +[@dead "getUnsafe"] /** [getUnsafe arr i] {b Unsafe} @@ -52,7 +52,7 @@ let getExn: (array('a), int) => 'a; */ external getUnsafe: (array('a), int) => 'a = "%array_unsafe_get"; -/** [getUndefined arr i] +[@dead "getUndefined"] /** [getUndefined arr i] It does the samething in the runtime as {!getUnsafe}; it is {i type safe} since the return type still track whether it is @@ -61,31 +61,31 @@ external getUnsafe: (array('a), int) => 'a = "%array_unsafe_get"; external getUndefined: (array('a), int) => Js.undefined('a) = "%array_unsafe_get"; -/** [set arr n x] modifies [arr] in place; +[@dead "set"] /** [set arr n x] modifies [arr] in place; it replaces the nth element of [arr] with [x] @return false means not updated due to out of range */ let set: (array('a), int, 'a) => bool; -/** [setExn arr i x] +[@dead "setExn"] /** [setExn arr i x] {b raise} an exception if [i] is out of range */ let setExn: (array('a), int, 'a) => unit; -external setUnsafe: (array('a), int, 'a) => unit = "%array_unsafe_set"; +[@dead "setUnsafe"] external setUnsafe: (array('a), int, 'a) => unit = "%array_unsafe_set"; -/** [shuffleInPlace arr] randomly re-orders the items in [arr] */ +[@dead "shuffleInPlace"] /** [shuffleInPlace arr] randomly re-orders the items in [arr] */ let shuffleInPlace: array('a) => unit; -/** [shuffle xs] +[@dead "shuffle"] /** [shuffle xs] @return a fresh array with items in original array randomly shuffled */ let shuffle: array('a) => array('a); -/** [reverseInPlace arr] reverses items in [arr] in place +[@dead "reverseInPlace"] /** [reverseInPlace arr] reverses items in [arr] in place @example {[ let arr = [|10;11;12;13;14|];; @@ -96,7 +96,7 @@ let shuffle: array('a) => array('a); let reverseInPlace: array('a) => unit; -/** [reverse arr] +[@dead "reverse"] /** [reverse arr] @return a fresh array with items in [arr] in reverse order @example {[ @@ -106,7 +106,7 @@ let reverseInPlace: array('a) => unit; let reverse: array('a) => array('a); -/** +[@dead "makeUninitialized"] /** [makeUninitialized n] creates an array of length [n] filled with the undefined value. You must specify the type of data that will eventually fill the array. @@ -118,7 +118,7 @@ let reverse: array('a) => array('a); [@bs.new] external makeUninitialized: int => array(Js.undefined('a)) = "Array"; -/** [makeUninitializedUnsafe n] +[@dead "makeUninitializedUnsafe"] /** [makeUninitializedUnsafe n] {b Unsafe} @@ -132,14 +132,14 @@ external makeUninitialized: int => array(Js.undefined('a)) = "Array"; [@bs.new] external makeUninitializedUnsafe: int => array('a) = "Array"; -/** [make n e] +[@dead "make"] /** [make n e] return an array of size [n] filled with value [e] @return an empty array when [n] is negative. */ let make: (int, 'a) => array('a); -/** [range start finish] create an inclusive array +[@dead "range"] /** [range start finish] create an inclusive array @example {[ range 0 3 = [|0;1;2;3|];; range 3 0 = [||] ;; @@ -149,7 +149,7 @@ let make: (int, 'a) => array('a); let range: (int, int) => array(int); -/** [range start finish] create an inclusive array +[@dead "rangeBy"] /** [range start finish] create an inclusive array @example {[ range 0 3 = [|0;1;2;3|];; range 3 0 = [||] ;; @@ -174,8 +174,8 @@ let range: (int, int) => array(int); let rangeBy: (int, int, ~step: int) => array(int); -let makeByU: (int, (. int) => 'a) => array('a); -/** [makeBy n f] +[@dead "makeByU"] let makeByU: (int, (. int) => 'a) => array('a); +[@dead "makeBy"] /** [makeBy n f] return an empty array when [n] is negative return an array of size [n] populated by [f i] start from [0] to [n - 1] @@ -188,15 +188,15 @@ let makeByU: (int, (. int) => 'a) => array('a); let makeBy: (int, int => 'a) => array('a); -let makeByAndShuffleU: (int, (. int) => 'a) => array('a); -/** [makeByAndShuffle n f] +[@dead "makeByAndShuffleU"] let makeByAndShuffleU: (int, (. int) => 'a) => array('a); +[@dead "makeByAndShuffle"] /** [makeByAndShuffle n f] Equivalent to [shuffle (makeBy n f)] */ let makeByAndShuffle: (int, int => 'a) => array('a); -/** [zip a b] +[@dead "zip"] /** [zip a b] Create an array of pairs from corresponding elements of [a] and [b]. Stop with the shorter array @@ -208,8 +208,8 @@ let makeByAndShuffle: (int, int => 'a) => array('a); let zip: (array('a), array('b)) => array(('a, 'b)); -let zipByU: (array('a), array('b), (. 'a, 'b) => 'c) => array('c); -/** +[@dead "zipByU"] let zipByU: (array('a), array('b), (. 'a, 'b) => 'c) => array('c); +[@dead "zipBy"] /** [zipBy xs ys f] Create an array by applying [f] to corresponding elements of [xs] and [ys] @@ -224,7 +224,7 @@ let zipByU: (array('a), array('b), (. 'a, 'b) => 'c) => array('c); let zipBy: (array('a), array('b), ('a, 'b) => 'c) => array('c); -/** [unzip a] takes an array of pairs and creates a pair of arrays. The first array contains all the first items of the pairs; the second array contains all the second items. +[@dead "unzip"] /** [unzip a] takes an array of pairs and creates a pair of arrays. The first array contains all the first items of the pairs; the second array contains all the second items. @example {[ unzip [|(1,2) ; (3,4)|] = ([|1;3|], [|2;4|]);; @@ -234,7 +234,7 @@ let zipBy: (array('a), array('b), ('a, 'b) => 'c) => array('c); let unzip: array(('a, 'b)) => (array('a), array('b)); -/** [concat xs ys] +[@dead "concat"] /** [concat xs ys] @return a fresh array containing the concatenation of the arrays [v1] and [v2];so even if [v1] or [v2] @@ -248,7 +248,7 @@ let unzip: array(('a, 'b)) => (array('a), array('b)); let concat: (array('a), array('a)) => array('a); -/** +[@dead "concatMany"] /** [concatMany xss] @return a fresh array as the concatenation of [xss] (an array of arrays) @@ -260,7 +260,7 @@ let concat: (array('a), array('a)) => array('a); let concatMany: array(array('a)) => array('a); -/** [slice xs offset len] creates a new array with the [len] elements of [xs] starting at [offset] for +[@dead "slice"] /** [slice xs offset len] creates a new array with the [len] elements of [xs] starting at [offset] for [offset] can be negative;and is evaluated as [length xs - offset] [slice xs -1 1] means get the last element as a singleton array @@ -281,7 +281,7 @@ let concatMany: array(array('a)) => array('a); let slice: (array('a), ~offset: int, ~len: int) => array('a); -/** [sliceToEnd xs offset] creates a new array with the elements of [xs] starting at [offset] +[@dead "sliceToEnd"] /** [sliceToEnd xs offset] creates a new array with the elements of [xs] starting at [offset] [offset] can be negative;and is evaluated as [length xs - offset] [sliceToEnd xs -1] means get the last element as a singleton array @@ -296,7 +296,7 @@ let slice: (array('a), ~offset: int, ~len: int) => array('a); let sliceToEnd: (array('a), int) => array('a); -/** [copy a] +[@dead "copy"] /** [copy a] @return a copy of [a];that is;a fresh array containing the same elements as [a]. @@ -304,7 +304,7 @@ let sliceToEnd: (array('a), int) => array('a); [@bs.send] external copy: (array('a), [@bs.as 0] _) => array('a) = "slice"; -/** [fill arr ~offset ~len x] +[@dead "fill"] /** [fill arr ~offset ~len x] Modifies [arr] in place, storing [x] in elements number [offset] to [offset + len - 1]. @@ -326,7 +326,7 @@ external copy: (array('a), [@bs.as 0] _) => array('a) = "slice"; let fill: (array('a), ~offset: int, ~len: int, 'a) => unit; -/** [blit ~src:v1 ~srcOffset:o1 ~dst:v2 ~dstOffset:o2 ~len] +[@dead "blit"] /** [blit ~src:v1 ~srcOffset:o1 ~dst:v2 ~dstOffset:o2 ~len] copies [len] elements from array [v1];starting at element number [o1];to array [v2], @@ -361,7 +361,7 @@ let blit: ) => unit; -/** +[@dead "blitUnsafe"] /** {b Unsafe} blit without bounds checking */ @@ -375,8 +375,8 @@ let blitUnsafe: ) => unit; -let forEachU: (array('a), (. 'a) => unit) => unit; -/** [forEach xs f] +[@dead "forEachU"] let forEachU: (array('a), (. 'a) => unit) => unit; +[@dead "forEach"] /** [forEach xs f] Call [f] on each element of [xs] from the beginning to end. [f] returns [unit];so no new array is created. Use [forEach] when you are primarily concerned with repetitively @@ -399,8 +399,8 @@ let forEachU: (array('a), (. 'a) => unit) => unit; let forEach: (array('a), 'a => unit) => unit; -let mapU: (array('a), (. 'a) => 'b) => array('b); -/** [map xs f ] +[@dead "mapU"] let mapU: (array('a), (. 'a) => 'b) => array('b); +[@dead "map"] /** [map xs f ] @return a new array by calling [f] for each element of [xs] from the beginning to end @@ -413,8 +413,8 @@ let mapU: (array('a), (. 'a) => 'b) => array('b); let map: (array('a), 'a => 'b) => array('b); -let getByU: (array('a), (. 'a) => bool) => option('a); -/** [getBy xs p] returns [Some value] for the first value in [xs] that satisifies the predicate function [p]; returns [None] if no element satisifies the function. +[@dead "getByU"] let getByU: (array('a), (. 'a) => bool) => option('a); +[@dead "getBy"] /** [getBy xs p] returns [Some value] for the first value in [xs] that satisifies the predicate function [p]; returns [None] if no element satisifies the function. @example {[ getBy [|1;4;3;2|] (fun x -> x mod 2 = 0) = Some 4 @@ -424,8 +424,8 @@ let getByU: (array('a), (. 'a) => bool) => option('a); let getBy: (array('a), 'a => bool) => option('a); -let getIndexByU: (array('a), (. 'a) => bool) => option(int); -/** [getIndexBy xs p] returns [Some index] for the first value in [xs] that satisifies the predicate function [p]; returns [None] if no element satisifies the function. +[@dead "getIndexByU"] let getIndexByU: (array('a), (. 'a) => bool) => option(int); +[@dead "getIndexBy"] /** [getIndexBy xs p] returns [Some index] for the first value in [xs] that satisifies the predicate function [p]; returns [None] if no element satisifies the function. @example {[ getIndexBy [|1;4;3;2|] (fun x -> x mod 2 = 0) = Some 1 @@ -435,8 +435,8 @@ let getIndexByU: (array('a), (. 'a) => bool) => option(int); let getIndexBy: (array('a), 'a => bool) => option(int); -let keepU: (array('a), (. 'a) => bool) => array('a); -/** [keep xs p ] +[@dead "keepU"] let keepU: (array('a), (. 'a) => bool) => array('a); +[@dead "keep"] /** [keep xs p ] @return a new array that keep all elements satisfy [p] @example {[ @@ -446,8 +446,8 @@ let keepU: (array('a), (. 'a) => bool) => array('a); let keep: (array('a), 'a => bool) => array('a); -let keepWithIndexU: (array('a), (. 'a, int) => bool) => array('a); -/** [keepWithIndex xs p ] +[@dead "keepWithIndexU"] let keepWithIndexU: (array('a), (. 'a, int) => bool) => array('a); +[@dead "keepWithIndex"] /** [keepWithIndex xs p ] @return a new array that keep all elements satisfy [p] @example {[ @@ -457,8 +457,8 @@ let keepWithIndexU: (array('a), (. 'a, int) => bool) => array('a); let keepWithIndex: (array('a), ('a, int) => bool) => array('a); -let keepMapU: (array('a), (. 'a) => option('b)) => array('b); -/** [keepMap xs p] +[@dead "keepMapU"] let keepMapU: (array('a), (. 'a) => option('b)) => array('b); +[@dead "keepMap"] /** [keepMap xs p] @return a new array that keep all elements that return a non-None applied [p] @example {[ @@ -469,8 +469,8 @@ let keepMapU: (array('a), (. 'a) => option('b)) => array('b); let keepMap: (array('a), 'a => option('b)) => array('b); -let forEachWithIndexU: (array('a), (. int, 'a) => unit) => unit; -/** [forEachWithIndex xs f] +[@dead "forEachWithIndexU"] let forEachWithIndexU: (array('a), (. int, 'a) => unit) => unit; +[@dead "forEachWithIndex"] /** [forEachWithIndex xs f] The same as {!forEach};except that [f] is supplied two arguments: the index starting from 0 and the element from [xs] @@ -493,8 +493,8 @@ let forEachWithIndexU: (array('a), (. int, 'a) => unit) => unit; let forEachWithIndex: (array('a), (int, 'a) => unit) => unit; -let mapWithIndexU: (array('a), (. int, 'a) => 'b) => array('b); -/** [mapWithIndex xs f ] +[@dead "mapWithIndexU"] let mapWithIndexU: (array('a), (. int, 'a) => 'b) => array('b); +[@dead "mapWithIndex"] /** [mapWithIndex xs f ] [mapWithIndex xs f] applies [f] to each element of [xs]. Function [f] takes two arguments: the index starting from 0 and the element from [xs]. @@ -507,8 +507,8 @@ let mapWithIndexU: (array('a), (. int, 'a) => 'b) => array('b); let mapWithIndex: (array('a), (int, 'a) => 'b) => array('b); -let partitionU: (array('a), (. 'a) => bool) => (array('a), array('a)); -/** [partition f a] split array into tuple of two arrays based on predicate f; first of tuple where predicate cause true, second where predicate cause false +[@dead "partitionU"] let partitionU: (array('a), (. 'a) => bool) => (array('a), array('a)); +[@dead "partition"] /** [partition f a] split array into tuple of two arrays based on predicate f; first of tuple where predicate cause true, second where predicate cause false @example {[ partition [|1;2;3;4;5|] (fun x -> x mod 2 = 0 ) = ([|2;4|], [|1;2;3|]);; @@ -518,8 +518,8 @@ let partitionU: (array('a), (. 'a) => bool) => (array('a), array('a)); let partition: (array('a), 'a => bool) => (array('a), array('a)); -let reduceU: (array('b), 'a, (. 'a, 'b) => 'a) => 'a; -/** [reduce xs init f] +[@dead "reduceU"] let reduceU: (array('b), 'a, (. 'a, 'b) => 'a) => 'a; +[@dead "reduce"] /** [reduce xs init f] Applies [f] to each element of [xs] from beginning to end. Function [f] has two parameters: the item from the list and an “accumulator”;which starts with a value of [init]. [reduce] @@ -534,8 +534,8 @@ let reduceU: (array('b), 'a, (. 'a, 'b) => 'a) => 'a; let reduce: (array('b), 'a, ('a, 'b) => 'a) => 'a; -let reduceReverseU: (array('b), 'a, (. 'a, 'b) => 'a) => 'a; -/** [reduceReverse xs init f] +[@dead "reduceReverseU"] let reduceReverseU: (array('b), 'a, (. 'a, 'b) => 'a) => 'a; +[@dead "reduceReverse"] /** [reduceReverse xs init f] Works like {!reduce};except that function [f] is applied to each item of [xs] from the last back to the first. @@ -547,8 +547,8 @@ let reduceReverseU: (array('b), 'a, (. 'a, 'b) => 'a) => 'a; let reduceReverse: (array('b), 'a, ('a, 'b) => 'a) => 'a; -let reduceReverse2U: (array('a), array('b), 'c, (. 'c, 'a, 'b) => 'c) => 'c; -/** +[@dead "reduceReverse2U"] let reduceReverse2U: (array('a), array('b), 'c, (. 'c, 'a, 'b) => 'c) => 'c; +[@dead "reduceReverse2"] /** [reduceReverse2 xs ys init f] Reduces two arrays [xs] and [ys];taking items starting at [min (length xs) (length ys)] down to and including zero. @@ -560,8 +560,8 @@ let reduceReverse2U: (array('a), array('b), 'c, (. 'c, 'a, 'b) => 'c) => 'c; let reduceReverse2: (array('a), array('b), 'c, ('c, 'a, 'b) => 'c) => 'c; -let reduceWithIndexU: (array('a), 'b, (. 'b, 'a, int) => 'b) => 'b; -/** [reduceWithIndex xs f] +[@dead "reduceWithIndexU"] let reduceWithIndexU: (array('a), 'b, (. 'b, 'a, int) => 'b) => 'b; +[@dead "reduceWithIndex"] /** [reduceWithIndex xs f] Applies [f] to each element of [xs] from beginning to end. Function [f] has three parameters: the item from the array and an “accumulator”, which starts with a value of [init] and the index of each element. [reduceWithIndex] @@ -574,8 +574,8 @@ let reduceWithIndexU: (array('a), 'b, (. 'b, 'a, int) => 'b) => 'b; let reduceWithIndex: (array('a), 'b, ('b, 'a, int) => 'b) => 'b; -let someU: (array('a), (. 'a) => bool) => bool; -/** [some xs p] +[@dead "someU"] let someU: (array('a), (. 'a) => bool) => bool; +[@dead "some"] /** [some xs p] @return true if at least one of the elements in [xs] satifies [p];where [p] is a {i predicate}: a function taking an element and returning a [bool]. @@ -588,8 +588,8 @@ let someU: (array('a), (. 'a) => bool) => bool; let some: (array('a), 'a => bool) => bool; -let everyU: (array('a), (. 'a) => bool) => bool; -/** [every xs p] +[@dead "everyU"] let everyU: (array('a), (. 'a) => bool) => bool; +[@dead "every"] /** [every xs p] @return true if all elements satisfy [p];where [p] is a {i predicate}: a function taking an element and returning a [bool]. @@ -602,8 +602,8 @@ let everyU: (array('a), (. 'a) => bool) => bool; let every: (array('a), 'a => bool) => bool; -let every2U: (array('a), array('b), (. 'a, 'b) => bool) => bool; -/** [every2 xs ys p] returns true if [p xi yi] is true for all pairs of elements +[@dead "every2U"] let every2U: (array('a), array('b), (. 'a, 'b) => bool) => bool; +[@dead "every2"] /** [every2 xs ys p] returns true if [p xi yi] is true for all pairs of elements up to the shorter length (i.e. [min (length xs) (length ys)]) @example {[ every2 [|1;2;3|] [|0;1|] (>) = true;; @@ -615,8 +615,8 @@ let every2U: (array('a), array('b), (. 'a, 'b) => bool) => bool; let every2: (array('a), array('b), ('a, 'b) => bool) => bool; -let some2U: (array('a), array('b), (. 'a, 'b) => bool) => bool; -/** [some2 xs ys p] returns true if [p xi yi] is true for any pair of elements +[@dead "some2U"] let some2U: (array('a), array('b), (. 'a, 'b) => bool) => bool; +[@dead "some2"] /** [some2 xs ys p] returns true if [p xi yi] is true for any pair of elements up to the shorter length (i.e. [min (length xs) (length ys)]) @example {[ @@ -628,8 +628,8 @@ let some2U: (array('a), array('b), (. 'a, 'b) => bool) => bool; let some2: (array('a), array('b), ('a, 'b) => bool) => bool; -let cmpU: (array('a), array('a), (. 'a, 'a) => int) => int; -/** [cmp xs ys f] +[@dead "cmpU"] let cmpU: (array('a), array('a), (. 'a, 'a) => int) => int; +[@dead "cmp"] /** [cmp xs ys f] - Compared by length if [length xs <> length ys];returning -1 if[length xs < length ys] or 1 if [length xs > length ys] - Otherwise compare one by one [f x y]. [f] returns @@ -647,8 +647,8 @@ let cmpU: (array('a), array('a), (. 'a, 'a) => int) => int; let cmp: (array('a), array('a), ('a, 'a) => int) => int; -let eqU: (array('a), array('a), (. 'a, 'a) => bool) => bool; -/** [eq xs ys] +[@dead "eqU"] let eqU: (array('a), array('a), (. 'a, 'a) => bool) => bool; +[@dead "eq"] /** [eq xs ys] - return false if length is not the same - otherwise compare items one by one using [f xi yi];and return true if all results are true;false otherwise @@ -660,7 +660,7 @@ let eqU: (array('a), array('a), (. 'a, 'a) => bool) => bool; let eq: (array('a), array('a), ('a, 'a) => bool) => bool; -/** {b Unsafe} +[@dead "truncateToLengthUnsafe"] /** {b Unsafe} [truncateToLengthUnsafe xs n] sets length of array [xs] to [n]. If [n] is greater than the length of [xs];the extra elements are set to [Js.Null_undefined.null] @@ -675,4 +675,4 @@ let eq: (array('a), array('a), ('a, 'a) => bool) => bool; */ [@bs.set] -external truncateToLengthUnsafe: (array('a), int) => unit = "length"; +external truncateToLengthUnsafe: (array('a), int) => unit = "length"; \ No newline at end of file