From 1229489f9e981542cf91c1237090023ce081fb20 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Mon, 5 Aug 2024 07:43:03 +0200 Subject: [PATCH] Sync Belt sources from compiler repo --- belt/src/belt_Array.js | 17 +- belt/src/belt_Array.res | 27 +-- belt/src/belt_Array.resi | 52 +++--- belt/src/belt_HashMap.res | 26 +-- belt/src/belt_HashMap.resi | 6 +- belt/src/belt_HashMapInt.resi | 6 +- belt/src/belt_HashMapString.resi | 6 +- belt/src/belt_HashSet.res | 16 +- belt/src/belt_HashSet.resi | 4 +- belt/src/belt_HashSetInt.resi | 4 +- belt/src/belt_HashSetString.resi | 4 +- belt/src/belt_Id.res | 24 +-- belt/src/belt_Id.resi | 16 +- belt/src/belt_List.js | 39 +---- belt/src/belt_List.res | 144 +++++++-------- belt/src/belt_List.resi | 62 +++---- belt/src/belt_Map.res | 26 +-- belt/src/belt_Map.resi | 27 ++- belt/src/belt_MapDict.res | 24 +-- belt/src/belt_MapDict.resi | 31 ++-- belt/src/belt_MapInt.res | 6 +- belt/src/belt_MapInt.resi | 26 +-- belt/src/belt_MapString.res | 6 +- belt/src/belt_MapString.resi | 26 +-- belt/src/belt_MutableMap.res | 26 +-- belt/src/belt_MutableMap.resi | 18 +- belt/src/belt_MutableMapInt.res | 22 +-- belt/src/belt_MutableMapInt.resi | 18 +- belt/src/belt_MutableMapString.res | 22 +-- belt/src/belt_MutableMapString.resi | 18 +- belt/src/belt_MutableQueue.res | 12 +- belt/src/belt_MutableQueue.resi | 6 +- belt/src/belt_MutableSet.res | 28 +-- belt/src/belt_MutableSet.resi | 12 +- belt/src/belt_MutableSetInt.res | 12 +- belt/src/belt_MutableSetInt.resi | 12 +- belt/src/belt_MutableSetString.res | 12 +- belt/src/belt_MutableSetString.resi | 12 +- belt/src/belt_MutableStack.res | 8 +- belt/src/belt_MutableStack.resi | 4 +- belt/src/belt_Option.res | 28 +-- belt/src/belt_Option.resi | 14 +- belt/src/belt_Range.res | 20 +-- belt/src/belt_Range.resi | 10 +- belt/src/belt_Result.res | 20 +-- belt/src/belt_Result.resi | 10 +- belt/src/belt_Set.res | 12 +- belt/src/belt_Set.resi | 12 +- belt/src/belt_SetDict.res | 8 +- belt/src/belt_SetDict.resi | 12 +- belt/src/belt_SetInt.resi | 14 +- belt/src/belt_SetString.resi | 14 +- belt/src/belt_SortArray.res | 46 ++--- belt/src/belt_SortArray.resi | 16 +- belt/src/belt_internalAVLset.js | 242 +++++++------------------- belt/src/belt_internalAVLset.res | 50 +++--- belt/src/belt_internalAVLset.resi | 16 +- belt/src/belt_internalAVLtree.js | 228 ++++++------------------ belt/src/belt_internalAVLtree.res | 68 ++++---- belt/src/belt_internalAVLtree.resi | 24 +-- belt/src/belt_internalBuckets.res | 26 +-- belt/src/belt_internalBuckets.resi | 6 +- belt/src/belt_internalMapInt.js | 24 +-- belt/src/belt_internalMapInt.res | 18 +- belt/src/belt_internalMapString.js | 24 +-- belt/src/belt_internalMapString.res | 18 +- belt/src/belt_internalSetBuckets.res | 14 +- belt/src/belt_internalSetBuckets.resi | 4 +- 68 files changed, 767 insertions(+), 1098 deletions(-) diff --git a/belt/src/belt_Array.js b/belt/src/belt_Array.js index 3204ded..9800ea2 100644 --- a/belt/src/belt_Array.js +++ b/belt/src/belt_Array.js @@ -58,22 +58,11 @@ function swapUnsafe(xs, i, j) { xs[j] = tmp; } -function floor_int(f) { - if (f > 2147483647) { - return 2147483647; - } else if (f < -2147483648) { - return -2147483648; - } else { - return floor(f); - } -} - -function random_int(min, max) { - return floor_int(Math.random() * (max - min | 0)) + min | 0; -} - function shuffleInPlace(xs) { let len = xs.length; + let random_int = function (min, max) { + return Math.floor(Math.random() * (max - min | 0)) + min | 0; + }; for(let i = 0; i < len; ++i){ swapUnsafe(xs, i, random_int(i, len)); } diff --git a/belt/src/belt_Array.res b/belt/src/belt_Array.res index a45a6ed..e83e044 100644 --- a/belt/src/belt_Array.res +++ b/belt/src/belt_Array.res @@ -64,32 +64,15 @@ let swapUnsafe = (xs, i, j) => { setUnsafe(xs, j, tmp) } -// TODO? Parts of Js.Math/Js.Int that we need for the shuffle function -module Js_math = { - @val @scope("Math") - external random: unit => float = "random" - external intToFloat: int => float = "%floatofint" - external unsafe_floor_int: float => int = "floor" - - let intMax: int = 2147483647 - let intMin: int = -2147483648 - - let floor_int = f => - if f > intToFloat(intMax) { - intMax - } else if f < intToFloat(intMin) { - intMin - } else { - unsafe_floor_int(f) - } - - let random_int = (min, max) => floor_int(random() *. intToFloat(max - min)) + min -} +@val @scope("Math") external random: unit => float = "random" +@val @scope("Math") external floor: float => int = "floor" +external toFloat: int => float = "%floatofint" let shuffleInPlace = xs => { let len = length(xs) + let random_int = (min, max) => floor(random() *. toFloat(max - min)) + min for i in 0 to len - 1 { - swapUnsafe(xs, i, Js_math.random_int(i, len)) /* [i,len) */ + swapUnsafe(xs, i, random_int(i, len)) /* [i,len) */ } } diff --git a/belt/src/belt_Array.resi b/belt/src/belt_Array.resi index eb81098..ba2c628 100644 --- a/belt/src/belt_Array.resi +++ b/belt/src/belt_Array.resi @@ -205,7 +205,7 @@ Belt.Array.rangeBy(3, 3, ~step=1) == [3] */ let rangeBy: (int, int, ~step: int) => array -let makeByU: (int, (. int) => 'a) => t<'a> +let makeByU: (int, int => 'a) => t<'a> /** `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`. @@ -220,7 +220,7 @@ Belt.Array.makeBy(5, (i) => i * i) == [0, 1, 4, 9, 16] */ let makeBy: (int, int => 'a) => t<'a> -let makeByAndShuffleU: (int, (. int) => 'a) => t<'a> +let makeByAndShuffleU: (int, int => 'a) => t<'a> /** Equivalent to `shuffle(makeBy(n, f))` */ @@ -238,7 +238,7 @@ Belt.Array.zip([1, 2], [3, 4, 5]) == [(1, 3), (2, 4)] */ let zip: (t<'a>, array<'b>) => array<('a, 'b)> -let zipByU: (t<'a>, array<'b>, (. 'a, 'b) => 'c) => array<'c> +let zipByU: (t<'a>, array<'b>, ('a, 'b) => 'c) => array<'c> /** `zipBy(xs, ys, f)` create an array by applying `f` to corresponding elements of `xs` and `ys`. Stops with shorter array. @@ -392,7 +392,7 @@ Unsafe blit without bounds checking. */ let blitUnsafe: (~src: t<'a>, ~srcOffset: int, ~dst: t<'a>, ~dstOffset: int, ~len: int) => unit -let forEachU: (t<'a>, (. 'a) => unit) => unit +let forEachU: (t<'a>, 'a => unit) => unit /** `forEach(xs, f)` @@ -420,7 +420,7 @@ total.contents == 1 + 2 + 3 + 4 */ let forEach: (t<'a>, 'a => unit) => unit -let mapU: (t<'a>, (. 'a) => 'b) => array<'b> +let mapU: (t<'a>, 'a => 'b) => array<'b> /** `map(xs, f)` returns a new array by calling `f` for each element of `xs` from the beginning to end. @@ -433,7 +433,7 @@ Belt.Array.map([1, 2], (x) => x + 1) == [3, 4] */ let map: (t<'a>, 'a => 'b) => array<'b> -let flatMapU: (t<'a>, (. 'a) => array<'b>) => array<'b> +let flatMapU: (t<'a>, 'a => array<'b>) => array<'b> /** `flatMap(xs, f)` returns a new array by calling `f` for each element of `xs` from the beginning to end, concatenating the results. @@ -446,7 +446,7 @@ Belt.Array.flatMap([1, 2], x => [x + 10, x + 20]) == [11, 21, 12, 22] */ let flatMap: (t<'a>, 'a => array<'b>) => array<'b> -let getByU: (t<'a>, (. 'a) => bool) => option<'a> +let getByU: (t<'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. @@ -460,7 +460,7 @@ Belt.Array.getBy([15, 13, 11], (x) => mod(x, 2) == 0) == None */ let getBy: (t<'a>, 'a => bool) => option<'a> -let getIndexByU: (t<'a>, (. 'a) => bool) => option +let getIndexByU: (t<'a>, 'a => bool) => option /** `getIndexBy(xs, p)` returns `Some(index)` for the first value in `xs` that satisifies the predicate function `p`; returns `None` if no element satisifies @@ -475,13 +475,13 @@ Belt.Array.getIndexBy([15, 13, 11], (x) => mod(x, 2) == 0) == None */ let getIndexBy: (t<'a>, 'a => bool) => option -let keepU: (t<'a>, (. 'a) => bool) => t<'a> +let keepU: (t<'a>, 'a => bool) => t<'a> /** `keep(xs, p)` returns a new array that keep all elements satisfy `p`. */ let keep: (t<'a>, 'a => bool) => t<'a> -let keepWithIndexU: (t<'a>, (. 'a, int) => bool) => t<'a> +let keepWithIndexU: (t<'a>, ('a, int) => bool) => t<'a> /** `keepWithIndex(xs, p)` returns a new array that keep all elements satisfy `p`. @@ -493,7 +493,7 @@ Belt.Array.keepWithIndex([1, 2, 3], (_x, i) => i == 1) == [2] */ let keepWithIndex: (t<'a>, ('a, int) => bool) => t<'a> -let keepMapU: (t<'a>, (. 'a) => option<'b>) => array<'b> +let keepMapU: (t<'a>, 'a => option<'b>) => array<'b> /** `keepMap(xs, p)` returns a new array that keep all elements that return a non None applied `p`. @@ -513,7 +513,7 @@ Belt.Array.keepMap([1, 2, 3], x => */ let keepMap: (t<'a>, 'a => option<'b>) => array<'b> -let forEachWithIndexU: (t<'a>, (. int, 'a) => unit) => unit +let forEachWithIndexU: (t<'a>, (int, 'a) => unit) => unit /** `forEachWithIndex(xs, f)` same as `Belt.Array.forEach`, except that `f` is supplied two arguments: the index starting from 0 and the element from `xs`. @@ -538,7 +538,7 @@ total.contents == 0 + 10 + 1 + 11 + 2 + 12 + 3 + 13 */ let forEachWithIndex: (t<'a>, (int, 'a) => unit) => unit -let mapWithIndexU: (t<'a>, (. int, 'a) => 'b) => array<'b> +let mapWithIndexU: (t<'a>, (int, 'a) => 'b) => array<'b> /** `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`. @@ -551,7 +551,7 @@ Belt.Array.mapWithIndex([1, 2, 3], (i, x) => i + x) == [0 + 1, 1 + 2, 2 + 3] */ let mapWithIndex: (t<'a>, (int, 'a) => 'b) => array<'b> -let partitionU: (t<'a>, (. 'a) => bool) => (t<'a>, t<'a>) +let partitionU: (t<'a>, 'a => bool) => (t<'a>, t<'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 @@ -566,7 +566,7 @@ Belt.Array.partition([1, 2, 3, 4, 5], (x) => mod(x, 2) != 0) == ([1, 3, 5], [2, */ let partition: (t<'a>, 'a => bool) => (t<'a>, t<'a>) -let reduceU: (array<'b>, 'a, (. 'a, 'b) => 'a) => 'a +let reduceU: (array<'b>, 'a, ('a, 'b) => 'a) => 'a /** `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”; @@ -583,7 +583,7 @@ Belt.Array.reduce(["a", "b", "c", "d"], "", (a, b) => a ++ b) == "abcd" */ let reduce: (array<'b>, 'a, ('a, 'b) => 'a) => 'a -let reduceReverseU: (array<'b>, 'a, (. 'a, 'b) => 'a) => 'a +let reduceReverseU: (array<'b>, 'a, ('a, 'b) => 'a) => 'a /** `reduceReverse(xs, init, f)` works like `Belt.Array.reduce` except that function `f` is applied to each item of `xs` from the last back to the first. @@ -596,7 +596,7 @@ Belt.Array.reduceReverse(["a", "b", "c", "d"], "", (a, b) => a ++ b) == "dcba" */ let reduceReverse: (array<'b>, 'a, ('a, 'b) => 'a) => 'a -let reduceReverse2U: (t<'a>, array<'b>, 'c, (. 'c, 'a, 'b) => 'c) => 'c +let reduceReverse2U: (t<'a>, array<'b>, 'c, ('c, 'a, 'b) => 'c) => 'c /** `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. @@ -609,7 +609,7 @@ Belt.Array.reduceReverse2([1, 2, 3], [1, 2], 0, (acc, x, y) => acc + x + y) == 6 */ let reduceReverse2: (t<'a>, array<'b>, 'c, ('c, 'a, 'b) => 'c) => 'c -let reduceWithIndexU: (t<'a>, 'b, (. 'b, 'a, int) => 'b) => 'b +let reduceWithIndexU: (t<'a>, 'b, ('b, 'a, int) => 'b) => 'b /** 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 @@ -624,7 +624,7 @@ Belt.Array.reduceWithIndex([1, 2, 3, 4], 0, (acc, x, i) => acc + x + i) == 16 */ let reduceWithIndex: (t<'a>, 'b, ('b, 'a, int) => 'b) => 'b -let joinWithU: (t<'a>, string, (. 'a) => string) => string +let joinWithU: (t<'a>, string, 'a => string) => string /** `joinWith(xs, sep, toString)` @@ -643,7 +643,7 @@ Belt.Array.joinWith([1], " ", Js.Int.toString) == "1" */ let joinWith: (t<'a>, string, 'a => string) => string -let someU: (t<'a>, (. 'a) => bool) => bool +let someU: (t<'a>, 'a => bool) => bool /** `some(xs, p)` returns true if at least one of the elements in `xs` satifies `p`; where `p` is a predicate: a function taking an element and returning a `bool`. @@ -658,7 +658,7 @@ Belt.Array.some([(-1), (-3), (-5)], (x) => x > 0) == false */ let some: (t<'a>, 'a => bool) => bool -let everyU: (t<'a>, (. 'a) => bool) => bool +let everyU: (t<'a>, 'a => bool) => bool /** `every(xs, p)` returns `true` if all elements satisfy `p`; where `p` is a predicate: a function taking an element and returning a `bool`. @@ -673,7 +673,7 @@ Belt.Array.every([1, (-3), 5], (x) => x > 0) == false */ let every: (t<'a>, 'a => bool) => bool -let every2U: (t<'a>, array<'b>, (. 'a, 'b) => bool) => bool +let every2U: (t<'a>, array<'b>, ('a, 'b) => bool) => bool /** `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))`) @@ -692,7 +692,7 @@ Belt.Array.every2([0, 1], [5, 0], (x, y) => x > y) == false */ let every2: (t<'a>, array<'b>, ('a, 'b) => bool) => bool -let some2U: (t<'a>, array<'b>, (. 'a, 'b) => bool) => bool +let some2U: (t<'a>, array<'b>, ('a, 'b) => bool) => bool /** `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))`) @@ -709,7 +709,7 @@ Belt.Array.some2([2, 3], [1, 4], (x, y) => x > y) == true */ let some2: (t<'a>, array<'b>, ('a, 'b) => bool) => bool -let cmpU: (t<'a>, t<'a>, (. 'a, 'a) => int) => int +let cmpU: (t<'a>, t<'a>, ('a, 'a) => int) => int /** `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 @@ -730,7 +730,7 @@ Belt.Array.cmp([1, 3, 5], [1, 3, 5], (a, b) => compare(a, b)) == 0 */ let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int -let eqU: (t<'a>, t<'a>, (. 'a, 'a) => bool) => bool +let eqU: (t<'a>, t<'a>, ('a, 'a) => bool) => bool /** `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 @@ -761,7 +761,7 @@ arr == ["ant", "bee", "cat"] */ external truncateToLengthUnsafe: (t<'a>, int) => unit = "length" -let initU: (int, (. int) => 'a) => t<'a> +let initU: (int, int => 'a) => t<'a> let init: (int, int => 'a) => t<'a> /** diff --git a/belt/src/belt_HashMap.res b/belt/src/belt_HashMap.res index 38650bd..7b0928b 100644 --- a/belt/src/belt_HashMap.res +++ b/belt/src/belt_HashMap.res @@ -41,7 +41,7 @@ let rec copyBucketReHash = (~hash, ~h_buckets, ~ndata_tail, old_bucket) => switch C.toOpt(old_bucket) { | None => () | Some(cell) => - let nidx = land(hash(. cell.N.key), A.length(h_buckets) - 1) + let nidx = land(hash(cell.N.key), A.length(h_buckets) - 1) let v = C.return(cell) switch C.toOpt(A.getUnsafe(ndata_tail, nidx)) { | None => A.setUnsafe(h_buckets, nidx, v) @@ -73,7 +73,7 @@ let resize = (~hash, h) => { } let rec replaceInBucket = (~eq, key, info, cell) => - if eq(. cell.N.key, key) { + if eq(cell.N.key, key) { cell.N.value = info false } else { @@ -86,7 +86,7 @@ let rec replaceInBucket = (~eq, key, info, cell) => let set0 = (h, key, value, ~eq, ~hash) => { let h_buckets = h.C.buckets let buckets_len = A.length(h_buckets) - let i = land(hash(. key), buckets_len - 1) + let i = land(hash(key), buckets_len - 1) let l = A.getUnsafe(h_buckets, i) switch C.toOpt(l) { | None => @@ -114,7 +114,7 @@ let rec removeInBucket = (h, h_buckets, i, key, prec, bucket, ~eq) => | None => () | Some(cell) => let cell_next = cell.N.next - if eq(. cell.N.key, key) { + if eq(cell.N.key, key) { prec.N.next = cell_next h.C.size = h.C.size - 1 } else { @@ -124,13 +124,13 @@ let rec removeInBucket = (h, h_buckets, i, key, prec, bucket, ~eq) => let remove = (h, key) => { let h_buckets = h.C.buckets - let i = land(Belt_Id.getHashInternal(h.C.hash)(. key), A.length(h_buckets) - 1) + let i = land(Belt_Id.getHashInternal(h.C.hash)(key), A.length(h_buckets) - 1) let bucket = A.getUnsafe(h_buckets, i) switch C.toOpt(bucket) { | None => () | Some(cell) => let eq = Belt_Id.getEqInternal(h.C.eq) - if eq(. cell.N.key, key) { + if eq(cell.N.key, key) { A.setUnsafe(h_buckets, i, cell.N.next) h.C.size = h.C.size - 1 } else { @@ -143,7 +143,7 @@ let rec getAux = (~eq, key, buckets) => switch C.toOpt(buckets) { | None => None | Some(cell) => - if eq(. key, cell.N.key) { + if eq(key, cell.N.key) { Some(cell.N.value) } else { getAux(~eq, key, cell.N.next) @@ -152,24 +152,24 @@ let rec getAux = (~eq, key, buckets) => let get = (h, key) => { let h_buckets = h.C.buckets - let nid = land(Belt_Id.getHashInternal(h.C.hash)(. key), A.length(h_buckets) - 1) + let nid = land(Belt_Id.getHashInternal(h.C.hash)(key), A.length(h_buckets) - 1) switch C.toOpt(A.getUnsafe(h_buckets, nid)) { | None => None | Some(cell1: N.bucket<_>) => let eq = Belt_Id.getEqInternal(h.C.eq) - if eq(. key, cell1.key) { + if eq(key, cell1.key) { Some(cell1.value) } else { switch C.toOpt(cell1.N.next) { | None => None | Some(cell2) => - if eq(. key, cell2.key) { + if eq(key, cell2.key) { Some(cell2.value) } else { switch C.toOpt(cell2.next) { | None => None | Some(cell3) => - if eq(. key, cell3.key) { + if eq(key, cell3.key) { Some(cell3.value) } else { getAux(~eq, key, cell3.next) @@ -182,7 +182,7 @@ let get = (h, key) => { } let rec memInBucket = (key, cell, ~eq) => - eq(. cell.N.key, key) || + eq(cell.N.key, key) || switch C.toOpt(cell.N.next) { | None => false | Some(nextCell) => memInBucket(~eq, key, nextCell) @@ -190,7 +190,7 @@ let rec memInBucket = (key, cell, ~eq) => let has = (h, key) => { let h_buckets = h.C.buckets - let nid = land(Belt_Id.getHashInternal(h.C.hash)(. key), A.length(h_buckets) - 1) + let nid = land(Belt_Id.getHashInternal(h.C.hash)(key), A.length(h_buckets) - 1) let bucket = A.getUnsafe(h_buckets, nid) switch C.toOpt(bucket) { | None => false diff --git a/belt/src/belt_HashMap.resi b/belt/src/belt_HashMap.resi index 972b858..e60d5ad 100644 --- a/belt/src/belt_HashMap.resi +++ b/belt/src/belt_HashMap.resi @@ -242,7 +242,7 @@ Belt.HashMap.has(s0, 1) == false let remove: (t<'key, 'value, 'id>, 'key) => unit /** Same as [forEach](#forEach) but takes uncurried function. */ -let forEachU: (t<'key, 'value, 'id>, (. 'key, 'value) => unit) => unit +let forEachU: (t<'key, 'value, 'id>, ('key, 'value) => unit) => unit /** `forEach(tbl, f)` applies `f` to all bindings in table `tbl`. `f` receives the key as first argument, and the associated value as second argument. Each binding is presented exactly once to `f`. @@ -264,7 +264,7 @@ Belt.HashMap.forEach(s0, (key, value) => Js.log2(key, value)) */ let forEach: (t<'key, 'value, 'id>, ('key, 'value) => unit) => unit -let reduceU: (t<'key, 'value, 'id>, 'c, (. 'c, 'key, 'value) => 'c) => 'c +let reduceU: (t<'key, 'value, 'id>, 'c, ('c, 'key, 'value) => 'c) => 'c /** `reduce(tbl, init, f)` computes `(f(kN, dN) ... (f(k1, d1, init))...)`, where `k1 ... kN` are the keys of all bindings in `tbl`, and `d1 ... dN` are the associated values. Each binding is presented exactly once to `f`. @@ -289,7 +289,7 @@ Belt.HashMap.reduce(s0, "", (acc, key, value) => acc ++ (", " ++ value)) == "val let reduce: (t<'key, 'value, 'id>, 'c, ('c, 'key, 'value) => 'c) => 'c /** Same as [keepMapInPlace](#keepMapInPlace) but takes uncurried function. */ -let keepMapInPlaceU: (t<'key, 'value, 'id>, (. 'key, 'value) => option<'value>) => unit +let keepMapInPlaceU: (t<'key, 'value, 'id>, ('key, 'value) => option<'value>) => unit /** Filters out values for which function `f` returned `None`. diff --git a/belt/src/belt_HashMapInt.resi b/belt/src/belt_HashMapInt.resi index 67ea502..b5a5f04 100644 --- a/belt/src/belt_HashMapInt.resi +++ b/belt/src/belt_HashMapInt.resi @@ -21,13 +21,13 @@ let has: (t<'b>, key) => bool let remove: (t<'a>, key) => unit -let forEachU: (t<'b>, (. key, 'b) => unit) => unit +let forEachU: (t<'b>, (key, 'b) => unit) => unit let forEach: (t<'b>, (key, 'b) => unit) => unit -let reduceU: (t<'b>, 'c, (. 'c, key, 'b) => 'c) => 'c +let reduceU: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c let reduce: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c -let keepMapInPlaceU: (t<'a>, (. key, 'a) => option<'a>) => unit +let keepMapInPlaceU: (t<'a>, (key, 'a) => option<'a>) => unit let keepMapInPlace: (t<'a>, (key, 'a) => option<'a>) => unit let size: t<_> => int diff --git a/belt/src/belt_HashMapString.resi b/belt/src/belt_HashMapString.resi index be4cf46..81a7f51 100644 --- a/belt/src/belt_HashMapString.resi +++ b/belt/src/belt_HashMapString.resi @@ -21,13 +21,13 @@ let has: (t<'b>, key) => bool let remove: (t<'a>, key) => unit -let forEachU: (t<'b>, (. key, 'b) => unit) => unit +let forEachU: (t<'b>, (key, 'b) => unit) => unit let forEach: (t<'b>, (key, 'b) => unit) => unit -let reduceU: (t<'b>, 'c, (. 'c, key, 'b) => 'c) => 'c +let reduceU: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c let reduce: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c -let keepMapInPlaceU: (t<'a>, (. key, 'a) => option<'a>) => unit +let keepMapInPlaceU: (t<'a>, (key, 'a) => option<'a>) => unit let keepMapInPlace: (t<'a>, (key, 'a) => option<'a>) => unit let size: t<_> => int diff --git a/belt/src/belt_HashSet.res b/belt/src/belt_HashSet.res index f4d0a70..4d2a858 100644 --- a/belt/src/belt_HashSet.res +++ b/belt/src/belt_HashSet.res @@ -40,7 +40,7 @@ let rec copyBucket = (~hash, ~h_buckets, ~ndata_tail, old_bucket) => switch C.toOpt(old_bucket) { | None => () | Some(cell) => - let nidx = land(Belt_Id.getHashInternal(hash)(. cell.N.key), A.length(h_buckets) - 1) + let nidx = land(Belt_Id.getHashInternal(hash)(cell.N.key), A.length(h_buckets) - 1) let v = C.return(cell) switch C.toOpt(A.getUnsafe(ndata_tail, nidx)) { | None => A.setUnsafe(h_buckets, nidx, v) @@ -73,7 +73,7 @@ let tryDoubleResize = (~hash, h) => { let rec removeBucket = (~eq, h, h_buckets, i, key, prec, cell) => { let cell_next = cell.N.next - if Belt_Id.getEqInternal(eq)(. cell.N.key, key) { + if Belt_Id.getEqInternal(eq)(cell.N.key, key) { prec.N.next = cell_next h.C.size = h.C.size - 1 } else { @@ -87,13 +87,13 @@ let rec removeBucket = (~eq, h, h_buckets, i, key, prec, cell) => { let remove = (h, key) => { let eq = h.C.eq let h_buckets = h.C.buckets - let i = land(Belt_Id.getHashInternal(h.C.hash)(. key), A.length(h_buckets) - 1) + let i = land(Belt_Id.getHashInternal(h.C.hash)(key), A.length(h_buckets) - 1) let l = A.getUnsafe(h_buckets, i) switch C.toOpt(l) { | None => () | Some(cell) => let next_cell = cell.N.next - if Belt_Id.getEqInternal(eq)(. cell.N.key, key) { + if Belt_Id.getEqInternal(eq)(cell.N.key, key) { h.C.size = h.C.size - 1 A.setUnsafe(h_buckets, i, next_cell) } else { @@ -106,7 +106,7 @@ let remove = (h, key) => { } let rec addBucket = (h, key, cell, ~eq) => - if !Belt_Id.getEqInternal(eq)(. cell.N.key, key) { + if !Belt_Id.getEqInternal(eq)(cell.N.key, key) { let n = cell.N.next switch C.toOpt(n) { | None => @@ -119,7 +119,7 @@ let rec addBucket = (h, key, cell, ~eq) => let add0 = (h, key, ~hash, ~eq) => { let h_buckets = h.C.buckets let buckets_len = A.length(h_buckets) - let i = land(Belt_Id.getHashInternal(hash)(. key), buckets_len - 1) + let i = land(Belt_Id.getHashInternal(hash)(key), buckets_len - 1) let l = A.getUnsafe(h_buckets, i) switch C.toOpt(l) { | None => @@ -135,7 +135,7 @@ let add0 = (h, key, ~hash, ~eq) => { let add = (h, key) => add0(~hash=h.C.hash, ~eq=h.C.eq, h, key) let rec memInBucket = (~eq, key, cell) => - Belt_Id.getEqInternal(eq)(. cell.N.key, key) || + Belt_Id.getEqInternal(eq)(cell.N.key, key) || switch C.toOpt(cell.N.next) { | None => false | Some(nextCell) => memInBucket(~eq, key, nextCell) @@ -143,7 +143,7 @@ let rec memInBucket = (~eq, key, cell) => let has = (h, key) => { let (eq, h_buckets) = (h.C.eq, h.C.buckets) - let nid = land(Belt_Id.getHashInternal(h.C.hash)(. key), A.length(h_buckets) - 1) + let nid = land(Belt_Id.getHashInternal(h.C.hash)(key), A.length(h_buckets) - 1) let bucket = A.getUnsafe(h_buckets, nid) switch C.toOpt(bucket) { | None => false diff --git a/belt/src/belt_HashSet.resi b/belt/src/belt_HashSet.resi index 6055194..990e80d 100644 --- a/belt/src/belt_HashSet.resi +++ b/belt/src/belt_HashSet.resi @@ -101,11 +101,11 @@ let has: (t<'a, 'id>, 'a) => bool let remove: (t<'a, 'id>, 'a) => unit -let forEachU: (t<'a, 'id>, (. 'a) => unit) => unit +let forEachU: (t<'a, 'id>, 'a => unit) => unit /** Order unspecified. */ let forEach: (t<'a, 'id>, 'a => unit) => unit -let reduceU: (t<'a, 'id>, 'c, (. 'c, 'a) => 'c) => 'c +let reduceU: (t<'a, 'id>, 'c, ('c, 'a) => 'c) => 'c /** Order unspecified. */ let reduce: (t<'a, 'id>, 'c, ('c, 'a) => 'c) => 'c diff --git a/belt/src/belt_HashSetInt.resi b/belt/src/belt_HashSetInt.resi index 05325e8..526ffc2 100644 --- a/belt/src/belt_HashSetInt.resi +++ b/belt/src/belt_HashSetInt.resi @@ -49,10 +49,10 @@ let has: (t, key) => bool let remove: (t, key) => unit -let forEachU: (t, (. key) => unit) => unit +let forEachU: (t, key => unit) => unit let forEach: (t, key => unit) => unit -let reduceU: (t, 'c, (. 'c, key) => 'c) => 'c +let reduceU: (t, 'c, ('c, key) => 'c) => 'c let reduce: (t, 'c, ('c, key) => 'c) => 'c let size: t => int diff --git a/belt/src/belt_HashSetString.resi b/belt/src/belt_HashSetString.resi index 3c2532f..f4dbad1 100644 --- a/belt/src/belt_HashSetString.resi +++ b/belt/src/belt_HashSetString.resi @@ -49,10 +49,10 @@ let has: (t, key) => bool let remove: (t, key) => unit -let forEachU: (t, (. key) => unit) => unit +let forEachU: (t, key => unit) => unit let forEach: (t, key => unit) => unit -let reduceU: (t, 'c, (. 'c, key) => 'c) => 'c +let reduceU: (t, 'c, ('c, key) => 'c) => 'c let reduce: (t, 'c, ('c, key) => 'c) => 'c let size: t => int diff --git a/belt/src/belt_Id.res b/belt/src/belt_Id.res index 7fc993e..d88456e 100644 --- a/belt/src/belt_Id.res +++ b/belt/src/belt_Id.res @@ -22,13 +22,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -type hash<'a, 'id> = (. 'a) => int -type eq<'a, 'id> = (. 'a, 'a) => bool -type cmp<'a, 'id> = (. 'a, 'a) => int +type hash<'a, 'id> = 'a => int +type eq<'a, 'id> = ('a, 'a) => bool +type cmp<'a, 'id> = ('a, 'a) => int -external getHashInternal: hash<'a, 'id> => (. 'a) => int = "%identity" -external getEqInternal: eq<'a, 'id> => (. 'a, 'a) => bool = "%identity" -external getCmpInternal: cmp<'a, 'id> => (. 'a, 'a) => int = "%identity" +external getHashInternal: hash<'a, 'id> => 'a => int = "%identity" +external getEqInternal: eq<'a, 'id> => ('a, 'a) => bool = "%identity" +external getCmpInternal: cmp<'a, 'id> => ('a, 'a) => int = "%identity" module type Comparable = { type identity @@ -41,7 +41,7 @@ type comparable<'key, 'id> = module(Comparable with type t = 'key and type ident module MakeComparableU = ( M: { type t - let cmp: (. t, t) => int + let cmp: (t, t) => int }, ) => { type identity @@ -59,7 +59,7 @@ module MakeComparable = ( /* see https://github.com/rescript-lang/rescript-compiler/pull/2589/files/5ef875b7665ee08cfdc59af368fc52bac1fe9130#r173330825 */ let cmp = { let cmp = M.cmp - (. a, b) => cmp(a, b) + (a, b) => cmp(a, b) } } @@ -91,8 +91,8 @@ type hashable<'key, 'id> = module(Hashable with type t = 'key and type identity module MakeHashableU = ( M: { type t - let hash: (. t) => int - let eq: (. t, t) => bool + let hash: t => int + let eq: (t, t) => bool }, ) => { type identity @@ -110,11 +110,11 @@ module MakeHashable = ( type t = M.t let hash = { let hash = M.hash - (. a) => hash(a) + a => hash(a) } let eq = { let eq = M.eq - (. a, b) => eq(a, b) + (a, b) => eq(a, b) } } diff --git a/belt/src/belt_Id.resi b/belt/src/belt_Id.resi index 72aecc4..921d783 100644 --- a/belt/src/belt_Id.resi +++ b/belt/src/belt_Id.resi @@ -78,7 +78,7 @@ type comparable<'key, 'id> = module(Comparable with type t = 'key and type ident module MakeComparableU: ( M: { type t - let cmp: (. t, t) => int + let cmp: (t, t) => int }, ) => (Comparable with type t = M.t) @@ -89,7 +89,7 @@ module MakeComparable: ( }, ) => (Comparable with type t = M.t) -let comparableU: (~cmp: (. 'a, 'a) => int) => module(Comparable with type t = 'a) +let comparableU: (~cmp: ('a, 'a) => int) => module(Comparable with type t = 'a) /** ## Examples @@ -127,8 +127,8 @@ type hashable<'key, 'id> = module(Hashable with type t = 'key and type identity module MakeHashableU: ( M: { type t - let hash: (. t) => int - let eq: (. t, t) => bool + let hash: t => int + let eq: (t, t) => bool }, ) => (Hashable with type t = M.t) @@ -140,10 +140,10 @@ module MakeHashable: ( }, ) => (Hashable with type t = M.t) -let hashableU: (~hash: (. 'a) => int, ~eq: (. 'a, 'a) => bool) => module(Hashable with type t = 'a) +let hashableU: (~hash: 'a => int, ~eq: ('a, 'a) => bool) => module(Hashable with type t = 'a) let hashable: (~hash: 'a => int, ~eq: ('a, 'a) => bool) => module(Hashable with type t = 'a) -external getHashInternal: hash<'a, 'id> => (. 'a) => int = "%identity" -external getEqInternal: eq<'a, 'id> => (. 'a, 'a) => bool = "%identity" -external getCmpInternal: cmp<'a, 'id> => (. 'a, 'a) => int = "%identity" +external getHashInternal: hash<'a, 'id> => 'a => int = "%identity" +external getEqInternal: eq<'a, 'id> => ('a, 'a) => bool = "%identity" +external getCmpInternal: cmp<'a, 'id> => ('a, 'a) => int = "%identity" diff --git a/belt/src/belt_List.js b/belt/src/belt_List.js index aaafd4a..f6fa499 100644 --- a/belt/src/belt_List.js +++ b/belt/src/belt_List.js @@ -1419,45 +1419,16 @@ function partitionU(l, p) { let b = p(h); partitionAux(p, l.tl, nextX, nextY); if (b) { - let tmp; - if (nextY) { - tmp = nextY.tl; - } else { - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_List.res", - 876, - 20 - ] - } - }); - } return [ nextX, - tmp + nextY.tl ]; - } - let tmp$1; - if (nextX) { - tmp$1 = nextX.tl; } else { - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_List.res", - 883, - 20 - ] - } - }); + return [ + nextX.tl, + nextY + ]; } - return [ - tmp$1, - nextY - ]; } function partition(l, p) { diff --git a/belt/src/belt_List.res b/belt/src/belt_List.res index e3f73fd..ff661eb 100644 --- a/belt/src/belt_List.res +++ b/belt/src/belt_List.res @@ -59,7 +59,7 @@ ``` */ -@@bs.config({flags: ["-bs-noassertfalse"]}) +@@config({flags: ["-bs-noassertfalse"]}) type t<'a> = list<'a> @@ -148,7 +148,7 @@ let rec partitionAux = (p, cell, precX, precY) => | list{} => () | list{h, ...t} => let next = mutableCell(h, list{}) - if p(. h) { + if p(h) { unsafeMutateTail(precX, next) partitionAux(p, t, next, precY) } else { @@ -184,7 +184,7 @@ let rec copyAuxWitFilter = (f, cellX, prec) => switch cellX { | list{} => () | list{h, ...t} => - if f(. h) { + if f(h) { let next = mutableCell(h, list{}) unsafeMutateTail(prec, next) copyAuxWitFilter(f, t, next) @@ -197,7 +197,7 @@ let rec copyAuxWithFilterIndex = (f, cellX, prec, i) => switch cellX { | list{} => () | list{h, ...t} => - if f(. h, i) { + if f(h, i) { let next = mutableCell(h, list{}) unsafeMutateTail(prec, next) copyAuxWithFilterIndex(f, t, next, i + 1) @@ -210,7 +210,7 @@ let rec copyAuxWitFilterMap = (f, cellX, prec) => switch cellX { | list{} => () | list{h, ...t} => - switch f(. h) { + switch f(h) { | Some(h) => let next = mutableCell(h, list{}) unsafeMutateTail(prec, next) @@ -223,7 +223,7 @@ let rec removeAssocAuxWithMap = (cellX, x, prec, f) => switch cellX { | list{} => false | list{(a, _) as h, ...t} => - if f(. a, x) { + if f(a, x) { unsafeMutateTail(prec, t) true } else { @@ -237,7 +237,7 @@ let rec setAssocAuxWithMap = (cellX, x, k, prec, eq) => switch cellX { | list{} => false | list{(a, _) as h, ...t} => - if eq(. a, x) { + if eq(a, x) { unsafeMutateTail(prec, list{(x, k), ...t}) true } else { @@ -251,7 +251,7 @@ let rec copyAuxWithMap = (cellX, prec, f) => switch cellX { | list{} => () | list{h, ...t} => - let next = mutableCell(f(. h), list{}) + let next = mutableCell(f(h), list{}) unsafeMutateTail(prec, next) copyAuxWithMap(t, next, f) } @@ -268,7 +268,7 @@ let rec zipAux = (cellX, cellY, prec) => let rec copyAuxWithMap2 = (f, cellX, cellY, prec) => switch (cellX, cellY) { | (list{h1, ...t1}, list{h2, ...t2}) => - let next = mutableCell(f(. h1, h2), list{}) + let next = mutableCell(f(h1, h2), list{}) unsafeMutateTail(prec, next) copyAuxWithMap2(f, t1, t2, next) | (list{}, _) | (_, list{}) => () @@ -277,7 +277,7 @@ let rec copyAuxWithMap2 = (f, cellX, cellY, prec) => let rec copyAuxWithMapI = (f, i, cellX, prec) => switch cellX { | list{h, ...t} => - let next = mutableCell(f(. i, h), list{}) + let next = mutableCell(f(i, h), list{}) unsafeMutateTail(prec, next) copyAuxWithMapI(f, i + 1, t, next) | list{} => () @@ -377,44 +377,44 @@ let mapU = (xs, f) => switch xs { | list{} => list{} | list{h, ...t} => - let cell = mutableCell(f(. h), list{}) + let cell = mutableCell(f(h), list{}) copyAuxWithMap(t, cell, f) cell } -let map = (xs, f) => mapU(xs, (. x) => f(x)) +let map = (xs, f) => mapU(xs, x => f(x)) let zipByU = (l1, l2, f) => switch (l1, l2) { | (list{a1, ...l1}, list{a2, ...l2}) => - let cell = mutableCell(f(. a1, a2), list{}) + let cell = mutableCell(f(a1, a2), list{}) copyAuxWithMap2(f, l1, l2, cell) cell | (list{}, _) | (_, list{}) => list{} } -let zipBy = (l1, l2, f) => zipByU(l1, l2, (. x, y) => f(x, y)) +let zipBy = (l1, l2, f) => zipByU(l1, l2, (x, y) => f(x, y)) let mapWithIndexU = (xs, f) => switch xs { | list{} => list{} | list{h, ...t} => - let cell = mutableCell(f(. 0, h), list{}) + let cell = mutableCell(f(0, h), list{}) copyAuxWithMapI(f, 1, t, cell) cell } -let mapWithIndex = (xs, f) => mapWithIndexU(xs, (. i, x) => f(i, x)) +let mapWithIndex = (xs, f) => mapWithIndexU(xs, (i, x) => f(i, x)) let makeByU = (n, f) => if n <= 0 { list{} } else { - let headX = mutableCell(f(. 0), list{}) + let headX = mutableCell(f(0), list{}) let cur = ref(headX) let i = ref(1) while i.contents < n { - let v = mutableCell(f(. i.contents), list{}) + let v = mutableCell(f(i.contents), list{}) unsafeMutateTail(cur.contents, v) cur.contents = v i.contents = i.contents + 1 @@ -423,7 +423,7 @@ let makeByU = (n, f) => headX } -let makeBy = (n, f) => makeByU(n, (. x) => f(x)) +let makeBy = (n, f) => makeByU(n, x => f(x)) let make = (type a, n, v: a): list => if n <= 0 { @@ -541,46 +541,46 @@ let concatMany = xs => let rec mapRevAux = (f, accu, xs) => switch xs { | list{} => accu - | list{a, ...l} => mapRevAux(f, list{f(. a), ...accu}, l) + | list{a, ...l} => mapRevAux(f, list{f(a), ...accu}, l) } let mapReverseU = (l, f) => mapRevAux(f, list{}, l) -let mapReverse = (l, f) => mapReverseU(l, (. x) => f(x)) +let mapReverse = (l, f) => mapReverseU(l, x => f(x)) let rec forEachU = (xs, f) => switch xs { | list{} => () | list{a, ...l} => - f(. a)->ignore + f(a)->ignore forEachU(l, f) } -let forEach = (xs, f) => forEachU(xs, (. x) => f(x)) +let forEach = (xs, f) => forEachU(xs, x => f(x)) let rec iteri = (xs, i, f) => switch xs { | list{} => () | list{a, ...l} => - f(. i, a)->ignore + f(i, a)->ignore iteri(l, i + 1, f) } let forEachWithIndexU = (l, f) => iteri(l, 0, f) -let forEachWithIndex = (l, f) => forEachWithIndexU(l, (. i, x) => f(i, x)) +let forEachWithIndex = (l, f) => forEachWithIndexU(l, (i, x) => f(i, x)) let rec reduceU = (l, accu, f) => switch l { | list{} => accu - | list{a, ...l} => reduceU(l, f(. accu, a), f) + | list{a, ...l} => reduceU(l, f(accu, a), f) } -let reduce = (l, accu, f) => reduceU(l, accu, (. acc, x) => f(acc, x)) +let reduce = (l, accu, f) => reduceU(l, accu, (acc, x) => f(acc, x)) let rec reduceReverseUnsafeU = (l, accu, f) => switch l { | list{} => accu - | list{a, ...l} => f(. reduceReverseUnsafeU(l, accu, f), a) + | list{a, ...l} => f(reduceReverseUnsafeU(l, accu, f), a) } let reduceReverseU = (type a b, l: list, acc: b, f) => { @@ -592,50 +592,50 @@ let reduceReverseU = (type a b, l: list, acc: b, f) => { } } -let reduceReverse = (l, accu, f) => reduceReverseU(l, accu, (. a, b) => f(a, b)) +let reduceReverse = (l, accu, f) => reduceReverseU(l, accu, (a, b) => f(a, b)) let rec reduceWithIndexAuxU = (l, acc, f, i) => switch l { | list{} => acc - | list{x, ...xs} => reduceWithIndexAuxU(xs, f(. acc, x, i), f, i + 1) + | list{x, ...xs} => reduceWithIndexAuxU(xs, f(acc, x, i), f, i + 1) } let reduceWithIndexU = (l, acc, f) => reduceWithIndexAuxU(l, acc, f, 0) -let reduceWithIndex = (l, acc, f) => reduceWithIndexU(l, acc, (. acc, x, i) => f(acc, x, i)) +let reduceWithIndex = (l, acc, f) => reduceWithIndexU(l, acc, (acc, x, i) => f(acc, x, i)) let rec mapRevAux2 = (l1, l2, accu, f) => switch (l1, l2) { - | (list{a1, ...l1}, list{a2, ...l2}) => mapRevAux2(l1, l2, list{f(. a1, a2), ...accu}, f) + | (list{a1, ...l1}, list{a2, ...l2}) => mapRevAux2(l1, l2, list{f(a1, a2), ...accu}, f) | (_, list{}) | (list{}, _) => accu } let mapReverse2U = (l1, l2, f) => mapRevAux2(l1, l2, list{}, f) -let mapReverse2 = (l1, l2, f) => mapReverse2U(l1, l2, (. a, b) => f(a, b)) +let mapReverse2 = (l1, l2, f) => mapReverse2U(l1, l2, (a, b) => f(a, b)) let rec forEach2U = (l1, l2, f) => switch (l1, l2) { | (list{a1, ...l1}, list{a2, ...l2}) => - f(. a1, a2)->ignore + f(a1, a2)->ignore forEach2U(l1, l2, f) | (list{}, _) | (_, list{}) => () } -let forEach2 = (l1, l2, f) => forEach2U(l1, l2, (. a, b) => f(a, b)) +let forEach2 = (l1, l2, f) => forEach2U(l1, l2, (a, b) => f(a, b)) let rec reduce2U = (l1, l2, accu, f) => switch (l1, l2) { - | (list{a1, ...l1}, list{a2, ...l2}) => reduce2U(l1, l2, f(. accu, a1, a2), f) + | (list{a1, ...l1}, list{a2, ...l2}) => reduce2U(l1, l2, f(accu, a1, a2), f) | (list{}, _) | (_, list{}) => accu } -let reduce2 = (l1, l2, acc, f) => reduce2U(l1, l2, acc, (. a, b, c) => f(a, b, c)) +let reduce2 = (l1, l2, acc, f) => reduce2U(l1, l2, acc, (a, b, c) => f(a, b, c)) let rec reduceReverse2UnsafeU = (l1, l2, accu, f) => switch (l1, l2) { | (list{}, list{}) => accu - | (list{a1, ...l1}, list{a2, ...l2}) => f(. reduceReverse2UnsafeU(l1, l2, accu, f), a1, a2) + | (list{a1, ...l1}, list{a2, ...l2}) => f(reduceReverse2UnsafeU(l1, l2, accu, f), a1, a2) | (_, list{}) | (list{}, _) => accu } @@ -648,31 +648,31 @@ let reduceReverse2U = (type a b c, l1: list, l2: list, acc: c, f) => { } } -let reduceReverse2 = (l1, l2, acc, f) => reduceReverse2U(l1, l2, acc, (. a, b, c) => f(a, b, c)) +let reduceReverse2 = (l1, l2, acc, f) => reduceReverse2U(l1, l2, acc, (a, b, c) => f(a, b, c)) let rec everyU = (xs, p) => switch xs { | list{} => true - | list{a, ...l} => p(. a) && everyU(l, p) + | list{a, ...l} => p(a) && everyU(l, p) } -let every = (xs, p) => everyU(xs, (. x) => p(x)) +let every = (xs, p) => everyU(xs, x => p(x)) let rec someU = (xs, p) => switch xs { | list{} => false - | list{a, ...l} => p(. a) || someU(l, p) + | list{a, ...l} => p(a) || someU(l, p) } -let some = (xs, p) => someU(xs, (. x) => p(x)) +let some = (xs, p) => someU(xs, x => p(x)) let rec every2U = (l1, l2, p) => switch (l1, l2) { | (_, list{}) | (list{}, _) => true - | (list{a1, ...l1}, list{a2, ...l2}) => p(. a1, a2) && every2U(l1, l2, p) + | (list{a1, ...l1}, list{a2, ...l2}) => p(a1, a2) && every2U(l1, l2, p) } -let every2 = (l1, l2, p) => every2U(l1, l2, (. a, b) => p(a, b)) +let every2 = (l1, l2, p) => every2U(l1, l2, (a, b) => p(a, b)) let rec cmpByLength = (l1, l2) => switch (l1, l2) { @@ -688,7 +688,7 @@ let rec cmpU = (l1, l2, p) => | (_, list{}) => 1 | (list{}, _) => -1 | (list{a1, ...l1}, list{a2, ...l2}) => - let c = p(. a1, a2) + let c = p(a1, a2) if c == 0 { cmpU(l1, l2, p) } else { @@ -696,7 +696,7 @@ let rec cmpU = (l1, l2, p) => } } -let cmp = (l1, l2, f) => cmpU(l1, l2, (. x, y) => f(x, y)) +let cmp = (l1, l2, f) => cmpU(l1, l2, (x, y) => f(x, y)) let rec eqU = (l1, l2, p) => switch (l1, l2) { @@ -704,56 +704,56 @@ let rec eqU = (l1, l2, p) => | (_, list{}) | (list{}, _) => false | (list{a1, ...l1}, list{a2, ...l2}) => - if p(. a1, a2) { + if p(a1, a2) { eqU(l1, l2, p) } else { false } } -let eq = (l1, l2, f) => eqU(l1, l2, (. x, y) => f(x, y)) +let eq = (l1, l2, f) => eqU(l1, l2, (x, y) => f(x, y)) let rec some2U = (l1, l2, p) => switch (l1, l2) { | (list{}, _) | (_, list{}) => false - | (list{a1, ...l1}, list{a2, ...l2}) => p(. a1, a2) || some2U(l1, l2, p) + | (list{a1, ...l1}, list{a2, ...l2}) => p(a1, a2) || some2U(l1, l2, p) } -let some2 = (l1, l2, p) => some2U(l1, l2, (. a, b) => p(a, b)) +let some2 = (l1, l2, p) => some2U(l1, l2, (a, b) => p(a, b)) let rec hasU = (xs, x, eq) => switch xs { | list{} => false - | list{a, ...l} => eq(. a, x) || hasU(l, x, eq) + | list{a, ...l} => eq(a, x) || hasU(l, x, eq) } -let has = (xs, x, eq) => hasU(xs, x, (. a, b) => eq(a, b)) +let has = (xs, x, eq) => hasU(xs, x, (a, b) => eq(a, b)) let rec getAssocU = (xs, x, eq) => switch xs { | list{} => None | list{(a, b), ...l} => - if eq(. a, x) { + if eq(a, x) { Some(b) } else { getAssocU(l, x, eq) } } -let getAssoc = (xs, x, eq) => getAssocU(xs, x, (. a, b) => eq(a, b)) +let getAssoc = (xs, x, eq) => getAssocU(xs, x, (a, b) => eq(a, b)) let rec hasAssocU = (xs, x, eq) => switch xs { | list{} => false - | list{(a, _), ...l} => eq(. a, x) || hasAssocU(l, x, eq) + | list{(a, _), ...l} => eq(a, x) || hasAssocU(l, x, eq) } -let hasAssoc = (xs, x, eq) => hasAssocU(xs, x, (. a, b) => eq(a, b)) +let hasAssoc = (xs, x, eq) => hasAssocU(xs, x, (a, b) => eq(a, b)) let removeAssocU = (xs, x, eq) => switch xs { | list{} => list{} | list{(a, _) as pair, ...l} => - if eq(. a, x) { + if eq(a, x) { l } else { let cell = mutableCell(pair, list{}) @@ -766,13 +766,13 @@ let removeAssocU = (xs, x, eq) => } } -let removeAssoc = (xs, x, eq) => removeAssocU(xs, x, (. a, b) => eq(a, b)) +let removeAssoc = (xs, x, eq) => removeAssocU(xs, x, (a, b) => eq(a, b)) let setAssocU = (xs, x, k, eq) => switch xs { | list{} => list{(x, k)} | list{(a, _) as pair, ...l} => - if eq(. a, x) { + if eq(a, x) { list{(x, k), ...l} } else { let cell = mutableCell(pair, list{}) @@ -785,7 +785,7 @@ let setAssocU = (xs, x, k, eq) => } } -let setAssoc = (xs, x, k, eq) => setAssocU(xs, x, k, (. a, b) => eq(a, b)) +let setAssoc = (xs, x, k, eq) => setAssocU(xs, x, k, (a, b) => eq(a, b)) let sortU = (xs, cmp) => { let arr = toArray(xs) @@ -793,26 +793,26 @@ let sortU = (xs, cmp) => { fromArray(arr) } -let sort = (xs, cmp) => sortU(xs, (. x, y) => cmp(x, y)) +let sort = (xs, cmp) => sortU(xs, (x, y) => cmp(x, y)) let rec getByU = (xs, p) => switch xs { | list{} => None | list{x, ...l} => - if p(. x) { + if p(x) { Some(x) } else { getByU(l, p) } } -let getBy = (xs, p) => getByU(xs, (. a) => p(a)) +let getBy = (xs, p) => getByU(xs, a => p(a)) let rec keepU = (xs, p) => switch xs { | list{} => list{} | list{h, ...t} => - if p(. h) { + if p(h) { let cell = mutableCell(h, list{}) copyAuxWitFilter(p, t, cell) cell @@ -821,7 +821,7 @@ let rec keepU = (xs, p) => } } -let keep = (xs, p) => keepU(xs, (. x) => p(x)) +let keep = (xs, p) => keepU(xs, x => p(x)) let filter = keep @@ -830,7 +830,7 @@ let keepWithIndexU = (xs, p) => { switch xs { | list{} => list{} | list{h, ...t} => - if p(. h, i) { + if p(h, i) { let cell = mutableCell(h, list{}) copyAuxWithFilterIndex(p, t, cell, i + 1) cell @@ -841,7 +841,7 @@ let keepWithIndexU = (xs, p) => { auxKeepWithIndex(xs, p, 0) } -let keepWithIndex = (xs, p) => keepWithIndexU(xs, (. x, i) => p(x, i)) +let keepWithIndex = (xs, p) => keepWithIndexU(xs, (x, i) => p(x, i)) let filterWithIndex = keepWithIndex @@ -849,7 +849,7 @@ let rec keepMapU = (xs, p) => switch xs { | list{} => list{} | list{h, ...t} => - switch p(. h) { + switch p(h) { | Some(h) => let cell = mutableCell(h, list{}) copyAuxWitFilterMap(p, t, cell) @@ -858,7 +858,7 @@ let rec keepMapU = (xs, p) => } } -let keepMap = (xs, p) => keepMapU(xs, (. x) => p(x)) +let keepMap = (xs, p) => keepMapU(xs, x => p(x)) let partitionU = (l, p) => switch l { @@ -866,7 +866,7 @@ let partitionU = (l, p) => | list{h, ...t} => let nextX = mutableCell(h, list{}) let nextY = mutableCell(h, list{}) - let b = p(. h) + let b = p(h) partitionAux(p, t, nextX, nextY) if b { ( @@ -887,7 +887,7 @@ let partitionU = (l, p) => } } -let partition = (l, p) => partitionU(l, (. x) => p(x)) +let partition = (l, p) => partitionU(l, x => p(x)) let unzip = xs => switch xs { diff --git a/belt/src/belt_List.resi b/belt/src/belt_List.resi index 15811ed..86ad8d7 100644 --- a/belt/src/belt_List.resi +++ b/belt/src/belt_List.resi @@ -161,7 +161,7 @@ Belt.List.make(3, 1) // list{1, 1, 1} let make: (int, 'a) => t<'a> /** Uncurried version of [makeBy](#makeBy) */ -let makeByU: (int, (. int) => 'a) => t<'a> +let makeByU: (int, int => 'a) => t<'a> /** Return a list of length `numItems` with element `i` initialized with `f(i)`. @@ -277,7 +277,7 @@ Belt.List.flatten(list{list{1, 2, 3}, list{}, list{3}}) // list{1, 2, 3, 3} let flatten: t> => t<'a> /** Uncurried version of [map](#map). */ -let mapU: (t<'a>, (. 'a) => 'b) => t<'b> +let mapU: (t<'a>, 'a => 'b) => t<'b> /** Returns a new list with `f` applied to each element of `someList`. @@ -302,7 +302,7 @@ Belt.List.zip(list{1, 2}, list{3, 4, 5}) // list{(1, 3), (2, 4)} let zip: (t<'a>, t<'b>) => t<('a, 'b)> /** Uncurried version of [zipBy](#zipBy). */ -let zipByU: (t<'a>, t<'b>, (. 'a, 'b) => 'c) => t<'c> +let zipByU: (t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c> /** See [Belt.List.zip](#zip) @@ -316,7 +316,7 @@ Belt.List.zipBy(list{1, 2, 3}, list{4, 5}, (a, b) => 2 * a + b) // list{6, 9} let zipBy: (t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c> /** Uncurried version of [mapWithIndex](#mapWithIndex). */ -let mapWithIndexU: (t<'a>, (. int, 'a) => 'b) => t<'b> +let mapWithIndexU: (t<'a>, (int, 'a) => 'b) => t<'b> /** Applies `f` to each element of `someList`. @@ -369,7 +369,7 @@ Belt.List.reverse(list{1, 2, 3}) /* list{3, 2, 1} */ let reverse: t<'a> => t<'a> /** Uncurried version of [mapReverse](#mapReverse). */ -let mapReverseU: (t<'a>, (. 'a) => 'b) => t<'b> +let mapReverseU: (t<'a>, 'a => 'b) => t<'b> /** Equivalent to: @@ -387,7 +387,7 @@ list{3, 4, 5}->Belt.List.mapReverse(x => x * x) /* list{25, 16, 9} */ let mapReverse: (t<'a>, 'a => 'b) => t<'b> /** Uncurried version of [forEach](#forEach). */ -let forEachU: (t<'a>, (. 'a) => 'b) => unit +let forEachU: (t<'a>, 'a => 'b) => unit /** Call `f` on each element of `someList` from the beginning to end. @@ -408,7 +408,7 @@ Belt.List.forEach(list{"a", "b", "c"}, x => Js.log("Item: " ++ x)) let forEach: (t<'a>, 'a => 'b) => unit /** Uncurried version of [forEachWithIndex](#forEachWithIndex). */ -let forEachWithIndexU: (t<'a>, (. int, 'a) => 'b) => unit +let forEachWithIndexU: (t<'a>, (int, 'a) => 'b) => unit /** Call `f` on each element of `someList` from beginning to end. @@ -431,7 +431,7 @@ Belt.List.forEachWithIndex(list{"a", "b", "c"}, (index, x) => { let forEachWithIndex: (t<'a>, (int, 'a) => 'b) => unit /** Uncurried version of [reduce](#reduce). */ -let reduceU: (t<'a>, 'b, (. 'b, 'a) => 'b) => 'b +let reduceU: (t<'a>, 'b, ('b, 'a) => 'b) => 'b /** Applies `f` to each element of `someList` from beginning to end. Function `f` has two parameters: the item from the list and an “accumulator”, which starts with a value of `initialValue`. reduce returns the final value of the accumulator. @@ -449,7 +449,7 @@ list{1, 2, 3, 4}->Belt.List.reduce(0, (acc, item) => acc + item) /* 10 */ let reduce: (t<'a>, 'b, ('b, 'a) => 'b) => 'b /** Uncurried version of [reduceWithIndex](#reduceWithIndex). */ -let reduceWithIndexU: (t<'a>, 'b, (. 'b, 'a, int) => 'b) => 'b +let reduceWithIndexU: (t<'a>, 'b, ('b, 'a, int) => 'b) => 'b /** Applies `f` to each element of `someList` from beginning to end. Function `f` has three parameters: the item from the list and an “accumulator”, which starts with a value of `initialValue` and the index of each element. `reduceWithIndex` returns the final value of the accumulator. @@ -463,7 +463,7 @@ list{1, 2, 3, 4}->Belt.List.reduceWithIndex(0, (acc, item, index) => acc + item let reduceWithIndex: (t<'a>, 'b, ('b, 'a, int) => 'b) => 'b /** Uncurried version of [reduceReverse](#reduceReverse). */ -let reduceReverseU: (t<'a>, 'b, (. 'b, 'a) => 'b) => 'b +let reduceReverseU: (t<'a>, 'b, ('b, 'a) => 'b) => 'b /** Works like [reduce](#reduce), except that function `f` is applied to each @@ -482,7 +482,7 @@ list{1, 2, 3, 4}->Belt.List.reduceReverse(list{}, Belt.List.add) // list{1, 2, 3 let reduceReverse: (t<'a>, 'b, ('b, 'a) => 'b) => 'b /** Uncurried version of [mapReverse2](#mapReverse2). */ -let mapReverse2U: (t<'a>, t<'b>, (. 'a, 'b) => 'c) => t<'c> +let mapReverse2U: (t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c> /** Equivalent to: `zipBy(xs, ys, f)->reverse` @@ -497,7 +497,7 @@ Belt.List.mapReverse2(list{1, 2, 3}, list{1, 2}, (a, b) => a + b) // list{4, 2} let mapReverse2: (t<'a>, t<'b>, ('a, 'b) => 'c) => t<'c> /** Uncurried version of [forEach2](#forEach2). */ -let forEach2U: (t<'a>, t<'b>, (. 'a, 'b) => 'c) => unit +let forEach2U: (t<'a>, t<'b>, ('a, 'b) => 'c) => unit /** Stops at the length of the shorter list. @@ -517,7 +517,7 @@ Belt.List.forEach2(list{"Z", "Y"}, list{"A", "B", "C"}, (x, y) => Js.log2(x, y)) let forEach2: (t<'a>, t<'b>, ('a, 'b) => 'c) => unit /** Uncurried version of [reduce2](#reduce2). */ -let reduce2U: (t<'b>, t<'c>, 'a, (. 'a, 'b, 'c) => 'a) => 'a +let reduce2U: (t<'b>, t<'c>, 'a, ('a, 'b, 'c) => 'a) => 'a /** Applies `f` to each element of `firstList` and `secondList` from beginning to end. Stops with the shorter list. Function `f` has three parameters: an “accumulator” which starts with a value of `initialValue`, an item from `firstList`, and an item from `secondList`. `reduce2` returns the final value of the accumulator. @@ -531,7 +531,7 @@ Belt.List.reduce2(list{1, 2, 3}, list{4, 5}, 0, (acc, x, y) => acc + x * x + y) let reduce2: (t<'b>, t<'c>, 'a, ('a, 'b, 'c) => 'a) => 'a /** Uncurried version of [reduceReverse2](#reduceReverse2). */ -let reduceReverse2U: (t<'a>, t<'b>, 'c, (. 'c, 'a, 'b) => 'c) => 'c +let reduceReverse2U: (t<'a>, t<'b>, 'c, ('c, 'a, 'b) => 'c) => 'c /** Applies `f` to each element of `firstList` and `secondList` from end to @@ -549,7 +549,7 @@ Belt.List.reduceReverse2(list{1, 2, 3}, list{4, 5}, 0, (acc, x, y) => acc + x * let reduceReverse2: (t<'a>, t<'b>, 'c, ('c, 'a, 'b) => 'c) => 'c /** Uncurried version of [every](#every). */ -let everyU: (t<'a>, (. 'a) => bool) => bool +let everyU: (t<'a>, 'a => bool) => bool /** Returns `true` if all elements satisfy `pred`, where `pred` is a predicate: a function taking an element and returning a bool. @@ -567,7 +567,7 @@ list{1, 99, 8, 2}->Belt.List.every(isBelow10) /* false */ let every: (t<'a>, 'a => bool) => bool /** Uncurried version of [some](#some). */ -let someU: (t<'a>, (. 'a) => bool) => bool +let someU: (t<'a>, 'a => bool) => bool /** Returns `true` if at least _one_ of the elements in `someList` satisfies @@ -587,7 +587,7 @@ list{1, 2, 3, 4}->Belt.List.some(isAbove100) /* false */ let some: (t<'a>, 'a => bool) => bool /** Uncurried version of [every2](#every2). */ -let every2U: (t<'a>, t<'b>, (. 'a, 'b) => bool) => bool +let every2U: (t<'a>, t<'b>, ('a, 'b) => bool) => bool /** Returns `true` if predicate `pred(a, b)` is `true` for all pairs of elements @@ -608,7 +608,7 @@ Belt.List.every2(list{0, 1}, list{5, 0}, (a, b) => a > b) /* false */ let every2: (t<'a>, t<'b>, ('a, 'b) => bool) => bool /** Uncurried version of [some2](#some2). */ -let some2U: (t<'a>, t<'b>, (. 'a, 'b) => bool) => bool +let some2U: (t<'a>, t<'b>, ('a, 'b) => bool) => bool /** Returns `true` if predicate `pred(a, b)` is true for any pair of elements up @@ -647,7 +647,7 @@ Belt.List.cmpByLength(list{1, 2, 3, 4}, list{5, 6}) /* = 1 */ let cmpByLength: (t<'a>, t<'a>) => int /** Uncurried version of [cmp](#cmp). */ -let cmpU: (t<'a>, t<'a>, (. 'a, 'a) => int) => int +let cmpU: (t<'a>, t<'a>, ('a, 'a) => int) => int /** Compare elements one by one `compareFn(a, b)`. `compareFn` returns a negative number if `a` is "less than" `b`, zero if `a` is "equal to" `b`, a positive number if `a` is "greater than" `b`. @@ -678,7 +678,7 @@ For lists, we just compare elements one by one. let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int /** Uncurried version of [eq](#eq). */ -let eqU: (t<'a>, t<'a>, (. 'a, 'a) => bool) => bool +let eqU: (t<'a>, t<'a>, ('a, 'a) => bool) => bool /** Check equality of `firstList` and `secondList` using `eqElem` for equality on @@ -699,7 +699,7 @@ Belt.List.eq(list{1, 2, 3}, list{(-1), (-2), (-3)}, (a, b) => abs(a) == abs(b)) let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool /** Uncurried version of [has](#has). */ -let hasU: (t<'a>, 'b, (. 'a, 'b) => bool) => bool +let hasU: (t<'a>, 'b, ('a, 'b) => bool) => bool /** Returns `true` if the list contains at least one element for which @@ -718,7 +718,7 @@ list{(-1), (-2), (-3)}->Belt.List.has(2, (a, b) => abs(a) == abs(b)) /* true */ let has: (t<'a>, 'b, ('a, 'b) => bool) => bool /** Uncurried version of [getBy](#getBy). */ -let getByU: (t<'a>, (. 'a) => bool) => option<'a> +let getByU: (t<'a>, 'a => bool) => option<'a> /** Returns `Some(value)` for the first value in `someList` that satisfies the @@ -735,7 +735,7 @@ Belt.List.getBy(list{1, 4, 3, 2}, x => x > 4) /* None */ let getBy: (t<'a>, 'a => bool) => option<'a> /** Uncurried version of [keep](#keep). */ -let keepU: (t<'a>, (. 'a) => bool) => t<'a> +let keepU: (t<'a>, 'a => bool) => t<'a> /** Returns a list of all elements in `someList` which satisfy the predicate function `pred`. @@ -769,7 +769,7 @@ Belt.List.filter(list{None, Some(2), Some(3), None}, Belt.Option.isSome) /* list let filter: (t<'a>, 'a => bool) => t<'a> /** Uncurried version of [keepWithIndex](#keepWithIndex). */ -let keepWithIndexU: (t<'a>, (. 'a, int) => bool) => t<'a> +let keepWithIndexU: (t<'a>, ('a, int) => bool) => t<'a> /** Returns a list of all elements in `someList` which satisfy the predicate function `pred`. @@ -802,7 +802,7 @@ Belt.List.filterWithIndex(list{1, 2, 3, 4}, (_x, index) => isEven(index)) /* lis let filterWithIndex: (t<'a>, ('a, int) => bool) => t<'a> /** Uncurried version of [keepMap](#keepMap). */ -let keepMapU: (t<'a>, (. 'a) => option<'b>) => t<'b> +let keepMapU: (t<'a>, 'a => option<'b>) => t<'b> /** Applies `f` to each element of `someList`. If `f(x)` returns `Some(value)`, then `value` is _kept_ in the resulting list. @@ -828,7 +828,7 @@ list{Some(1), Some(2), None}->Belt.List.keepMap(x => x) /* list{1, 2} */ let keepMap: (t<'a>, 'a => option<'b>) => t<'b> /** Uncurried version of [partition](#partition). */ -let partitionU: (t<'a>, (. 'a) => bool) => (t<'a>, t<'a>) +let partitionU: (t<'a>, 'a => bool) => (t<'a>, t<'a>) /** Creates a pair of lists; the first list consists of all elements of `someList` that satisfy the predicate function `pred`; the second list consists of all elements of `someList` that _do not_ satisfy `pred. @@ -862,7 +862,7 @@ Belt.List.unzip(list{("H", "W"), ("e", "o"), ("l", "r"), ("l", "l"), ("o", "d"), let unzip: t<('a, 'b)> => (t<'a>, t<'b>) /** Uncurried version of [getAssoc](#getAssoc). */ -let getAssocU: (t<('a, 'c)>, 'b, (. 'a, 'b) => bool) => option<'c> +let getAssocU: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => option<'c> /** Return the second element of a pair in `someList` where the first element equals `k` as per the predicate function `eqFunction`, or `None` if not found. @@ -880,7 +880,7 @@ list{(9, "morning"), (15, "afternoon"), (22, "night")} let getAssoc: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => option<'c> /** Uncurried version of [hasAssoc](#hasAssoc). */ -let hasAssocU: (t<('a, 'c)>, 'b, (. 'a, 'b) => bool) => bool +let hasAssocU: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => bool /** Returns `true` if there is a pair in `someList` where the first element equals `k` as per the predicate function `eqFunction`. @@ -897,7 +897,7 @@ list{(9, "morning"), (15, "afternoon"), (22, "night")} let hasAssoc: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => bool /** Uncurried version of [removeAssoc](#removeAssoc). */ -let removeAssocU: (t<('a, 'c)>, 'b, (. 'a, 'b) => bool) => t<('a, 'c)> +let removeAssocU: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => t<('a, 'c)> /** Return a list after removing the first pair whose first value is `k` per the equality predicate `eqFunction`; if not found, return a new list identical to `someList`. @@ -915,7 +915,7 @@ list{(9, "morning"), (15, "afternoon"), (22, "night")} let removeAssoc: (t<('a, 'c)>, 'b, ('a, 'b) => bool) => t<('a, 'c)> /** Uncurried version of [setAssoc](#setAssoc). */ -let setAssocU: (t<('a, 'c)>, 'a, 'c, (. 'a, 'a) => bool) => t<('a, 'c)> +let setAssocU: (t<('a, 'c)>, 'a, 'c, ('a, 'a) => bool) => t<('a, 'c)> /** If `k` exists in `someList` by satisfying the `eqFunction` predicate, return a new list with the key and value replaced by the new `k` and `v`; otherwise, return a new list with the pair `k`, `v` added to the head of `someList`. @@ -941,7 +941,7 @@ Both the key _and_ the value are replaced in the list. let setAssoc: (t<('a, 'c)>, 'a, 'c, ('a, 'a) => bool) => t<('a, 'c)> /** Uncurried version of [sort](#sort). */ -let sortU: (t<'a>, (. 'a, 'a) => int) => t<'a> +let sortU: (t<'a>, ('a, 'a) => int) => t<'a> /** Returns a sorted list. diff --git a/belt/src/belt_Map.res b/belt/src/belt_Map.res index cfd9edf..3f82c33 100644 --- a/belt/src/belt_Map.res +++ b/belt/src/belt_Map.res @@ -70,7 +70,7 @@ let updateU = (m, key, f) => { let cmp = m.cmp {cmp, data: Dict.updateU(~cmp, m.data, key, f)} } -let update = (m, key, f) => updateU(m, key, (. a) => f(a)) +let update = (m, key, f) => updateU(m, key, a => f(a)) let split = (m, x) => { let cmp = m.cmp let ((l, r), b) = Dict.split(~cmp, m.data, x) @@ -82,7 +82,7 @@ let mergeU = (s1, s2, f) => { {cmp, data: Dict.mergeU(~cmp, s1.data, s2.data, f)} } -let merge = (s1, s2, f) => mergeU(s1, s2, (. a, b, c) => f(a, b, c)) +let merge = (s1, s2, f) => mergeU(s1, s2, (a, b, c) => f(a, b, c)) let make = (type key idx, ~id: id) => { module M = unpack(id) @@ -92,29 +92,29 @@ let make = (type key idx, ~id: id) => { let isEmpty = map => Dict.isEmpty(map.data) let findFirstByU = (m, f) => Dict.findFirstByU(m.data, f) -let findFirstBy = (m, f) => findFirstByU(m, (. a, b) => f(a, b)) +let findFirstBy = (m, f) => findFirstByU(m, (a, b) => f(a, b)) let forEachU = (m, f) => Dict.forEachU(m.data, f) -let forEach = (m, f) => forEachU(m, (. a, b) => f(a, b)) +let forEach = (m, f) => forEachU(m, (a, b) => f(a, b)) let reduceU = (m, acc, f) => Dict.reduceU(m.data, acc, f) -let reduce = (m, acc, f) => reduceU(m, acc, (. a, b, c) => f(a, b, c)) +let reduce = (m, acc, f) => reduceU(m, acc, (a, b, c) => f(a, b, c)) let everyU = (m, f) => Dict.everyU(m.data, f) -let every = (m, f) => everyU(m, (. a, b) => f(a, b)) +let every = (m, f) => everyU(m, (a, b) => f(a, b)) let someU = (m, f) => Dict.someU(m.data, f) -let some = (m, f) => someU(m, (. a, b) => f(a, b)) +let some = (m, f) => someU(m, (a, b) => f(a, b)) let keepU = (m, f) => {cmp: m.cmp, data: Dict.keepU(m.data, f)} -let keep = (m, f) => keepU(m, (. a, b) => f(a, b)) +let keep = (m, f) => keepU(m, (a, b) => f(a, b)) let partitionU = (m, p) => { let cmp = m.cmp let (l, r) = m.data->Dict.partitionU(p) ({cmp, data: l}, {cmp, data: r}) } -let partition = (m, p) => partitionU(m, (. a, b) => p(a, b)) +let partition = (m, p) => partitionU(m, (a, b) => p(a, b)) let mapU = (m, f) => {cmp: m.cmp, data: Dict.mapU(m.data, f)} -let map = (m, f) => mapU(m, (. a) => f(a)) +let map = (m, f) => mapU(m, a => f(a)) let mapWithKeyU = (m, f) => {cmp: m.cmp, data: Dict.mapWithKeyU(m.data, f)} -let mapWithKey = (m, f) => mapWithKeyU(m, (. a, b) => f(a, b)) +let mapWithKey = (m, f) => mapWithKeyU(m, (a, b) => f(a, b)) let size = map => Dict.size(map.data) let toList = map => Dict.toList(map.data) let toArray = m => Dict.toArray(m.data) @@ -142,10 +142,10 @@ let has = (map, x) => Dict.has(~cmp=map.cmp, map.data, x) let checkInvariantInternal = m => Dict.checkInvariantInternal(m.data) let eqU = (m1, m2, veq) => Dict.eqU(~kcmp=m1.cmp, ~veq, m1.data, m2.data) -let eq = (m1, m2, veq) => eqU(m1, m2, (. a, b) => veq(a, b)) +let eq = (m1, m2, veq) => eqU(m1, m2, (a, b) => veq(a, b)) let cmpU = (m1, m2, vcmp) => Dict.cmpU(~kcmp=m1.cmp, ~vcmp, m1.data, m2.data) -let cmp = (m1, m2, vcmp) => cmpU(m1, m2, (. a, b) => vcmp(a, b)) +let cmp = (m1, m2, vcmp) => cmpU(m1, m2, (a, b) => vcmp(a, b)) let getData = m => m.data diff --git a/belt/src/belt_Map.resi b/belt/src/belt_Map.resi index ae5638d..9c84a01 100644 --- a/belt/src/belt_Map.resi +++ b/belt/src/belt_Map.resi @@ -27,7 +27,6 @@ type t<'key, 'value, 'identity> type id<'key, 'id> = Belt_Id.comparable<'key, 'id> ``` */ - module Int = Belt_MapInt module String = Belt_MapString @@ -97,7 +96,7 @@ Belt.Map.has(Belt.Map.fromArray([(1, "1")], ~id=module(IntCmp)), 1) == true */ let has: (t<'k, 'v, 'id>, 'k) => bool -let cmpU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, (. 'v, 'v) => int) => int +let cmpU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ('v, 'v) => int) => int /** `cmp(m0, m1, vcmp);` @@ -107,7 +106,7 @@ It will compare size first and each element following the order one by one. */ let cmp: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ('v, 'v) => int) => int -let eqU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, (. 'v, 'v) => bool) => bool +let eqU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ('v, 'v) => bool) => bool /** eq(m1, m2, veq)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. `veq` is the @@ -115,7 +114,7 @@ equality predicate used to compare the data associated with the keys. */ let eq: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ('v, 'v) => bool) => bool -let findFirstByU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => option<('k, 'v)> +let findFirstByU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)> /** ` findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. @@ -134,7 +133,7 @@ Belt.Map.findFirstBy(s0, (k, v) => k == 4) /* (4, "4") */ */ let findFirstBy: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)> -let forEachU: (t<'k, 'v, 'id>, (. 'k, 'v) => unit) => unit +let forEachU: (t<'k, 'v, 'id>, ('k, 'v) => unit) => unit /** `forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the `'k` as first argument, and the associated value as second argument. The @@ -160,7 +159,7 @@ acc.contents == list{(4, "4"), (3, "3"), (2, "2"), (1, "1")} */ let forEach: (t<'k, 'v, 'id>, ('k, 'v) => unit) => unit -let reduceU: (t<'k, 'v, 'id>, 'acc, (. 'acc, 'k, 'v) => 'acc) => 'acc +let reduceU: (t<'k, 'v, 'id>, 'acc, ('acc, 'k, 'v) => 'acc) => 'acc /** `reduce(m, a, f)` computes `(f(kN, dN) ... (f(k1, d1, a))...)`, where `k1 ... kN` are the keys of all bindings in m (in increasing order), and `d1 @@ -184,14 +183,14 @@ Belt.Map.reduce(s0, list{}, (acc, k, v) => list{ */ let reduce: (t<'k, 'v, 'id>, 'acc, ('acc, 'k, 'v) => 'acc) => 'acc -let everyU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => bool +let everyU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => bool /** `every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified */ let every: (t<'k, 'v, 'id>, ('k, 'v) => bool) => bool -let someU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => bool +let someU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => bool /** `some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. Order unspecified */ @@ -414,7 +413,7 @@ Belt.Map.valuesToArray(s1) == ["1", "3", "3"] */ let set: (t<'k, 'v, 'id>, 'k, 'v) => t<'k, 'v, 'id> -let updateU: (t<'k, 'v, 'id>, 'k, (. option<'v>) => option<'v>) => t<'k, 'v, 'id> +let updateU: (t<'k, 'v, 'id>, 'k, option<'v> => option<'v>) => t<'k, 'v, 'id> /** `update(m, x, f)` returns a map containing the same bindings as `m`, except for the binding of `x`. Depending on the value of `y` where `y` is @@ -435,7 +434,7 @@ let mergeMany: (t<'k, 'v, 'id>, array<('k, 'v)>) => t<'k, 'v, 'id> let mergeU: ( t<'k, 'v, 'id>, t<'k, 'v2, 'id>, - (. 'k, option<'v>, option<'v2>) => option<'v3>, + ('k, option<'v>, option<'v2>) => option<'v3>, ) => t<'k, 'v3, 'id> /** `merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` @@ -448,14 +447,14 @@ let merge: ( ('k, option<'v>, option<'v2>) => option<'v3>, ) => t<'k, 'v3, 'id> -let keepU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => t<'k, 'v, 'id> +let keepU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => t<'k, 'v, 'id> /** `keep(m, p)` returns the map with all the bindings in m that satisfy predicate `p`. */ let keep: (t<'k, 'v, 'id>, ('k, 'v) => bool) => t<'k, 'v, 'id> -let partitionU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => (t<'k, 'v, 'id>, t<'k, 'v, 'id>) +let partitionU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => (t<'k, 'v, 'id>, t<'k, 'v, 'id>) /** `partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map @@ -472,7 +471,7 @@ all the bindings of m whose 'k is strictly greater than `x`; `data` is */ let split: (t<'k, 'v, 'id>, 'k) => ((t<'k, 'v, 'id>, t<'k, 'v, 'id>), option<'v>) -let mapU: (t<'k, 'v, 'id>, (. 'v) => 'v2) => t<'k, 'v2, 'id> +let mapU: (t<'k, 'v, 'id>, 'v => 'v2) => t<'k, 'v2, 'id> /** `map(m, f) returns a map with same domain as`m`, where the associated value`a`of all bindings of`m`has been replaced by the result of the @@ -481,7 +480,7 @@ with respect to the ordering over the type of the keys. */ let map: (t<'k, 'v, 'id>, 'v => 'v2) => t<'k, 'v2, 'id> -let mapWithKeyU: (t<'k, 'v, 'id>, (. 'k, 'v) => 'v2) => t<'k, 'v2, 'id> +let mapWithKeyU: (t<'k, 'v, 'id>, ('k, 'v) => 'v2) => t<'k, 'v2, 'id> /** `mapWithKey(m, f)` diff --git a/belt/src/belt_MapDict.res b/belt/src/belt_MapDict.res index 0b9dff9..e73af24 100644 --- a/belt/src/belt_MapDict.res +++ b/belt/src/belt_MapDict.res @@ -81,7 +81,7 @@ let rec set = (t: t<_>, newK, newD, ~cmp) => | None => N.singleton(newK, newD) | Some(n) => let k = n.N.key - let c = Belt_Id.getCmpInternal(cmp)(. newK, k) + let c = Belt_Id.getCmpInternal(cmp)(newK, k) if c == 0 { Some(N.updateValue(n, newD)) } else { @@ -98,15 +98,15 @@ let rec set = (t: t<_>, newK, newD, ~cmp) => let rec updateU = (t: t<_>, newK, f, ~cmp): t<_> => switch t { | None => - switch f(. None) { + switch f(None) { | None => t | Some(newD) => N.singleton(newK, newD) } | Some(n) => let k = n.N.key - let c = Belt_Id.getCmpInternal(cmp)(. newK, k) + let c = Belt_Id.getCmpInternal(cmp)(newK, k) if c == 0 { - switch f(. Some(n.N.value)) { + switch f(Some(n.N.value)) { | None => let (l, r) = (n.N.left, n.N.right) switch (l, r) { @@ -139,7 +139,7 @@ let rec updateU = (t: t<_>, newK, f, ~cmp): t<_> => } } -let update = (t, newK, f, ~cmp) => updateU(t, newK, (. a) => f(a), ~cmp) +let update = (t, newK, f, ~cmp) => updateU(t, newK, a => f(a), ~cmp) /* unboxing API was not exported since the correct API is really awkard @@ -158,7 +158,7 @@ let update = (t, newK, f, ~cmp) => updateU(t, newK, (. a) => f(a), ~cmp) let rec removeAux0 = (n, x, ~cmp) => { let {N.left: l, key: v, right: r} = n - let c = Belt_Id.getCmpInternal(cmp)(. x, v) + let c = Belt_Id.getCmpInternal(cmp)(x, v) if c == 0 { switch (l, r) { | (None, _) => r @@ -211,7 +211,7 @@ let mergeMany = (h, arr, ~cmp) => { let rec splitAuxPivot = (n, x, pres, ~cmp) => { let {N.left: l, key: v, value: d, right: r} = n - let c = Belt_Id.getCmpInternal(cmp)(. x, v) + let c = Belt_Id.getCmpInternal(cmp)(x, v) if c == 0 { pres.contents = Some(d) (l, r) @@ -247,8 +247,8 @@ let findFirstBy = N.findFirstBy let rec mergeU = (s1, s2, f, ~cmp) => switch (s1, s2) { | (None, None) => None - | (Some(_), None) => N.keepMapU(s1, (. k, v) => f(. k, Some(v), None)) - | (None, Some(_)) => N.keepMapU(s2, (. k, v) => f(. k, None, Some(v))) + | (Some(_), None) => N.keepMapU(s1, (k, v) => f(k, Some(v), None)) + | (None, Some(_)) => N.keepMapU(s2, (k, v) => f(k, None, Some(v))) | (Some(s1n), Some(s2n)) => if s1n.height >= s2n.height { let {N.left: l1, key: v1, value: d1, right: r1} = s1n @@ -256,7 +256,7 @@ let rec mergeU = (s1, s2, f, ~cmp) => let (l2, r2) = splitAuxPivot(~cmp, s2n, v1, d2) let d2 = d2.contents let newLeft = mergeU(~cmp, l1, l2, f) - let newD = f(. v1, Some(d1), d2) + let newD = f(v1, Some(d1), d2) let newRight = mergeU(~cmp, r1, r2, f) N.concatOrJoin(newLeft, v1, newD, newRight) } else { @@ -265,13 +265,13 @@ let rec mergeU = (s1, s2, f, ~cmp) => let (l1, r1) = splitAuxPivot(~cmp, s1n, v2, d1) let d1 = d1.contents let newLeft = mergeU(~cmp, l1, l2, f) - let newD = f(. v2, d1, Some(d2)) + let newD = f(v2, d1, Some(d2)) let newRight = mergeU(~cmp, r1, r2, f) N.concatOrJoin(newLeft, v2, newD, newRight) } } -let merge = (s1, s2, f, ~cmp) => mergeU(s1, s2, (. a, b, c) => f(a, b, c), ~cmp) +let merge = (s1, s2, f, ~cmp) => mergeU(s1, s2, (a, b, c) => f(a, b, c), ~cmp) let rec removeMany0 = (t, xs, i, len, ~cmp) => if i < len { diff --git a/belt/src/belt_MapDict.resi b/belt/src/belt_MapDict.resi index 7dafef6..96862ce 100644 --- a/belt/src/belt_MapDict.resi +++ b/belt/src/belt_MapDict.resi @@ -49,10 +49,10 @@ let isEmpty: t<'k, 'v, 'id> => bool let has: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => bool -let cmpU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ~kcmp: cmp<'k, 'id>, ~vcmp: (. 'v, 'v) => int) => int +let cmpU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ~kcmp: cmp<'k, 'id>, ~vcmp: ('v, 'v) => int) => int let cmp: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ~kcmp: cmp<'k, 'id>, ~vcmp: ('v, 'v) => int) => int -let eqU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ~kcmp: cmp<'k, 'id>, ~veq: (. 'a, 'a) => bool) => bool +let eqU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ~kcmp: cmp<'k, 'id>, ~veq: ('a, 'a) => bool) => bool /** `eq(m1, m2, cmp)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. `cmp` is the @@ -60,7 +60,7 @@ equality predicate used to compare the data associated with the keys. */ let eq: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ~kcmp: cmp<'k, 'id>, ~veq: ('a, 'a) => bool) => bool -let findFirstByU: (t<'k, 'v, 'id>, (. 'k, 'v) => bool) => option<('k, 'v)> +let findFirstByU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)> /** `findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. @@ -80,7 +80,7 @@ Belt.Map.Dict.findFirstBy(s0, (k, _) => k == 4) == Some((4, "4")) */ let findFirstBy: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)> -let forEachU: (t<'k, 'a, 'id>, (. 'k, 'a) => unit) => unit +let forEachU: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit /** `forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The @@ -89,7 +89,7 @@ over the type of the keys. */ let forEach: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit -let reduceU: (t<'k, 'a, 'id>, 'b, (. 'b, 'k, 'a) => 'b) => 'b +let reduceU: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b /** `reduce(m, a, f)` computes `f(kN, dN ... f(k1, d1, a)...)`, where `k1 ... kN` are the keys of all bindings in `m` (in increasing order), and `d1 ... dN` @@ -97,14 +97,14 @@ are the associated data. */ let reduce: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b -let everyU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => bool +let everyU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool /** `every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified */ let every: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool -let someU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => bool +let someU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool /** `some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. Order unspecified @@ -165,18 +165,13 @@ binding disappears. */ let set: (t<'a, 'b, 'id>, 'a, 'b, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> -let updateU: ( - t<'a, 'b, 'id>, - 'a, - (. option<'b>) => option<'b>, - ~cmp: cmp<'a, 'id>, -) => t<'a, 'b, 'id> +let updateU: (t<'a, 'b, 'id>, 'a, option<'b> => option<'b>, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> let update: (t<'a, 'b, 'id>, 'a, option<'b> => option<'b>, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> let mergeU: ( t<'a, 'b, 'id>, t<'a, 'c, 'id>, - (. 'a, option<'b>, option<'c>) => option<'d>, + ('a, option<'b>, option<'c>) => option<'d>, ~cmp: cmp<'a, 'id>, ) => t<'a, 'd, 'id> /** @@ -193,14 +188,14 @@ let merge: ( let mergeMany: (t<'a, 'b, 'id>, array<('a, 'b)>, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> -let keepU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => t<'k, 'a, 'id> +let keepU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => t<'k, 'a, 'id> /** `keep(m, p)` returns the map with all the bindings in `m` that satisfy predicate `p`. */ let keep: (t<'k, 'a, 'id>, ('k, 'a) => bool) => t<'k, 'a, 'id> -let partitionU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => (t<'k, 'a, 'id>, t<'k, 'a, 'id>) +let partitionU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => (t<'k, 'a, 'id>, t<'k, 'a, 'id>) /** `partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map @@ -221,7 +216,7 @@ let split: ( ~cmp: cmp<'a, 'id>, ) => ((t<'a, 'b, 'id>, t<'a, 'b, 'id>), option<'b>) -let mapU: (t<'k, 'a, 'id>, (. 'a) => 'b) => t<'k, 'b, 'id> +let mapU: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id> /** `map(m, f)` returns a map with same domain as `m`, where the associated value `a` of all bindings of `m` has been replaced by the result of the @@ -230,5 +225,5 @@ order with respect to the ordering over the type of the keys. */ let map: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id> -let mapWithKeyU: (t<'k, 'a, 'id>, (. 'k, 'a) => 'b) => t<'k, 'b, 'id> +let mapWithKeyU: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id> let mapWithKey: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id> diff --git a/belt/src/belt_MapInt.res b/belt/src/belt_MapInt.res index d560164..db0bcd4 100644 --- a/belt/src/belt_MapInt.res +++ b/belt/src/belt_MapInt.res @@ -61,14 +61,14 @@ let rec set = (t, newK: key, newD: _) => let rec updateU = (t, x: key, f) => switch t { | None => - switch f(. None) { + switch f(None) { | None => t | Some(data) => N.singleton(x, data) } | Some(n) => let k = n.N.key if x == k { - switch f(. Some(n.N.value)) { + switch f(Some(n.N.value)) { | None => let {N.left: l, right: r} = n switch (l, r) { @@ -101,7 +101,7 @@ let rec updateU = (t, x: key, f) => } } -let update = (t, x, f) => updateU(t, x, (. a) => f(a)) +let update = (t, x, f) => updateU(t, x, a => f(a)) let rec removeAux = (n, x: key) => { let {N.left: l, key: v, right: r} = n diff --git a/belt/src/belt_MapInt.resi b/belt/src/belt_MapInt.resi index a4c1f60..c394e9b 100644 --- a/belt/src/belt_MapInt.resi +++ b/belt/src/belt_MapInt.resi @@ -9,10 +9,10 @@ let isEmpty: t<'v> => bool let has: (t<'v>, key) => bool -let cmpU: (t<'v>, t<'v>, (. 'v, 'v) => int) => int +let cmpU: (t<'v>, t<'v>, ('v, 'v) => int) => int let cmp: (t<'v>, t<'v>, ('v, 'v) => int) => int -let eqU: (t<'v>, t<'v>, (. 'v, 'v) => bool) => bool +let eqU: (t<'v>, t<'v>, ('v, 'v) => bool) => bool /** `eq(m1, m2)` tests whether the maps `m1` and `m2` are @@ -21,7 +21,7 @@ equal data. */ let eq: (t<'v>, t<'v>, ('v, 'v) => bool) => bool -let findFirstByU: (t<'v>, (. key, 'v) => bool) => option<(key, 'v)> +let findFirstByU: (t<'v>, (key, 'v) => bool) => option<(key, 'v)> /** `findFirstBy(m, p)` uses funcion `f` to find the first key value pair @@ -34,7 +34,7 @@ findFirstBy(s0, (k, v) => k == 4) == option((4, "4")) */ let findFirstBy: (t<'v>, (key, 'v) => bool) => option<(key, 'v)> -let forEachU: (t<'v>, (. key, 'v) => unit) => unit +let forEachU: (t<'v>, (key, 'v) => unit) => unit /** `forEach(m, f)` applies `f` to all bindings in map `m`. @@ -44,7 +44,7 @@ order with respect to the ordering over the type of the keys. */ let forEach: (t<'v>, (key, 'v) => unit) => unit -let reduceU: (t<'v>, 'v2, (. 'v2, key, 'v) => 'v2) => 'v2 +let reduceU: (t<'v>, 'v2, ('v2, key, 'v) => 'v2) => 'v2 /** `reduce(m, a, f)` computes `(f kN dN ... (f k1 d1 a)...)`, @@ -53,14 +53,14 @@ where `k1 ... kN` are the keys of all bindings in `m` */ let reduce: (t<'v>, 'v2, ('v2, key, 'v) => 'v2) => 'v2 -let everyU: (t<'v>, (. key, 'v) => bool) => bool +let everyU: (t<'v>, (key, 'v) => bool) => bool /** `every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified */ let every: (t<'v>, (key, 'v) => bool) => bool -let someU: (t<'v>, (. key, 'v) => bool) => bool +let someU: (t<'v>, (key, 'v) => bool) => bool /** `some(m, p)` checks if at least one binding of the map satisfy the predicate @@ -122,10 +122,10 @@ in `m`, its previous binding disappears. */ let set: (t<'v>, key, 'v) => t<'v> -let updateU: (t<'v>, key, (. option<'v>) => option<'v>) => t<'v> +let updateU: (t<'v>, key, option<'v> => option<'v>) => t<'v> let update: (t<'v>, key, option<'v> => option<'v>) => t<'v> -let mergeU: (t<'v>, t<'v2>, (. key, option<'v>, option<'v2>) => option<'c>) => t<'c> +let mergeU: (t<'v>, t<'v2>, (key, option<'v>, option<'v2>) => option<'c>) => t<'c> /** `merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` @@ -136,7 +136,7 @@ let merge: (t<'v>, t<'v2>, (key, option<'v>, option<'v2>) => option<'c>) => t<'c let mergeMany: (t<'v>, array<(key, 'v)>) => t<'v> -let keepU: (t<'v>, (. key, 'v) => bool) => t<'v> +let keepU: (t<'v>, (key, 'v) => bool) => t<'v> /** `keep(m, p)` returns the map with all the bindings in `m` that satisfy predicate @@ -144,7 +144,7 @@ let keepU: (t<'v>, (. key, 'v) => bool) => t<'v> */ let keep: (t<'v>, (key, 'v) => bool) => t<'v> -let partitionU: (t<'v>, (. key, 'v) => bool) => (t<'v>, t<'v>) +let partitionU: (t<'v>, (key, 'v) => bool) => (t<'v>, t<'v>) /** `partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the @@ -161,7 +161,7 @@ contains no binding for `x`, or `Some(v)` if `m` binds `v` to `x`. */ let split: (key, t<'v>) => (t<'v>, option<'v>, t<'v>) -let mapU: (t<'v>, (. 'v) => 'v2) => t<'v2> +let mapU: (t<'v>, 'v => 'v2) => t<'v2> /** `map(m, f)` returns a map with same domain as `m`, where the associated value `a` @@ -171,5 +171,5 @@ ordering over the type of the keys. */ let map: (t<'v>, 'v => 'v2) => t<'v2> -let mapWithKeyU: (t<'v>, (. key, 'v) => 'v2) => t<'v2> +let mapWithKeyU: (t<'v>, (key, 'v) => 'v2) => t<'v2> let mapWithKey: (t<'v>, (key, 'v) => 'v2) => t<'v2> diff --git a/belt/src/belt_MapString.res b/belt/src/belt_MapString.res index 460e6a4..1ff0d91 100644 --- a/belt/src/belt_MapString.res +++ b/belt/src/belt_MapString.res @@ -61,14 +61,14 @@ let rec set = (t, newK: key, newD: _) => let rec updateU = (t, x: key, f) => switch t { | None => - switch f(. None) { + switch f(None) { | None => t | Some(data) => N.singleton(x, data) } | Some(n) => let k = n.N.key if x == k { - switch f(. Some(n.N.value)) { + switch f(Some(n.N.value)) { | None => let {N.left: l, right: r} = n switch (l, r) { @@ -101,7 +101,7 @@ let rec updateU = (t, x: key, f) => } } -let update = (t, x, f) => updateU(t, x, (. a) => f(a)) +let update = (t, x, f) => updateU(t, x, a => f(a)) let rec removeAux = (n, x: key) => { let {N.left: l, key: v, right: r} = n diff --git a/belt/src/belt_MapString.resi b/belt/src/belt_MapString.resi index 5cd8792..145f38c 100644 --- a/belt/src/belt_MapString.resi +++ b/belt/src/belt_MapString.resi @@ -9,10 +9,10 @@ let isEmpty: t<'v> => bool let has: (t<'v>, key) => bool -let cmpU: (t<'v>, t<'v>, (. 'v, 'v) => int) => int +let cmpU: (t<'v>, t<'v>, ('v, 'v) => int) => int let cmp: (t<'v>, t<'v>, ('v, 'v) => int) => int -let eqU: (t<'v>, t<'v>, (. 'v, 'v) => bool) => bool +let eqU: (t<'v>, t<'v>, ('v, 'v) => bool) => bool /** `eq(m1, m2)` tests whether the maps `m1` and `m2` are @@ -21,7 +21,7 @@ equal data. */ let eq: (t<'v>, t<'v>, ('v, 'v) => bool) => bool -let findFirstByU: (t<'v>, (. key, 'v) => bool) => option<(key, 'v)> +let findFirstByU: (t<'v>, (key, 'v) => bool) => option<(key, 'v)> /** `findFirstBy(m, p)` uses funcion `f` to find the first key value pair @@ -34,7 +34,7 @@ findFirstBy(s0, (k, v) => k == 4) == option((4, "4")) */ let findFirstBy: (t<'v>, (key, 'v) => bool) => option<(key, 'v)> -let forEachU: (t<'v>, (. key, 'v) => unit) => unit +let forEachU: (t<'v>, (key, 'v) => unit) => unit /** `forEach(m, f)` applies `f` to all bindings in map `m`. @@ -44,7 +44,7 @@ order with respect to the ordering over the type of the keys. */ let forEach: (t<'v>, (key, 'v) => unit) => unit -let reduceU: (t<'v>, 'v2, (. 'v2, key, 'v) => 'v2) => 'v2 +let reduceU: (t<'v>, 'v2, ('v2, key, 'v) => 'v2) => 'v2 /** `reduce(m, a, f)` computes `(f kN dN ... (f k1 d1 a)...)`, @@ -53,14 +53,14 @@ where `k1 ... kN` are the keys of all bindings in `m` */ let reduce: (t<'v>, 'v2, ('v2, key, 'v) => 'v2) => 'v2 -let everyU: (t<'v>, (. key, 'v) => bool) => bool +let everyU: (t<'v>, (key, 'v) => bool) => bool /** `every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified */ let every: (t<'v>, (key, 'v) => bool) => bool -let someU: (t<'v>, (. key, 'v) => bool) => bool +let someU: (t<'v>, (key, 'v) => bool) => bool /** `some(m, p)` checks if at least one binding of the map satisfy the predicate @@ -122,10 +122,10 @@ in `m`, its previous binding disappears. */ let set: (t<'v>, key, 'v) => t<'v> -let updateU: (t<'v>, key, (. option<'v>) => option<'v>) => t<'v> +let updateU: (t<'v>, key, option<'v> => option<'v>) => t<'v> let update: (t<'v>, key, option<'v> => option<'v>) => t<'v> -let mergeU: (t<'v>, t<'v2>, (. key, option<'v>, option<'v2>) => option<'c>) => t<'c> +let mergeU: (t<'v>, t<'v2>, (key, option<'v>, option<'v2>) => option<'c>) => t<'c> /** `merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` @@ -136,7 +136,7 @@ let merge: (t<'v>, t<'v2>, (key, option<'v>, option<'v2>) => option<'c>) => t<'c let mergeMany: (t<'v>, array<(key, 'v)>) => t<'v> -let keepU: (t<'v>, (. key, 'v) => bool) => t<'v> +let keepU: (t<'v>, (key, 'v) => bool) => t<'v> /** `keep(m, p)` returns the map with all the bindings in `m` that satisfy predicate @@ -144,7 +144,7 @@ let keepU: (t<'v>, (. key, 'v) => bool) => t<'v> */ let keep: (t<'v>, (key, 'v) => bool) => t<'v> -let partitionU: (t<'v>, (. key, 'v) => bool) => (t<'v>, t<'v>) +let partitionU: (t<'v>, (key, 'v) => bool) => (t<'v>, t<'v>) /** `partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the @@ -161,7 +161,7 @@ contains no binding for `x`, or `Some(v)` if `m` binds `v` to `x`. */ let split: (key, t<'v>) => (t<'v>, option<'v>, t<'v>) -let mapU: (t<'v>, (. 'v) => 'v2) => t<'v2> +let mapU: (t<'v>, 'v => 'v2) => t<'v2> /** `map(m, f)` returns a map with same domain as `m`, where the associated value `a` @@ -171,5 +171,5 @@ ordering over the type of the keys. */ let map: (t<'v>, 'v => 'v2) => t<'v2> -let mapWithKeyU: (t<'v>, (. key, 'v) => 'v2) => t<'v2> +let mapWithKeyU: (t<'v>, (key, 'v) => 'v2) => t<'v2> let mapWithKey: (t<'v>, (key, 'v) => 'v2) => t<'v2> diff --git a/belt/src/belt_MutableMap.res b/belt/src/belt_MutableMap.res index ba367b4..3409a82 100644 --- a/belt/src/belt_MutableMap.res +++ b/belt/src/belt_MutableMap.res @@ -38,7 +38,7 @@ type t<'k, 'v, 'id> = { let rec removeMutateAux = (nt, x, ~cmp) => { let k = nt.N.key - let c = Belt_Id.getCmpInternal(cmp)(. x, k) + let c = Belt_Id.getCmpInternal(cmp)(x, k) if c == 0 { let {N.left: l, right: r} = nt switch (l, r) { @@ -105,15 +105,15 @@ let removeMany = (d, xs) => { let rec updateDone = (t, x, f, ~cmp) => switch t { | None => - switch f(. None) { + switch f(None) { | Some(data) => N.singleton(x, data) | None => t } | Some(nt) => let k = nt.N.key - let c = Belt_Id.getCmpInternal(cmp)(. x, k) + let c = Belt_Id.getCmpInternal(cmp)(x, k) if c == 0 { - switch f(. Some(nt.value)) { + switch f(Some(nt.value)) { | None => let {N.left: l, right: r} = nt switch (l, r) { @@ -143,7 +143,7 @@ let updateU = (t, x, f) => { t.data = newRoot } } -let update = (t, x, f) => updateU(t, x, (. a) => f(a)) +let update = (t, x, f) => updateU(t, x, a => f(a)) let make = (type key identity, ~id: id) => { module M = unpack(id) @@ -164,13 +164,13 @@ let maximum = m => N.maximum(m.data) let maxUndefined = m => N.maxUndefined(m.data) let forEachU = (d, f) => N.forEachU(d.data, f) -let forEach = (d, f) => forEachU(d, (. a, b) => f(a, b)) +let forEach = (d, f) => forEachU(d, (a, b) => f(a, b)) let reduceU = (d, acc, cb) => N.reduceU(d.data, acc, cb) -let reduce = (d, acc, cb) => reduceU(d, acc, (. a, b, c) => cb(a, b, c)) +let reduce = (d, acc, cb) => reduceU(d, acc, (a, b, c) => cb(a, b, c)) let everyU = (d, p) => N.everyU(d.data, p) -let every = (d, p) => everyU(d, (. a, b) => p(a, b)) +let every = (d, p) => everyU(d, (a, b) => p(a, b)) let someU = (d, p) => N.someU(d.data, p) -let some = (d, p) => someU(d, (. a, b) => p(a, b)) +let some = (d, p) => someU(d, (a, b) => p(a, b)) let size = d => N.size(d.data) let toList = d => N.toList(d.data) let toArray = d => N.toArray(d.data) @@ -184,15 +184,15 @@ let valuesToArray = d => N.valuesToArray(d.data) let checkInvariantInternal = d => N.checkInvariantInternal(d.data) let cmpU = (m1, m2, cmp) => N.cmpU(~kcmp=m1.cmp, ~vcmp=cmp, m1.data, m2.data) -let cmp = (m1, m2, cmp) => cmpU(m1, m2, (. a, b) => cmp(a, b)) +let cmp = (m1, m2, cmp) => cmpU(m1, m2, (a, b) => cmp(a, b)) let eqU = (m1, m2, cmp) => N.eqU(~kcmp=m1.cmp, ~veq=cmp, m1.data, m2.data) -let eq = (m1, m2, cmp) => eqU(m1, m2, (. a, b) => cmp(a, b)) +let eq = (m1, m2, cmp) => eqU(m1, m2, (a, b) => cmp(a, b)) let mapU = (m, f) => {cmp: m.cmp, data: N.mapU(m.data, f)} -let map = (m, f) => mapU(m, (. a) => f(a)) +let map = (m, f) => mapU(m, a => f(a)) let mapWithKeyU = (m, f) => {cmp: m.cmp, data: N.mapWithKeyU(m.data, f)} -let mapWithKey = (m, f) => mapWithKeyU(m, (. a, b) => f(a, b)) +let mapWithKey = (m, f) => mapWithKeyU(m, (a, b) => f(a, b)) let get = (m, x) => N.get(~cmp=m.cmp, m.data, x) let getUndefined = (m, x) => N.getUndefined(~cmp=m.cmp, m.data, x) diff --git a/belt/src/belt_MutableMap.resi b/belt/src/belt_MutableMap.resi index 5451272..e4000cc 100644 --- a/belt/src/belt_MutableMap.resi +++ b/belt/src/belt_MutableMap.resi @@ -49,14 +49,14 @@ let clear: t<_> => unit let isEmpty: t<_> => bool let has: (t<'k, _, _>, 'k) => bool -let cmpU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, (. 'a, 'a) => int) => int +let cmpU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => int) => int /** `cmp(m1, m2, cmp)` First compare by size, if size is the same, compare by key, value pair. */ let cmp: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => int) => int -let eqU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, (. 'a, 'a) => bool) => bool +let eqU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => bool) => bool /** `eq(m1, m2, eqf)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. `eqf` is the @@ -64,7 +64,7 @@ equality predicate used to compare the data associated with the keys. */ let eq: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => bool) => bool -let forEachU: (t<'k, 'a, 'id>, (. 'k, 'a) => unit) => unit +let forEachU: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit /** `forEach(m, f)` applies f to all bindings in map `m`. `f` receives the `'k` as first argument, and the associated value as second argument. The @@ -73,7 +73,7 @@ over the type of the keys. */ let forEach: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit -let reduceU: (t<'k, 'a, 'id>, 'b, (. 'b, 'k, 'a) => 'b) => 'b +let reduceU: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b /** `reduce(m, a, f), computes`(f(kN, dN) ... (f(k1, d1, a))...)`, where`k1 ... kN`are the keys of all bindings in`m`(in increasing order), and`d1 ... dN` @@ -81,13 +81,13 @@ are the associated data. */ let reduce: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b -let everyU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => bool +let everyU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool /** `every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. */ let every: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool -let someU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => bool +let someU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool /** `some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. */ @@ -130,12 +130,12 @@ let removeMany: (t<'k, 'a, 'id>, array<'k>) => unit /** `set(m, x, y)` do the in-place modification */ let set: (t<'k, 'a, 'id>, 'k, 'a) => unit -let updateU: (t<'k, 'a, 'id>, 'k, (. option<'a>) => option<'a>) => unit +let updateU: (t<'k, 'a, 'id>, 'k, option<'a> => option<'a>) => unit let update: (t<'k, 'a, 'id>, 'k, option<'a> => option<'a>) => unit let mergeMany: (t<'k, 'a, 'id>, array<('k, 'a)>) => unit -let mapU: (t<'k, 'a, 'id>, (. 'a) => 'b) => t<'k, 'b, 'id> +let mapU: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id> /** `map(m, f)` returns a map with same domain as `m`, where the associated value a of all bindings of `m` has been replaced by the result of the @@ -144,5 +144,5 @@ order with respect to the ordering over the type of the keys. */ let map: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id> -let mapWithKeyU: (t<'k, 'a, 'id>, (. 'k, 'a) => 'b) => t<'k, 'b, 'id> +let mapWithKeyU: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id> let mapWithKey: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id> diff --git a/belt/src/belt_MutableMapInt.res b/belt/src/belt_MutableMapInt.res index a8e7d69..f10b06a 100644 --- a/belt/src/belt_MutableMapInt.res +++ b/belt/src/belt_MutableMapInt.res @@ -29,17 +29,17 @@ let set = (m: t<_>, k, v) => { } let forEachU = (d, f) => N.forEachU(d.data, f) -let forEach = (d, f) => forEachU(d, (. a, b) => f(a, b)) +let forEach = (d, f) => forEachU(d, (a, b) => f(a, b)) let mapU = (d, f) => {data: N.mapU(d.data, f)} -let map = (d, f) => mapU(d, (. a) => f(a)) +let map = (d, f) => mapU(d, a => f(a)) let mapWithKeyU = (d, f) => {data: N.mapWithKeyU(d.data, f)} -let mapWithKey = (d, f) => mapWithKeyU(d, (. a, b) => f(a, b)) +let mapWithKey = (d, f) => mapWithKeyU(d, (a, b) => f(a, b)) let reduceU = (d, acc, f) => N.reduceU(d.data, acc, f) -let reduce = (d, acc, f) => reduceU(d, acc, (. a, b, c) => f(a, b, c)) +let reduce = (d, acc, f) => reduceU(d, acc, (a, b, c) => f(a, b, c)) let everyU = (d, f) => N.everyU(d.data, f) -let every = (d, f) => everyU(d, (. a, b) => f(a, b)) +let every = (d, f) => everyU(d, (a, b) => f(a, b)) let someU = (d, f) => N.someU(d.data, f) -let some = (d, f) => someU(d, (. a, b) => f(a, b)) +let some = (d, f) => someU(d, (a, b) => f(a, b)) let size = d => N.size(d.data) let toList = d => N.toList(d.data) let toArray = d => N.toArray(d.data) @@ -91,7 +91,7 @@ let remove = (d, v) => { let rec updateDone = (t, x: key, f) => switch t { | None => - switch f(. None) { + switch f(None) { | Some(data) => N.singleton(x, data) | None => t } @@ -100,7 +100,7 @@ let rec updateDone = (t, x: key, f) => /* let c = (Belt_Cmp.getCmpInternal cmp) x k [@bs] in */ if k == x { - switch f(. Some(nt.value)) { + switch f(Some(nt.value)) { | None => let {N.left: l, right: r} = nt switch (l, r) { @@ -133,7 +133,7 @@ let updateU = (t, x, f) => { t.data = newRoot } } -let update = (t, x, f) => updateU(t, x, (. a) => f(a)) +let update = (t, x, f) => updateU(t, x, a => f(a)) let rec removeArrayMutateAux = (t, xs, i, len) => if i < len { let ele = A.getUnsafe(xs, i) @@ -165,10 +165,10 @@ let removeMany = (d: t<_>, xs) => { let fromArray = xs => {data: I.fromArray(xs)} let cmpU = (d0, d1, f) => I.cmpU(d0.data, d1.data, f) -let cmp = (d0, d1, f) => cmpU(d0, d1, (. a, b) => f(a, b)) +let cmp = (d0, d1, f) => cmpU(d0, d1, (a, b) => f(a, b)) let eqU = (d0, d1, f) => I.eqU(d0.data, d1.data, f) -let eq = (d0, d1, f) => eqU(d0, d1, (. a, b) => f(a, b)) +let eq = (d0, d1, f) => eqU(d0, d1, (a, b) => f(a, b)) let get = (d, x) => I.get(d.data, x) let getUndefined = (d, x) => I.getUndefined(d.data, x) diff --git a/belt/src/belt_MutableMapInt.resi b/belt/src/belt_MutableMapInt.resi index 6f1b66a..1bd09b2 100644 --- a/belt/src/belt_MutableMapInt.resi +++ b/belt/src/belt_MutableMapInt.resi @@ -32,7 +32,7 @@ let isEmpty: t<'a> => bool let has: (t<'a>, key) => bool -let cmpU: (t<'a>, t<'a>, (. 'a, 'a) => int) => int +let cmpU: (t<'a>, t<'a>, ('a, 'a) => int) => int /** `cmp(m1, m2, cmp)`. First compare by size, if size is the same, compare by key, @@ -40,12 +40,12 @@ value pair */ let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int -let eqU: (t<'a>, t<'a>, (. 'a, 'a) => bool) => bool +let eqU: (t<'a>, t<'a>, ('a, 'a) => bool) => bool /** `eq(m1, m2, cmp)` */ let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool -let forEachU: (t<'a>, (. key, 'a) => unit) => unit +let forEachU: (t<'a>, (key, 'a) => unit) => unit /** `forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as @@ -53,7 +53,7 @@ first argument, and the associated value as second argument. The application order of `f` is in increasing order. */ let forEach: (t<'a>, (key, 'a) => unit) => unit -let reduceU: (t<'a>, 'b, (. 'b, key, 'a) => 'b) => 'b +let reduceU: (t<'a>, 'b, ('b, key, 'a) => 'b) => 'b /** `reduce(m, a, f)` computes `(f kN dN ... (f k1 d1 a)...)`, where `k1 ... kN` are @@ -61,7 +61,7 @@ the keys of all bindings in `m` (in increasing order), and `d1 ... dN` are the associated data. */ let reduce: (t<'a>, 'b, ('b, key, 'a) => 'b) => 'b -let everyU: (t<'a>, (. key, 'a) => bool) => bool +let everyU: (t<'a>, (key, 'a) => bool) => bool /** `every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. @@ -69,7 +69,7 @@ The application order of `p` is unspecified. */ let every: (t<'a>, (key, 'a) => bool) => bool -let someU: (t<'a>, (. key, 'a) => bool) => bool +let someU: (t<'a>, (key, 'a) => bool) => bool /** `some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. @@ -121,10 +121,10 @@ already bound in `m`, its previous binding disappears. */ let set: (t<'a>, key, 'a) => unit -let updateU: (t<'a>, key, (. option<'a>) => option<'a>) => unit +let updateU: (t<'a>, key, option<'a> => option<'a>) => unit let update: (t<'a>, key, option<'a> => option<'a>) => unit -let mapU: (t<'a>, (. 'a) => 'b) => t<'b> +let mapU: (t<'a>, 'a => 'b) => t<'b> /** `map(m, f)` returns a map with same domain as `m`, where the associated value `a` @@ -133,5 +133,5 @@ to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. */ let map: (t<'a>, 'a => 'b) => t<'b> -let mapWithKeyU: (t<'a>, (. key, 'a) => 'b) => t<'b> +let mapWithKeyU: (t<'a>, (key, 'a) => 'b) => t<'b> let mapWithKey: (t<'a>, (key, 'a) => 'b) => t<'b> diff --git a/belt/src/belt_MutableMapString.res b/belt/src/belt_MutableMapString.res index 3bbb2c0..7c3278f 100644 --- a/belt/src/belt_MutableMapString.res +++ b/belt/src/belt_MutableMapString.res @@ -29,17 +29,17 @@ let set = (m: t<_>, k, v) => { } let forEachU = (d, f) => N.forEachU(d.data, f) -let forEach = (d, f) => forEachU(d, (. a, b) => f(a, b)) +let forEach = (d, f) => forEachU(d, (a, b) => f(a, b)) let mapU = (d, f) => {data: N.mapU(d.data, f)} -let map = (d, f) => mapU(d, (. a) => f(a)) +let map = (d, f) => mapU(d, a => f(a)) let mapWithKeyU = (d, f) => {data: N.mapWithKeyU(d.data, f)} -let mapWithKey = (d, f) => mapWithKeyU(d, (. a, b) => f(a, b)) +let mapWithKey = (d, f) => mapWithKeyU(d, (a, b) => f(a, b)) let reduceU = (d, acc, f) => N.reduceU(d.data, acc, f) -let reduce = (d, acc, f) => reduceU(d, acc, (. a, b, c) => f(a, b, c)) +let reduce = (d, acc, f) => reduceU(d, acc, (a, b, c) => f(a, b, c)) let everyU = (d, f) => N.everyU(d.data, f) -let every = (d, f) => everyU(d, (. a, b) => f(a, b)) +let every = (d, f) => everyU(d, (a, b) => f(a, b)) let someU = (d, f) => N.someU(d.data, f) -let some = (d, f) => someU(d, (. a, b) => f(a, b)) +let some = (d, f) => someU(d, (a, b) => f(a, b)) let size = d => N.size(d.data) let toList = d => N.toList(d.data) let toArray = d => N.toArray(d.data) @@ -91,7 +91,7 @@ let remove = (d, v) => { let rec updateDone = (t, x: key, f) => switch t { | None => - switch f(. None) { + switch f(None) { | Some(data) => N.singleton(x, data) | None => t } @@ -100,7 +100,7 @@ let rec updateDone = (t, x: key, f) => /* let c = (Belt_Cmp.getCmpInternal cmp) x k [@bs] in */ if k == x { - switch f(. Some(nt.value)) { + switch f(Some(nt.value)) { | None => let {N.left: l, right: r} = nt switch (l, r) { @@ -133,7 +133,7 @@ let updateU = (t, x, f) => { t.data = newRoot } } -let update = (t, x, f) => updateU(t, x, (. a) => f(a)) +let update = (t, x, f) => updateU(t, x, a => f(a)) let rec removeArrayMutateAux = (t, xs, i, len) => if i < len { let ele = A.getUnsafe(xs, i) @@ -165,10 +165,10 @@ let removeMany = (d: t<_>, xs) => { let fromArray = xs => {data: I.fromArray(xs)} let cmpU = (d0, d1, f) => I.cmpU(d0.data, d1.data, f) -let cmp = (d0, d1, f) => cmpU(d0, d1, (. a, b) => f(a, b)) +let cmp = (d0, d1, f) => cmpU(d0, d1, (a, b) => f(a, b)) let eqU = (d0, d1, f) => I.eqU(d0.data, d1.data, f) -let eq = (d0, d1, f) => eqU(d0, d1, (. a, b) => f(a, b)) +let eq = (d0, d1, f) => eqU(d0, d1, (a, b) => f(a, b)) let get = (d, x) => I.get(d.data, x) let getUndefined = (d, x) => I.getUndefined(d.data, x) diff --git a/belt/src/belt_MutableMapString.resi b/belt/src/belt_MutableMapString.resi index fc4fcb3..6bdec0a 100644 --- a/belt/src/belt_MutableMapString.resi +++ b/belt/src/belt_MutableMapString.resi @@ -32,7 +32,7 @@ let isEmpty: t<'a> => bool let has: (t<'a>, key) => bool -let cmpU: (t<'a>, t<'a>, (. 'a, 'a) => int) => int +let cmpU: (t<'a>, t<'a>, ('a, 'a) => int) => int /** `cmp(m1, m2, cmp)`. First compare by size, if size is the same, compare by key, @@ -40,12 +40,12 @@ value pair */ let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int -let eqU: (t<'a>, t<'a>, (. 'a, 'a) => bool) => bool +let eqU: (t<'a>, t<'a>, ('a, 'a) => bool) => bool /** `eq(m1, m2, cmp)` */ let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool -let forEachU: (t<'a>, (. key, 'a) => unit) => unit +let forEachU: (t<'a>, (key, 'a) => unit) => unit /** `forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as @@ -53,7 +53,7 @@ first argument, and the associated value as second argument. The application order of `f` is in increasing order. */ let forEach: (t<'a>, (key, 'a) => unit) => unit -let reduceU: (t<'a>, 'b, (. 'b, key, 'a) => 'b) => 'b +let reduceU: (t<'a>, 'b, ('b, key, 'a) => 'b) => 'b /** `reduce(m, a, f)` computes `(f kN dN ... (f k1 d1 a)...)`, where `k1 ... kN` are @@ -61,7 +61,7 @@ the keys of all bindings in `m` (in increasing order), and `d1 ... dN` are the associated data. */ let reduce: (t<'a>, 'b, ('b, key, 'a) => 'b) => 'b -let everyU: (t<'a>, (. key, 'a) => bool) => bool +let everyU: (t<'a>, (key, 'a) => bool) => bool /** `every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. @@ -69,7 +69,7 @@ The application order of `p` is unspecified. */ let every: (t<'a>, (key, 'a) => bool) => bool -let someU: (t<'a>, (. key, 'a) => bool) => bool +let someU: (t<'a>, (key, 'a) => bool) => bool /** `some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. @@ -121,10 +121,10 @@ already bound in `m`, its previous binding disappears. */ let set: (t<'a>, key, 'a) => unit -let updateU: (t<'a>, key, (. option<'a>) => option<'a>) => unit +let updateU: (t<'a>, key, option<'a> => option<'a>) => unit let update: (t<'a>, key, option<'a> => option<'a>) => unit -let mapU: (t<'a>, (. 'a) => 'b) => t<'b> +let mapU: (t<'a>, 'a => 'b) => t<'b> /** `map(m, f)` returns a map with same domain as `m`, where the associated value `a` @@ -133,5 +133,5 @@ to `a`. The bindings are passed to `f` in increasing order with respect to the ordering over the type of the keys. */ let map: (t<'a>, 'a => 'b) => t<'b> -let mapWithKeyU: (t<'a>, (. key, 'a) => 'b) => t<'b> +let mapWithKeyU: (t<'a>, (key, 'a) => 'b) => t<'b> let mapWithKey: (t<'a>, (key, 'a) => 'b) => t<'b> diff --git a/belt/src/belt_MutableQueue.res b/belt/src/belt_MutableQueue.res index 86dd07f..aeec077 100644 --- a/belt/src/belt_MutableQueue.res +++ b/belt/src/belt_MutableQueue.res @@ -148,7 +148,7 @@ let rec copyMapAux = (qRes, prev, cell, f) => qRes.last = prev qRes | Some(x) => - let content = f(. x.content) + let content = f(x.content) let res = Some({content, next: None}) switch prev { /* TODO: optimize to remove such check */ @@ -160,7 +160,7 @@ let rec copyMapAux = (qRes, prev, cell, f) => let mapU = (q, f) => copyMapAux({length: q.length, first: None, last: None}, None, q.first, f) -let map = (q, f) => mapU(q, (. a) => f(a)) +let map = (q, f) => mapU(q, a => f(a)) let isEmpty = q => q.length == 0 @@ -170,25 +170,25 @@ let rec iterAux = (cell, f) => switch cell { | None => () | Some(x) => - f(. x.content) + f(x.content) iterAux(x.next, f) } let forEachU = (q, f) => iterAux(q.first, f) -let forEach = (q, f) => forEachU(q, (. a) => f(a)) +let forEach = (q, f) => forEachU(q, a => f(a)) let rec foldAux = (f, accu, cell) => switch cell { | None => accu | Some(x) => - let accu = f(. accu, x.content) + let accu = f(accu, x.content) foldAux(f, accu, x.next) } let reduceU = (q, accu, f) => foldAux(f, accu, q.first) -let reduce = (q, accu, f) => reduceU(q, accu, (. a, b) => f(a, b)) +let reduce = (q, accu, f) => reduceU(q, accu, (a, b) => f(a, b)) let transfer = (q1, q2) => if q1.length > 0 { diff --git a/belt/src/belt_MutableQueue.resi b/belt/src/belt_MutableQueue.resi index 1bc2f8c..d388b7e 100644 --- a/belt/src/belt_MutableQueue.resi +++ b/belt/src/belt_MutableQueue.resi @@ -89,9 +89,9 @@ Returns the number of elements in a queue. */ let size: t<'a> => int -let mapU: (t<'a>, (. 'a) => 'b) => t<'b> +let mapU: (t<'a>, 'a => 'b) => t<'b> let map: (t<'a>, 'a => 'b) => t<'b> -let forEachU: (t<'a>, (. 'a) => unit) => unit +let forEachU: (t<'a>, 'a => unit) => unit /** `forEach(q, f) applies`f`in turn to all elements of`q`, from the least @@ -99,7 +99,7 @@ recently entered to the most recently entered. The queue itself is unchanged. */ let forEach: (t<'a>, 'a => unit) => unit -let reduceU: (t<'a>, 'b, (. 'b, 'a) => 'b) => 'b +let reduceU: (t<'a>, 'b, ('b, 'a) => 'b) => 'b /** `reduce(q, accu, f)` is equivalent to `List.reduce(l, accu, f)`, where `l` is the diff --git a/belt/src/belt_MutableSet.res b/belt/src/belt_MutableSet.res index e48b6a0..3cd0fb2 100644 --- a/belt/src/belt_MutableSet.res +++ b/belt/src/belt_MutableSet.res @@ -39,7 +39,7 @@ type t<'value, 'id> = { let rec remove0 = (nt, x, ~cmp) => { let k = nt.N.value - let c = cmp(. x, k) + let c = cmp(x, k) if c == 0 { let {N.left: l, right: r} = nt switch (l, r) { @@ -102,7 +102,7 @@ let removeMany = (d, xs) => { let rec removeCheck0 = (nt, x, removed, ~cmp) => { let k = nt.N.value - let c = Belt_Id.getCmpInternal(cmp)(. x, k) + let c = Belt_Id.getCmpInternal(cmp)(x, k) if c == 0 { let () = removed.contents = true let {N.left: l, right: r} = nt @@ -151,7 +151,7 @@ let rec addCheck0 = (t, x, added, ~cmp) => N.singleton(x) | Some(nt) => let k = nt.N.value - let c = cmp(. x, k) + let c = cmp(x, k) if c == 0 { t } else { @@ -207,13 +207,13 @@ let maximum = d => N.maximum(d.data) let maxUndefined = d => N.maxUndefined(d.data) let forEachU = (d, f) => N.forEachU(d.data, f) -let forEach = (d, f) => forEachU(d, (. a) => f(a)) +let forEach = (d, f) => forEachU(d, a => f(a)) let reduceU = (d, acc, cb) => N.reduceU(d.data, acc, cb) -let reduce = (d, acc, cb) => reduceU(d, acc, (. a, b) => cb(a, b)) +let reduce = (d, acc, cb) => reduceU(d, acc, (a, b) => cb(a, b)) let everyU = (d, p) => N.everyU(d.data, p) -let every = (d, p) => everyU(d, (. a) => p(a)) +let every = (d, p) => everyU(d, a => p(a)) let someU = (d, p) => N.someU(d.data, p) -let some = (d, p) => someU(d, (. a) => p(a)) +let some = (d, p) => someU(d, a => p(a)) let size = d => N.size(d.data) let toList = d => N.toList(d.data) let toArray = d => N.toArray(d.data) @@ -280,7 +280,7 @@ let split = (d, key) => { let keepU = (d, p) => {data: N.keepCopyU(d.data, p), cmp: d.cmp} -let keep = (d, p) => keepU(d, (. a) => p(a)) +let keep = (d, p) => keepU(d, a => p(a)) let partitionU = (d, p) => { let cmp = d.cmp @@ -288,7 +288,7 @@ let partitionU = (d, p) => { ({data: a, cmp}, {data: b, cmp}) } -let partition = (d, p) => partitionU(d, (. a) => p(a)) +let partition = (d, p) => partitionU(d, a => p(a)) let subset = (a, b) => N.subset(~cmp=a.cmp, a.data, b.data) @@ -305,8 +305,8 @@ let intersect = (a, b): t<_> => { ignore(N.fillArray(datab0, sizea, tmp)) let p = Belt_Id.getCmpInternal(cmp) if ( - p(. A.getUnsafe(tmp, sizea - 1), A.getUnsafe(tmp, sizea)) < 0 || - p(. A.getUnsafe(tmp, totalSize - 1), A.getUnsafe(tmp, 0)) < 0 + p(A.getUnsafe(tmp, sizea - 1), A.getUnsafe(tmp, sizea)) < 0 || + p(A.getUnsafe(tmp, totalSize - 1), A.getUnsafe(tmp, 0)) < 0 ) { {cmp, data: None} } else { @@ -334,8 +334,8 @@ let diff = (a, b): t<_> => { ignore(N.fillArray(datab0, sizea, tmp)) let p = Belt_Id.getCmpInternal(cmp) if ( - p(. A.getUnsafe(tmp, sizea - 1), A.getUnsafe(tmp, sizea)) < 0 || - p(. A.getUnsafe(tmp, totalSize - 1), A.getUnsafe(tmp, 0)) < 0 + p(A.getUnsafe(tmp, sizea - 1), A.getUnsafe(tmp, sizea)) < 0 || + p(A.getUnsafe(tmp, totalSize - 1), A.getUnsafe(tmp, 0)) < 0 ) { {data: N.copy(dataa), cmp} } else { @@ -359,7 +359,7 @@ let union = (a, b) => { ignore(N.fillArray(dataa0, 0, tmp)) ignore(N.fillArray(datab0, sizea, tmp)) let p = Belt_Id.getCmpInternal(cmp) - if p(. A.getUnsafe(tmp, sizea - 1), A.getUnsafe(tmp, sizea)) < 0 { + if p(A.getUnsafe(tmp, sizea - 1), A.getUnsafe(tmp, sizea)) < 0 { {data: N.fromSortedArrayAux(tmp, 0, totalSize), cmp} } else { let tmp2 = A.makeUninitializedUnsafe(totalSize) diff --git a/belt/src/belt_MutableSet.resi b/belt/src/belt_MutableSet.resi index 8a52652..e5fd8b7 100644 --- a/belt/src/belt_MutableSet.resi +++ b/belt/src/belt_MutableSet.resi @@ -340,7 +340,7 @@ let eq: (t<'value, 'id>, t<'value, 'id>) => bool /** Same as `Belt.MutableSet.forEach` but takes uncurried functon. */ -let forEachU: (t<'value, 'id>, (. 'value) => unit) => unit +let forEachU: (t<'value, 'id>, 'value => unit) => unit /** Applies function `f` in turn to all elements of set in increasing order. @@ -361,7 +361,7 @@ acc /* [6,5,3,2] */ */ let forEach: (t<'value, 'id>, 'value => unit) => unit -let reduceU: (t<'value, 'id>, 'a, (. 'a, 'value) => 'a) => 'a +let reduceU: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a /** Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. @@ -380,7 +380,7 @@ s0->Belt.MutableSet.reduce(list{}, (acc, element) => acc->Belt.List.add(element) */ let reduce: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a -let everyU: (t<'value, 'id>, (. 'value) => bool) => bool +let everyU: (t<'value, 'id>, 'value => bool) => bool /** Checks if all elements of the set satisfy the predicate. Order unspecified. @@ -401,7 +401,7 @@ s0->Belt.MutableSet.every(isEven) /* true */ */ let every: (t<'value, 'id>, 'value => bool) => bool -let someU: (t<'value, 'id>, (. 'value) => bool) => bool +let someU: (t<'value, 'id>, 'value => bool) => bool /** Checks if at least one element of the set satisfies the predicate. @@ -422,7 +422,7 @@ s0->Belt.MutableSet.some(isOdd) /* true */ */ let some: (t<'value, 'id>, 'value => bool) => bool -let keepU: (t<'value, 'id>, (. 'value) => bool) => t<'value, 'id> +let keepU: (t<'value, 'id>, 'value => bool) => t<'value, 'id> /** Returns the set of all elements that satisfy the predicate. @@ -445,7 +445,7 @@ s1->Belt.MutableSet.toArray /* [2, 4] */ */ let keep: (t<'value, 'id>, 'value => bool) => t<'value, 'id> -let partitionU: (t<'value, 'id>, (. 'value) => bool) => (t<'value, 'id>, t<'value, 'id>) +let partitionU: (t<'value, 'id>, 'value => bool) => (t<'value, 'id>, t<'value, 'id>) /** ## Examples diff --git a/belt/src/belt_MutableSetInt.res b/belt/src/belt_MutableSetInt.res index 4c50fcd..1dc90e2 100644 --- a/belt/src/belt_MutableSetInt.res +++ b/belt/src/belt_MutableSetInt.res @@ -206,15 +206,15 @@ let maximum = d => N.maximum(d.data) let maxUndefined = d => N.maxUndefined(d.data) let forEachU = (d, f) => N.forEachU(d.data, f) -let forEach = (d, f) => forEachU(d, (. a) => f(a)) +let forEach = (d, f) => forEachU(d, a => f(a)) let reduceU = (d, acc, cb) => N.reduceU(d.data, acc, cb) -let reduce = (d, acc, cb) => reduceU(d, acc, (. a, b) => cb(a, b)) +let reduce = (d, acc, cb) => reduceU(d, acc, (a, b) => cb(a, b)) let everyU = (d, p) => N.everyU(d.data, p) -let every = (d, p) => everyU(d, (. a) => p(a)) +let every = (d, p) => everyU(d, a => p(a)) let someU = (d, p) => N.someU(d.data, p) -let some = (d, p) => someU(d, (. a) => p(a)) +let some = (d, p) => someU(d, a => p(a)) let size = d => N.size(d.data) let toList = d => N.toList(d.data) let toArray = d => N.toArray(d.data) @@ -256,13 +256,13 @@ let split = (d, key) => { } let keepU = (d, p) => {data: N.keepCopyU(d.data, p)} -let keep = (d, p) => keepU(d, (. a) => p(a)) +let keep = (d, p) => keepU(d, a => p(a)) let partitionU = (d, p) => { let (a, b) = N.partitionCopyU(d.data, p) ({data: a}, {data: b}) } -let partition = (d, p) => partitionU(d, (. a) => p(a)) +let partition = (d, p) => partitionU(d, a => p(a)) let subset = (a, b) => I.subset(a.data, b.data) let intersect = (dataa, datab) => { diff --git a/belt/src/belt_MutableSetInt.resi b/belt/src/belt_MutableSetInt.resi index e7dc512..7078dbd 100644 --- a/belt/src/belt_MutableSetInt.resi +++ b/belt/src/belt_MutableSetInt.resi @@ -61,24 +61,24 @@ let subset: (t, t) => bool let cmp: (t, t) => int let eq: (t, t) => bool -let forEachU: (t, (. value) => unit) => unit +let forEachU: (t, value => unit) => unit /** In increasing order*/ let forEach: (t, value => unit) => unit -let reduceU: (t, 'a, (. 'a, value) => 'a) => 'a +let reduceU: (t, 'a, ('a, value) => 'a) => 'a /** Iterate in increasing order. */ let reduce: (t, 'a, ('a, value) => 'a) => 'a -let everyU: (t, (. value) => bool) => bool +let everyU: (t, value => bool) => bool /** `every(p, s)` checks if all elements of the set satisfy the predicate `p`. Order unspecified. */ let every: (t, value => bool) => bool -let someU: (t, (. value) => bool) => bool +let someU: (t, value => bool) => bool /** `some(p, s)` checks if at least one element of the set satisfies the predicate @@ -86,7 +86,7 @@ let someU: (t, (. value) => bool) => bool */ let some: (t, value => bool) => bool -let keepU: (t, (. value) => bool) => t +let keepU: (t, value => bool) => t /** `keep(s, p)` returns a fresh copy of the set of all elements in `s` that satisfy @@ -94,7 +94,7 @@ predicate `p`. */ let keep: (t, value => bool) => t -let partitionU: (t, (. value) => bool) => (t, t) +let partitionU: (t, value => bool) => (t, t) /** `partition(s, p)` returns a fresh copy pair of sets `(s1, s2)`, where `s1` is diff --git a/belt/src/belt_MutableSetString.res b/belt/src/belt_MutableSetString.res index eb0cb4f..62f9c09 100644 --- a/belt/src/belt_MutableSetString.res +++ b/belt/src/belt_MutableSetString.res @@ -206,15 +206,15 @@ let maximum = d => N.maximum(d.data) let maxUndefined = d => N.maxUndefined(d.data) let forEachU = (d, f) => N.forEachU(d.data, f) -let forEach = (d, f) => forEachU(d, (. a) => f(a)) +let forEach = (d, f) => forEachU(d, a => f(a)) let reduceU = (d, acc, cb) => N.reduceU(d.data, acc, cb) -let reduce = (d, acc, cb) => reduceU(d, acc, (. a, b) => cb(a, b)) +let reduce = (d, acc, cb) => reduceU(d, acc, (a, b) => cb(a, b)) let everyU = (d, p) => N.everyU(d.data, p) -let every = (d, p) => everyU(d, (. a) => p(a)) +let every = (d, p) => everyU(d, a => p(a)) let someU = (d, p) => N.someU(d.data, p) -let some = (d, p) => someU(d, (. a) => p(a)) +let some = (d, p) => someU(d, a => p(a)) let size = d => N.size(d.data) let toList = d => N.toList(d.data) let toArray = d => N.toArray(d.data) @@ -256,13 +256,13 @@ let split = (d, key) => { } let keepU = (d, p) => {data: N.keepCopyU(d.data, p)} -let keep = (d, p) => keepU(d, (. a) => p(a)) +let keep = (d, p) => keepU(d, a => p(a)) let partitionU = (d, p) => { let (a, b) = N.partitionCopyU(d.data, p) ({data: a}, {data: b}) } -let partition = (d, p) => partitionU(d, (. a) => p(a)) +let partition = (d, p) => partitionU(d, a => p(a)) let subset = (a, b) => I.subset(a.data, b.data) let intersect = (dataa, datab) => { diff --git a/belt/src/belt_MutableSetString.resi b/belt/src/belt_MutableSetString.resi index 72aa9be..75dbe5a 100644 --- a/belt/src/belt_MutableSetString.resi +++ b/belt/src/belt_MutableSetString.resi @@ -61,24 +61,24 @@ let subset: (t, t) => bool let cmp: (t, t) => int let eq: (t, t) => bool -let forEachU: (t, (. value) => unit) => unit +let forEachU: (t, value => unit) => unit /** In increasing order*/ let forEach: (t, value => unit) => unit -let reduceU: (t, 'a, (. 'a, value) => 'a) => 'a +let reduceU: (t, 'a, ('a, value) => 'a) => 'a /** Iterate in increasing order. */ let reduce: (t, 'a, ('a, value) => 'a) => 'a -let everyU: (t, (. value) => bool) => bool +let everyU: (t, value => bool) => bool /** `every(p, s)` checks if all elements of the set satisfy the predicate `p`. Order unspecified. */ let every: (t, value => bool) => bool -let someU: (t, (. value) => bool) => bool +let someU: (t, value => bool) => bool /** `some(p, s)` checks if at least one element of the set satisfies the predicate @@ -86,7 +86,7 @@ let someU: (t, (. value) => bool) => bool */ let some: (t, value => bool) => bool -let keepU: (t, (. value) => bool) => t +let keepU: (t, value => bool) => t /** `keep(s, p)` returns a fresh copy of the set of all elements in `s` that satisfy @@ -94,7 +94,7 @@ predicate `p`. */ let keep: (t, value => bool) => t -let partitionU: (t, (. value) => bool) => (t, t) +let partitionU: (t, value => bool) => (t, t) /** `partition(s, p)` returns a fresh copy pair of sets `(s1, s2)`, where `s1` is diff --git a/belt/src/belt_MutableStack.res b/belt/src/belt_MutableStack.res index 2d7b34f..07709d3 100644 --- a/belt/src/belt_MutableStack.res +++ b/belt/src/belt_MutableStack.res @@ -83,21 +83,21 @@ let rec iterAux = (s: opt_cell<_>, f) => switch s { | None => () | Some(x) => - f(. x.head) + f(x.head) iterAux(x.tail, f) } let forEachU = (s, f) => iterAux(s.root, f) -let forEach = (s, f) => forEachU(s, (. x) => f(x)) +let forEach = (s, f) => forEachU(s, x => f(x)) let rec dynamicPopIterU = (s, f) => switch s.root { | Some({tail, head}) => s.root = tail - f(. head) + f(head) dynamicPopIterU(s, f) /* using root, `f` may change it */ | None => () } -let dynamicPopIter = (s, f) => dynamicPopIterU(s, (. x) => f(x)) +let dynamicPopIter = (s, f) => dynamicPopIterU(s, x => f(x)) diff --git a/belt/src/belt_MutableStack.resi b/belt/src/belt_MutableStack.resi index cb11d4a..26a30cc 100644 --- a/belt/src/belt_MutableStack.resi +++ b/belt/src/belt_MutableStack.resi @@ -51,9 +51,9 @@ let topUndefined: t<'a> => Js.undefined<'a> let top: t<'a> => option<'a> let isEmpty: t<'a> => bool let size: t<'a> => int -let forEachU: (t<'a>, (. 'a) => unit) => unit +let forEachU: (t<'a>, 'a => unit) => unit let forEach: (t<'a>, 'a => unit) => unit -let dynamicPopIterU: (t<'a>, (. 'a) => unit) => unit +let dynamicPopIterU: (t<'a>, 'a => unit) => unit /** `dynamicPopIter(s, f)` apply `f` to each element of `s`. The item is poped diff --git a/belt/src/belt_Option.res b/belt/src/belt_Option.res index b7371b4..19145fa 100644 --- a/belt/src/belt_Option.res +++ b/belt/src/belt_Option.res @@ -24,19 +24,19 @@ let keepU = (opt, p) => switch opt { - | Some(x) as some if p(. x) => some + | Some(x) as some if p(x) => some | _ => None } -let keep = (opt, p) => keepU(opt, (. x) => p(x)) +let keep = (opt, p) => keepU(opt, x => p(x)) let forEachU = (opt, f) => switch opt { - | Some(x) => f(. x) + | Some(x) => f(x) | None => () } -let forEach = (opt, f) => forEachU(opt, (. x) => f(x)) +let forEach = (opt, f) => forEachU(opt, x => f(x)) let getExn = x => switch x { @@ -48,27 +48,27 @@ external getUnsafe: option<'a> => 'a = "%identity" let mapWithDefaultU = (opt, default, f) => switch opt { - | Some(x) => f(. x) + | Some(x) => f(x) | None => default } -let mapWithDefault = (opt, default, f) => mapWithDefaultU(opt, default, (. x) => f(x)) +let mapWithDefault = (opt, default, f) => mapWithDefaultU(opt, default, x => f(x)) let mapU = (opt, f) => switch opt { - | Some(x) => Some(f(. x)) + | Some(x) => Some(f(x)) | None => None } -let map = (opt, f) => mapU(opt, (. x) => f(x)) +let map = (opt, f) => mapU(opt, x => f(x)) let flatMapU = (opt, f) => switch opt { - | Some(x) => f(. x) + | Some(x) => f(x) | None => None } -let flatMap = (opt, f) => flatMapU(opt, (. x) => f(x)) +let flatMap = (opt, f) => flatMapU(opt, x => f(x)) let getWithDefault = (opt, default) => switch opt { @@ -95,19 +95,19 @@ let eqU = (a, b, f) => | Some(a) => switch b { | None => false - | Some(b) => f(. a, b) + | Some(b) => f(a, b) } | None => b == None } -let eq = (a, b, f) => eqU(a, b, (. x, y) => f(x, y)) +let eq = (a, b, f) => eqU(a, b, (x, y) => f(x, y)) let cmpU = (a, b, f) => switch (a, b) { - | (Some(a), Some(b)) => f(. a, b) + | (Some(a), Some(b)) => f(a, b) | (None, Some(_)) => -1 | (Some(_), None) => 1 | (None, None) => 0 } -let cmp = (a, b, f) => cmpU(a, b, (. x, y) => f(x, y)) +let cmp = (a, b, f) => cmpU(a, b, (x, y) => f(x, y)) diff --git a/belt/src/belt_Option.resi b/belt/src/belt_Option.resi index 5764811..31ab9b7 100644 --- a/belt/src/belt_Option.resi +++ b/belt/src/belt_Option.resi @@ -41,7 +41,7 @@ let someString: option = Some("hello") */ /** Uncurried version of `keep` */ -let keepU: (option<'a>, (. 'a) => bool) => option<'a> +let keepU: (option<'a>, 'a => bool) => option<'a> /** If `optionValue` is `Some(value)` and `p(value) = true`, it returns `Some(value)`; otherwise returns `None` @@ -57,7 +57,7 @@ Belt.Option.keep(None, x => x > 5) /* returns `None` */ let keep: (option<'a>, 'a => bool) => option<'a> /** Uncurried version of `forEach` */ -let forEachU: (option<'a>, (. 'a) => unit) => unit +let forEachU: (option<'a>, 'a => unit) => unit /** If `optionValue` is `Some(value`), it calls `f(value)`; otherwise returns `()` @@ -93,7 +93,7 @@ nor `Some(None(...)))` external getUnsafe: option<'a> => 'a = "%identity" /** Uncurried version of `mapWithDefault` */ -let mapWithDefaultU: (option<'a>, 'b, (. 'a) => 'b) => 'b +let mapWithDefaultU: (option<'a>, 'b, 'a => 'b) => 'b /** If `optionValue` is of `Some(value)`, @@ -114,7 +114,7 @@ noneValue->Belt.Option.mapWithDefault(0, x => x + 5) /* 0 */ let mapWithDefault: (option<'a>, 'b, 'a => 'b) => 'b /** Uncurried version of `map` */ -let mapU: (option<'a>, (. 'a) => 'b) => option<'b> +let mapU: (option<'a>, 'a => 'b) => option<'b> /** If `optionValue` is `Some(value)` this returns `f(value)`, otherwise it returns `None`. @@ -130,7 +130,7 @@ Belt.Option.map(None, x => x * x) /* None */ let map: (option<'a>, 'a => 'b) => option<'b> /** Uncurried version of `flatMap` */ -let flatMapU: (option<'a>, (. 'a) => option<'b>) => option<'b> +let flatMapU: (option<'a>, 'a => option<'b>) => option<'b> /** If `optionValue` is `Some(value)`, returns `f(value)`, otherwise returns @@ -221,7 +221,7 @@ let isNone: option<'a> => bool /** Uncurried version of `eq` */ -let eqU: (option<'a>, option<'b>, (. 'a, 'b) => bool) => bool +let eqU: (option<'a>, option<'b>, ('a, 'b) => bool) => bool /** Evaluates two optional values for equality with respect to a predicate @@ -253,7 +253,7 @@ let eq: (option<'a>, option<'b>, ('a, 'b) => bool) => bool /** Uncurried version of `cmp` */ -let cmpU: (option<'a>, option<'b>, (. 'a, 'b) => int) => int +let cmpU: (option<'a>, option<'b>, ('a, 'b) => int) => int /** `cmp(optValue1, optValue2, comparisonFunction)` compares two optional values diff --git a/belt/src/belt_Range.res b/belt/src/belt_Range.res index c8f5d33..a4018ae 100644 --- a/belt/src/belt_Range.res +++ b/belt/src/belt_Range.res @@ -24,25 +24,25 @@ let forEachU = (s, f, action) => for i in s to f { - (action(. i): unit) + (action(i): unit) } -let forEach = (s, f, action) => forEachU(s, f, (. a) => action(a)) +let forEach = (s, f, action) => forEachU(s, f, a => action(a)) let rec everyU = (s, f, p) => if s > f { true } else { - p(. s) && everyU(s + 1, f, p) + p(s) && everyU(s + 1, f, p) } -let every = (s, f, p) => everyU(s, f, (. a) => p(a)) +let every = (s, f, p) => everyU(s, f, a => p(a)) let rec everyByAux = (s, f, ~step, p) => if s > f { true } else { - p(. s) && everyByAux(s + step, f, ~step, p) + p(s) && everyByAux(s + step, f, ~step, p) } let everyByU = (s, f, ~step, p) => @@ -52,22 +52,22 @@ let everyByU = (s, f, ~step, p) => true } /* return empty range `true` */ -let everyBy = (s, f, ~step, p) => everyByU(s, f, ~step, (. a) => p(a)) +let everyBy = (s, f, ~step, p) => everyByU(s, f, ~step, a => p(a)) let rec someU = (s, f, p) => if s > f { false } else { - p(. s) || someU(s + 1, f, p) + p(s) || someU(s + 1, f, p) } -let some = (s, f, p) => someU(s, f, (. a) => p(a)) +let some = (s, f, p) => someU(s, f, a => p(a)) let rec someByAux = (s, f, ~step, p) => if s > f { false } else { - p(. s) || someByAux(s + step, f, ~step, p) + p(s) || someByAux(s + step, f, ~step, p) } let someByU = (s, f, ~step, p) => @@ -77,4 +77,4 @@ let someByU = (s, f, ~step, p) => false } /* return empty range, `false` */ -let someBy = (s, f, ~step, p) => someByU(s, f, ~step, (. a) => p(a)) +let someBy = (s, f, ~step, p) => someByU(s, f, ~step, a => p(a)) diff --git a/belt/src/belt_Range.resi b/belt/src/belt_Range.resi index b0ad2f2..3f805ab 100644 --- a/belt/src/belt_Range.resi +++ b/belt/src/belt_Range.resi @@ -28,7 +28,7 @@ Internally it is relying on loops instead of creating new arrays, which makes it pretty performant and memory friendly. */ -let forEachU: (int, int, (. int) => unit) => unit +let forEachU: (int, int, int => unit) => unit /** `forEach(start, finish, action)` equivalent to `Belt.Array.forEach(Belt.Array.range(start, finish), action))` @@ -48,7 +48,7 @@ Belt.Range.forEach(0, 4, (i) => Js.log(i)) */ let forEach: (int, int, int => unit) => unit -let everyU: (int, int, (. int) => bool) => bool +let everyU: (int, int, int => bool) => bool /** `every(start, finish, p)` equivalent to `Belt.Array.every(Belt.Array.range(start, finish), p)` @@ -62,7 +62,7 @@ Belt.Range.every(0, 4, (i) => i < 4) /* false */ */ let every: (int, int, int => bool) => bool -let everyByU: (int, int, ~step: int, (. int) => bool) => bool +let everyByU: (int, int, ~step: int, int => bool) => bool /** `everyBy(start, finish, ~step, p)`. See `Belt.Array.rangeBy`, equivalent to @@ -78,7 +78,7 @@ Belt.Range.everyBy(0, 4, ~step=2, (i) => mod(i, 2) === 0) /* true */ */ let everyBy: (int, int, ~step: int, int => bool) => bool -let someU: (int, int, (. int) => bool) => bool +let someU: (int, int, int => bool) => bool /** `some(start, finish, p)` equivalent to `Belt.Array.some(Belt.Array.range(start, finish), p)` @@ -93,7 +93,7 @@ Belt.Range.some(0, 4, (i) => i > 2) /* true */ */ let some: (int, int, int => bool) => bool -let someByU: (int, int, ~step: int, (. int) => bool) => bool +let someByU: (int, int, ~step: int, int => bool) => bool /** `someBy(start, finish, ~step, p)` See `Belt.Array.rangeBy`, equivalent to diff --git a/belt/src/belt_Result.res b/belt/src/belt_Result.res index a1cbba1..08d2193 100644 --- a/belt/src/belt_Result.res +++ b/belt/src/belt_Result.res @@ -34,27 +34,27 @@ let getExn = x => let mapWithDefaultU = (opt, default, f) => switch opt { - | Ok(x) => f(. x) + | Ok(x) => f(x) | Error(_) => default } -let mapWithDefault = (opt, default, f) => mapWithDefaultU(opt, default, (. x) => f(x)) +let mapWithDefault = (opt, default, f) => mapWithDefaultU(opt, default, x => f(x)) let mapU = (opt, f) => switch opt { - | Ok(x) => Ok(f(. x)) + | Ok(x) => Ok(f(x)) | Error(y) => Error(y) } -let map = (opt, f) => mapU(opt, (. x) => f(x)) +let map = (opt, f) => mapU(opt, x => f(x)) let flatMapU = (opt, f) => switch opt { - | Ok(x) => f(. x) + | Ok(x) => f(x) | Error(y) => Error(y) } -let flatMap = (opt, f) => flatMapU(opt, (. x) => f(x)) +let flatMap = (opt, f) => flatMapU(opt, x => f(x)) let getWithDefault = (opt, default) => switch opt { @@ -76,20 +76,20 @@ let isError = x => let eqU = (a, b, f) => switch (a, b) { - | (Ok(a), Ok(b)) => f(. a, b) + | (Ok(a), Ok(b)) => f(a, b) | (Error(_), Ok(_)) | (Ok(_), Error(_)) => false | (Error(_), Error(_)) => true } -let eq = (a, b, f) => eqU(a, b, (. x, y) => f(x, y)) +let eq = (a, b, f) => eqU(a, b, (x, y) => f(x, y)) let cmpU = (a, b, f) => switch (a, b) { - | (Ok(a), Ok(b)) => f(. a, b) + | (Ok(a), Ok(b)) => f(a, b) | (Error(_), Ok(_)) => -1 | (Ok(_), Error(_)) => 1 | (Error(_), Error(_)) => 0 } -let cmp = (a, b, f) => cmpU(a, b, (. x, y) => f(x, y)) +let cmp = (a, b, f) => cmpU(a, b, (x, y) => f(x, y)) diff --git a/belt/src/belt_Result.resi b/belt/src/belt_Result.resi index 91e1f66..f3821d5 100644 --- a/belt/src/belt_Result.resi +++ b/belt/src/belt_Result.resi @@ -46,7 +46,7 @@ Belt.Result.getExn(Belt.Result.Error("Invalid data")) /* raises exception */ */ let getExn: t<'a, 'b> => 'a -let mapWithDefaultU: (t<'a, 'c>, 'b, (. 'a) => 'b) => 'b +let mapWithDefaultU: (t<'a, 'c>, 'b, 'a => 'b) => 'b /** `mapWithDefault(res, default, f)`: When res is `Ok(n)`, returns `f(n)`, otherwise `default`. @@ -63,7 +63,7 @@ Belt.Result.mapWithDefault(error, 0, (x) => x / 2) == 0 */ let mapWithDefault: (t<'a, 'c>, 'b, 'a => 'b) => 'b -let mapU: (t<'a, 'c>, (. 'a) => 'b) => t<'b, 'c> +let mapU: (t<'a, 'c>, 'a => 'b) => t<'b, 'c> /** `map(res, f)`: When res is `Ok(n)`, returns `Ok(f(n))`. Otherwise returns res unchanged. Function `f` takes a value of the same type as `n` and returns an @@ -81,7 +81,7 @@ Belt.Result.map(Error("Invalid data"), f) == Error("Invalid data") */ let map: (t<'a, 'c>, 'a => 'b) => t<'b, 'c> -let flatMapU: (t<'a, 'c>, (. 'a) => t<'b, 'c>) => t<'b, 'c> +let flatMapU: (t<'a, 'c>, 'a => t<'b, 'c>) => t<'b, 'c> /** `flatMap(res, f)`: When res is `Ok(n)`, returns `f(n)`. Otherwise, returns res unchanged. Function `f` takes a value of the same type as `n` and returns a @@ -132,7 +132,7 @@ it is the `Ok(n)` variant. */ let isError: t<'a, 'b> => bool -let eqU: (t<'a, 'c>, t<'b, 'd>, (. 'a, 'b) => bool) => bool +let eqU: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => bool) => bool /** `eq(res1, res2, f)`: Determine if two `Belt.Result` variables are equal with respect to an equality function. If `res1` and `res2` are of the form `Ok(n)` @@ -164,7 +164,7 @@ Belt.Result.eq(bad1, bad2, mod10equal) == true */ let eq: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => bool) => bool -let cmpU: (t<'a, 'c>, t<'b, 'd>, (. 'a, 'b) => int) => int +let cmpU: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => int) => int /** `cmp(res1, res2, f)`: Compare two `Belt.Result` variables with respect to a comparison function. The comparison function returns -1 if the first variable diff --git a/belt/src/belt_Set.res b/belt/src/belt_Set.res index 612a9fd..dbfdd3a 100644 --- a/belt/src/belt_Set.res +++ b/belt/src/belt_Set.res @@ -102,26 +102,26 @@ let cmp = (m, n) => { let eq = (m, n) => Dict.eq(~cmp=m.cmp, m.data, n.data) let forEachU = (m, f) => Dict.forEachU(m.data, f) -let forEach = (m, f) => forEachU(m, (. a) => f(a)) +let forEach = (m, f) => forEachU(m, a => f(a)) let reduceU = (m, acc, f) => Dict.reduceU(m.data, acc, f) -let reduce = (m, acc, f) => reduceU(m, acc, (. a, b) => f(a, b)) +let reduce = (m, acc, f) => reduceU(m, acc, (a, b) => f(a, b)) let everyU = (m, f) => Dict.everyU(m.data, f) -let every = (m, f) => everyU(m, (. a) => f(a)) +let every = (m, f) => everyU(m, a => f(a)) let someU = (m, f) => Dict.someU(m.data, f) -let some = (m, f) => someU(m, (. a) => f(a)) +let some = (m, f) => someU(m, a => f(a)) let keepU = (m, f) => {cmp: m.cmp, data: Dict.keepU(m.data, f)} -let keep = (m, f) => keepU(m, (. a) => f(a)) +let keep = (m, f) => keepU(m, a => f(a)) let partitionU = (m, f) => { let (l, r) = Dict.partitionU(m.data, f) let cmp = m.cmp ({data: l, cmp}, {data: r, cmp}) } -let partition = (m, f) => partitionU(m, (. a) => f(a)) +let partition = (m, f) => partitionU(m, a => f(a)) let size = m => Dict.size(m.data) let toList = m => Dict.toList(m.data) diff --git a/belt/src/belt_Set.resi b/belt/src/belt_Set.resi index a7b8e00..5a6319e 100644 --- a/belt/src/belt_Set.resi +++ b/belt/src/belt_Set.resi @@ -297,7 +297,7 @@ let eq: (t<'value, 'id>, t<'value, 'id>) => bool /** Same as [forEach](#forEach) but takes uncurried functon. */ -let forEachU: (t<'value, 'id>, (. 'value) => unit) => unit +let forEachU: (t<'value, 'id>, 'value => unit) => unit /** Applies function `f` in turn to all elements of set in increasing order. @@ -315,7 +315,7 @@ acc /* [6,5,3,2] */ */ let forEach: (t<'value, 'id>, 'value => unit) => unit -let reduceU: (t<'value, 'id>, 'a, (. 'a, 'value) => 'a) => 'a +let reduceU: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a /** Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. @@ -331,7 +331,7 @@ s0->Belt.Set.reduce(list{}, (acc, element) => */ let reduce: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a -let everyU: (t<'value, 'id>, (. 'value) => bool) => bool +let everyU: (t<'value, 'id>, 'value => bool) => bool /** Checks if all elements of the set satisfy the predicate. Order unspecified. @@ -347,7 +347,7 @@ s0->Belt.Set.every(isEven) /* true */ */ let every: (t<'value, 'id>, 'value => bool) => bool -let someU: (t<'value, 'id>, (. 'value) => bool) => bool +let someU: (t<'value, 'id>, 'value => bool) => bool /** Checks if at least one element of the set satisfies the predicate. @@ -363,7 +363,7 @@ s0->Belt.Set.some(isOdd) /* true */ */ let some: (t<'value, 'id>, 'value => bool) => bool -let keepU: (t<'value, 'id>, (. 'value) => bool) => t<'value, 'id> +let keepU: (t<'value, 'id>, 'value => bool) => t<'value, 'id> /** Returns the set of all elements that satisfy the predicate. @@ -381,7 +381,7 @@ s1->Belt.Set.toArray /* [2,4] */ */ let keep: (t<'value, 'id>, 'value => bool) => t<'value, 'id> -let partitionU: (t<'value, 'id>, (. 'value) => bool) => (t<'value, 'id>, t<'value, 'id>) +let partitionU: (t<'value, 'id>, 'value => bool) => (t<'value, 'id>, t<'value, 'id>) /** Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. diff --git a/belt/src/belt_SetDict.res b/belt/src/belt_SetDict.res index 0a9a59b..60337c3 100644 --- a/belt/src/belt_SetDict.res +++ b/belt/src/belt_SetDict.res @@ -38,7 +38,7 @@ let rec add = (t: t<_>, x, ~cmp): t<_> => | None => N.singleton(x) | Some(nt) => let k = nt.value - let c = Belt_Id.getCmpInternal(cmp)(. x, k) + let c = Belt_Id.getCmpInternal(cmp)(x, k) if c == 0 { t } else { @@ -66,7 +66,7 @@ let rec remove = (t: t<_>, x, ~cmp): t<_> => | None => t | Some(n) => let {N.left: l, value: v, right: r} = n - let c = Belt_Id.getCmpInternal(cmp)(. x, v) + let c = Belt_Id.getCmpInternal(cmp)(x, v) if c == 0 { switch (l, r) { | (None, _) => r @@ -115,7 +115,7 @@ let removeMany = (h, arr, ~cmp) => { let rec splitAuxNoPivot = (~cmp, n: N.node<_>, x): (_, _) => { let {N.left: l, value: v, right: r} = n - let c = Belt_Id.getCmpInternal(cmp)(. x, v) + let c = Belt_Id.getCmpInternal(cmp)(x, v) if c == 0 { (l, r) } else if c < 0 { @@ -137,7 +137,7 @@ let rec splitAuxNoPivot = (~cmp, n: N.node<_>, x): (_, _) => { let rec splitAuxPivot = (~cmp, n: N.node<_>, x, pres): (_, _) => { let {N.left: l, value: v, right: r} = n - let c = Belt_Id.getCmpInternal(cmp)(. x, v) + let c = Belt_Id.getCmpInternal(cmp)(x, v) if c == 0 { pres.contents = true (l, r) diff --git a/belt/src/belt_SetDict.resi b/belt/src/belt_SetDict.resi index 4f740a6..d736f27 100644 --- a/belt/src/belt_SetDict.resi +++ b/belt/src/belt_SetDict.resi @@ -308,7 +308,7 @@ let eq: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => bool /** Same as [forEach](##forEach) but takes uncurried functon. */ -let forEachU: (t<'value, 'id>, (. 'value) => unit) => unit +let forEachU: (t<'value, 'id>, 'value => unit) => unit /** Applies function `f` in turn to all elements of set in increasing order. @@ -329,7 +329,7 @@ acc /* [6,5,3,2] */ */ let forEach: (t<'value, 'id>, 'value => unit) => unit -let reduceU: (t<'value, 'id>, 'a, (. 'a, 'value) => 'a) => 'a +let reduceU: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a /** Applies function `f` to each element of set in increasing order. Function `f` has two parameters: the item from the set and an “accumulator”, which starts with a value of `initialValue`. `reduce` returns the final value of the accumulator. @@ -348,7 +348,7 @@ s0->Belt.Set.Dict.reduce(list{}, (acc, element) => acc->Belt.List.add(element)) */ let reduce: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a -let everyU: (t<'value, 'id>, (. 'value) => bool) => bool +let everyU: (t<'value, 'id>, 'value => bool) => bool /** Checks if all elements of the set satisfy the predicate. Order unspecified. @@ -369,7 +369,7 @@ s0->Belt.Set.Dict.every(isEven) /* true */ */ let every: (t<'value, 'id>, 'value => bool) => bool -let someU: (t<'value, 'id>, (. 'value) => bool) => bool +let someU: (t<'value, 'id>, 'value => bool) => bool /** Checks if at least one element of the set satisfies the predicate. @@ -390,7 +390,7 @@ s0->Belt.Set.Dict.some(isOdd) /* true */ */ let some: (t<'value, 'id>, 'value => bool) => bool -let keepU: (t<'value, 'id>, (. 'value) => bool) => t<'value, 'id> +let keepU: (t<'value, 'id>, 'value => bool) => t<'value, 'id> /** Returns the set of all elements that satisfy the predicate. @@ -413,7 +413,7 @@ s1->Belt.Set.Dict.toArray /* [2,4] */ */ let keep: (t<'value, 'id>, 'value => bool) => t<'value, 'id> -let partitionU: (t<'value, 'id>, (. 'value) => bool) => (t<'value, 'id>, t<'value, 'id>) +let partitionU: (t<'value, 'id>, 'value => bool) => (t<'value, 'id>, t<'value, 'id>) /** Returns a pair of sets, where first is the set of all the elements of set that satisfy the predicate, and second is the set of all the elements of set that do not satisfy the predicate. diff --git a/belt/src/belt_SetInt.resi b/belt/src/belt_SetInt.resi index a943ce7..ef7a9fd 100644 --- a/belt/src/belt_SetInt.resi +++ b/belt/src/belt_SetInt.resi @@ -67,7 +67,7 @@ let intersect: (t, t) => t let diff: (t, t) => t /** -`subset(s1, s20)` tests whether the set `s1` is a subset of the set `s2`. +`subset(s1, s2)` tests whether the set `s1` is a subset of the set `s2`. */ let subset: (t, t) => bool @@ -83,19 +83,19 @@ equal elements. */ let eq: (t, t) => bool -let forEachU: (t, (. value) => unit) => unit +let forEachU: (t, value => unit) => unit /** `forEach(s, f)` applies `f` in turn to all elements of `s`. In increasing order */ let forEach: (t, value => unit) => unit -let reduceU: (t, 'a, (. 'a, value) => 'a) => 'a +let reduceU: (t, 'a, ('a, value) => 'a) => 'a /** Iterate in increasing order. */ let reduce: (t, 'a, ('a, value) => 'a) => 'a -let everyU: (t, (. value) => bool) => bool +let everyU: (t, value => bool) => bool /** `every(p, s)` checks if all elements of the set satisfy the predicate `p`. Order @@ -103,7 +103,7 @@ unspecified. */ let every: (t, value => bool) => bool -let someU: (t, (. value) => bool) => bool +let someU: (t, value => bool) => bool /** `some(p, s)` checks if at least one element of the set satisfies the predicate @@ -111,14 +111,14 @@ let someU: (t, (. value) => bool) => bool */ let some: (t, value => bool) => bool -let keepU: (t, (. value) => bool) => t +let keepU: (t, value => bool) => t /** `keep(p, s)` returns the set of all elements in `s` that satisfy predicate `p`. */ let keep: (t, value => bool) => t -let partitionU: (t, (. value) => bool) => (t, t) +let partitionU: (t, value => bool) => (t, t) /** `partition(p, s)` returns a pair of sets `(s1, s2)`, where `s1` is the set of diff --git a/belt/src/belt_SetString.resi b/belt/src/belt_SetString.resi index 64f0644..cffbc13 100644 --- a/belt/src/belt_SetString.resi +++ b/belt/src/belt_SetString.resi @@ -67,7 +67,7 @@ let intersect: (t, t) => t let diff: (t, t) => t /** -`subset(s1, s20)` tests whether the set `s1` is a subset of the set `s2`. +`subset(s1, s2)` tests whether the set `s1` is a subset of the set `s2`. */ let subset: (t, t) => bool @@ -83,19 +83,19 @@ equal elements. */ let eq: (t, t) => bool -let forEachU: (t, (. value) => unit) => unit +let forEachU: (t, value => unit) => unit /** `forEach(s, f)` applies `f` in turn to all elements of `s`. In increasing order */ let forEach: (t, value => unit) => unit -let reduceU: (t, 'a, (. 'a, value) => 'a) => 'a +let reduceU: (t, 'a, ('a, value) => 'a) => 'a /** Iterate in increasing order. */ let reduce: (t, 'a, ('a, value) => 'a) => 'a -let everyU: (t, (. value) => bool) => bool +let everyU: (t, value => bool) => bool /** `every(p, s)` checks if all elements of the set satisfy the predicate `p`. Order @@ -103,7 +103,7 @@ unspecified. */ let every: (t, value => bool) => bool -let someU: (t, (. value) => bool) => bool +let someU: (t, value => bool) => bool /** `some(p, s)` checks if at least one element of the set satisfies the predicate @@ -111,14 +111,14 @@ let someU: (t, (. value) => bool) => bool */ let some: (t, value => bool) => bool -let keepU: (t, (. value) => bool) => t +let keepU: (t, value => bool) => t /** `keep(p, s)` returns the set of all elements in `s` that satisfy predicate `p`. */ let keep: (t, value => bool) => t -let partitionU: (t, (. value) => bool) => (t, t) +let partitionU: (t, value => bool) => (t, t) /** `partition(p, s)` returns a pair of sets `(s1, s2)`, where `s1` is the set of diff --git a/belt/src/belt_SortArray.res b/belt/src/belt_SortArray.res index 462b468..ee4ee55 100644 --- a/belt/src/belt_SortArray.res +++ b/belt/src/belt_SortArray.res @@ -33,7 +33,7 @@ let rec sortedLengthAuxMore = (xs, prec, acc, len, lt) => acc } else { let v = A.getUnsafe(xs, acc) - if lt(. v, prec) { + if lt(v, prec) { sortedLengthAuxMore(xs, v, acc + 1, len, lt) } else { acc @@ -45,7 +45,7 @@ let rec sortedLengthAuxLess = (xs, prec, acc, len, lt) => acc } else { let v = A.getUnsafe(xs, acc) - if lt(. prec, v) { + if lt(prec, v) { sortedLengthAuxLess(xs, v, acc + 1, len, lt) } else { acc @@ -60,9 +60,9 @@ let strictlySortedLengthU = (xs, lt) => { let (x0, x1) = (A.getUnsafe(xs, 0), A.getUnsafe(xs, 1)) /* let c = cmp x0 x1 [@bs] in */ - if lt(. x0, x1) { + if lt(x0, x1) { sortedLengthAuxLess(xs, x1, 2, len, lt) - } else if lt(. x1, x0) { + } else if lt(x1, x0) { -sortedLengthAuxMore(xs, x1, 2, len, lt) } else { 1 @@ -70,13 +70,13 @@ let strictlySortedLengthU = (xs, lt) => { } } -let strictlySortedLength = (xs, lt) => strictlySortedLengthU(xs, (. x, y) => lt(x, y)) +let strictlySortedLength = (xs, lt) => strictlySortedLengthU(xs, (x, y) => lt(x, y)) let rec isSortedAux = (a, i, cmp, last_bound) => /* when `i = len - 1`, it reaches the last element */ if i == last_bound { true - } else if cmp(. A.getUnsafe(a, i), A.getUnsafe(a, i + 1)) <= 0 { + } else if cmp(A.getUnsafe(a, i), A.getUnsafe(a, i + 1)) <= 0 { isSortedAux(a, i + 1, cmp, last_bound) } else { false @@ -91,14 +91,14 @@ let isSortedU = (a, cmp) => { } } -let isSorted = (a, cmp) => isSortedU(a, (. x, y) => cmp(x, y)) +let isSorted = (a, cmp) => isSortedU(a, (x, y) => cmp(x, y)) let cutoff = 5 let merge = (src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) => { let src1r = src1ofs + src1len and src2r = src2ofs + src2len let rec loop = (i1, s1, i2, s2, d) => - if cmp(. s1, s2) <= 0 { + if cmp(s1, s2) <= 0 { A.setUnsafe(dst, d, s1) let i1 = i1 + 1 if i1 < src1r { @@ -123,7 +123,7 @@ let unionU = (src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) = let src1r = src1ofs + src1len let src2r = src2ofs + src2len let rec loop = (i1, s1, i2, s2, d) => { - let c = cmp(. s1, s2) + let c = cmp(s1, s2) if c < 0 { /* `s1` is larger than all elements in `d` */ A.setUnsafe(dst, d, s1) @@ -166,13 +166,13 @@ let unionU = (src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) = } let union = (src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) => - unionU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, (. x, y) => cmp(x, y)) + unionU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, (x, y) => cmp(x, y)) let intersectU = (src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) => { let src1r = src1ofs + src1len let src2r = src2ofs + src2len let rec loop = (i1, s1, i2, s2, d) => { - let c = cmp(. s1, s2) + let c = cmp(s1, s2) if c < 0 { /* A.setUnsafe dst d s1; */ let i1 = i1 + 1 @@ -206,13 +206,13 @@ let intersectU = (src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cm } let intersect = (src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) => - intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, (. x, y) => cmp(x, y)) + intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, (x, y) => cmp(x, y)) let diffU = (src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) => { let src1r = src1ofs + src1len let src2r = src2ofs + src2len let rec loop = (i1, s1, i2, s2, d) => { - let c = cmp(. s1, s2) + let c = cmp(s1, s2) if c < 0 { A.setUnsafe(dst, d, s1) let d = d + 1 @@ -248,14 +248,14 @@ let diffU = (src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) => } let diff = (src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) => - diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, (. x, y) => cmp(x, y)) + diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, (x, y) => cmp(x, y)) /* `<=` alone is not enough for stable sort */ let insertionSort = (src, srcofs, dst, dstofs, len, cmp) => for i in 0 to len - 1 { let e = A.getUnsafe(src, srcofs + i) let j = ref(dstofs + i - 1) - while j.contents >= dstofs && cmp(. A.getUnsafe(dst, j.contents), e) > 0 { + while j.contents >= dstofs && cmp(A.getUnsafe(dst, j.contents), e) > 0 { A.setUnsafe(dst, j.contents + 1, A.getUnsafe(dst, j.contents)) j.contents = j.contents - 1 } @@ -287,7 +287,7 @@ let stableSortInPlaceByU = (a, cmp) => { } } -let stableSortInPlaceBy = (a, cmp) => stableSortInPlaceByU(a, (. x, y) => cmp(x, y)) +let stableSortInPlaceBy = (a, cmp) => stableSortInPlaceByU(a, (x, y) => cmp(x, y)) let stableSortByU = (a, cmp) => { let b = A.copy(a) @@ -295,7 +295,7 @@ let stableSortByU = (a, cmp) => { b } -let stableSortBy = (a, cmp) => stableSortByU(a, (. x, y) => cmp(x, y)) +let stableSortBy = (a, cmp) => stableSortByU(a, (x, y) => cmp(x, y)) /* `binarySearchAux arr lo hi key cmp` range [lo, hi] @@ -304,13 +304,13 @@ let stableSortBy = (a, cmp) => stableSortByU(a, (. x, y) => cmp(x, y)) let rec binarySearchAux = (arr, lo, hi, key, cmp) => { let mid = (lo + hi) / 2 let midVal = A.getUnsafe(arr, mid) - let c = cmp(. key, midVal) + let c = cmp(key, midVal) if c == 0 { mid } else if c < 0 { /* a[lo] =< key < a[mid] <= a[hi] */ if hi == mid { - if cmp(. A.getUnsafe(arr, lo), key) == 0 { + if cmp(A.getUnsafe(arr, lo), key) == 0 { lo } else { -(hi + 1) @@ -320,7 +320,7 @@ let rec binarySearchAux = (arr, lo, hi, key, cmp) => { } } /* a[lo] =< a[mid] < key <= a[hi] */ else if lo == mid { - if cmp(. A.getUnsafe(arr, hi), key) == 0 { + if cmp(A.getUnsafe(arr, hi), key) == 0 { hi } else { -(hi + 1) @@ -336,12 +336,12 @@ let binarySearchByU = (sorted, key, cmp): int => { -1 } else { let lo = A.getUnsafe(sorted, 0) - let c = cmp(. key, lo) + let c = cmp(key, lo) if c < 0 { -1 } else { let hi = A.getUnsafe(sorted, len - 1) - let c2 = cmp(. key, hi) + let c2 = cmp(key, hi) if c2 > 0 { -(len + 1) } else { @@ -351,4 +351,4 @@ let binarySearchByU = (sorted, key, cmp): int => { } } -let binarySearchBy = (sorted, key, cmp) => binarySearchByU(sorted, key, (. x, y) => cmp(x, y)) +let binarySearchBy = (sorted, key, cmp) => binarySearchByU(sorted, key, (x, y) => cmp(x, y)) diff --git a/belt/src/belt_SortArray.resi b/belt/src/belt_SortArray.resi index ced18fc..24d08df 100644 --- a/belt/src/belt_SortArray.resi +++ b/belt/src/belt_SortArray.resi @@ -36,7 +36,7 @@ Specalized when key type is `string`, more efficient than the generic type */ module String = Belt_SortArrayString -let strictlySortedLengthU: (array<'a>, (. 'a, 'a) => bool) => int +let strictlySortedLengthU: (array<'a>, ('a, 'a) => bool) => int /** `strictlySortedLenght(xs, cmp);` return `+n` means increasing order `-n` means negative order @@ -55,16 +55,16 @@ Belt.SortArray.strictlySortedLength([4, 3, 2, 1], (x, y) => x < y) == -4 */ let strictlySortedLength: (array<'a>, ('a, 'a) => bool) => int -let isSortedU: (array<'a>, (. 'a, 'a) => int) => bool +let isSortedU: (array<'a>, ('a, 'a) => int) => bool /** `isSorted(arr, cmp)`: Returns true if array is increasingly sorted (equal is okay) */ let isSorted: (array<'a>, ('a, 'a) => int) => bool -let stableSortInPlaceByU: (array<'a>, (. 'a, 'a) => int) => unit +let stableSortInPlaceByU: (array<'a>, ('a, 'a) => int) => unit let stableSortInPlaceBy: (array<'a>, ('a, 'a) => int) => unit -let stableSortByU: (array<'a>, (. 'a, 'a) => int) => array<'a> +let stableSortByU: (array<'a>, ('a, 'a) => int) => array<'a> /** `stableSortBy(xs, cmp)`: Returns a fresh array Sort `xs` in place using comparator `cmp`, the stable means if the elements are equal, their order will @@ -72,7 +72,7 @@ be preserved */ let stableSortBy: (array<'a>, ('a, 'a) => int) => array<'a> -let binarySearchByU: (array<'a>, 'a, (. 'a, 'a) => int) => int +let binarySearchByU: (array<'a>, 'a, ('a, 'a) => int) => int /** If value is not found and value is less than one or more elements in array, the @@ -95,7 +95,7 @@ lnot(Belt.SortArray.binarySearchBy([1, 3, 5, 7], 4, Pervasives.compare)) == 2 */ let binarySearchBy: (array<'a>, 'a, ('a, 'a) => int) => int -let unionU: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, (. 'a, 'a) => int) => int +let unionU: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, ('a, 'a) => int) => int /** `union src src1ofs src1len src2 src2ofs src2len dst dstofs cmp` assume `src` and `src2` is strictly sorted. for equivalent elements, it is picked from `src` @@ -103,7 +103,7 @@ also assume that `dst` is large enough to store all elements */ let union: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, ('a, 'a) => int) => int -let intersectU: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, (. 'a, 'a) => int) => int +let intersectU: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, ('a, 'a) => int) => int /** `union src src1ofs src1len src2 src2ofs src2len dst dstofs cmp` @@ -111,5 +111,5 @@ let intersectU: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, (. 'a */ let intersect: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, ('a, 'a) => int) => int -let diffU: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, (. 'a, 'a) => int) => int +let diffU: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, ('a, 'a) => int) => int let diff: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, ('a, 'a) => int) => int diff --git a/belt/src/belt_internalAVLset.js b/belt/src/belt_internalAVLset.js index ad986a9..b25c0d9 100644 --- a/belt/src/belt_internalAVLset.js +++ b/belt/src/belt_internalAVLset.js @@ -54,36 +54,13 @@ function bal(l, v, r) { let hl = l !== undefined ? l.h : 0; let hr = r !== undefined ? r.h : 0; if (hl > (hr + 2 | 0)) { - if (l !== undefined) { - let ll = l.l; - let lr = l.r; - if (heightGe(ll, lr)) { - return create(ll, l.v, create(lr, v, r)); - } - if (lr !== undefined) { - return create(create(ll, l.v, lr.l), lr.v, create(lr.r, v, r)); - } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLset.res", - 102, - 18 - ] - } - }); + let ll = l.l; + let lr = l.r; + if (heightGe(ll, lr)) { + return create(ll, l.v, create(lr, v, r)); + } else { + return create(create(ll, l.v, lr.l), lr.v, create(lr.r, v, r)); } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLset.res", - 96, - 14 - ] - } - }); } if (hr <= (hl + 2 | 0)) { return { @@ -95,36 +72,13 @@ function bal(l, v, r) { r: r }; } - if (r !== undefined) { - let rl = r.l; - let rr = r.r; - if (heightGe(rr, rl)) { - return create(create(l, v, rl), r.v, rr); - } - if (rl !== undefined) { - return create(create(l, v, rl.l), rl.v, create(rl.r, r.v, rr)); - } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLset.res", - 115, - 18 - ] - } - }); + let rl = r.l; + let rr = r.r; + if (heightGe(rr, rl)) { + return create(create(l, v, rl), r.v, rr); + } else { + return create(create(l, v, rl.l), rl.v, create(rl.r, r.v, rr)); } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLset.res", - 109, - 14 - ] - } - }); } function min0Aux(_n) { @@ -804,104 +758,56 @@ function getExn(_n, x, cmp) { function rotateWithLeftChild(k2) { let k1 = k2.l; - if (k1 !== undefined) { - k2.l = k1.r; - k1.r = k2; - let n = k2.l; - let hlk2 = n !== undefined ? n.h : 0; - let n$1 = k2.r; - let hrk2 = n$1 !== undefined ? n$1.h : 0; - k2.h = ( - hlk2 > hrk2 ? hlk2 : hrk2 - ) + 1 | 0; - let n$2 = k1.l; - let hlk1 = n$2 !== undefined ? n$2.h : 0; - let hk2 = k2.h; - k1.h = ( - hlk1 > hk2 ? hlk1 : hk2 - ) + 1 | 0; - return k1; - } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLset.res", - 633, - 12 - ] - } - }); + k2.l = k1.r; + k1.r = k2; + let n = k2.l; + let hlk2 = n !== undefined ? n.h : 0; + let n$1 = k2.r; + let hrk2 = n$1 !== undefined ? n$1.h : 0; + k2.h = ( + hlk2 > hrk2 ? hlk2 : hrk2 + ) + 1 | 0; + let n$2 = k1.l; + let hlk1 = n$2 !== undefined ? n$2.h : 0; + let hk2 = k2.h; + k1.h = ( + hlk1 > hk2 ? hlk1 : hk2 + ) + 1 | 0; + return k1; } function rotateWithRightChild(k1) { let k2 = k1.r; - if (k2 !== undefined) { - k1.r = k2.l; - k2.l = k1; - let n = k1.l; - let hlk1 = n !== undefined ? n.h : 0; - let n$1 = k1.r; - let hrk1 = n$1 !== undefined ? n$1.h : 0; - k1.h = ( - hlk1 > hrk1 ? hlk1 : hrk1 - ) + 1 | 0; - let n$2 = k2.r; - let hrk2 = n$2 !== undefined ? n$2.h : 0; - let hk1 = k1.h; - k2.h = ( - hrk2 > hk1 ? hrk2 : hk1 - ) + 1 | 0; - return k2; - } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLset.res", - 646, - 12 - ] - } - }); + k1.r = k2.l; + k2.l = k1; + let n = k1.l; + let hlk1 = n !== undefined ? n.h : 0; + let n$1 = k1.r; + let hrk1 = n$1 !== undefined ? n$1.h : 0; + k1.h = ( + hlk1 > hrk1 ? hlk1 : hrk1 + ) + 1 | 0; + let n$2 = k2.r; + let hrk2 = n$2 !== undefined ? n$2.h : 0; + let hk1 = k1.h; + k2.h = ( + hrk2 > hk1 ? hrk2 : hk1 + ) + 1 | 0; + return k2; } function doubleWithLeftChild(k3) { let k3l = k3.l; - if (k3l !== undefined) { - let v = rotateWithRightChild(k3l); - k3.l = v; - return rotateWithLeftChild(k3); - } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLset.res", - 663, - 12 - ] - } - }); + let v = rotateWithRightChild(k3l); + k3.l = v; + return rotateWithLeftChild(k3); } function doubleWithRightChild(k2) { let k2r = k2.r; - if (k2r !== undefined) { - let v = rotateWithLeftChild(k2r); - k2.r = v; - return rotateWithRightChild(k2); - } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLset.res", - 672, - 12 - ] - } - }); + let v = rotateWithLeftChild(k2r); + k2.r = v; + return rotateWithRightChild(k2); } function heightUpdateMutate(t) { @@ -921,46 +827,22 @@ function balMutate(nt) { let hl = l !== undefined ? l.h : 0; let hr = r !== undefined ? r.h : 0; if (hl > (2 + hr | 0)) { - if (l !== undefined) { - let ll = l.l; - let lr = l.r; - if (heightGe(ll, lr)) { - return heightUpdateMutate(rotateWithLeftChild(nt)); - } else { - return heightUpdateMutate(doubleWithLeftChild(nt)); - } + let ll = l.l; + let lr = l.r; + if (heightGe(ll, lr)) { + return heightUpdateMutate(rotateWithLeftChild(nt)); + } else { + return heightUpdateMutate(doubleWithLeftChild(nt)); } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLset.res", - 690, - 14 - ] - } - }); } if (hr > (2 + hl | 0)) { - if (r !== undefined) { - let rl = r.l; - let rr = r.r; - if (heightGe(rr, rl)) { - return heightUpdateMutate(rotateWithRightChild(nt)); - } else { - return heightUpdateMutate(doubleWithRightChild(nt)); - } + let rl = r.l; + let rr = r.r; + if (heightGe(rr, rl)) { + return heightUpdateMutate(rotateWithRightChild(nt)); + } else { + return heightUpdateMutate(doubleWithRightChild(nt)); } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLset.res", - 700, - 14 - ] - } - }); } nt.h = ( hl > hr ? hl : hr diff --git a/belt/src/belt_internalAVLset.res b/belt/src/belt_internalAVLset.res index 1fedc4f..c48fc98 100644 --- a/belt/src/belt_internalAVLset.res +++ b/belt/src/belt_internalAVLset.res @@ -21,7 +21,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -@@bs.config({flags: ["-bs-noassertfalse"]}) +@@config({flags: ["-bs-noassertfalse"]}) type rec node<'value> = { @as("v") mutable value: 'value, @as("h") mutable height: int, @@ -185,35 +185,35 @@ let rec forEachU = (n, f) => | None => () | Some(n) => forEachU(n.left, f) - f(. n.value) + f(n.value) forEachU(n.right, f) } -let forEach = (n, f) => forEachU(n, (. a) => f(a)) +let forEach = (n, f) => forEachU(n, a => f(a)) let rec reduceU = (s, accu, f) => switch s { | None => accu - | Some(n) => reduceU(n.right, f(. reduceU(n.left, accu, f), n.value), f) + | Some(n) => reduceU(n.right, f(reduceU(n.left, accu, f), n.value), f) } -let reduce = (s, accu, f) => reduceU(s, accu, (. a, b) => f(a, b)) +let reduce = (s, accu, f) => reduceU(s, accu, (a, b) => f(a, b)) let rec everyU = (n, p) => switch n { | None => true - | Some(n) => p(. n.value) && (n.left->everyU(p) && n.right->everyU(p)) + | Some(n) => p(n.value) && (n.left->everyU(p) && n.right->everyU(p)) } -let every = (n, p) => everyU(n, (. a) => p(a)) +let every = (n, p) => everyU(n, a => p(a)) let rec someU = (n, p) => switch n { | None => false - | Some(n) => p(. n.value) || (someU(n.left, p) || someU(n.right, p)) + | Some(n) => p(n.value) || (someU(n.left, p) || someU(n.right, p)) } -let some = (n, p) => someU(n, (. a) => p(a)) +let some = (n, p) => someU(n, a => p(a)) /* `addMinElement v n` and `addMaxElement v n` assume that the added v is *strictly* smaller (or bigger) than all the present elements in the tree. @@ -272,7 +272,7 @@ let rec partitionSharedU = (n, p) => | Some(n) => let value = n.value let (lt, lf) = partitionSharedU(n.left, p) - let pv = p(. value) + let pv = p(value) let (rt, rf) = partitionSharedU(n.right, p) if pv { (joinShared(lt, value, rt), concatShared(lf, rf)) @@ -281,7 +281,7 @@ let rec partitionSharedU = (n, p) => } } -let partitionShared = (n, p) => partitionSharedU(n, (. a) => p(a)) +let partitionShared = (n, p) => partitionSharedU(n, a => p(a)) let rec lengthNode = n => { let {left: l, right: r} = n @@ -343,7 +343,7 @@ let rec fillArrayWithPartition = (n, cursor, arr, p) => { | None => () | Some(l) => fillArrayWithPartition(l, cursor, arr, p) } - if p(. v) { + if p(v) { let c = cursor.forward A.setUnsafe(arr, c, v) cursor.forward = c + 1 @@ -364,7 +364,7 @@ let rec fillArrayWithFilter = (n, i, arr, p) => { | None => i | Some(l) => fillArrayWithFilter(l, i, arr, p) } - let rnext = if p(. v) { + let rnext = if p(v) { A.setUnsafe(arr, next, v) next + 1 } else { @@ -454,7 +454,7 @@ let rec keepSharedU = (n, p) => | Some(n) => let {left: l, value: v, right: r} = n let newL = keepSharedU(l, p) - let pv = p(. v) + let pv = p(v) let newR = keepSharedU(r, p) if pv { if l === newL && r === newR { @@ -467,7 +467,7 @@ let rec keepSharedU = (n, p) => } } -let keepShared = (n, p) => keepSharedU(n, (. a) => p(a)) +let keepShared = (n, p) => keepSharedU(n, a => p(a)) /* ATT: functional methods in general can be shared with imperative methods, however, it does not apply when functional methods makes use of referential equality @@ -483,7 +483,7 @@ let keepCopyU = (n, p): t<_> => fromSortedArrayAux(v, 0, last) } -let keepCopy = (n, p) => keepCopyU(n, (. x) => p(x)) +let keepCopy = (n, p) => keepCopyU(n, x => p(x)) let partitionCopyU = (n, p) => switch n { @@ -498,14 +498,14 @@ let partitionCopyU = (n, p) => (fromSortedArrayAux(v, 0, forwardLen), fromSortedArrayRevAux(v, backward, size - forwardLen)) } -let partitionCopy = (n, p) => partitionCopyU(n, (. a) => p(a)) +let partitionCopy = (n, p) => partitionCopyU(n, a => p(a)) let rec has = (t: t<_>, x, ~cmp) => switch t { | None => false | Some(n) => let v = n.value - let c = Belt_Id.getCmpInternal(cmp)(. x, v) + let c = Belt_Id.getCmpInternal(cmp)(x, v) c == 0 || has( ~cmp, @@ -521,7 +521,7 @@ let rec has = (t: t<_>, x, ~cmp) => let rec compareAux = (e1, e2, ~cmp) => switch (e1, e2) { | (list{h1, ...t1}, list{h2, ...t2}) => - let c = Belt_Id.getCmpInternal(cmp)(. h1.value, h2.value) + let c = Belt_Id.getCmpInternal(cmp)(h1.value, h2.value) if c == 0 { compareAux(~cmp, h1.right->stackAllLeft(t1), h2.right->stackAllLeft(t2)) } else { @@ -550,7 +550,7 @@ let rec subset = (s1: t<_>, s2: t<_>, ~cmp) => | (Some(t1), Some(t2)) => let {left: l1, value: v1, right: r1} = t1 let {left: l2, value: v2, right: r2} = t2 - let c = Belt_Id.getCmpInternal(cmp)(. v1, v2) + let c = Belt_Id.getCmpInternal(cmp)(v1, v2) if c == 0 { subset(~cmp, l1, l2) && subset(~cmp, r1, r2) } else if c < 0 { @@ -565,7 +565,7 @@ let rec get = (n: t<_>, x, ~cmp) => | None => None | Some(t) /* Node(l, v, r, _) */ => let v = t.value - let c = Belt_Id.getCmpInternal(cmp)(. x, v) + let c = Belt_Id.getCmpInternal(cmp)(x, v) if c == 0 { Some(v) } else { @@ -586,7 +586,7 @@ let rec getUndefined = (n: t<_>, x, ~cmp) => | None => Js.Undefined.empty | Some(t) /* Node(l, v, r, _) */ => let v = t.value - let c = Belt_Id.getCmpInternal(cmp)(. x, v) + let c = Belt_Id.getCmpInternal(cmp)(x, v) if c == 0 { Js.Undefined.return(v) } else { @@ -607,7 +607,7 @@ let rec getExn = (n: t<_>, x, ~cmp) => | None => raise(Not_found) | Some(t) /* Node(l, v, r, _) */ => let v = t.value - let c = Belt_Id.getCmpInternal(cmp)(. x, v) + let c = Belt_Id.getCmpInternal(cmp)(x, v) if c == 0 { v } else { @@ -716,7 +716,7 @@ let rec addMutate = (~cmp, t: t<_>, x) => | None => singleton(x) | Some(nt) => let k = nt.value - let c = Belt_Id.getCmpInternal(cmp)(. x, k) + let c = Belt_Id.getCmpInternal(cmp)(x, k) if c == 0 { t } else { @@ -736,7 +736,7 @@ let fromArray = (xs: array<_>, ~cmp) => { if len == 0 { None } else { - let next = ref(S.strictlySortedLengthU(xs, (. x, y) => Belt_Id.getCmpInternal(cmp)(. x, y) < 0)) + let next = ref(S.strictlySortedLengthU(xs, (x, y) => Belt_Id.getCmpInternal(cmp)(x, y) < 0)) let result = ref( if next.contents >= 0 { fromSortedArrayAux(xs, 0, next.contents) diff --git a/belt/src/belt_internalAVLset.resi b/belt/src/belt_internalAVLset.resi index 0f7ccf5..5068724 100644 --- a/belt/src/belt_internalAVLset.resi +++ b/belt/src/belt_internalAVLset.resi @@ -55,31 +55,31 @@ let isEmpty: t<'a> => bool let stackAllLeft: (t<'a>, list>) => list> -let forEachU: (t<'a>, (. 'a) => unit) => unit +let forEachU: (t<'a>, 'a => unit) => unit let forEach: (t<'a>, 'a => unit) => unit -let reduceU: (t<'a>, 'b, (. 'b, 'a) => 'b) => 'b +let reduceU: (t<'a>, 'b, ('b, 'a) => 'b) => 'b let reduce: (t<'a>, 'b, ('b, 'a) => 'b) => 'b -let everyU: (t<'a>, (. 'a) => bool) => bool +let everyU: (t<'a>, 'a => bool) => bool let every: (t<'a>, 'a => bool) => bool -let someU: (t<'a>, (. 'a) => bool) => bool +let someU: (t<'a>, 'a => bool) => bool let some: (t<'a>, 'a => bool) => bool let joinShared: (t<'a>, 'a, t<'a>) => t<'a> let concatShared: (t<'a>, t<'a>) => t<'a> -let keepSharedU: (t<'a>, (. 'a) => bool) => t<'a> +let keepSharedU: (t<'a>, 'a => bool) => t<'a> let keepShared: (t<'a>, 'a => bool) => t<'a> -let keepCopyU: (t<'a>, (. 'a) => bool) => t<'a> +let keepCopyU: (t<'a>, 'a => bool) => t<'a> let keepCopy: (t<'a>, 'a => bool) => t<'a> -let partitionSharedU: (t<'a>, (. 'a) => bool) => (t<'a>, t<'a>) +let partitionSharedU: (t<'a>, 'a => bool) => (t<'a>, t<'a>) let partitionShared: (t<'a>, 'a => bool) => (t<'a>, t<'a>) -let partitionCopyU: (t<'a>, (. 'a) => bool) => (t<'a>, t<'a>) +let partitionCopyU: (t<'a>, 'a => bool) => (t<'a>, t<'a>) let partitionCopy: (t<'a>, 'a => bool) => (t<'a>, t<'a>) let lengthNode: node<'a> => int diff --git a/belt/src/belt_internalAVLtree.js b/belt/src/belt_internalAVLtree.js index 8db4bbc..f97e3b4 100644 --- a/belt/src/belt_internalAVLtree.js +++ b/belt/src/belt_internalAVLtree.js @@ -77,36 +77,13 @@ function bal(l, x, d, r) { let hl = l !== undefined ? l.h : 0; let hr = r !== undefined ? r.h : 0; if (hl > (hr + 2 | 0)) { - if (l !== undefined) { - let ll = l.l; - let lr = l.r; - if (treeHeight(ll) >= treeHeight(lr)) { - return create(ll, l.k, l.v, create(lr, x, d, r)); - } - if (lr !== undefined) { - return create(create(ll, l.k, l.v, lr.l), lr.k, lr.v, create(lr.r, x, d, r)); - } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLtree.res", - 97, - 18 - ] - } - }); + let ll = l.l; + let lr = l.r; + if (treeHeight(ll) >= treeHeight(lr)) { + return create(ll, l.k, l.v, create(lr, x, d, r)); + } else { + return create(create(ll, l.k, l.v, lr.l), lr.k, lr.v, create(lr.r, x, d, r)); } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLtree.res", - 91, - 14 - ] - } - }); } if (hr <= (hl + 2 | 0)) { return { @@ -117,36 +94,13 @@ function bal(l, x, d, r) { r: r }; } - if (r !== undefined) { - let rl = r.l; - let rr = r.r; - if (treeHeight(rr) >= treeHeight(rl)) { - return create(create(l, x, d, rl), r.k, r.v, rr); - } - if (rl !== undefined) { - return create(create(l, x, d, rl.l), rl.k, rl.v, create(rl.r, r.k, r.v, rr)); - } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLtree.res", - 111, - 18 - ] - } - }); + let rl = r.l; + let rr = r.r; + if (treeHeight(rr) >= treeHeight(rl)) { + return create(create(l, x, d, rl), r.k, r.v, rr); + } else { + return create(create(l, x, d, rl.l), rl.k, rl.v, create(rl.r, r.k, r.v, rr)); } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLtree.res", - 105, - 14 - ] - } - }); } function minKey0Aux(_n) { @@ -1009,102 +963,48 @@ function has(_n, x, cmp) { function rotateWithLeftChild(k2) { let k1 = k2.l; - if (k1 !== undefined) { - k2.l = k1.r; - k1.r = k2; - let hlk2 = treeHeight(k2.l); - let hrk2 = treeHeight(k2.r); - k2.h = ( - hlk2 > hrk2 ? hlk2 : hrk2 - ) + 1 | 0; - let hlk1 = treeHeight(k1.l); - let hk2 = k2.h; - k1.h = ( - hlk1 > hk2 ? hlk1 : hk2 - ) + 1 | 0; - return k1; - } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLtree.res", - 804, - 12 - ] - } - }); + k2.l = k1.r; + k1.r = k2; + let hlk2 = treeHeight(k2.l); + let hrk2 = treeHeight(k2.r); + k2.h = ( + hlk2 > hrk2 ? hlk2 : hrk2 + ) + 1 | 0; + let hlk1 = treeHeight(k1.l); + let hk2 = k2.h; + k1.h = ( + hlk1 > hk2 ? hlk1 : hk2 + ) + 1 | 0; + return k1; } function rotateWithRightChild(k1) { let k2 = k1.r; - if (k2 !== undefined) { - k1.r = k2.l; - k2.l = k1; - let hlk1 = treeHeight(k1.l); - let hrk1 = treeHeight(k1.r); - k1.h = ( - hlk1 > hrk1 ? hlk1 : hrk1 - ) + 1 | 0; - let hrk2 = treeHeight(k2.r); - let hk1 = k1.h; - k2.h = ( - hrk2 > hk1 ? hrk2 : hk1 - ) + 1 | 0; - return k2; - } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLtree.res", - 817, - 12 - ] - } - }); + k1.r = k2.l; + k2.l = k1; + let hlk1 = treeHeight(k1.l); + let hrk1 = treeHeight(k1.r); + k1.h = ( + hlk1 > hrk1 ? hlk1 : hrk1 + ) + 1 | 0; + let hrk2 = treeHeight(k2.r); + let hk1 = k1.h; + k2.h = ( + hrk2 > hk1 ? hrk2 : hk1 + ) + 1 | 0; + return k2; } function doubleWithLeftChild(k3) { let x = k3.l; - let k3l; - if (x !== undefined) { - k3l = x; - } else { - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLtree.res", - 833, - 12 - ] - } - }); - } - let v = rotateWithRightChild(k3l); + let v = rotateWithRightChild(x); k3.l = v; return rotateWithLeftChild(k3); } function doubleWithRightChild(k2) { let x = k2.r; - let k2r; - if (x !== undefined) { - k2r = x; - } else { - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLtree.res", - 843, - 12 - ] - } - }); - } - let v = rotateWithLeftChild(k2r); + let v = rotateWithLeftChild(x); k2.r = v; return rotateWithRightChild(k2); } @@ -1124,46 +1024,22 @@ function balMutate(nt) { let hl = treeHeight(l); let hr = treeHeight(r); if (hl > (2 + hr | 0)) { - if (l !== undefined) { - let ll = l.l; - let lr = l.r; - if (heightGe(ll, lr)) { - return heightUpdateMutate(rotateWithLeftChild(nt)); - } else { - return heightUpdateMutate(doubleWithLeftChild(nt)); - } + let ll = l.l; + let lr = l.r; + if (heightGe(ll, lr)) { + return heightUpdateMutate(rotateWithLeftChild(nt)); + } else { + return heightUpdateMutate(doubleWithLeftChild(nt)); } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLtree.res", - 862, - 14 - ] - } - }); } if (hr > (2 + hl | 0)) { - if (r !== undefined) { - let rl = r.l; - let rr = r.r; - if (heightGe(rr, rl)) { - return heightUpdateMutate(rotateWithRightChild(nt)); - } else { - return heightUpdateMutate(doubleWithRightChild(nt)); - } + let rl = r.l; + let rr = r.r; + if (heightGe(rr, rl)) { + return heightUpdateMutate(rotateWithRightChild(nt)); + } else { + return heightUpdateMutate(doubleWithRightChild(nt)); } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLtree.res", - 872, - 14 - ] - } - }); } nt.h = ( hl > hr ? hl : hr diff --git a/belt/src/belt_internalAVLtree.res b/belt/src/belt_internalAVLtree.res index ff557ba..0a70808 100644 --- a/belt/src/belt_internalAVLtree.res +++ b/belt/src/belt_internalAVLtree.res @@ -13,7 +13,7 @@ /* Almost rewritten by authors of ReScript */ -@@bs.config({flags: ["-bs-noassertfalse"]}) +@@config({flags: ["-bs-noassertfalse"]}) type rec node<'k, 'v> = { @as("k") mutable key: 'k, @as("v") mutable value: 'v, @@ -232,7 +232,7 @@ let rec findFirstByU = (n, p) => left } else { let {key: v, value: d} = n - let pvd = p(. v, d) + let pvd = p(v, d) if pvd { Some(v, d) } else { @@ -246,30 +246,30 @@ let rec findFirstByU = (n, p) => } } -let findFirstBy = (n, p) => findFirstByU(n, (. a, b) => p(a, b)) +let findFirstBy = (n, p) => findFirstByU(n, (a, b) => p(a, b)) let rec forEachU = (n, f) => switch n { | None => () | Some(n) => forEachU(n.left, f) - f(. n.key, n.value) + f(n.key, n.value) forEachU(n.right, f) } -let forEach = (n, f) => forEachU(n, (. a, b) => f(a, b)) +let forEach = (n, f) => forEachU(n, (a, b) => f(a, b)) let rec mapU = (n, f) => switch n { | None => None | Some(n) => let newLeft = mapU(n.left, f) - let newD = f(. n.value) + let newD = f(n.value) let newRight = mapU(n.right, f) Some({left: newLeft, key: n.key, value: newD, right: newRight, height: n.height}) } -let map = (n, f) => mapU(n, (. a) => f(a)) +let map = (n, f) => mapU(n, a => f(a)) let rec mapWithKeyU = (n, f) => switch n { @@ -277,36 +277,36 @@ let rec mapWithKeyU = (n, f) => | Some(n) => let key = n.key let newLeft = mapWithKeyU(n.left, f) - let newD = f(. key, n.value) + let newD = f(key, n.value) let newRight = mapWithKeyU(n.right, f) Some({left: newLeft, key, value: newD, right: newRight, height: n.height}) } -let mapWithKey = (n, f) => mapWithKeyU(n, (. a, b) => f(a, b)) +let mapWithKey = (n, f) => mapWithKeyU(n, (a, b) => f(a, b)) let rec reduceU = (m, accu, f) => switch m { | None => accu | Some(n) => let {left: l, key: v, value: d, right: r} = n - reduceU(r, f(. reduceU(l, accu, f), v, d), f) + reduceU(r, f(reduceU(l, accu, f), v, d), f) } -let reduce = (m, accu, f) => reduceU(m, accu, (. a, b, c) => f(a, b, c)) +let reduce = (m, accu, f) => reduceU(m, accu, (a, b, c) => f(a, b, c)) let rec everyU = (n, p) => switch n { | None => true - | Some(n) => p(. n.key, n.value) && (everyU(n.left, p) && everyU(n.right, p)) + | Some(n) => p(n.key, n.value) && (everyU(n.left, p) && everyU(n.right, p)) } -let every = (n, p) => everyU(n, (. a, b) => p(a, b)) +let every = (n, p) => everyU(n, (a, b) => p(a, b)) let rec someU = (n, p) => switch n { | None => false - | Some(n) => p(. n.key, n.value) || (someU(n.left, p) || someU(n.right, p)) + | Some(n) => p(n.key, n.value) || (someU(n.left, p) || someU(n.right, p)) } -let some = (n, p) => someU(n, (. a, b) => p(a, b)) +let some = (n, p) => someU(n, (a, b) => p(a, b)) /* Beware: those two functions assume that the added k is *strictly* smaller (or bigger) than all the present keys in the tree; it does not test for equality with the current min (or max) key. @@ -373,7 +373,7 @@ let rec keepSharedU = (n, p) => /* call `p` in the expected left-to-right order */ let {key: v, value: d} = n let newLeft = keepSharedU(n.left, p) - let pvd = p(. v, d) + let pvd = p(v, d) let newRight = keepSharedU(n.right, p) if pvd { join(newLeft, v, d, newRight) @@ -382,7 +382,7 @@ let rec keepSharedU = (n, p) => } } -let keepShared = (n, p) => keepSharedU(n, (. a, b) => p(a, b)) +let keepShared = (n, p) => keepSharedU(n, (a, b) => p(a, b)) let rec keepMapU = (n, p) => switch n { @@ -391,7 +391,7 @@ let rec keepMapU = (n, p) => /* call `p` in the expected left-to-right order */ let {key: v, value: d} = n let newLeft = keepMapU(n.left, p) - let pvd = p(. v, d) + let pvd = p(v, d) let newRight = keepMapU(n.right, p) switch pvd { | None => concat(newLeft, newRight) @@ -399,7 +399,7 @@ let rec keepMapU = (n, p) => } } -let keepMap = (n, p) => keepMapU(n, (. a, b) => p(a, b)) +let keepMap = (n, p) => keepMapU(n, (a, b) => p(a, b)) let rec partitionSharedU = (n, p) => switch n { @@ -408,7 +408,7 @@ let rec partitionSharedU = (n, p) => let {key, value} = n /* call `p` in the expected left-to-right order */ let (lt, lf) = partitionSharedU(n.left, p) - let pvd = p(. key, value) + let pvd = p(key, value) let (rt, rf) = partitionSharedU(n.right, p) if pvd { (join(lt, key, value, rt), concat(lf, rf)) @@ -417,7 +417,7 @@ let rec partitionSharedU = (n, p) => } } -let partitionShared = (n, p) => partitionSharedU(n, (. a, b) => p(a, b)) +let partitionShared = (n, p) => partitionSharedU(n, (a, b) => p(a, b)) let rec lengthNode = n => { let {left: l, right: r} = n @@ -642,9 +642,9 @@ let fromSortedArrayUnsafe = arr => fromSortedArrayAux(arr, 0, A.length(arr)) let rec compareAux = (e1, e2, ~kcmp, ~vcmp) => switch (e1, e2) { | (list{h1, ...t1}, list{h2, ...t2}) => - let c = Belt_Id.getCmpInternal(kcmp)(. h1.key, h2.key) + let c = Belt_Id.getCmpInternal(kcmp)(h1.key, h2.key) if c == 0 { - let cx = vcmp(. h1.value, h2.value) + let cx = vcmp(h1.value, h2.value) if cx == 0 { compareAux(~kcmp, ~vcmp, stackAllLeft(h1.right, t1), stackAllLeft(h2.right, t2)) } else { @@ -659,7 +659,7 @@ let rec compareAux = (e1, e2, ~kcmp, ~vcmp) => let rec eqAux = (e1, e2, ~kcmp, ~veq) => switch (e1, e2) { | (list{h1, ...t1}, list{h2, ...t2}) => - if Belt_Id.getCmpInternal(kcmp)(. h1.key, h2.key) == 0 && veq(. h1.value, h2.value) { + if Belt_Id.getCmpInternal(kcmp)(h1.key, h2.key) == 0 && veq(h1.value, h2.value) { eqAux(~kcmp, ~veq, stackAllLeft(h1.right, t1), stackAllLeft(h2.right, t2)) } else { false @@ -678,7 +678,7 @@ let cmpU = (s1, s2, ~kcmp, ~vcmp) => { } } -let cmp = (s1, s2, ~kcmp, ~vcmp) => cmpU(s1, s2, ~kcmp, ~vcmp=(. a, b) => vcmp(a, b)) +let cmp = (s1, s2, ~kcmp, ~vcmp) => cmpU(s1, s2, ~kcmp, ~vcmp=(a, b) => vcmp(a, b)) let eqU = (s1, s2, ~kcmp, ~veq) => { let (len1, len2) = (size(s1), size(s2)) @@ -689,14 +689,14 @@ let eqU = (s1, s2, ~kcmp, ~veq) => { } } -let eq = (s1, s2, ~kcmp, ~veq) => eqU(s1, s2, ~kcmp, ~veq=(. a, b) => veq(a, b)) +let eq = (s1, s2, ~kcmp, ~veq) => eqU(s1, s2, ~kcmp, ~veq=(a, b) => veq(a, b)) let rec get = (n, x, ~cmp) => switch n { | None => None | Some(n) /* Node(l, v, d, r, _) */ => let v = n.key - let c = Belt_Id.getCmpInternal(cmp)(. x, v) + let c = Belt_Id.getCmpInternal(cmp)(x, v) if c == 0 { Some(n.value) } else { @@ -717,7 +717,7 @@ let rec getUndefined = (n, x, ~cmp) => | None => Js.undefined | Some(n) => let v = n.key - let c = Belt_Id.getCmpInternal(cmp)(. x, v) + let c = Belt_Id.getCmpInternal(cmp)(x, v) if c == 0 { Js.Undefined.return(n.value) } else { @@ -738,7 +738,7 @@ let rec getExn = (n, x, ~cmp) => | None => raise(Not_found) | Some(n) /* Node(l, v, d, r, _) */ => let v = n.key - let c = Belt_Id.getCmpInternal(cmp)(. x, v) + let c = Belt_Id.getCmpInternal(cmp)(x, v) if c == 0 { n.value } else { @@ -759,7 +759,7 @@ let rec getWithDefault = (n, x, def, ~cmp) => | None => def | Some(n) /* Node(l, v, d, r, _) */ => let v = n.key - let c = Belt_Id.getCmpInternal(cmp)(. x, v) + let c = Belt_Id.getCmpInternal(cmp)(x, v) if c == 0 { n.value } else { @@ -781,7 +781,7 @@ let rec has = (n, x, ~cmp) => | None => false | Some(n) /* Node(l, v, d, r, _) */ => let v = n.key - let c = Belt_Id.getCmpInternal(cmp)(. x, v) + let c = Belt_Id.getCmpInternal(cmp)(x, v) c == 0 || has( ~cmp, @@ -888,7 +888,7 @@ let rec updateMutate = (t: t<_>, x, data, ~cmp) => | None => singleton(x, data) | Some(nt) => let k = nt.key - let c = Belt_Id.getCmpInternal(cmp)(. x, k) + let c = Belt_Id.getCmpInternal(cmp)(x, k) if c == 0 { nt.value = data Some(nt) @@ -910,9 +910,7 @@ let fromArray = (xs: array<_>, ~cmp) => { None } else { let next = ref( - S.strictlySortedLengthU(xs, (. (x0, _), (y0, _)) => - Belt_Id.getCmpInternal(cmp)(. x0, y0) < 0 - ), + S.strictlySortedLengthU(xs, ((x0, _), (y0, _)) => Belt_Id.getCmpInternal(cmp)(x0, y0) < 0), ) let result = ref( diff --git a/belt/src/belt_internalAVLtree.resi b/belt/src/belt_internalAVLtree.resi index a1b58f3..9b55a0f 100644 --- a/belt/src/belt_internalAVLtree.resi +++ b/belt/src/belt_internalAVLtree.resi @@ -60,25 +60,25 @@ let isEmpty: t<_> => bool let stackAllLeft: (t<'a, 'b>, list>) => list> -let findFirstByU: (t<'a, 'b>, (. 'a, 'b) => bool) => option<('a, 'b)> +let findFirstByU: (t<'a, 'b>, ('a, 'b) => bool) => option<('a, 'b)> let findFirstBy: (t<'a, 'b>, ('a, 'b) => bool) => option<('a, 'b)> -let forEachU: (t<'a, 'b>, (. 'a, 'b) => unit) => unit +let forEachU: (t<'a, 'b>, ('a, 'b) => unit) => unit let forEach: (t<'a, 'b>, ('a, 'b) => unit) => unit -let mapU: (t<'c, 'a>, (. 'a) => 'b) => t<'c, 'b> +let mapU: (t<'c, 'a>, 'a => 'b) => t<'c, 'b> let map: (t<'c, 'a>, 'a => 'b) => t<'c, 'b> -let mapWithKeyU: (t<'a, 'b>, (. 'a, 'b) => 'c) => t<'a, 'c> +let mapWithKeyU: (t<'a, 'b>, ('a, 'b) => 'c) => t<'a, 'c> let mapWithKey: (t<'a, 'b>, ('a, 'b) => 'c) => t<'a, 'c> -let reduceU: (t<'a, 'b>, 'c, (. 'c, 'a, 'b) => 'c) => 'c +let reduceU: (t<'a, 'b>, 'c, ('c, 'a, 'b) => 'c) => 'c let reduce: (t<'a, 'b>, 'c, ('c, 'a, 'b) => 'c) => 'c -let everyU: (t<'a, 'b>, (. 'a, 'b) => bool) => bool +let everyU: (t<'a, 'b>, ('a, 'b) => bool) => bool let every: (t<'a, 'b>, ('a, 'b) => bool) => bool -let someU: (t<'a, 'b>, (. 'a, 'b) => bool) => bool +let someU: (t<'a, 'b>, ('a, 'b) => bool) => bool let some: (t<'a, 'b>, ('a, 'b) => bool) => bool let join: (t<'a, 'b>, 'a, 'b, t<'a, 'b>) => t<'a, 'b> @@ -87,14 +87,14 @@ let concat: (t<'a, 'b>, t<'a, 'b>) => t<'a, 'b> let concatOrJoin: (t<'a, 'b>, 'a, option<'b>, t<'a, 'b>) => t<'a, 'b> -let keepSharedU: (t<'a, 'b>, (. 'a, 'b) => bool) => t<'a, 'b> +let keepSharedU: (t<'a, 'b>, ('a, 'b) => bool) => t<'a, 'b> let keepShared: (t<'a, 'b>, ('a, 'b) => bool) => t<'a, 'b> -let keepMapU: (t<'a, 'b>, (. 'a, 'b) => option<'c>) => t<'a, 'c> +let keepMapU: (t<'a, 'b>, ('a, 'b) => option<'c>) => t<'a, 'c> let keepMap: (t<'a, 'b>, ('a, 'b) => option<'c>) => t<'a, 'c> /* seems no sharing, could be shared with mutation */ -let partitionSharedU: (t<'a, 'b>, (. 'a, 'b) => bool) => (t<'a, 'b>, t<'a, 'b>) +let partitionSharedU: (t<'a, 'b>, ('a, 'b) => bool) => (t<'a, 'b>, t<'a, 'b>) let partitionShared: (t<'a, 'b>, ('a, 'b) => bool) => (t<'a, 'b>, t<'a, 'b>) let lengthNode: node<'a, 'b> => int @@ -115,10 +115,10 @@ let fromSortedArrayAux: (array<('a, 'b)>, int, int) => t<'a, 'b> let fromSortedArrayRevAux: (array<('a, 'b)>, int, int) => t<'a, 'b> let fromSortedArrayUnsafe: array<('a, 'b)> => t<'a, 'b> -let cmpU: (t<'a, 'b>, t<'a, 'c>, ~kcmp: cmp<'a, _>, ~vcmp: (. 'b, 'c) => int) => int +let cmpU: (t<'a, 'b>, t<'a, 'c>, ~kcmp: cmp<'a, _>, ~vcmp: ('b, 'c) => int) => int let cmp: (t<'a, 'b>, t<'a, 'c>, ~kcmp: cmp<'a, _>, ~vcmp: ('b, 'c) => int) => int -let eqU: (t<'a, 'b>, t<'a, 'c>, ~kcmp: cmp<'a, _>, ~veq: (. 'b, 'c) => bool) => bool +let eqU: (t<'a, 'b>, t<'a, 'c>, ~kcmp: cmp<'a, _>, ~veq: ('b, 'c) => bool) => bool let eq: (t<'a, 'b>, t<'a, 'c>, ~kcmp: cmp<'a, _>, ~veq: ('b, 'c) => bool) => bool let get: (t<'a, 'b>, 'a, ~cmp: cmp<'a, _>) => option<'b> diff --git a/belt/src/belt_internalBuckets.res b/belt/src/belt_internalBuckets.res index d9eeb7e..c70b6e5 100644 --- a/belt/src/belt_internalBuckets.res +++ b/belt/src/belt_internalBuckets.res @@ -80,7 +80,7 @@ let rec do_bucket_iter = (~f, buckets) => switch C.toOpt(buckets) { | None => () | Some(cell) => - f(. cell.key, cell.value)->ignore + f(cell.key, cell.value)->ignore do_bucket_iter(~f, cell.next) } @@ -91,12 +91,12 @@ let forEachU = (h, f) => { } } -let forEach = (h, f) => forEachU(h, (. a, b) => f(a, b)) +let forEach = (h, f) => forEachU(h, (a, b) => f(a, b)) let rec do_bucket_fold = (~f, b, accu) => switch C.toOpt(b) { | None => accu - | Some(cell) => do_bucket_fold(~f, cell.next, f(. accu, cell.key, cell.value)) + | Some(cell) => do_bucket_fold(~f, cell.next, f(accu, cell.key, cell.value)) } let reduceU = (h, init, f) => { @@ -108,18 +108,18 @@ let reduceU = (h, init, f) => { accu.contents } -let reduce = (h, init, f) => reduceU(h, init, (. a, b, c) => f(a, b, c)) +let reduce = (h, init, f) => reduceU(h, init, (a, b, c) => f(a, b, c)) let getMaxBucketLength = h => - A.reduceU(h.C.buckets, 0, (. m, b) => { + A.reduceU(h.C.buckets, 0, (m, b) => { let len = bucketLength(0, b) Pervasives.max(m, len) }) let getBucketHistogram = h => { let mbl = getMaxBucketLength(h) - let histo = A.makeByU(mbl + 1, (. _) => 0) - A.forEachU(h.C.buckets, (. b) => { + let histo = A.makeByU(mbl + 1, _ => 0) + A.forEachU(h.C.buckets, b => { let l = bucketLength(0, b) A.setUnsafe(histo, l, A.getUnsafe(histo, l) + 1) }) @@ -138,7 +138,7 @@ let logStats = h => { /** iterate the Buckets, in place remove the elements */ let rec filterMapInplaceBucket = (f, h, i, prec, cell) => { let n = cell.next - switch f(. cell.key, cell.value) { + switch f(cell.key, cell.value) { | None => h.C.size = h.C.size - 1 /* delete */ switch C.toOpt(n) { @@ -175,7 +175,7 @@ let keepMapInPlaceU = (h, f) => { } } -let keepMapInPlace = (h, f) => keepMapInPlaceU(h, (. a, b) => f(a, b)) +let keepMapInPlace = (h, f) => keepMapInPlaceU(h, (a, b) => f(a, b)) let rec fillArray = (i, arr, cell) => { A.setUnsafe(arr, i, (cell.key, cell.value)) @@ -199,7 +199,7 @@ let rec fillArray = (i, arr, cell) => { arr */ let rec fillArrayMap = (i, arr, cell, f) => { - A.setUnsafe(arr, i, f(. cell)) + A.setUnsafe(arr, i, f(cell)) switch C.toOpt(cell.next) { | None => i + 1 | Some(v) => fillArrayMap(i + 1, arr, v, f) @@ -220,6 +220,6 @@ let linear = (h, f) => { arr } -let keysToArray = h => linear(h, (. x) => x.key) -let valuesToArray = h => linear(h, (. x) => x.value) -let toArray = h => linear(h, (. x) => (x.key, x.value)) +let keysToArray = h => linear(h, x => x.key) +let valuesToArray = h => linear(h, x => x.value) +let toArray = h => linear(h, x => (x.key, x.value)) diff --git a/belt/src/belt_internalBuckets.resi b/belt/src/belt_internalBuckets.resi index 149309b..3190490 100644 --- a/belt/src/belt_internalBuckets.resi +++ b/belt/src/belt_internalBuckets.resi @@ -33,15 +33,15 @@ and t<'hash, 'eq, 'a, 'b> = C.container<'hash, 'eq, bucket<'a, 'b>> let copy: t<'hash, 'eq, 'a, 'b> => t<'hash, 'eq, 'a, 'b> -let forEachU: (t<_, _, 'a, 'b>, (. 'a, 'b) => 'c) => unit +let forEachU: (t<_, _, 'a, 'b>, ('a, 'b) => 'c) => unit let forEach: (t<_, _, 'a, 'b>, ('a, 'b) => 'c) => unit -let reduceU: (t<_, _, 'a, 'b>, 'c, (. 'c, 'a, 'b) => 'c) => 'c +let reduceU: (t<_, _, 'a, 'b>, 'c, ('c, 'a, 'b) => 'c) => 'c let reduce: (t<_, _, 'a, 'b>, 'c, ('c, 'a, 'b) => 'c) => 'c let logStats: t<_> => unit -let keepMapInPlaceU: (t<_, _, 'a, 'b>, (. 'a, 'b) => option<'b>) => unit +let keepMapInPlaceU: (t<_, _, 'a, 'b>, ('a, 'b) => option<'b>) => unit let keepMapInPlace: (t<_, _, 'a, 'b>, ('a, 'b) => option<'b>) => unit let fillArray: (int, array<('a, 'b)>, bucket<'a, 'b>) => int diff --git a/belt/src/belt_internalMapInt.js b/belt/src/belt_internalMapInt.js index 852e536..e055358 100644 --- a/belt/src/belt_internalMapInt.js +++ b/belt/src/belt_internalMapInt.js @@ -200,24 +200,12 @@ function mergeU(s1, s2, f) { } else if (s2 === undefined) { return; } - if (s2 !== undefined) { - let v2 = s2.k; - let d2 = s2.v; - let l2 = s2.l; - let r2 = s2.r; - let match$1 = split(v2, s1); - return Belt_internalAVLtree.concatOrJoin(mergeU(match$1[0], l2, f), v2, f(v2, match$1[1], Caml_option.some(d2)), mergeU(match$1[2], r2, f)); - } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalMapInt.res", - 187, - 9 - ] - } - }); + let v2 = s2.k; + let d2 = s2.v; + let l2 = s2.l; + let r2 = s2.r; + let match$1 = split(v2, s1); + return Belt_internalAVLtree.concatOrJoin(mergeU(match$1[0], l2, f), v2, f(v2, match$1[1], Caml_option.some(d2)), mergeU(match$1[2], r2, f)); } function merge(s1, s2, f) { diff --git a/belt/src/belt_internalMapInt.res b/belt/src/belt_internalMapInt.res index 86d18f7..72c2149 100644 --- a/belt/src/belt_internalMapInt.res +++ b/belt/src/belt_internalMapInt.res @@ -1,4 +1,4 @@ -@@bs.config({flags: ["-bs-noassertfalse"]}) +@@config({flags: ["-bs-noassertfalse"]}) type key = int @@ -179,22 +179,22 @@ let rec mergeU = (s1, s2, f) => } => let {N.left: l1, key: v1, value: d1, right: r1} = n let (l2, d2, r2) = split(v1, s2) - N.concatOrJoin(mergeU(l1, l2, f), v1, f(. v1, Some(d1), d2), mergeU(r1, r2, f)) + N.concatOrJoin(mergeU(l1, l2, f), v1, f(v1, Some(d1), d2), mergeU(r1, r2, f)) | (_, Some(n)) /* Node (l2, v2, d2, r2, h2) */ => let {N.left: l2, key: v2, value: d2, right: r2} = n let (l1, d1, r1) = split(v2, s1) - N.concatOrJoin(mergeU(l1, l2, f), v2, f(. v2, d1, Some(d2)), mergeU(r1, r2, f)) + N.concatOrJoin(mergeU(l1, l2, f), v2, f(v2, d1, Some(d2)), mergeU(r1, r2, f)) | _ => assert(false) } -let merge = (s1, s2, f) => mergeU(s1, s2, (. a, b, c) => f(a, b, c)) +let merge = (s1, s2, f) => mergeU(s1, s2, (a, b, c) => f(a, b, c)) let rec compareAux = (e1, e2, vcmp) => switch (e1, e2) { | (list{h1, ...t1}, list{h2, ...t2}) => let c = Pervasives.compare((h1.N.key: key), h2.N.key) if c == 0 { - let cx = vcmp(. h1.N.value, h2.N.value) + let cx = vcmp(h1.N.value, h2.N.value) if cx == 0 { compareAux(N.stackAllLeft(h1.N.right, t1), N.stackAllLeft(h2.N.right, t2), vcmp) } else { @@ -217,12 +217,12 @@ let cmpU = (s1, s2, cmp) => { } } -let cmp = (s1, s2, f) => cmpU(s1, s2, (. a, b) => f(a, b)) +let cmp = (s1, s2, f) => cmpU(s1, s2, (a, b) => f(a, b)) let rec eqAux = (e1, e2, eq) => switch (e1, e2) { | (list{h1, ...t1}, list{h2, ...t2}) => - if (h1.N.key: key) == h2.N.key && eq(. h1.N.value, h2.N.value) { + if (h1.N.key: key) == h2.N.key && eq(h1.N.value, h2.N.value) { eqAux(N.stackAllLeft(h1.N.right, t1), N.stackAllLeft(h2.N.right, t2), eq) } else { false @@ -239,7 +239,7 @@ let eqU = (s1, s2, eq) => { } } -let eq = (s1, s2, f) => eqU(s1, s2, (. a, b) => f(a, b)) +let eq = (s1, s2, f) => eqU(s1, s2, (a, b) => f(a, b)) let rec addMutate = (t: t<_>, x, data): t<_> => switch t { @@ -269,7 +269,7 @@ let fromArray = (xs: array<(key, _)>) => { if len == 0 { None } else { - let next = ref(S.strictlySortedLengthU(xs, (. (x0, _), (y0, _)) => x0 < y0)) + let next = ref(S.strictlySortedLengthU(xs, ((x0, _), (y0, _)) => x0 < y0)) let result = ref( if next.contents >= 0 { diff --git a/belt/src/belt_internalMapString.js b/belt/src/belt_internalMapString.js index dca86ae..da6164b 100644 --- a/belt/src/belt_internalMapString.js +++ b/belt/src/belt_internalMapString.js @@ -200,24 +200,12 @@ function mergeU(s1, s2, f) { } else if (s2 === undefined) { return; } - if (s2 !== undefined) { - let v2 = s2.k; - let d2 = s2.v; - let l2 = s2.l; - let r2 = s2.r; - let match$1 = split(v2, s1); - return Belt_internalAVLtree.concatOrJoin(mergeU(match$1[0], l2, f), v2, f(v2, match$1[1], Caml_option.some(d2)), mergeU(match$1[2], r2, f)); - } - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalMapString.res", - 187, - 9 - ] - } - }); + let v2 = s2.k; + let d2 = s2.v; + let l2 = s2.l; + let r2 = s2.r; + let match$1 = split(v2, s1); + return Belt_internalAVLtree.concatOrJoin(mergeU(match$1[0], l2, f), v2, f(v2, match$1[1], Caml_option.some(d2)), mergeU(match$1[2], r2, f)); } function merge(s1, s2, f) { diff --git a/belt/src/belt_internalMapString.res b/belt/src/belt_internalMapString.res index e088f69..fdc2d31 100644 --- a/belt/src/belt_internalMapString.res +++ b/belt/src/belt_internalMapString.res @@ -1,4 +1,4 @@ -@@bs.config({flags: ["-bs-noassertfalse"]}) +@@config({flags: ["-bs-noassertfalse"]}) type key = string @@ -179,22 +179,22 @@ let rec mergeU = (s1, s2, f) => } => let {N.left: l1, key: v1, value: d1, right: r1} = n let (l2, d2, r2) = split(v1, s2) - N.concatOrJoin(mergeU(l1, l2, f), v1, f(. v1, Some(d1), d2), mergeU(r1, r2, f)) + N.concatOrJoin(mergeU(l1, l2, f), v1, f(v1, Some(d1), d2), mergeU(r1, r2, f)) | (_, Some(n)) /* Node (l2, v2, d2, r2, h2) */ => let {N.left: l2, key: v2, value: d2, right: r2} = n let (l1, d1, r1) = split(v2, s1) - N.concatOrJoin(mergeU(l1, l2, f), v2, f(. v2, d1, Some(d2)), mergeU(r1, r2, f)) + N.concatOrJoin(mergeU(l1, l2, f), v2, f(v2, d1, Some(d2)), mergeU(r1, r2, f)) | _ => assert(false) } -let merge = (s1, s2, f) => mergeU(s1, s2, (. a, b, c) => f(a, b, c)) +let merge = (s1, s2, f) => mergeU(s1, s2, (a, b, c) => f(a, b, c)) let rec compareAux = (e1, e2, vcmp) => switch (e1, e2) { | (list{h1, ...t1}, list{h2, ...t2}) => let c = Pervasives.compare((h1.N.key: key), h2.N.key) if c == 0 { - let cx = vcmp(. h1.N.value, h2.N.value) + let cx = vcmp(h1.N.value, h2.N.value) if cx == 0 { compareAux(N.stackAllLeft(h1.N.right, t1), N.stackAllLeft(h2.N.right, t2), vcmp) } else { @@ -217,12 +217,12 @@ let cmpU = (s1, s2, cmp) => { } } -let cmp = (s1, s2, f) => cmpU(s1, s2, (. a, b) => f(a, b)) +let cmp = (s1, s2, f) => cmpU(s1, s2, (a, b) => f(a, b)) let rec eqAux = (e1, e2, eq) => switch (e1, e2) { | (list{h1, ...t1}, list{h2, ...t2}) => - if (h1.N.key: key) == h2.N.key && eq(. h1.N.value, h2.N.value) { + if (h1.N.key: key) == h2.N.key && eq(h1.N.value, h2.N.value) { eqAux(N.stackAllLeft(h1.N.right, t1), N.stackAllLeft(h2.N.right, t2), eq) } else { false @@ -239,7 +239,7 @@ let eqU = (s1, s2, eq) => { } } -let eq = (s1, s2, f) => eqU(s1, s2, (. a, b) => f(a, b)) +let eq = (s1, s2, f) => eqU(s1, s2, (a, b) => f(a, b)) let rec addMutate = (t: t<_>, x, data): t<_> => switch t { @@ -269,7 +269,7 @@ let fromArray = (xs: array<(key, _)>) => { if len == 0 { None } else { - let next = ref(S.strictlySortedLengthU(xs, (. (x0, _), (y0, _)) => x0 < y0)) + let next = ref(S.strictlySortedLengthU(xs, ((x0, _), (y0, _)) => x0 < y0)) let result = ref( if next.contents >= 0 { diff --git a/belt/src/belt_internalSetBuckets.res b/belt/src/belt_internalSetBuckets.res index 56fcb8c..e1f3602 100644 --- a/belt/src/belt_internalSetBuckets.res +++ b/belt/src/belt_internalSetBuckets.res @@ -83,7 +83,7 @@ let rec doBucketIter = (~f, buckets) => switch C.toOpt(buckets) { | None => () | Some(cell) => - f(. cell.key) + f(cell.key) doBucketIter(~f, cell.next) } @@ -94,7 +94,7 @@ let forEachU = (h, f) => { } } -let forEach = (h, f) => forEachU(h, (. a) => f(a)) +let forEach = (h, f) => forEachU(h, a => f(a)) let rec fillArray = (i, arr, cell) => { A.setUnsafe(arr, i, cell.key) @@ -121,7 +121,7 @@ let toArray = h => { let rec doBucketFold = (~f, b, accu) => switch C.toOpt(b) { | None => accu - | Some(cell) => doBucketFold(~f, cell.next, f(. accu, cell.key)) + | Some(cell) => doBucketFold(~f, cell.next, f(accu, cell.key)) } let reduceU = (h, init, f) => { @@ -133,18 +133,18 @@ let reduceU = (h, init, f) => { accu.contents } -let reduce = (h, init, f) => reduceU(h, init, (. a, b) => f(a, b)) +let reduce = (h, init, f) => reduceU(h, init, (a, b) => f(a, b)) let getMaxBucketLength = h => - A.reduceU(h.C.buckets, 0, (. m, b) => { + A.reduceU(h.C.buckets, 0, (m, b) => { let len = bucketLength(0, b) Pervasives.max(m, len) }) let getBucketHistogram = h => { let mbl = getMaxBucketLength(h) - let histo = A.makeByU(mbl + 1, (. _) => 0) - A.forEachU(h.C.buckets, (. b) => { + let histo = A.makeByU(mbl + 1, _ => 0) + A.forEachU(h.C.buckets, b => { let l = bucketLength(0, b) A.setUnsafe(histo, l, A.getUnsafe(histo, l) + 1) }) diff --git a/belt/src/belt_internalSetBuckets.resi b/belt/src/belt_internalSetBuckets.resi index bd71b16..8a3e255 100644 --- a/belt/src/belt_internalSetBuckets.resi +++ b/belt/src/belt_internalSetBuckets.resi @@ -32,13 +32,13 @@ and t<'hash, 'eq, 'a> = C.container<'hash, 'eq, bucket<'a>> let copy: t<'hash, 'eq, 'a> => t<'hash, 'eq, 'a> -let forEachU: (t<'hash, 'eq, 'a>, (. 'a) => unit) => unit +let forEachU: (t<'hash, 'eq, 'a>, 'a => unit) => unit let forEach: (t<'hash, 'eq, 'a>, 'a => unit) => unit let fillArray: (int, array<'a>, bucket<'a>) => int let toArray: t<_, _, 'a> => array<'a> -let reduceU: (t<_, _, 'a>, 'b, (. 'b, 'a) => 'b) => 'b +let reduceU: (t<_, _, 'a>, 'b, ('b, 'a) => 'b) => 'b let reduce: (t<_, _, 'a>, 'b, ('b, 'a) => 'b) => 'b let logStats: t<_> => unit