diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 80fff87c159..f9833aea201 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -222,36 +222,36 @@ jobs: if: runner.os != 'Windows' run: node scripts/ciTest.js -all - - name: Run gentype tests - if: runner.os != 'Windows' - run: make -C jscomp/gentype_tests/typescript-react-example clean test + # - name: Run gentype tests + # if: runner.os != 'Windows' + # run: make -C jscomp/gentype_tests/typescript-react-example clean test - name: Run tests (Windows) if: runner.os == 'Windows' run: node scripts/ciTest.js -mocha -theme -format # Build the playground compiler on our fastest runner (macOS ARM) - - name: Install JSOO - if: matrix.os == 'macos-arm' - run: opam install js_of_ocaml.4.0.0 - - - name: Build playground compiler - if: matrix.os == 'macos-arm' - run: | - opam exec -- node packages/playground-bundling/scripts/generate_cmijs.js - opam exec -- dune build --profile browser - cp ./_build/default/jscomp/jsoo/jsoo_playground_main.bc.js playground/compiler.js - - - name: Test playground compiler - if: matrix.os == 'macos-arm' - run: node playground/playground_test.js - - - name: Upload playground compiler to CDN - if: ${{ matrix.os == 'macos-arm' && startsWith(github.ref, 'refs/tags/v') }} - env: - KEYCDN_USER: ${{ secrets.KEYCDN_USER }} - KEYCDN_PASSWORD: ${{ secrets.KEYCDN_PASSWORD }} - run: sh playground/upload_bundle.sh + # - name: Install JSOO + # if: matrix.os == 'macos-arm' + # run: opam install js_of_ocaml.4.0.0 + + # - name: Build playground compiler + # if: matrix.os == 'macos-arm' + # run: | + # opam exec -- node packages/playground-bundling/scripts/generate_cmijs.js + # opam exec -- dune build --profile browser + # cp ./_build/default/jscomp/jsoo/jsoo_playground_main.bc.js playground/compiler.js + + # - name: Test playground compiler + # if: matrix.os == 'macos-arm' + # run: node playground/playground_test.js + + # - name: Upload playground compiler to CDN + # if: ${{ matrix.os == 'macos-arm' && startsWith(github.ref, 'refs/tags/v') }} + # env: + # KEYCDN_USER: ${{ secrets.KEYCDN_USER }} + # KEYCDN_PASSWORD: ${{ secrets.KEYCDN_PASSWORD }} + # run: sh playground/upload_bundle.sh - name: Prepare artifact upload run: node .github/workflows/get_artifact_info.js diff --git a/Makefile b/Makefile index 7fb14bda69a..12980e0ebc3 100644 --- a/Makefile +++ b/Makefile @@ -36,10 +36,10 @@ test-syntax-roundtrip: make reanalyze bash ./scripts/testok.sh -test-gentype: - make -C jscomp/gentype_tests/typescript-react-example clean test +# test-gentype: +# make -C jscomp/gentype_tests/typescript-react-example clean test -test-all: test test-gentype +test-all: test # test-gentype reanalyze: reanalyze.exe -set-exit-code -all-cmt _build/default/jscomp -suppress jscomp/syntax/testrunner -exclude-paths jscomp/outcome_printer,jscomp/ounit_tests,jscomp/ml,jscomp/js_parser,jscomp/frontend,jscomp/ext,jscomp/depends,jscomp/core,jscomp/common,jscomp/cmij,jscomp/bsb_helper,jscomp/bsb diff --git a/jscomp/build_tests/super_errors/fixtures/arity_mismatch3.res b/jscomp/build_tests/super_errors/fixtures/arity_mismatch3.res deleted file mode 100644 index 58d94f89218..00000000000 --- a/jscomp/build_tests/super_errors/fixtures/arity_mismatch3.res +++ /dev/null @@ -1 +0,0 @@ -Belt.Array.mapU([], (. a, b) => 1) diff --git a/jscomp/others/belt.res b/jscomp/others/belt.res deleted file mode 100644 index c97d77f4545..00000000000 --- a/jscomp/others/belt.res +++ /dev/null @@ -1,361 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** The ReScript standard library. - -Belt is currently mostly covering collection types. It has no string or date functions yet, although Belt.String is in the works. In the meantime, use [Js.String](js/string) for string functions and [Js.Date](js/date) for date functions. - -## Motivation - -Belt provides: - -- The **highest quality** immutable data structures in JavaScript. -- Safety by default: A Belt function will never throw exceptions, unless it is - indicated explicitly in the function name (suffix "Exn"). -- Better performance and smaller code size running on the JS platform. -- Ready for [Tree Shaking](https://webpack.js.org/guides/tree-shaking/). - -## Usage - -To use modules from Belt, either refer to them by their fully qualified name (`Belt.List`, `Belt.Array` etc.) or open the `Belt` module by putting - -## Examples - -```rescript -open Belt -``` - -at the top of your source files. After opening Belt this way, `Array` will refer to `Belt.Array`, `List` will refer to `Belt.List` etc. in the subsequent code. - -If you want to open Belt globally for all files in your project instead, you can put - -```json -{ - "bsc-flags": ["-open Belt"] -} -``` - -into your `bsconfig.json`. - -**Note**: this is the **only** `open` we encourage. - -Example usage: - -## Examples - -```rescript -let someNumbers = [1, 1, 4, 2, 3, 6, 3, 4, 2] - -let greaterThan2UniqueAndSorted = - someNumbers - ->Belt.Array.keep(x => x > 2) - // convert to and from set to make values unique - ->Belt.Set.Int.fromArray - ->Belt.Set.Int.toArray // output is already sorted - -Js.log2("result", greaterThan2UniqueAndSorted) -``` - -## Curried vs. Uncurried Callbacks - -For functions taking a callback parameter, there are usually two versions -available: - -- curried (no suffix) -- uncurried (suffixed with `U`) - -E.g.: - -## Examples - -```rescript -let forEach: (t<'a>, 'a => unit) => unit - -let forEachU: (t<'a>, (. 'a) => unit) => unit -``` - -The uncurried version will be faster in some cases, but for simplicity we recommend to stick with the curried version unless you need the extra performance. - -The two versions can be invoked as follows: - -## Examples - -```rescript -["a", "b", "c"]->Belt.Array.forEach(x => Js.log(x)) - -["a", "b", "c"]->Belt.Array.forEachU((. x) => Js.log(x)) -``` - -## Specialized Collections - -For collections types like set or map, Belt provides both a generic module as well as specialized, more efficient implementations for string and int keys. - -For example, Belt has the following set modules: - -- [Belt.Set](belt/set) -- [Belt.Set.Int](belt/set/int) -- [Belt.Set.String](belt/set/string) - -## Implementation Details - -### Array access runtime safety - -One common confusion comes from the way Belt handles array access. It differs from than the default standard library's. - -## Examples - -```rescript -let letters = ["a", "b", "c"] -let a = letters[0] // a == "a" -let capitalA = Js.String.toUpperCase(a) -let k = letters[10] // Raises an exception! The 10th index doesn't exist. -``` - -Because Belt avoids exceptions and returns `options` instead, this code behaves differently: - -## Examples - -```rescript -open Belt -let letters = ["a", "b", "c"] -let a = letters[0] // a == Some("a") -let captialA = Js.String.toUpperCase(a) // Type error! This code will not compile. -let k = letters[10] // k == None -``` - -Although we've fixed the problem where `k` raises an exception, we now have a type error when trying to capitalize `a`. There are a few things going on here: - -- Reason transforms array index access to the function `Array.get`. So `letters[0]` is the same as `Array.get(letters, 0)`. -- The compiler uses whichever `Array` module is in scope. If you `open Belt`, then it uses `Belt.Array`. -- `Belt.Array.get` returns values wrapped in options, so `letters[0] == Some("a")`. - -Fortunately, this is easy to fix: - -## Examples - -```rescript -open Belt -let letters = ["a", "b", "c"] -let a = letters[0] - -// Use a switch statement: -let capitalA = - switch a { - | Some(a) => Some(Js.String.toUpperCase(a)) - | None => None - } - -let k = letters[10] // k == None -``` - -With that little bit of tweaking, our code now compiles successfully and is 100% free of runtime errors! - -### A Special Encoding for Collection Safety - -When we create a collection library for a custom data type we need a way to provide a comparator function. Take Set for example, suppose its element type is a pair of ints, it needs a custom compare function that takes two tuples and returns their order. The Set could not just be typed as Set.t (int \* int) , its customized compare function needs to manifest itself in the signature, otherwise, if the user creates another customized compare function, the two collection could mix which would result in runtime error. - -We use a phantom type to solve the problem: - -## Examples - -```rescript -module Comparable1 = - Belt.Id.MakeComparable( - { - type t = (int, int) - let cmp = ((a0, a1), (b0, b1)) => - switch Pervasives.compare(a0, b0) { - | 0 => Pervasives.compare(a1, b1) - | c => c - } - } - ) - -let mySet1 = Belt.Set.make(~id=module(Comparable1)) - -module Comparable2 = - Belt.Id.MakeComparable( - { - type t = (int, int) - let cmp = ((a0, a1), (b0, b1)) => - switch Pervasives.compare(a0, b0) { - | 0 => Pervasives.compare(a1, b1) - | c => c - } - } - ) - -let mySet2 = Belt.Set.make(~id=module(Comparable2)) -``` - -Here, the compiler would infer `mySet1` and `mySet2` having different type, so e.g. a `merge` operation that tries to merge these two sets will correctly fail. - -## Examples - -```rescript -let mySet1: t<(int, int), Comparable1.identity> -let mySet2: t<(int, int), Comparable2.identity> -``` - -`Comparable1.identity` and `Comparable2.identity` are not the same using our encoding scheme. - -*/ - -@@warning("-49") - -/** [`Belt.Id`]() - - Provide utilities to create identified comparators or hashes for - data structures used below. - - It create a unique identifier per module of - functions so that different data structures with slightly different - comparison functions won't mix -*/ -module Id = Belt_Id - -/** [`Belt.Array`]() - - **mutable array**: Utilities functions -*/ -module Array = Belt_Array - -/** [`Belt.SortArray`]() - - The top level provides some generic sort related utilities. - - It also has two specialized inner modules - [`Belt.SortArray.Int`]() and [`Belt.SortArray.String`]() -*/ -module SortArray = Belt_SortArray - -/** [`Belt.MutableQueue`]() - - An FIFO(first in first out) queue data structure -*/ -module MutableQueue = Belt_MutableQueue - -/** [`Belt.MutableStack`]() - - An FILO(first in last out) stack data structure -*/ -module MutableStack = Belt_MutableStack - -/** [`Belt.List`]() - - Utilities for List data type -*/ -module List = Belt_List - -/** [`Belt.Range`]() - - Utilities for a closed range `(from, start)` -*/ -module Range = Belt_Range - -/** [`Belt.Set`]() - - The top level provides generic **immutable** set operations. - - It also has three specialized inner modules - [`Belt.Set.Int`](), [`Belt.Set.String`]() and - - [`Belt.Set.Dict`](): This module separates data from function - which is more verbose but slightly more efficient - -*/ -module Set = Belt_Set - -/** [`Belt.Map`](), - - The top level provides generic **immutable** map operations. - - It also has three specialized inner modules - [`Belt.Map.Int`](), [`Belt.Map.String`]() and - - [`Belt.Map.Dict`](): This module separates data from function - which is more verbose but slightly more efficient -*/ -module Map = Belt_Map - -/** [`Belt.MutableSet`]() - - The top level provides generic **mutable** set operations. - - It also has two specialized inner modules - [`Belt.MutableSet.Int`]() and [`Belt.MutableSet.String`]() -*/ -module MutableSet = Belt_MutableSet - -/** [`Belt.MutableMap`]() - - The top level provides generic **mutable** map operations. - - It also has two specialized inner modules - [`Belt.MutableMap.Int`]() and [`Belt.MutableMap.String`]() - -*/ -module MutableMap = Belt_MutableMap - -/** [`Belt.HashSet`]() - - The top level provides generic **mutable** hash set operations. - - It also has two specialized inner modules - [`Belt.HashSet.Int`]() and [`Belt.HashSet.String`]() -*/ -module HashSet = Belt_HashSet - -/** [`Belt.HashMap`]() - - The top level provides generic **mutable** hash map operations. - - It also has two specialized inner modules - [`Belt.HashMap.Int`]() and [`Belt.HashMap.String`]() -*/ -module HashMap = Belt_HashMap - -/** [`Belt.Option`]() - - Utilities for option data type. -*/ -module Option = Belt_Option - -/** [`Belt.Result`]() - - Utilities for result data type. -*/ -module Result = Belt_Result - -/** [`Belt.Int`]() - - Utilities for Int. -*/ -module Int = Belt_Int - -/** [`Belt.Float`]() - - Utilities for Float. -*/ -module Float = Belt_Float diff --git a/jscomp/others/belt_Array.res b/jscomp/others/belt_Array.res deleted file mode 100644 index fdb72f48ad0..00000000000 --- a/jscomp/others/belt_Array.res +++ /dev/null @@ -1,647 +0,0 @@ -/* ********************************************************************* */ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1996 Institut National de Recherche en Informatique et */ -/* en Automatique. All rights reserved. This file is distributed */ -/* under the terms of the GNU Library General Public License, with */ -/* the special exception on linking described in file ../LICENSE. */ -/* */ -/* ********************************************************************* */ - -/* Array operations */ -type t<'a> = array<'a> - -external length: t<'a> => int = "%array_length" - -external size: t<'a> => int = "%array_length" - -external getUnsafe: (t<'a>, int) => 'a = "%array_unsafe_get" - -external setUnsafe: (t<'a>, int, 'a) => unit = "%array_unsafe_set" - -external getUndefined: (t<'a>, int) => Js.undefined<'a> = "%array_unsafe_get" - -/* external get: 'a t -> int -> 'a = "%array_safe_get" */ -let get = (arr, i) => - if i >= 0 && i < length(arr) { - Some(getUnsafe(arr, i)) - } else { - None - } - -let getExn = (arr, i) => { - assert(i >= 0 && i < length(arr)) - getUnsafe(arr, i) -} - -let set = (arr, i, v) => - if i >= 0 && i < length(arr) { - setUnsafe(arr, i, v) - true - } else { - false - } - -let setExn = (arr, i, v) => { - assert(i >= 0 && i < length(arr)) - setUnsafe(arr, i, v) -} - -@set external truncateToLengthUnsafe: (t<'a>, int) => unit = "length" - -@new external makeUninitialized: int => array> = "Array" - -@new external makeUninitializedUnsafe: int => array<'a> = "Array" - -@send external copy: (t<'a>, @as(0) _) => t<'a> = "slice" - -let swapUnsafe = (xs, i, j) => { - let tmp = getUnsafe(xs, i) - setUnsafe(xs, i, getUnsafe(xs, j)) - setUnsafe(xs, j, tmp) -} - -let shuffleInPlace = xs => { - let len = length(xs) - for i in 0 to len - 1 { - swapUnsafe(xs, i, Js_math.random_int(i, len)) /* [i,len) */ - } -} - -let shuffle = xs => { - let result = copy(xs) - shuffleInPlace(result) - - /* TODO: improve */ - result -} - -let reverseAux = (xs, ofs, len) => - for i in 0 to len / 2 - 1 { - swapUnsafe(xs, ofs + i, ofs + len - i - 1) - } - -let reverseInPlace = xs => { - let len = length(xs) - reverseAux(xs, 0, len) -} - -let reverse = xs => { - let len = length(xs) - let result = makeUninitializedUnsafe(len) - for i in 0 to len - 1 { - setUnsafe(result, i, getUnsafe(xs, len - 1 - i)) - } - result -} - -let make = (l, f) => - if l <= 0 { - [] - } else { - let res = makeUninitializedUnsafe(l) - for i in 0 to l - 1 { - setUnsafe(res, i, f) - } - res - } - -/* See #6575. We could also check for maximum array size, but this depends - on whether we create a float array or a regular one... */ -let makeByU = (l, f) => - if l <= 0 { - [] - } else { - let res = makeUninitializedUnsafe(l) - for i in 0 to l - 1 { - setUnsafe(res, i, f(. i)) - } - res - } - -let makeBy = (l, f) => makeByU(l, (. a) => f(a)) - -let makeByAndShuffleU = (l, f) => { - let u = makeByU(l, f) - shuffleInPlace(u) - u -} - -let makeByAndShuffle = (l, f) => makeByAndShuffleU(l, (. a) => f(a)) - -let range = (start, finish) => { - let cut = finish - start - if cut < 0 { - [] - } else { - let arr = makeUninitializedUnsafe(cut + 1) - for i in 0 to cut { - setUnsafe(arr, i, start + i) - } - arr - } -} - -let rangeBy = (start, finish, ~step) => { - let cut = finish - start - if cut < 0 || step <= 0 { - [] - } else { - let nb = cut / step + 1 - let arr = makeUninitializedUnsafe(nb) - let cur = ref(start) - for i in 0 to nb - 1 { - setUnsafe(arr, i, cur.contents) - cur.contents = cur.contents + step - } - arr - } -} - -let zip = (xs, ys) => { - let (lenx, leny) = (length(xs), length(ys)) - let len = Pervasives.min(lenx, leny) - let s = makeUninitializedUnsafe(len) - for i in 0 to len - 1 { - setUnsafe(s, i, (getUnsafe(xs, i), getUnsafe(ys, i))) - } - s -} - -let zipByU = (xs, ys, f) => { - let (lenx, leny) = (length(xs), length(ys)) - let len = Pervasives.min(lenx, leny) - let s = makeUninitializedUnsafe(len) - for i in 0 to len - 1 { - setUnsafe(s, i, f(. getUnsafe(xs, i), getUnsafe(ys, i))) - } - s -} - -let zipBy = (xs, ys, f) => zipByU(xs, ys, (. a, b) => f(a, b)) - -let concat = (a1, a2) => { - let l1 = length(a1) - let l2 = length(a2) - let a1a2 = makeUninitializedUnsafe(l1 + l2) - for i in 0 to l1 - 1 { - setUnsafe(a1a2, i, getUnsafe(a1, i)) - } - for i in 0 to l2 - 1 { - setUnsafe(a1a2, l1 + i, getUnsafe(a2, i)) - } - a1a2 -} - -let concatMany = arrs => { - let lenArrs = length(arrs) - let totalLen = ref(0) - for i in 0 to lenArrs - 1 { - totalLen.contents = totalLen.contents + length(getUnsafe(arrs, i)) - } - let result = makeUninitializedUnsafe(totalLen.contents) - totalLen.contents = 0 - for j in 0 to lenArrs - 1 { - let cur = getUnsafe(arrs, j) - for k in 0 to length(cur) - 1 { - setUnsafe(result, totalLen.contents, getUnsafe(cur, k)) - totalLen.contents = totalLen.contents + 1 - } - } - result -} - -let slice = (a, ~offset, ~len) => - if len <= 0 { - [] - } else { - let lena = length(a) - let ofs = if offset < 0 { - Pervasives.max(lena + offset, 0) - } else { - offset - } - let hasLen = lena - ofs - let copyLength = Pervasives.min(hasLen, len) - if copyLength <= 0 { - [] - } else { - let result = makeUninitializedUnsafe(copyLength) - for i in 0 to copyLength - 1 { - setUnsafe(result, i, getUnsafe(a, ofs + i)) - } - result - } - } - -let sliceToEnd = (a, offset) => { - let lena = length(a) - let ofs = if offset < 0 { - Pervasives.max(lena + offset, 0) - } else { - offset - } - let len = if lena > ofs { - lena - ofs - } else { - 0 - } - let result = makeUninitializedUnsafe(len) - for i in 0 to len - 1 { - setUnsafe(result, i, getUnsafe(a, ofs + i)) - } - result -} - -let fill = (a, ~offset, ~len, v) => - if len > 0 { - let lena = length(a) - let ofs = if offset < 0 { - Pervasives.max(lena + offset, 0) - } else { - offset - } - let hasLen = lena - ofs - let fillLength = Pervasives.min(hasLen, len) - if fillLength > 0 { - for i in ofs to ofs + fillLength - 1 { - setUnsafe(a, i, v) - } - } - } - -let blitUnsafe = ( - ~src as a1, - ~srcOffset as srcofs1, - ~dst as a2, - ~dstOffset as srcofs2, - ~len as blitLength, -) => - if srcofs2 <= srcofs1 { - for j in 0 to blitLength - 1 { - setUnsafe(a2, j + srcofs2, getUnsafe(a1, j + srcofs1)) - } - } else { - for j in blitLength - 1 downto 0 { - setUnsafe(a2, j + srcofs2, getUnsafe(a1, j + srcofs1)) - } - } - -/* We don't need check `blitLength` since when `blitLength < 0` the - for loop will be nop -*/ -let blit = (~src as a1, ~srcOffset as ofs1, ~dst as a2, ~dstOffset as ofs2, ~len) => { - let lena1 = length(a1) - let lena2 = length(a2) - let srcofs1 = if ofs1 < 0 { - Pervasives.max(lena1 + ofs1, 0) - } else { - ofs1 - } - let srcofs2 = if ofs2 < 0 { - Pervasives.max(lena2 + ofs2, 0) - } else { - ofs2 - } - let blitLength = Pervasives.min(len, Pervasives.min(lena1 - srcofs1, lena2 - srcofs2)) - - /* blitUnsafe a1 srcofs1 a2 srcofs2 blitLength */ - if srcofs2 <= srcofs1 { - for j in 0 to blitLength - 1 { - setUnsafe(a2, j + srcofs2, getUnsafe(a1, j + srcofs1)) - } - } else { - for j in blitLength - 1 downto 0 { - setUnsafe(a2, j + srcofs2, getUnsafe(a1, j + srcofs1)) - } - } -} - -let forEachU = (a, f) => - for i in 0 to length(a) - 1 { - f(. getUnsafe(a, i)) - } - -let forEach = (a, f) => forEachU(a, (. a) => f(a)) - -let mapU = (a, f) => { - let l = length(a) - let r = makeUninitializedUnsafe(l) - for i in 0 to l - 1 { - setUnsafe(r, i, f(. getUnsafe(a, i))) - } - r -} - -let map = (a, f) => mapU(a, (. a) => f(a)) - -let flatMapU = (a, f) => concatMany(mapU(a, f)) - -let flatMap = (a, f) => flatMapU(a, (. a) => f(a)) - -let getByU = (a, p) => { - let l = length(a) - let i = ref(0) - let r = ref(None) - while r.contents == None && i.contents < l { - let v = getUnsafe(a, i.contents) - if p(. v) { - r.contents = Some(v) - } - i.contents = i.contents + 1 - } - r.contents -} - -let getBy = (a, p) => getByU(a, (. a) => p(a)) - -let getIndexByU = (a, p) => { - let l = length(a) - let i = ref(0) - let r = ref(None) - while r.contents == None && i.contents < l { - let v = getUnsafe(a, i.contents) - if p(. v) { - r.contents = Some(i.contents) - } - i.contents = i.contents + 1 - } - r.contents -} - -let getIndexBy = (a, p) => getIndexByU(a, (. a) => p(a)) - -let keepU = (a, f) => { - let l = length(a) - let r = makeUninitializedUnsafe(l) - let j = ref(0) - for i in 0 to l - 1 { - let v = getUnsafe(a, i) - if f(. v) { - setUnsafe(r, j.contents, v) - j.contents = j.contents + 1 - } - } - truncateToLengthUnsafe(r, j.contents) - r -} - -let keep = (a, f) => keepU(a, (. a) => f(a)) - -let keepWithIndexU = (a, f) => { - let l = length(a) - let r = makeUninitializedUnsafe(l) - let j = ref(0) - for i in 0 to l - 1 { - let v = getUnsafe(a, i) - if f(. v, i) { - setUnsafe(r, j.contents, v) - j.contents = j.contents + 1 - } - } - truncateToLengthUnsafe(r, j.contents) - r -} - -let keepWithIndex = (a, f) => keepWithIndexU(a, (. a, i) => f(a, i)) - -let keepMapU = (a, f) => { - let l = length(a) - let r = makeUninitializedUnsafe(l) - let j = ref(0) - for i in 0 to l - 1 { - let v = getUnsafe(a, i) - switch f(. v) { - | None => () - | Some(v) => - setUnsafe(r, j.contents, v) - j.contents = j.contents + 1 - } - } - truncateToLengthUnsafe(r, j.contents) - r -} - -let keepMap = (a, f) => keepMapU(a, (. a) => f(a)) - -let forEachWithIndexU = (a, f) => - for i in 0 to length(a) - 1 { - f(. i, getUnsafe(a, i)) - } - -let forEachWithIndex = (a, f) => forEachWithIndexU(a, (. a, b) => f(a, b)) - -let mapWithIndexU = (a, f) => { - let l = length(a) - let r = makeUninitializedUnsafe(l) - for i in 0 to l - 1 { - setUnsafe(r, i, f(. i, getUnsafe(a, i))) - } - r -} - -let mapWithIndex = (a, f) => mapWithIndexU(a, (. a, b) => f(a, b)) - -let reduceU = (a, x, f) => { - let r = ref(x) - for i in 0 to length(a) - 1 { - r.contents = f(. r.contents, getUnsafe(a, i)) - } - r.contents -} - -let reduce = (a, x, f) => reduceU(a, x, (. a, b) => f(a, b)) - -let reduceReverseU = (a, x, f) => { - let r = ref(x) - for i in length(a) - 1 downto 0 { - r.contents = f(. r.contents, getUnsafe(a, i)) - } - r.contents -} - -let reduceReverse = (a, x, f) => reduceReverseU(a, x, (. a, b) => f(a, b)) - -let reduceReverse2U = (a, b, x, f) => { - let r = ref(x) - let len = Pervasives.min(length(a), length(b)) - for i in len - 1 downto 0 { - r.contents = f(. r.contents, getUnsafe(a, i), getUnsafe(b, i)) - } - r.contents -} - -let reduceReverse2 = (a, b, x, f) => reduceReverse2U(a, b, x, (. a, b, c) => f(a, b, c)) - -let reduceWithIndexU = (a, x, f) => { - let r = ref(x) - for i in 0 to length(a) - 1 { - r.contents = f(. r.contents, getUnsafe(a, i), i) - } - r.contents -} - -let reduceWithIndex = (a, x, f) => reduceWithIndexU(a, x, (. a, b, c) => f(a, b, c)) - -let rec everyAux = (arr, i, b, len) => - if i == len { - true - } else if b(. getUnsafe(arr, i)) { - everyAux(arr, i + 1, b, len) - } else { - false - } - -let rec someAux = (arr, i, b, len) => - if i == len { - false - } else if b(. getUnsafe(arr, i)) { - true - } else { - someAux(arr, i + 1, b, len) - } - -let everyU = (arr, b) => { - let len = length(arr) - everyAux(arr, 0, b, len) -} - -let every = (arr, f) => everyU(arr, (. b) => f(b)) - -let someU = (arr, b) => { - let len = length(arr) - someAux(arr, 0, b, len) -} - -let some = (arr, f) => someU(arr, (. b) => f(b)) - -let rec everyAux2 = (arr1, arr2, i, b, len) => - if i == len { - true - } else if b(. getUnsafe(arr1, i), getUnsafe(arr2, i)) { - everyAux2(arr1, arr2, i + 1, b, len) - } else { - false - } - -let rec someAux2 = (arr1, arr2, i, b, len) => - if i == len { - false - } else if b(. getUnsafe(arr1, i), getUnsafe(arr2, i)) { - true - } else { - someAux2(arr1, arr2, i + 1, b, len) - } - -let every2U = (a, b, p) => everyAux2(a, b, 0, p, Pervasives.min(length(a), length(b))) - -let every2 = (a, b, p) => every2U(a, b, (. a, b) => p(a, b)) - -let some2U = (a, b, p) => someAux2(a, b, 0, p, Pervasives.min(length(a), length(b))) - -let some2 = (a, b, p) => some2U(a, b, (. a, b) => p(a, b)) - -let eqU = (a, b, p) => { - let lena = length(a) - let lenb = length(b) - if lena == lenb { - everyAux2(a, b, 0, p, lena) - } else { - false - } -} - -let eq = (a, b, p) => eqU(a, b, (. a, b) => p(a, b)) - -let rec everyCmpAux2 = (arr1, arr2, i, b, len) => - if i == len { - 0 - } else { - let c = b(. getUnsafe(arr1, i), getUnsafe(arr2, i)) - if c == 0 { - everyCmpAux2(arr1, arr2, i + 1, b, len) - } else { - c - } - } - -let cmpU = (a, b, p) => { - let lena = length(a) - let lenb = length(b) - if lena > lenb { - 1 - } else if lena < lenb { - -1 - } else { - everyCmpAux2(a, b, 0, p, lena) - } -} - -let cmp = (a, b, p) => cmpU(a, b, (. a, b) => p(a, b)) - -let partitionU = (a, f) => { - let l = length(a) - let i = ref(0) - let j = ref(0) - let a1 = makeUninitializedUnsafe(l) - let a2 = makeUninitializedUnsafe(l) - for ii in 0 to l - 1 { - let v = getUnsafe(a, ii) - if f(. v) { - setUnsafe(a1, i.contents, v) - i.contents = i.contents + 1 - } else { - setUnsafe(a2, j.contents, v) - j.contents = j.contents + 1 - } - } - truncateToLengthUnsafe(a1, i.contents) - truncateToLengthUnsafe(a2, j.contents) - (a1, a2) -} - -let partition = (a, f) => partitionU(a, (. x) => f(x)) - -let unzip = a => { - let l = length(a) - let a1 = makeUninitializedUnsafe(l) - let a2 = makeUninitializedUnsafe(l) - for i in 0 to l - 1 { - let (v1, v2) = getUnsafe(a, i) - setUnsafe(a1, i, v1) - setUnsafe(a2, i, v2) - } - (a1, a2) -} - -let joinWithU = (a, sep, toString) => - switch length(a) { - | 0 => "" - | l => - let lastIndex = l - 1 - let rec aux = (i, res) => - if i == lastIndex { - res ++ toString(. getUnsafe(a, i)) - } else { - aux(i + 1, res ++ (toString(. getUnsafe(a, i)) ++ sep)) - } - - aux(0, "") - } - -let joinWith = (a, sep, toString) => joinWithU(a, sep, (. x) => toString(x)) - -let initU = (n, f) => { - let v = makeUninitializedUnsafe(n) - for i in 0 to n - 1 { - setUnsafe(v, i, f(. i)) - } - v -} - -let init = (n, f) => initU(n, (. i) => f(i)) - -@send external push: (t<'a>, 'a) => unit = "push" diff --git a/jscomp/others/belt_Array.resi b/jscomp/others/belt_Array.resi deleted file mode 100644 index 01a7f509344..00000000000 --- a/jscomp/others/belt_Array.resi +++ /dev/null @@ -1,771 +0,0 @@ -/* ********************************************************************* */ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1996 Institut National de Recherche en Informatique et */ -/* en Automatique. All rights reserved. This file is distributed */ -/* under the terms of the GNU Library General Public License, with */ -/* the special exception on linking described in file ../LICENSE. */ -/* */ -/* ********************************************************************* */ -/* Adapted significantly by Authors of ReScript */ - -/*** -Utililites for `Array` functions. - -### Note about index syntax - -Code like `arr[0]` does *not* compile to JavaScript `arr[0]`. Reason transforms -the `[]` index syntax into a function: `Array.get(arr, 0)`. By default, this -uses the default standard library's `Array.get` function, which may raise an -exception if the index isn't found. If you `open Belt`, it will use the -`Belt.Array.get` function which returns options instead of raising exceptions. -[See this for more information](../belt.mdx#array-access-runtime-safety). -*/ - -type t<'a> = array<'a> - -/** -Return the size of the array - -## Examples - -```rescript -// Returns 1 -Belt.Array.length(["test"]) -``` -*/ -external length: t<'a> => int = "%array_length" - -/** See [`Belt.Array.length`]() */ -external size: t<'a> => int = "%array_length" - -/** -If `i <= 0 <= length(arr)` returns `Some(value)` where `value` is the item at index `i`. -If `i` is out of range returns `None`. - -## Examples - -```rescript -Belt.Array.get(["a", "b", "c"], 0) == Some("a") -Belt.Array.get(["a", "b", "c"], 3) == None -Belt.Array.get(["a", "b", "c"], -1) == None -``` -*/ -let get: (t<'a>, int) => option<'a> - -/** -Raise an exception if `i` is out of range. -Otherwise return the value at index `i` in `arr`. -*/ -let getExn: (t<'a>, int) => 'a - -/** -`getUnsafe(arr, i)` - -**Unsafe** - -no bounds checking; this would cause type error if `i` does not stay within range -*/ -external getUnsafe: (t<'a>, int) => 'a = "%array_unsafe_get" - -/** -`getUndefined(arr, i)` - -It does the samething in the runtime as [`getUnsafe`](); -it is _type safe_ since the return type still track whether it is -in range or not -*/ -external getUndefined: (t<'a>, int) => Js.undefined<'a> = "%array_unsafe_get" - -/** -`set(arr, n, x)` modifies `arr` in place; it replaces the nth element of `arr` -with `x`. Returning `false` means not updated due to out of range. -*/ -let set: (t<'a>, int, 'a) => bool - -/** -`setExn(arr, i, x)` raise an exception if `i` is out of range. -*/ -let setExn: (t<'a>, int, 'a) => unit - -external setUnsafe: (t<'a>, int, 'a) => unit = "%array_unsafe_set" - -/** -`shuffleInPlace(arr)` randomly re-orders the items in `arr` -*/ -let shuffleInPlace: t<'a> => unit - -/** Returns a fresh array with items in original array randomly shuffled. */ -let shuffle: t<'a> => t<'a> - -/** -`reverseInPlace(arr)` reverses items in `arr` in place. - -## Examples - -```rescript -let arr = [10, 11, 12, 13, 14] - -let () = Belt.Array.reverseInPlace(arr) - -arr == [14, 13, 12, 11, 10] -``` -*/ -let reverseInPlace: t<'a> => unit - -/** -`reverse(arr)` returns a fresh array with items in arr in reverse order. - -## Examples - -```rescript -Belt.Array.reverse([10, 11, 12, 13, 14]) == [14, 13, 12, 11, 10] -``` -*/ -let reverse: t<'a> => t<'a> - -@new -/** -`makeUninitialized(n)` creates an array of length `n` filled with the undefined -value. You must specify the type of data that will eventually fill the array. - -## Examples - -```rescript -let arr: array> = Belt.Array.makeUninitialized(5) - -Belt.Array.getExn(arr, 0) == Js.undefined -``` -*/ -external makeUninitialized: int => array> = "Array" - -@new -/** -**Unsafe** - -## Examples - -```rescript -let arr = Belt.Array.makeUninitializedUnsafe(5) - -Js.log(Belt.Array.getExn(arr, 0)) // undefined - -Belt.Array.setExn(arr, 0, "example") - -Js.log(Belt.Array.getExn(arr, 0) == "example") -``` -*/ -external makeUninitializedUnsafe: int => t<'a> = "Array" - -/** -`make(n, e)` return an array of size `n` filled with value `e`. -Returns an empty array when `n` is negative. -*/ -let make: (int, 'a) => t<'a> - -/** -`range(start, finish)` create an inclusive array. - -## Examples - -```rescript -Belt.Array.range(0, 3) == [0, 1, 2, 3] - -Belt.Array.range(3, 0) == [] - -Belt.Array.range(3, 3) == [3] -``` -*/ -let range: (int, int) => array - -/** -`rangeBy(start, finish, ~step)` returns empty array when step is 0 or negative. -It also return an empty array when `start > finish`. - -## Examples - -```rescript -Belt.Array.rangeBy(0, 10, ~step=3) == [0, 3, 6, 9] - -Belt.Array.rangeBy(0, 12, ~step=3) == [0, 3, 6, 9, 12] - -Belt.Array.rangeBy(33, 0, ~step=1) == [] - -Belt.Array.rangeBy(33, 0, ~step=-1) == [] - -Belt.Array.rangeBy(3, 12, ~step=-1) == [] - -Belt.Array.rangeBy(3, 3, ~step=0) == [] - -Belt.Array.rangeBy(3, 3, ~step=1) == [3] -``` -*/ -let rangeBy: (int, int, ~step: int) => array - -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`. - -## Examples - -```rescript -Belt.Array.makeBy(5, (i) => i) == [0, 1, 2, 3, 4] - -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> -/** -Equivalent to `shuffle(makeBy(n, f))` -*/ -let makeByAndShuffle: (int, int => 'a) => t<'a> - -/** -`zip(a, b)` create an array of pairs from corresponding elements of a and b. -Stop with the shorter array. - -## Examples - -```rescript -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> -/** -`zipBy(xs, ys, f)` create an array by applying `f` to corresponding elements of -`xs` and `ys`. Stops with shorter array. - -Equivalent to `map(zip(xs, ys), ((a, b)) => f(a, b))` - -## Examples - -```rescript -Belt.Array.zipBy([1, 2, 3], [4, 5], (a, b) => 2 * a + b) == [6, 9] -``` -*/ -let zipBy: (t<'a>, array<'b>, ('a, 'b) => 'c) => array<'c> - -/** -`unzip(a)` takes an array of pairs and creates a pair of arrays. The first array -contains all the first items of the pairs; the second array contains all the -second items. - -## Examples - -```rescript -Belt.Array.unzip([(1, 2), (3, 4)]) == ([1, 3], [2, 4]) - -Belt.Array.unzip([(1, 2), (3, 4), (5, 6), (7, 8)]) == ([1, 3, 5, 7], [2, 4, 6, 8]) -``` -*/ -let unzip: array<('a, 'b)> => (t<'a>, array<'b>) - -/** -`concat(xs, ys)` returns a fresh array containing the concatenation of the arrays -`v1` and `v2`, so even if `v1` or `v2` is empty; it can not be shared. - -## Examples - -```rescript -Belt.Array.concat([1, 2, 3], [4, 5]) == [1, 2, 3, 4, 5] - -Belt.Array.concat([], ["a", "b", "c"]) == ["a", "b", "c"] -``` -*/ -let concat: (t<'a>, t<'a>) => t<'a> - -/** -`concatMany(xss)` returns a fresh array as the concatenation of `xss` (an array of arrays) - -## Examples - -```rescript -Belt.Array.concatMany([[1, 2, 3], [4, 5, 6], [7, 8]]) == [1, 2, 3, 4, 5, 6, 7, 8] -``` -*/ -let concatMany: array> => t<'a> - -/** -`slice(xs, offset, len)` creates a new array with the len elements of `xs` -starting at `offset` for `offset` can be negative;and is evaluated as -`length(xs) - offset(slice, xs) - 1(1)` means get the last element as a -singleton array `slice(xs, ~-len, len)` will return a copy of the array if the -array does not have enough data; `slice` extracts through the end of sequence. - -if `len` is negative; returns the empty array. - -## Examples - -```rescript -Belt.Array.slice([10, 11, 12, 13, 14, 15, 16], ~offset=2, ~len=3) == [12, 13, 14] - -Belt.Array.slice([10, 11, 12, 13, 14, 15, 16], ~offset=-4, ~len=3) == [13, 14, 15] - -Belt.Array.slice([10, 11, 12, 13, 14, 15, 16], ~offset=4, ~len=9) == [14, 15, 16] -``` -*/ -let slice: (t<'a>, ~offset: int, ~len: int) => t<'a> - -/** -`sliceToEnd(xs, offset)` creates a new array with the elements of `xs` starting -at `offset` - -`offset` can be negative; and is evaluated as `length(xs) - offset(sliceToEnd, xs) - 1` -means get the last element as a singleton array - -`sliceToEnd(xs, 0)` will return a copy of the array - -## Examples - -```rescript -Belt.Array.sliceToEnd([10, 11, 12, 13, 14, 15, 16], 2) == [12, 13, 14, 15, 16] - -Belt.Array.sliceToEnd([10, 11, 12, 13, 14, 15, 16], -4) == [13, 14, 15, 16] -``` -*/ -let sliceToEnd: (t<'a>, int) => t<'a> - -@send -/** -`copy(a)` returns a copy of `a`; that is; a fresh array containing the same -elements as `a`. -*/ -external copy: (t<'a>, @as(0) _) => t<'a> = "slice" - -/** -`fill(arr, ~offset, ~len, x)` modifies `arr` in place, storing `x` in elements -number `offset` to `offset + len - 1`. `offset` can be negative; and is evaluated -as `length(arr - offset)`. - -`fill(arr, ~offset=-1, ~len=1)` means fill the last element, if the array does not have enough data; `fill` will ignore it - -## Examples - -```rescript -let arr = Belt.Array.makeBy(5, (i) => i) - -Belt.Array.fill(arr, ~offset=2, ~len=2, 9) - -arr == [0, 1, 9, 9, 4] - -Belt.Array.fill(arr, ~offset=7, ~len=2, 8) - -arr == [0, 1, 9, 9, 4] -*/ -let fill: (t<'a>, ~offset: int, ~len: int, 'a) => unit - -/** -`blit(~src=v1, ~srcOffset=o1, ~dst=v2, ~dstOffset=o2, ~len)` copies `len` elements -from array `v1`;starting at element number `o1`;to array `v2`, starting at element -number `o2`. It works correctly even if `v1` and `v2` are the same array and the -source and destination chunks overlap. - -`offset` can be negative; `-1` means `len - 1`; if `len + offset` is still negative;it will be set as 0 - -For each of the examples;presume that `v1 == [10, 11, 12, 13, 14, 15, 16, 17]` and `v2 == [20, 21, 22, 23, 24, 25, 26, 27]`. The result shown is the content of the destination array. - -## Examples - -```rescript -let v1 = [10, 11, 12, 13, 14, 15, 16, 17] -let v2 = [20, 21, 22, 23, 24, 25, 26, 27] - -Belt.Array.blit(~src=v1, ~srcOffset=4, ~dst=v2, ~dstOffset=2, ~len=3) -v2 == [20, 21, 14, 15, 16, 25, 26, 27] - -Belt.Array.blit(~src=v1, ~srcOffset=4, ~dst=v1, ~dstOffset=2, ~len=3) -v1 == [10, 11, 14, 15, 16, 15, 16, 17] -``` -*/ -let blit: (~src: t<'a>, ~srcOffset: int, ~dst: t<'a>, ~dstOffset: int, ~len: int) => unit - -/** -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 -/** -`forEach(xs, f)` - -Call `f` on each element of `xs` from the beginning to end. `f` returns `unit` -so no new array is created. Use `forEach` when you are primarily concerned with -repetitively creating side effects. - -## Examples - -```rescript -Belt.Array.forEach(["a", "b", "c"], x => Js.log("Item: " ++ x)) - -/* - prints: - Item: a - Item: b - Item: c -*/ -let total = ref(0) - -Belt.Array.forEach([1, 2, 3, 4], x => total := total.contents + x) - -total.contents == 1 + 2 + 3 + 4 -``` -*/ -let forEach: (t<'a>, 'a => unit) => unit - -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. - -## Examples - -```rescript -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> -/** -`flatMap(xs, f)` returns a new array by calling `f` for each element of `xs` from -the beginning to end, concatenating the results. - -## Examples - -```rescript -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> -/** -`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. - -## Examples - -```rescript -Belt.Array.getBy([1, 4, 3, 2], (x) => mod(x, 2) == 0) == Some(4) -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 -/** -`getIndexBy(xs, p)` returns `Some(index)` for the first value in `xs` that -satisifies the predicate function `p`; returns `None` if no element satisifies -the function. - -## Examples - -```rescript -Belt.Array.getIndexBy([1, 4, 3, 2], (x) => mod(x, 2) == 0) == Some(1) -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> -/** -`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> -/** -`keepWithIndex(xs, p)` returns a new array that keep all elements satisfy `p`. - -## Examples - -```rescript -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> -/** -`keepMap(xs, p)` returns a new array that keep all elements that return a non -None applied `p`. - -## Examples - -```rescript -Belt.Array.keepMap([1, 2, 3], x => - if mod(x, 2) == 0 { - Some(x) - } else { - None - } -) -== [2] -``` -*/ -let keepMap: (t<'a>, 'a => option<'b>) => array<'b> - -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`. - -## Examples - -```rescript -Belt.Array.forEachWithIndex(["a", "b", "c"], (i, x) => Js.log("Item " ++ Belt.Int.toString(i) ++ " is " ++ x)) - -/* - prints: - Item 0 is a - Item 1 is b - Item 2 is cc -*/ -let total = ref(0) - -Belt.Array.forEachWithIndex([10, 11, 12, 13], (i, x) => total := total.contents + x + i) - -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> -/** -`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`. - -## Examples - -```rescript -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>) -/** -`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 - -## Examples - -```rescript -Belt.Array.partition([1, 2, 3, 4, 5], (x) => mod(x, 2) == 0) == ([2, 4], [1, 3, 5]) - -Belt.Array.partition([1, 2, 3, 4, 5], (x) => mod(x, 2) != 0) == ([1, 3, 5], [2, 4]) -``` -*/ -let partition: (t<'a>, 'a => bool) => (t<'a>, t<'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”; -which starts with a value of `init`. `reduce` returns the final value of the -accumulator. - -## Examples - -```rescript -Belt.Array.reduce([2, 3, 4], 1, (a, b) => a + b) == 10 - -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 -/** -`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. - -## Examples - -```rescript -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 -/** -`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. - -## Examples - -```rescript -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 -/** -Applies `f` to each element of `xs` from beginning to end. Function `f` has -three parameters: the item from the array and an “accumulator”, which starts -with a value of `init` and the index of each element. `reduceWithIndex` returns -the final value of the accumulator. - -## Examples - -```rescript -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 -/** -`joinWith(xs, sep, toString)` - -Concatenates all the elements of `xs` converted to string with `toString`, each -separated by `sep`, the string given as the second argument, into a single string. -If the array has only one element, then that element will be returned without -using the separator. If the array is empty, the empty string will be returned. - -## Examples - -```rescript -Belt.Array.joinWith([0, 1], ", ", Js.Int.toString) == "0, 1" -Belt.Array.joinWith([], " ", Js.Int.toString) == "" -Belt.Array.joinWith([1], " ", Js.Int.toString) == "1" -``` -*/ -let joinWith: (t<'a>, string, 'a => string) => string - -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`. - -## Examples - -```rescript -Belt.Array.some([2, 3, 4], (x) => mod(x, 2) == 1) == true - -Belt.Array.some([(-1), (-3), (-5)], (x) => x > 0) == false -``` -*/ -let some: (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`. - -## Examples - -```rescript -Belt.Array.every([1, 3, 5], (x) => mod(x, 2) == 1) == true - -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 -/** -`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))`) - -## Examples - -```rescript -Belt.Array.every2([1, 2, 3], [0, 1], (a, b) => a > b) == true - -Belt.Array.every2([], [1], (x, y) => x > y) == true - -Belt.Array.every2([2, 3], [1], (x, y) => x > y) == true - -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 -/** -`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))`) - -## Examples - -```rescript -Belt.Array.some2([0, 2], [1, 0, 3], (a, b) => a > b) == true - -Belt.Array.some2([], [1], (x, y) => x > y) == false - -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 -/** -`cmp(xs, ys, f)` compared by length if `length(xs) != length(ys)`; returning `-1` -if `length(xs) < length(ys)` or 1 if `length(xs) > length(ys)`. Otherwise -compare one by one `f(x, y)`. `f` returns a negative number if `x` is “less than” `y` -zero if `x` is “equal to” `y` a positive number if `x` is “greater than” -`y`. The comparison returns the first non-zero result of `f`; or zero if `f` -returns zero for all `x` and `y`. - -## Examples - -```rescript -Belt.Array.cmp([1, 3, 5], [1, 4, 2], (a, b) => compare(a, b)) == -1 - -Belt.Array.cmp([1, 3, 5], [1, 2, 3], (a, b) => compare(a, b)) == 1 - -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 -/** -`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 - -## Examples - -```rescript -Belt.Array.eq([1, 2, 3], [(-1), (-2), (-3)], (a, b) => abs(a) == abs(b)) == true -``` -*/ -let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool - -@set -/** -Unsafe `truncateToLengthUnsafe(xs, n)` sets length of array `xs` to `n`. If `n` -is greater than the length of `xs`; the extra elements are set to `Js.Null_undefined.null`. -If `n` is less than zero; raises a `RangeError`. - -## Examples - -```rescript -let arr = ["ant", "bee", "cat", "dog", "elk"] - -Belt.Array.truncateToLengthUnsafe(arr, 3) - -arr == ["ant", "bee", "cat"] -``` -*/ -external truncateToLengthUnsafe: (t<'a>, int) => unit = "length" - -let initU: (int, (. int) => 'a) => t<'a> -let init: (int, int => 'a) => t<'a> - -/** -`arr->push(item)` pushes an element `item` into an array `arr`. -*/ -@send -external push: (t<'a>, 'a) => unit = "push" diff --git a/jscomp/others/belt_Float.res b/jscomp/others/belt_Float.res deleted file mode 100644 index 6bb704df887..00000000000 --- a/jscomp/others/belt_Float.res +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** [`Belt.Float`]() - Utililites for Float -*/ - -@val external isNaN: float => bool = "isNaN" - -external toInt: float => int = "%intoffloat" - -external fromInt: int => float = "%identity" - -@val external fromString: string => float = "parseFloat" - -let fromString = i => - switch fromString(i) { - | i if isNaN(i) => None - | i => Some(i) - } - -@val external toString: float => string = "String" - -external \"+": (float, float) => float = "%addfloat" - -external \"-": (float, float) => float = "%subfloat" - -external \"*": (float, float) => float = "%mulfloat" - -external \"/": (float, float) => float = "%divfloat" diff --git a/jscomp/others/belt_Float.resi b/jscomp/others/belt_Float.resi deleted file mode 100644 index bc6fbf9915c..00000000000 --- a/jscomp/others/belt_Float.resi +++ /dev/null @@ -1,122 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** This module includes convenience methods for handling `float` types. */ - -/** -Converts a given `float` to an `int`. - -## Examples - -```rescript -Js.log(Belt.Float.toInt(1.0) === 1) /* true */ -``` -*/ -external toInt: float => int = "%intoffloat" - -/** -Converts a given `int` to a `float`. - -## Examples - -```rescript -Js.log(Belt.Float.fromInt(1) === 1.0) /* true */ -``` -*/ -external fromInt: int => float = "%identity" - -/** -Converts a given `string` to a `float`. Returns `Some(float)` when the input is a number, `None` otherwise. - -## Examples - -```rescript -Js.log(Belt.Float.fromString("1.0") === Some(1.0)) /* true */ -``` -*/ -let fromString: string => option - -@val -/** -Converts a given `float` to a `string`. Uses the JavaScript `String` constructor under the hood. - -## Examples - -```rescript -Js.log(Belt.Float.toString(1.0) === "1.0") /* true */ -``` -*/ -external toString: float => string = "String" - -/** -Addition of two `float` values. -Can be opened in a module to avoid dot-notation (`+.`), however this yields a shadow warning (Warning number 44) in the default configuration. - -## Examples - -```rescript -open Belt.Float -Js.log(2.0 + 2.0 === 4.0) /* true */ -``` -*/ -external \"+": (float, float) => float = "%addfloat" - -/** -Subtraction of two `float` values. -Can be opened in a module to avoid dot-notation (`-.`), however this yields a shadow warning (Warning number 44) in the default configuration. - -## Examples - -```rescript -open Belt.Float -Js.log(2.0 - 1.0 === 1.0) /* true */ -``` -*/ -external \"-": (float, float) => float = "%subfloat" - -/** -Multiplication of two `float` values. -Can be opened in a module to avoid dot-notation (`*.`), however this yields a shadow warning (Warning number 44) in the default configuration. - -## Examples - -```rescript -open Belt.Float -Js.log(2.0 * 2.0 === 4.0) /* true */ -``` -*/ -external \"*": (float, float) => float = "%mulfloat" - -/** -Division of two `float` values. -Can be opened in a module to avoid dot-notation (`/.`), however this yields a shadow warning (Warning number 44) in the default configuration. - -## Examples - -```rescript -open Belt.Float -Js.log(4.0 / 2.0 === 2.0) /* true */ -``` -*/ -external \"/": (float, float) => float = "%divfloat" diff --git a/jscomp/others/belt_HashMap.res b/jscomp/others/belt_HashMap.res deleted file mode 100644 index 38650bdee4b..00000000000 --- a/jscomp/others/belt_HashMap.res +++ /dev/null @@ -1,229 +0,0 @@ -/* ********************************************************************* */ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1996 Institut National de Recherche en Informatique et */ -/* en Automatique. All rights reserved. This file is distributed */ -/* under the terms of the GNU Library General Public License, with */ -/* the special exception on linking described in file ../LICENSE. */ -/* */ -/* Adapted by Hongbo Zhang, Authors of ReScript 2017 */ -/* ********************************************************************* */ - -module N = Belt_internalBuckets -module C = Belt_internalBucketsType -module A = Belt_Array - -type eq<'a, 'id> = Belt_Id.eq<'a, 'id> -type hash<'a, 'id> = Belt_Id.hash<'a, 'id> -type id<'a, 'id> = Belt_Id.hashable<'a, 'id> -type t<'a, 'b, 'id> = N.t, eq<'a, 'id>, 'a, 'b> - -let clear = C.clear -let size = h => h.C.size -let forEach = N.forEach -let forEachU = N.forEachU -let reduce = N.reduce -let reduceU = N.reduceU -let logStats = N.logStats -let keepMapInPlaceU = N.keepMapInPlaceU -let keepMapInPlace = N.keepMapInPlace -let toArray = N.toArray -let copy = N.copy -let keysToArray = N.keysToArray -let valuesToArray = N.valuesToArray -let getBucketHistogram = N.getBucketHistogram -let isEmpty = C.isEmpty - -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 v = C.return(cell) - switch C.toOpt(A.getUnsafe(ndata_tail, nidx)) { - | None => A.setUnsafe(h_buckets, nidx, v) - | Some(tail) => tail.N.next = v /* cell put at the end */ - } - A.setUnsafe(ndata_tail, nidx, v) - copyBucketReHash(~hash, ~h_buckets, ~ndata_tail, cell.N.next) - } - -let resize = (~hash, h) => { - let odata = h.C.buckets - let osize = A.length(odata) - let nsize = osize * 2 - if nsize >= osize { - /* no overflow */ - let h_buckets = A.makeUninitialized(nsize) - let ndata_tail = A.makeUninitialized(nsize) /* keep track of tail */ - h.C.buckets = h_buckets /* so that indexfun sees the new bucket count */ - for i in 0 to osize - 1 { - copyBucketReHash(~hash, ~h_buckets, ~ndata_tail, A.getUnsafe(odata, i)) - } - for i in 0 to nsize - 1 { - switch C.toOpt(A.getUnsafe(ndata_tail, i)) { - | None => () - | Some(tail) => tail.N.next = C.emptyOpt - } - } - } -} - -let rec replaceInBucket = (~eq, key, info, cell) => - if eq(. cell.N.key, key) { - cell.N.value = info - false - } else { - switch C.toOpt(cell.N.next) { - | None => true - | Some(cell) => 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 l = A.getUnsafe(h_buckets, i) - switch C.toOpt(l) { - | None => - A.setUnsafe(h_buckets, i, C.return({N.key, value, next: C.emptyOpt})) - h.C.size = h.C.size + 1 - | Some(bucket) => - if replaceInBucket(~eq, key, value, bucket) { - A.setUnsafe(h_buckets, i, C.return({N.key, value, next: l})) - h.C.size = h.C.size + 1 - } - } - if h.C.size > lsl(buckets_len, 1) { - resize(~hash, h) - } -} - -/* if `key` already exists, replace it, otherwise add it - Here we add it to the head, it could be tail -*/ -let set = (h, key, value) => - set0(h, key, value, ~eq=Belt_Id.getEqInternal(h.C.eq), ~hash=Belt_Id.getHashInternal(h.C.hash)) - -let rec removeInBucket = (h, h_buckets, i, key, prec, bucket, ~eq) => - switch C.toOpt(bucket) { - | None => () - | Some(cell) => - let cell_next = cell.N.next - if eq(. cell.N.key, key) { - prec.N.next = cell_next - h.C.size = h.C.size - 1 - } else { - removeInBucket(~eq, h, h_buckets, i, key, cell, cell_next) - } - } - -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 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) { - A.setUnsafe(h_buckets, i, cell.N.next) - h.C.size = h.C.size - 1 - } else { - removeInBucket(~eq, h, h_buckets, i, key, cell, cell.N.next) - } - } -} - -let rec getAux = (~eq, key, buckets) => - switch C.toOpt(buckets) { - | None => None - | Some(cell) => - if eq(. key, cell.N.key) { - Some(cell.N.value) - } else { - getAux(~eq, key, cell.N.next) - } - } - -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) - 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) { - Some(cell1.value) - } else { - switch C.toOpt(cell1.N.next) { - | None => None - | Some(cell2) => - if eq(. key, cell2.key) { - Some(cell2.value) - } else { - switch C.toOpt(cell2.next) { - | None => None - | Some(cell3) => - if eq(. key, cell3.key) { - Some(cell3.value) - } else { - getAux(~eq, key, cell3.next) - } - } - } - } - } - } -} - -let rec memInBucket = (key, cell, ~eq) => - eq(. cell.N.key, key) || - switch C.toOpt(cell.N.next) { - | None => false - | Some(nextCell) => memInBucket(~eq, key, nextCell) - } - -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 bucket = A.getUnsafe(h_buckets, nid) - switch C.toOpt(bucket) { - | None => false - | Some(bucket) => memInBucket(~eq=Belt_Id.getEqInternal(h.C.eq), key, bucket) - } -} - -let make = (type key identity, ~hintSize, ~id: id) => { - module M = unpack(id) - C.make(~hash=M.hash, ~eq=M.eq, ~hintSize) -} - -let fromArray = (type a identity, arr, ~id: id) => { - module M = unpack(id) - let (hash, eq) = (M.hash, M.eq) - let len = A.length(arr) - let v = C.make(~hash, ~eq, ~hintSize=len) - let (eq, hash) = (Belt_Id.getEqInternal(eq), Belt_Id.getHashInternal(hash)) - for i in 0 to len - 1 { - let (key, value) = A.getUnsafe(arr, i) - set0(~eq, ~hash, v, key, value) - } - v -} - -let mergeMany = (h, arr) => { - let (hash, eq) = (Belt_Id.getHashInternal(h.C.hash), Belt_Id.getEqInternal(h.C.eq)) - let len = A.length(arr) - for i in 0 to len - 1 { - let (key, value) = A.getUnsafe(arr, i) - set0(h, ~eq, ~hash, key, value) - } -} - -module Int = Belt_HashMapInt -module String = Belt_HashMapString diff --git a/jscomp/others/belt_HashMap.resi b/jscomp/others/belt_HashMap.resi deleted file mode 100644 index 972b85819f5..00000000000 --- a/jscomp/others/belt_HashMap.resi +++ /dev/null @@ -1,467 +0,0 @@ -/* Copyright (C) 2018 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -A **mutable** Hash map which allows customized [`hash`]() behavior. - -All data are parameterized by not its only type but also a unique identity in -the time of initialization, so that two _HashMaps of ints_ initialized with different -_hash_ functions will have different type. - -## Examples - -```rescript -type t = int -module I0 = unpack(Belt.Id.hashableU(~hash=(. a: t) => "&"(a, 0xff_ff), ~eq=(. a, b) => a == b)) -let s0: t<_, string, _> = make(~hintSize=40, ~id=module(I0)) - -module I1 = unpack(Belt.Id.hashableU(~hash=(. a: t) => "&"(a, 0xff), ~eq=(. a, b) => a == b)) -let s1: t<_, string, _> = make(~hintSize=40, ~id=module(I1)) -``` - -The invariant must be held: for two elements who are _equal_, -their hashed value should be the same - -Here the compiler would infer `s0` and `s1` having different type so that -it would not mix. - -## Examples - -```rescript -let s0: t -let s1: t -``` - -We can add elements to the collection: - -## Examples - -```rescript -let () = { - add(s1, 0, "3") - add(s1, 1, "3") -} -``` - -Since this is an mutable data strucure, `s1` will contain two pairs. -*/ - -/** Specalized when key type is `int`, more efficient than the generic type */ -module Int = Belt_HashMapInt - -/** Specalized when key type is `string`, more efficient than the generic type */ -module String = Belt_HashMapString - -/** The type of hash tables from type `'key` to type `'value`. */ -type t<'key, 'value, 'id> - -/** The identity needed for making an empty hash map. */ -type id<'a, 'id> = Belt_Id.hashable<'a, 'id> - -/** -`make(~hintSize=10, ~id)` creates a new map by taking in the comparator and `hintSize`. - -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let hMap = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) - -Belt.HashMap.set(hMap, 0, "a") -``` -*/ -let make: (~hintSize: int, ~id: id<'key, 'id>) => t<'key, 'value, 'id> - -/* TODO: allow randomization for security */ - -/** -Clears a hash table. - -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let hMap = Belt.HashMap.fromArray([(1, "1")], ~id=module(IntHash)) -Belt.HashMap.clear(hMap) -Belt.HashMap.isEmpty(hMap) == true -``` -*/ -let clear: t<'key, 'value, 'id> => unit - -/** -`isEmpty(m)` checks whether a hash map is empty. - -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -Belt.HashMap.isEmpty(Belt.HashMap.fromArray([(1, "1")], ~id=module(IntHash))) == false -``` -*/ -let isEmpty: t<_> => bool - -/** -`set(hMap, k, v)` if `k` does not exist, add the binding `k,v`, otherwise, update the old value with the new `v`. - -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntHash)) - -Belt.HashMap.set(s0, 2, "3") - -Belt.HashMap.valuesToArray(s0) == ["1", "3", "3"] -``` -*/ -let set: (t<'key, 'value, 'id>, 'key, 'value) => unit - -/** -Creates copy of a hash map. - -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntHash)) -let s1 = Belt.HashMap.copy(s0) - -Belt.HashMap.set(s0, 2, "3") - -Belt.HashMap.get(s0, 2) != Belt.HashMap.get(s1, 2) -``` -*/ -let copy: t<'key, 'value, 'id> => t<'key, 'value, 'id> - -/** -Returns value bound under specific key. If values not exist returns `None`. - -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") - -Belt.HashMap.get(s0, 1) == Some("value1") -Belt.HashMap.get(s0, 2) == None -``` -*/ -let get: (t<'key, 'value, 'id>, 'key) => option<'value> - -/** -Checks if `x` is bound in `tbl`. - -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") - -Belt.HashMap.has(s0, 1) == true -Belt.HashMap.has(s0, 2) == false -``` -*/ -let has: (t<'key, 'value, 'id>, 'key) => bool - -/** -If bound exists, removes it from the hash map. - -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.remove(s0, 1) -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 - -/** -`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`. - -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.forEach(s0, (key, value) => Js.log2(key, value)) -// prints (1, "value1") -``` -*/ -let forEach: (t<'key, 'value, 'id>, ('key, 'value) => unit) => unit - -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`. - -The order in which the bindings are passed to `f` is unspecified. However, if the table contains several bindings for the same key, they are passed to `f` in reverse order of introduction, that is, the most recent binding is passed first. - -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.reduce(s0, "", (acc, key, value) => acc ++ (", " ++ value)) == "value1, value2" -``` -*/ -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 - -/** -Filters out values for which function `f` returned `None`. - -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.keepMapInPlace(s0, (key, value) => key == 1 ? None : Some(value)) -``` -*/ -let keepMapInPlace: (t<'key, 'value, 'id>, ('key, 'value) => option<'value>) => unit - -/** -`size(tbl)` returns the number of bindings in `tbl`. It takes constant time. - -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.size(s0) == 2 -``` -*/ -let size: t<_> => int - -/** -Returns array of key value pairs. - -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.toArray(s0) == [(1, "value1"), (2, "value2")] -``` -*/ -let toArray: t<'key, 'value, 'id> => array<('key, 'value)> - -/** -Returns array of keys. - -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.keysToArray(s0) == [1, 2] -``` - */ -let keysToArray: t<'key, _, _> => array<'key> - -/** -Returns array of values. - -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.set(s0, 2, "value2") - -Belt.HashMap.valuesToArray(s0) == ["value1", "value2"] -``` -*/ -let valuesToArray: t<_, 'value, _> => array<'value> - -/** -Creates new hash map from array of pairs. - -Returns array of values. - -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let s0 = Belt.HashMap.fromArray([(1, "value1"), (2, "value2")], ~id=module(IntHash)) -Belt.HashMap.toArray(s0) == [(1, "value1"), (2, "value2")] -``` -*/ -let fromArray: (array<('key, 'value)>, ~id: id<'key, 'id>) => t<'key, 'value, 'id> - -/** -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) - -let hMap = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.mergeMany(hMap, [(1, "1"), (2, "2")]) -``` -*/ -let mergeMany: (t<'key, 'value, 'id>, array<('key, 'value)>) => unit - -/** -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) -let hMap = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(hMap, 1, "1") - -Belt.HashMap.getBucketHistogram(hMap) -``` -*/ -let getBucketHistogram: t<_> => array - -/** -## Examples - -```rescript -module IntHash = Belt.Id.MakeHashable({ - type t = int - let hash = a => a - let eq = (a, b) => a == b -}) -let hMap = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) -Belt.HashMap.set(hMap, 1, "1") - -Belt.HashMap.logStats(hMap) -``` -*/ -let logStats: t<_> => unit diff --git a/jscomp/others/belt_HashMapInt.res b/jscomp/others/belt_HashMapInt.res deleted file mode 100644 index 0c19f8c3f26..00000000000 --- a/jscomp/others/belt_HashMapInt.res +++ /dev/null @@ -1,215 +0,0 @@ -/* ********************************************************************* */ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1996 Institut National de Recherche en Informatique et */ -/* en Automatique. All rights reserved. This file is distributed */ -/* under the terms of the GNU Library General Public License, with */ -/* the special exception on linking described in file ../LICENSE. */ -/* */ -/* ********************************************************************* */ - -/* Adapted by Hongbo Zhang, Authors of ReScript 2017 */ - -type key = int -type seed = int -external caml_hash_mix_int: (seed, int) => seed = "?hash_mix_int" -external final_mix: seed => seed = "?hash_final_mix" -let hash = (s: key) => final_mix(caml_hash_mix_int(0, s)) - -module N = Belt_internalBuckets -module C = Belt_internalBucketsType -module A = Belt_Array - -type t<'b> = N.t - -let rec copyBucketReHash = (~h_buckets, ~ndata_tail, old_bucket: C.opt>) => - switch C.toOpt(old_bucket) { - | None => () - | Some(cell) => - let nidx = land(hash(cell.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) - | Some(tail) => tail.N.next = v /* cell put at the end */ - } - A.setUnsafe(ndata_tail, nidx, v) - copyBucketReHash(~h_buckets, ~ndata_tail, cell.next) - } - -let resize = h => { - let odata = h.C.buckets - let osize = A.length(odata) - let nsize = osize * 2 - if nsize >= osize { - /* no overflow */ - let h_buckets = A.makeUninitialized(nsize) - let ndata_tail = A.makeUninitialized(nsize) /* keep track of tail */ - h.C.buckets = h_buckets /* so that indexfun sees the new bucket count */ - for i in 0 to osize - 1 { - copyBucketReHash(~h_buckets, ~ndata_tail, A.getUnsafe(odata, i)) - } - for i in 0 to nsize - 1 { - switch C.toOpt(A.getUnsafe(ndata_tail, i)) { - | None => () - | Some(tail) => tail.next = C.emptyOpt - } - } - } -} - -let rec replaceInBucket = (key: key, info, cell) => - if cell.N.key == key { - cell.N.value = info - false - } else { - switch C.toOpt(cell.next) { - | None => true - | Some(cell) => replaceInBucket(key, info, cell) - } - } - -let set = (h, key: key, value) => { - let h_buckets = h.C.buckets - let buckets_len = A.length(h_buckets) - let i = land(hash(key), buckets_len - 1) - let l = A.getUnsafe(h_buckets, i) - switch C.toOpt(l) { - | None => - A.setUnsafe(h_buckets, i, C.return({N.key, value, next: C.emptyOpt})) - h.C.size = h.C.size + 1 - | Some(bucket) => - if replaceInBucket(key, value, bucket) { - A.setUnsafe(h_buckets, i, C.return({N.key, value, next: l})) - h.C.size = h.C.size + 1 - } - } - if h.C.size > lsl(buckets_len, 1) { - resize(h) - } -} - -let rec removeInBucket = (h, h_buckets, i, key: key, prec, buckets) => - switch C.toOpt(buckets) { - | None => () - | Some(cell) => - let cell_next = cell.N.next - if cell.N.key == key { - prec.N.next = cell_next - h.C.size = h.C.size - 1 - } else { - removeInBucket(h, h_buckets, i, key, cell, cell_next) - } - } - -let remove = (h, key) => { - let h_buckets = h.C.buckets - let i = land(hash(key), A.length(h_buckets) - 1) - let bucket = A.getUnsafe(h_buckets, i) - switch C.toOpt(bucket) { - | None => () - | Some(cell) => - if cell.N.key == key { - A.setUnsafe(h_buckets, i, cell.next) - h.C.size = h.C.size - 1 - } else { - removeInBucket(h, h_buckets, i, key, cell, cell.next) - } - } -} - -let rec getAux = (key: key, buckets) => - switch C.toOpt(buckets) { - | None => None - | Some(cell) => - if key == cell.N.key { - Some(cell.N.value) - } else { - getAux(key, cell.next) - } - } - -let get = (h, key: key) => { - let h_buckets = h.C.buckets - let nid = land(hash(key), A.length(h_buckets) - 1) - switch C.toOpt(A.getUnsafe(h_buckets, nid)) { - | None => None - | Some(cell1) => - if key == cell1.N.key { - Some(cell1.N.value) - } else { - switch C.toOpt(cell1.N.next) { - | None => None - | Some(cell2) => - if key == cell2.N.key { - Some(cell2.N.value) - } else { - switch C.toOpt(cell2.N.next) { - | None => None - | Some(cell3) => - if key == cell3.N.key { - Some(cell3.N.value) - } else { - getAux(key, cell3.N.next) - } - } - } - } - } - } -} - -let rec memInBucket = (key: key, cell) => - cell.N.key == key || - switch C.toOpt(cell.next) { - | None => false - | Some(nextCell) => memInBucket(key, nextCell) - } - -let has = (h, key) => { - let h_buckets = h.C.buckets - let nid = land(hash(key), A.length(h_buckets) - 1) - let bucket = A.getUnsafe(h_buckets, nid) - switch C.toOpt(bucket) { - | None => false - | Some(bucket) => memInBucket(key, bucket) - } -} - -let make = (~hintSize) => C.make(~hintSize, ~hash=(), ~eq=()) -let clear = C.clear -let size = h => h.C.size -let forEachU = N.forEachU -let forEach = N.forEach -let reduceU = N.reduceU -let reduce = N.reduce -let logStats = N.logStats -let keepMapInPlaceU = N.keepMapInPlaceU -let keepMapInPlace = N.keepMapInPlace -let toArray = N.toArray -let copy = N.copy -let keysToArray = N.keysToArray -let valuesToArray = N.valuesToArray -let getBucketHistogram = N.getBucketHistogram -let isEmpty = C.isEmpty - -let fromArray = arr => { - let len = A.length(arr) - let v = make(~hintSize=len) - for i in 0 to len - 1 { - let (k, value) = A.getUnsafe(arr, i) - set(v, k, value) - } - v -} - -/* TOOD: optimize heuristics for resizing */ -let mergeMany = (h, arr) => { - let len = A.length(arr) - for i in 0 to len - 1 { - let (k, v) = A.getUnsafe(arr, i) - set(h, k, v) - } -} diff --git a/jscomp/others/belt_HashMapInt.resi b/jscomp/others/belt_HashMapInt.resi deleted file mode 100644 index 67ea5023469..00000000000 --- a/jscomp/others/belt_HashMapInt.resi +++ /dev/null @@ -1,41 +0,0 @@ -type key = int - -type t<'b> - -let make: (~hintSize: int) => t<'b> - -let clear: t<'b> => unit - -let isEmpty: t<_> => bool - -/** -`setDone(tbl, k, v)` if `k` does not exist, add the binding `k,v`, otherwise, -update the old value with the new `v` -*/ -let set: (t<'a>, key, 'a) => unit - -let copy: t<'a> => t<'a> -let get: (t<'a>, key) => option<'a> - -let has: (t<'b>, key) => bool - -let remove: (t<'a>, key) => 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 reduce: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c - -let keepMapInPlaceU: (t<'a>, (. key, 'a) => option<'a>) => unit -let keepMapInPlace: (t<'a>, (key, 'a) => option<'a>) => unit - -let size: t<_> => int - -let toArray: t<'a> => array<(key, 'a)> -let keysToArray: t<'a> => array -let valuesToArray: t<'a> => array<'a> -let fromArray: array<(key, 'a)> => t<'a> -let mergeMany: (t<'a>, array<(key, 'a)>) => unit -let getBucketHistogram: t<_> => array -let logStats: t<_> => unit diff --git a/jscomp/others/belt_HashMapString.res b/jscomp/others/belt_HashMapString.res deleted file mode 100644 index c4959dd4162..00000000000 --- a/jscomp/others/belt_HashMapString.res +++ /dev/null @@ -1,215 +0,0 @@ -/* ********************************************************************* */ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1996 Institut National de Recherche en Informatique et */ -/* en Automatique. All rights reserved. This file is distributed */ -/* under the terms of the GNU Library General Public License, with */ -/* the special exception on linking described in file ../LICENSE. */ -/* */ -/* ********************************************************************* */ - -/* Adapted by Hongbo Zhang, Authors of ReScript 2017 */ - -type key = string -type seed = int -external caml_hash_mix_string: (seed, string) => seed = "?hash_mix_string" -external final_mix: seed => seed = "?hash_final_mix" -let hash = (s: key) => final_mix(caml_hash_mix_string(0, s)) - -module N = Belt_internalBuckets -module C = Belt_internalBucketsType -module A = Belt_Array - -type t<'b> = N.t - -let rec copyBucketReHash = (~h_buckets, ~ndata_tail, old_bucket: C.opt>) => - switch C.toOpt(old_bucket) { - | None => () - | Some(cell) => - let nidx = land(hash(cell.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) - | Some(tail) => tail.N.next = v /* cell put at the end */ - } - A.setUnsafe(ndata_tail, nidx, v) - copyBucketReHash(~h_buckets, ~ndata_tail, cell.next) - } - -let resize = h => { - let odata = h.C.buckets - let osize = A.length(odata) - let nsize = osize * 2 - if nsize >= osize { - /* no overflow */ - let h_buckets = A.makeUninitialized(nsize) - let ndata_tail = A.makeUninitialized(nsize) /* keep track of tail */ - h.C.buckets = h_buckets /* so that indexfun sees the new bucket count */ - for i in 0 to osize - 1 { - copyBucketReHash(~h_buckets, ~ndata_tail, A.getUnsafe(odata, i)) - } - for i in 0 to nsize - 1 { - switch C.toOpt(A.getUnsafe(ndata_tail, i)) { - | None => () - | Some(tail) => tail.next = C.emptyOpt - } - } - } -} - -let rec replaceInBucket = (key: key, info, cell) => - if cell.N.key == key { - cell.N.value = info - false - } else { - switch C.toOpt(cell.next) { - | None => true - | Some(cell) => replaceInBucket(key, info, cell) - } - } - -let set = (h, key: key, value) => { - let h_buckets = h.C.buckets - let buckets_len = A.length(h_buckets) - let i = land(hash(key), buckets_len - 1) - let l = A.getUnsafe(h_buckets, i) - switch C.toOpt(l) { - | None => - A.setUnsafe(h_buckets, i, C.return({N.key, value, next: C.emptyOpt})) - h.C.size = h.C.size + 1 - | Some(bucket) => - if replaceInBucket(key, value, bucket) { - A.setUnsafe(h_buckets, i, C.return({N.key, value, next: l})) - h.C.size = h.C.size + 1 - } - } - if h.C.size > lsl(buckets_len, 1) { - resize(h) - } -} - -let rec removeInBucket = (h, h_buckets, i, key: key, prec, buckets) => - switch C.toOpt(buckets) { - | None => () - | Some(cell) => - let cell_next = cell.N.next - if cell.N.key == key { - prec.N.next = cell_next - h.C.size = h.C.size - 1 - } else { - removeInBucket(h, h_buckets, i, key, cell, cell_next) - } - } - -let remove = (h, key) => { - let h_buckets = h.C.buckets - let i = land(hash(key), A.length(h_buckets) - 1) - let bucket = A.getUnsafe(h_buckets, i) - switch C.toOpt(bucket) { - | None => () - | Some(cell) => - if cell.N.key == key { - A.setUnsafe(h_buckets, i, cell.next) - h.C.size = h.C.size - 1 - } else { - removeInBucket(h, h_buckets, i, key, cell, cell.next) - } - } -} - -let rec getAux = (key: key, buckets) => - switch C.toOpt(buckets) { - | None => None - | Some(cell) => - if key == cell.N.key { - Some(cell.N.value) - } else { - getAux(key, cell.next) - } - } - -let get = (h, key: key) => { - let h_buckets = h.C.buckets - let nid = land(hash(key), A.length(h_buckets) - 1) - switch C.toOpt(A.getUnsafe(h_buckets, nid)) { - | None => None - | Some(cell1) => - if key == cell1.N.key { - Some(cell1.N.value) - } else { - switch C.toOpt(cell1.N.next) { - | None => None - | Some(cell2) => - if key == cell2.N.key { - Some(cell2.N.value) - } else { - switch C.toOpt(cell2.N.next) { - | None => None - | Some(cell3) => - if key == cell3.N.key { - Some(cell3.N.value) - } else { - getAux(key, cell3.N.next) - } - } - } - } - } - } -} - -let rec memInBucket = (key: key, cell) => - cell.N.key == key || - switch C.toOpt(cell.next) { - | None => false - | Some(nextCell) => memInBucket(key, nextCell) - } - -let has = (h, key) => { - let h_buckets = h.C.buckets - let nid = land(hash(key), A.length(h_buckets) - 1) - let bucket = A.getUnsafe(h_buckets, nid) - switch C.toOpt(bucket) { - | None => false - | Some(bucket) => memInBucket(key, bucket) - } -} - -let make = (~hintSize) => C.make(~hintSize, ~hash=(), ~eq=()) -let clear = C.clear -let size = h => h.C.size -let forEachU = N.forEachU -let forEach = N.forEach -let reduceU = N.reduceU -let reduce = N.reduce -let logStats = N.logStats -let keepMapInPlaceU = N.keepMapInPlaceU -let keepMapInPlace = N.keepMapInPlace -let toArray = N.toArray -let copy = N.copy -let keysToArray = N.keysToArray -let valuesToArray = N.valuesToArray -let getBucketHistogram = N.getBucketHistogram -let isEmpty = C.isEmpty - -let fromArray = arr => { - let len = A.length(arr) - let v = make(~hintSize=len) - for i in 0 to len - 1 { - let (k, value) = A.getUnsafe(arr, i) - set(v, k, value) - } - v -} - -/* TOOD: optimize heuristics for resizing */ -let mergeMany = (h, arr) => { - let len = A.length(arr) - for i in 0 to len - 1 { - let (k, v) = A.getUnsafe(arr, i) - set(h, k, v) - } -} diff --git a/jscomp/others/belt_HashMapString.resi b/jscomp/others/belt_HashMapString.resi deleted file mode 100644 index be4cf461aef..00000000000 --- a/jscomp/others/belt_HashMapString.resi +++ /dev/null @@ -1,41 +0,0 @@ -type key = string - -type t<'b> - -let make: (~hintSize: int) => t<'b> - -let clear: t<'b> => unit - -let isEmpty: t<_> => bool - -/** -`setDone(tbl, k, v)` if `k` does not exist, add the binding `k,v`, otherwise, -update the old value with the new `v` -*/ -let set: (t<'a>, key, 'a) => unit - -let copy: t<'a> => t<'a> -let get: (t<'a>, key) => option<'a> - -let has: (t<'b>, key) => bool - -let remove: (t<'a>, key) => 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 reduce: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c - -let keepMapInPlaceU: (t<'a>, (. key, 'a) => option<'a>) => unit -let keepMapInPlace: (t<'a>, (key, 'a) => option<'a>) => unit - -let size: t<_> => int - -let toArray: t<'a> => array<(key, 'a)> -let keysToArray: t<'a> => array -let valuesToArray: t<'a> => array<'a> -let fromArray: array<(key, 'a)> => t<'a> -let mergeMany: (t<'a>, array<(key, 'a)>) => unit -let getBucketHistogram: t<_> => array -let logStats: t<_> => unit diff --git a/jscomp/others/belt_HashSet.res b/jscomp/others/belt_HashSet.res deleted file mode 100644 index f4d0a701233..00000000000 --- a/jscomp/others/belt_HashSet.res +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -module Int = Belt_HashSetInt - -module String = Belt_HashSetString - -module N = Belt_internalSetBuckets -module C = Belt_internalBucketsType -module A = Belt_Array - -type eq<'a, 'id> = Belt_Id.eq<'a, 'id> -type hash<'a, 'id> = Belt_Id.hash<'a, 'id> -type id<'a, 'id> = Belt_Id.hashable<'a, 'id> - -type t<'a, 'id> = N.t, eq<'a, 'id>, 'a> - -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 v = C.return(cell) - switch C.toOpt(A.getUnsafe(ndata_tail, nidx)) { - | None => A.setUnsafe(h_buckets, nidx, v) - | Some(tail) => tail.N.next = v /* cell put at the end */ - } - A.setUnsafe(ndata_tail, nidx, v) - copyBucket(~hash, ~h_buckets, ~ndata_tail, cell.N.next) - } - -let tryDoubleResize = (~hash, h) => { - let odata = h.C.buckets - let osize = A.length(odata) - let nsize = osize * 2 - if nsize >= osize { - /* no overflow */ - let h_buckets = A.makeUninitialized(nsize) - let ndata_tail = A.makeUninitialized(nsize) /* keep track of tail */ - h.buckets = h_buckets /* so that indexfun sees the new bucket count */ - for i in 0 to osize - 1 { - copyBucket(~hash, ~h_buckets, ~ndata_tail, A.getUnsafe(odata, i)) - } - for i in 0 to nsize - 1 { - switch C.toOpt(A.getUnsafe(ndata_tail, i)) { - | None => () - | Some(tail) => tail.N.next = C.emptyOpt - } - } - } -} - -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) { - prec.N.next = cell_next - h.C.size = h.C.size - 1 - } else { - switch C.toOpt(cell_next) { - | None => () - | Some(cell_next) => removeBucket(~eq, h, h_buckets, i, key, cell, cell_next) - } - } -} - -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 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) { - h.C.size = h.C.size - 1 - A.setUnsafe(h_buckets, i, next_cell) - } else { - switch C.toOpt(next_cell) { - | None => () - | Some(next_cell) => removeBucket(~eq, h, h_buckets, i, key, cell, next_cell) - } - } - } -} - -let rec addBucket = (h, key, cell, ~eq) => - if !Belt_Id.getEqInternal(eq)(. cell.N.key, key) { - let n = cell.N.next - switch C.toOpt(n) { - | None => - h.C.size = h.C.size + 1 - cell.N.next = C.return({N.key, next: C.emptyOpt}) - | Some(n) => addBucket(~eq, h, key, n) - } - } - -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 l = A.getUnsafe(h_buckets, i) - switch C.toOpt(l) { - | None => - h.C.size = h.C.size + 1 - A.setUnsafe(h_buckets, i, C.return({N.key, next: C.emptyOpt})) - | Some(cell) => addBucket(~eq, h, key, cell) - } - if h.C.size > lsl(buckets_len, 1) { - tryDoubleResize(~hash, h) - } -} - -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) || - switch C.toOpt(cell.N.next) { - | None => false - | Some(nextCell) => memInBucket(~eq, key, nextCell) - } - -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 bucket = A.getUnsafe(h_buckets, nid) - switch C.toOpt(bucket) { - | None => false - | Some(bucket) => memInBucket(~eq, key, bucket) - } -} - -let make = (type value identity, ~hintSize, ~id: id) => { - module M = unpack(id) - C.make(~hintSize, ~hash=M.hash, ~eq=M.eq) -} - -let clear = C.clear -let size = h => h.C.size -let forEachU = N.forEachU -let forEach = N.forEach -let reduceU = N.reduceU -let reduce = N.reduce -let logStats = N.logStats -let toArray = N.toArray -let copy = N.copy -let getBucketHistogram = N.getBucketHistogram -let isEmpty = C.isEmpty - -let fromArray = (type a identity, arr, ~id: id) => { - module M = unpack(id) - let (eq, hash) = (M.eq, M.hash) - let len = A.length(arr) - let v = C.make(~hintSize=len, ~hash, ~eq) - for i in 0 to len - 1 { - add0(~eq, ~hash, v, A.getUnsafe(arr, i)) - } - v -} - -let mergeMany = (h, arr) => { - let (eq, hash) = (h.C.eq, h.hash) - let len = A.length(arr) - for i in 0 to len - 1 { - add0(h, ~eq, ~hash, A.getUnsafe(arr, i)) - } -} diff --git a/jscomp/others/belt_HashSet.resi b/jscomp/others/belt_HashSet.resi deleted file mode 100644 index 6055194a489..00000000000 --- a/jscomp/others/belt_HashSet.resi +++ /dev/null @@ -1,122 +0,0 @@ -/* Copyright (C) 2018 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -A **mutable** Hash set which allows customized `hash` behavior. - -All data are parameterized by not its only type but also a unique identity in -the time of initialization, so that two _HashSets of ints_ initialized with -different _hash_ functions will have different type. - -## Examples - -```rescript -module I0 = unpack( - Belt.Id.hashableU( - ~hash=(. a: int) => land(a, 65535), - ~eq=(. a, b) => a == b, - ) -) - -let s0 = Belt.HashSet.make(~id=module(I0), ~hintSize=40) - -module I1 = unpack( - Belt.Id.hashableU( - ~hash=(. a: int) => land(a, 255), - ~eq=(. a, b) => a == b, - ) -) - -let s1 = Belt.HashSet.make(~id=module(I1), ~hintSize=40) - -Belt.HashSet.add(s1, 0) -Belt.HashSet.add(s1, 1) -``` - -The invariant must be held: for two elements who are equal, their hashed -value should be the same. - -Here the compiler would infer `s0` and `s1` having different type so that it -would not mix. - -## Examples - -```rescript -let s0: Belt.HashSet.t -let s1: Belt.HashSet.t -``` - -We can add elements to the collection (see last two lines in the example -above). Since this is an mutable data structure, `s1` will contain two pairs. -*/ - -/** Specalized when key type is `int`, more efficient than the generic type */ -module Int = Belt_HashSetInt - -/** Specalized when key type is `string`, more efficient than the generic type */ -module String = Belt_HashSetString - -/* TODO: add a poly module - module Poly = Belt_HashSetPoly - challenge: - - generic equal handles JS data structure - - eq/hash consistent -*/ - -type t<'a, 'id> - -/** The type of hash tables from type `'a` to type `'b`. */ -type id<'a, 'id> = Belt_Id.hashable<'a, 'id> - -let make: (~hintSize: int, ~id: id<'a, 'id>) => t<'a, 'id> -let clear: t<'a, 'id> => unit -let isEmpty: t<_> => bool - -let add: (t<'a, 'id>, 'a) => unit - -let copy: t<'a, 'id> => t<'a, 'id> - -let has: (t<'a, 'id>, 'a) => bool - -let remove: (t<'a, 'id>, 'a) => 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 -/** Order unspecified. */ -let reduce: (t<'a, 'id>, 'c, ('c, 'a) => 'c) => 'c - -let size: t<'a, 'id> => int - -let logStats: t<_> => unit - -let toArray: t<'a, 'id> => array<'a> - -let fromArray: (array<'a>, ~id: id<'a, 'id>) => t<'a, 'id> - -let mergeMany: (t<'a, 'id>, array<'a>) => unit - -let getBucketHistogram: t<_> => array diff --git a/jscomp/others/belt_HashSetInt.res b/jscomp/others/belt_HashSetInt.res deleted file mode 100644 index f8ad65c999f..00000000000 --- a/jscomp/others/belt_HashSetInt.res +++ /dev/null @@ -1,154 +0,0 @@ -type key = int -type seed = int -external caml_hash_mix_int: (seed, int) => seed = "?hash_mix_int" -external final_mix: seed => seed = "?hash_final_mix" -let hash = (s: key) => final_mix(caml_hash_mix_int(0, s)) - -module N = Belt_internalSetBuckets -module C = Belt_internalBucketsType -module A = Belt_Array - -type t = N.t - -let rec copyBucket = (~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 v = C.return(cell) - switch C.toOpt(A.getUnsafe(ndata_tail, nidx)) { - | None => A.setUnsafe(h_buckets, nidx, v) - | Some(tail) => tail.N.next = v /* cell put at the end */ - } - A.setUnsafe(ndata_tail, nidx, v) - copyBucket(~h_buckets, ~ndata_tail, cell.N.next) - } - -let tryDoubleResize = h => { - let odata = h.C.buckets - let osize = A.length(odata) - let nsize = osize * 2 - if nsize >= osize { - /* no overflow */ - let h_buckets = A.makeUninitialized(nsize) - let ndata_tail = A.makeUninitialized(nsize) /* keep track of tail */ - h.C.buckets = h_buckets /* so that indexfun sees the new bucket count */ - for i in 0 to osize - 1 { - copyBucket(~h_buckets, ~ndata_tail, A.getUnsafe(odata, i)) - } - for i in 0 to nsize - 1 { - switch C.toOpt(A.getUnsafe(ndata_tail, i)) { - | None => () - | Some(tail) => tail.N.next = C.emptyOpt - } - } - } -} - -let rec removeBucket = (h, h_buckets, i, key: key, prec, cell) => { - let cell_next = cell.N.next - if cell.N.key == key { - prec.N.next = cell_next - h.C.size = h.C.size - 1 - } else { - switch C.toOpt(cell_next) { - | None => () - | Some(cell_next) => removeBucket(h, h_buckets, i, key, cell, cell_next) - } - } -} - -let remove = (h, key: key) => { - let h_buckets = h.C.buckets - let i = land(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 cell.N.key == key { - h.C.size = h.C.size - 1 - A.setUnsafe(h_buckets, i, next_cell) - } else { - switch C.toOpt(next_cell) { - | None => () - | Some(next_cell) => removeBucket(h, h_buckets, i, key, cell, next_cell) - } - } - } -} - -let rec addBucket = (h, key: key, cell) => - if cell.N.key != key { - let n = cell.N.next - switch C.toOpt(n) { - | None => - h.C.size = h.C.size + 1 - cell.N.next = C.return({N.key, next: C.emptyOpt}) - | Some(n) => addBucket(h, key, n) - } - } - -let add = (h, key: key) => { - let h_buckets = h.C.buckets - let buckets_len = A.length(h_buckets) - let i = land(hash(key), buckets_len - 1) - let l = A.getUnsafe(h_buckets, i) - switch C.toOpt(l) { - | None => - A.setUnsafe(h_buckets, i, C.return({N.key, next: C.emptyOpt})) - h.C.size = h.C.size + 1 - | Some(cell) => addBucket(h, key, cell) - } - if h.C.size > lsl(buckets_len, 1) { - tryDoubleResize(h) - } -} - -let rec memInBucket = (key: key, cell) => - cell.N.key == key || - switch C.toOpt(cell.N.next) { - | None => false - | Some(nextCell) => memInBucket(key, nextCell) - } - -let has = (h, key) => { - let h_buckets = h.C.buckets - let nid = land(hash(key), A.length(h_buckets) - 1) - let bucket = A.getUnsafe(h_buckets, nid) - switch C.toOpt(bucket) { - | None => false - | Some(bucket) => memInBucket(key, bucket) - } -} - -let make = (~hintSize) => C.make(~hintSize, ~hash=(), ~eq=()) - -let clear = C.clear -let size = h => h.C.size -let forEachU = N.forEachU -let forEach = N.forEach -let reduceU = N.reduceU -let reduce = N.reduce -let logStats = N.logStats -let toArray = N.toArray -let copy = N.copy -let getBucketHistogram = N.getBucketHistogram -let isEmpty = C.isEmpty - -let fromArray = arr => { - let len = A.length(arr) - let v = C.make(~hintSize=len, ~hash=(), ~eq=()) - for i in 0 to len - 1 { - add(v, A.getUnsafe(arr, i)) - } - v -} - -/* TOOD: optimize heuristics for resizing */ -let mergeMany = (h, arr) => { - let len = A.length(arr) - for i in 0 to len - 1 { - add(h, A.getUnsafe(arr, i)) - } -} diff --git a/jscomp/others/belt_HashSetInt.resi b/jscomp/others/belt_HashSetInt.resi deleted file mode 100644 index 05325e845ad..00000000000 --- a/jscomp/others/belt_HashSetInt.resi +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -This module is [`Belt.HashSet`]() specialized with key type to be a primitive type. - -It is more efficient in general, the API is the same with [`Belt.HashSet`]() except its key type is fixed, -and identity is not needed(using the built-in one) - -**See** [`Belt.HashSet`]() -*/ - -type key = int - -type t - -let make: (~hintSize: int) => t - -let clear: t => unit - -let isEmpty: t => bool - -let add: (t, key) => unit - -let copy: t => t - -let has: (t, key) => bool - -let remove: (t, key) => unit - -let forEachU: (t, (. key) => unit) => unit -let forEach: (t, key => unit) => unit - -let reduceU: (t, 'c, (. 'c, key) => 'c) => 'c -let reduce: (t, 'c, ('c, key) => 'c) => 'c - -let size: t => int - -let logStats: t => unit - -let toArray: t => array - -let fromArray: array => t - -let mergeMany: (t, array) => unit - -let getBucketHistogram: t => array diff --git a/jscomp/others/belt_HashSetString.res b/jscomp/others/belt_HashSetString.res deleted file mode 100644 index be19839c247..00000000000 --- a/jscomp/others/belt_HashSetString.res +++ /dev/null @@ -1,154 +0,0 @@ -type key = string -type seed = int -external caml_hash_mix_string: (seed, string) => seed = "?hash_mix_string" -external final_mix: seed => seed = "?hash_final_mix" -let hash = (s: key) => final_mix(caml_hash_mix_string(0, s)) - -module N = Belt_internalSetBuckets -module C = Belt_internalBucketsType -module A = Belt_Array - -type t = N.t - -let rec copyBucket = (~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 v = C.return(cell) - switch C.toOpt(A.getUnsafe(ndata_tail, nidx)) { - | None => A.setUnsafe(h_buckets, nidx, v) - | Some(tail) => tail.N.next = v /* cell put at the end */ - } - A.setUnsafe(ndata_tail, nidx, v) - copyBucket(~h_buckets, ~ndata_tail, cell.N.next) - } - -let tryDoubleResize = h => { - let odata = h.C.buckets - let osize = A.length(odata) - let nsize = osize * 2 - if nsize >= osize { - /* no overflow */ - let h_buckets = A.makeUninitialized(nsize) - let ndata_tail = A.makeUninitialized(nsize) /* keep track of tail */ - h.C.buckets = h_buckets /* so that indexfun sees the new bucket count */ - for i in 0 to osize - 1 { - copyBucket(~h_buckets, ~ndata_tail, A.getUnsafe(odata, i)) - } - for i in 0 to nsize - 1 { - switch C.toOpt(A.getUnsafe(ndata_tail, i)) { - | None => () - | Some(tail) => tail.N.next = C.emptyOpt - } - } - } -} - -let rec removeBucket = (h, h_buckets, i, key: key, prec, cell) => { - let cell_next = cell.N.next - if cell.N.key == key { - prec.N.next = cell_next - h.C.size = h.C.size - 1 - } else { - switch C.toOpt(cell_next) { - | None => () - | Some(cell_next) => removeBucket(h, h_buckets, i, key, cell, cell_next) - } - } -} - -let remove = (h, key: key) => { - let h_buckets = h.C.buckets - let i = land(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 cell.N.key == key { - h.C.size = h.C.size - 1 - A.setUnsafe(h_buckets, i, next_cell) - } else { - switch C.toOpt(next_cell) { - | None => () - | Some(next_cell) => removeBucket(h, h_buckets, i, key, cell, next_cell) - } - } - } -} - -let rec addBucket = (h, key: key, cell) => - if cell.N.key != key { - let n = cell.N.next - switch C.toOpt(n) { - | None => - h.C.size = h.C.size + 1 - cell.N.next = C.return({N.key, next: C.emptyOpt}) - | Some(n) => addBucket(h, key, n) - } - } - -let add = (h, key: key) => { - let h_buckets = h.C.buckets - let buckets_len = A.length(h_buckets) - let i = land(hash(key), buckets_len - 1) - let l = A.getUnsafe(h_buckets, i) - switch C.toOpt(l) { - | None => - A.setUnsafe(h_buckets, i, C.return({N.key, next: C.emptyOpt})) - h.C.size = h.C.size + 1 - | Some(cell) => addBucket(h, key, cell) - } - if h.C.size > lsl(buckets_len, 1) { - tryDoubleResize(h) - } -} - -let rec memInBucket = (key: key, cell) => - cell.N.key == key || - switch C.toOpt(cell.N.next) { - | None => false - | Some(nextCell) => memInBucket(key, nextCell) - } - -let has = (h, key) => { - let h_buckets = h.C.buckets - let nid = land(hash(key), A.length(h_buckets) - 1) - let bucket = A.getUnsafe(h_buckets, nid) - switch C.toOpt(bucket) { - | None => false - | Some(bucket) => memInBucket(key, bucket) - } -} - -let make = (~hintSize) => C.make(~hintSize, ~hash=(), ~eq=()) - -let clear = C.clear -let size = h => h.C.size -let forEachU = N.forEachU -let forEach = N.forEach -let reduceU = N.reduceU -let reduce = N.reduce -let logStats = N.logStats -let toArray = N.toArray -let copy = N.copy -let getBucketHistogram = N.getBucketHistogram -let isEmpty = C.isEmpty - -let fromArray = arr => { - let len = A.length(arr) - let v = C.make(~hintSize=len, ~hash=(), ~eq=()) - for i in 0 to len - 1 { - add(v, A.getUnsafe(arr, i)) - } - v -} - -/* TOOD: optimize heuristics for resizing */ -let mergeMany = (h, arr) => { - let len = A.length(arr) - for i in 0 to len - 1 { - add(h, A.getUnsafe(arr, i)) - } -} diff --git a/jscomp/others/belt_HashSetString.resi b/jscomp/others/belt_HashSetString.resi deleted file mode 100644 index 3c2532f4186..00000000000 --- a/jscomp/others/belt_HashSetString.resi +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -This module is [`Belt.HashSet`]() specialized with key type to be a primitive type. - -It is more efficient in general, the API is the same with [`Belt.HashSet`]() except its key type is fixed, -and identity is not needed(using the built-in one) - -**See** [`Belt.HashSet`]() -*/ - -type key = string - -type t - -let make: (~hintSize: int) => t - -let clear: t => unit - -let isEmpty: t => bool - -let add: (t, key) => unit - -let copy: t => t - -let has: (t, key) => bool - -let remove: (t, key) => unit - -let forEachU: (t, (. key) => unit) => unit -let forEach: (t, key => unit) => unit - -let reduceU: (t, 'c, (. 'c, key) => 'c) => 'c -let reduce: (t, 'c, ('c, key) => 'c) => 'c - -let size: t => int - -let logStats: t => unit - -let toArray: t => array - -let fromArray: array => t - -let mergeMany: (t, array) => unit - -let getBucketHistogram: t => array diff --git a/jscomp/others/belt_Id.res b/jscomp/others/belt_Id.res deleted file mode 100644 index 7fc993eb768..00000000000 --- a/jscomp/others/belt_Id.res +++ /dev/null @@ -1,137 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -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" - -module type Comparable = { - type identity - type t - let cmp: cmp -} - -type comparable<'key, 'id> = module(Comparable with type t = 'key and type identity = 'id) - -module MakeComparableU = ( - M: { - type t - let cmp: (. t, t) => int - }, -) => { - type identity - include M -} - -module MakeComparable = ( - M: { - type t - let cmp: (t, t) => int - }, -) => { - type identity - type t = M.t - /* see https://github.com/rescript-lang/rescript-compiler/pull/2589/files/5ef875b7665ee08cfdc59af368fc52bac1fe9130#r173330825 */ - let cmp = { - let cmp = M.cmp - (. a, b) => cmp(a, b) - } -} - -let comparableU = (type key, ~cmp): module(Comparable with type t = key) => - module( - MakeComparableU({ - type t = key - let cmp = cmp - }) - ) - -let comparable = (type key, ~cmp) => { - module N = MakeComparable({ - type t = key - let cmp = cmp - }) - module(N: Comparable with type t = key) -} - -module type Hashable = { - type identity - type t - let hash: hash - let eq: eq -} - -type hashable<'key, 'id> = module(Hashable with type t = 'key and type identity = 'id) - -module MakeHashableU = ( - M: { - type t - let hash: (. t) => int - let eq: (. t, t) => bool - }, -) => { - type identity - include M -} - -module MakeHashable = ( - M: { - type t - let hash: t => int - let eq: (t, t) => bool - }, -) => { - type identity - type t = M.t - let hash = { - let hash = M.hash - (. a) => hash(a) - } - let eq = { - let eq = M.eq - (. a, b) => eq(a, b) - } -} - -let hashableU = (type key, ~hash, ~eq): module(Hashable with type t = key) => - module( - MakeHashableU({ - type t = key - let hash = hash - let eq = eq - }) - ) - -let hashable = (type key, ~hash, ~eq) => { - module N = MakeHashable({ - type t = key - let hash = hash - let eq = eq - }) - module(N: Hashable with type t = key) -} diff --git a/jscomp/others/belt_Id.resi b/jscomp/others/belt_Id.resi deleted file mode 100644 index 72aecc42740..00000000000 --- a/jscomp/others/belt_Id.resi +++ /dev/null @@ -1,149 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -[`Belt.Id`]() - -Provide utiliites to create identified comparators or hashes for -data structures used below. - -It create a unique identifer per module of functions so that different data structures with slightly different -comparison functions won't mix. -*/ - -/** -`('a, 'id) hash` - -Its runtime represenation is a `hash` function, but signed with a -type parameter, so that different hash functions type mismatch -*/ -type hash<'a, 'id> - -/** -`('a, 'id) eq` - -Its runtime represenation is an `eq` function, but signed with a -type parameter, so that different hash functions type mismatch -*/ -type eq<'a, 'id> - -/** -`('a,'id) cmp` - -Its runtime representation is a `cmp` function, but signed with a -type parameter, so that different hash functions type mismatch -*/ -type cmp<'a, 'id> - -module type Comparable = { - type identity - type t - let cmp: cmp -} - -/** -`('key, 'id) cmparable` is a module of functions, here it only includes `cmp`. - -Unlike normal functions, when created, it comes with a unique identity (guaranteed -by the type system). - -It can be created using function [`comparableU`]() or [`comparable`](). - -The idea of a unique identity when created is that it makes sure two sets would type -mismatch if they use different comparison function -*/ -type comparable<'key, 'id> = module(Comparable with type t = 'key and type identity = 'id) - -module MakeComparableU: ( - M: { - type t - let cmp: (. t, t) => int - }, -) => (Comparable with type t = M.t) - -module MakeComparable: ( - M: { - type t - let cmp: (t, t) => int - }, -) => (Comparable with type t = M.t) - -let comparableU: (~cmp: (. 'a, 'a) => int) => module(Comparable with type t = 'a) - -/** -## Examples - -```rescript -module C = ( - val Belt.Id.comparable ~cmp:(compare : int -> int -> int) -) -let m = Belt.Set.make(module C) -``` -Note that the name of C can not be ignored -*/ -let comparable: (~cmp: ('a, 'a) => int) => module(Comparable with type t = 'a) - -module type Hashable = { - type identity - type t - let hash: hash - let eq: eq -} - -/** -`('key, 'id) hashable` is a module of functions, here it only includes `hash`, `eq`. - -Unlike normal functions, when created, it comes with a unique identity (guaranteed -by the type system). - -It can be created using function [`hashableU`]() or [`hashable`](). - -The idea of a unique identity when created is that it makes sure two hash sets would type -mismatch if they use different comparison function -*/ -type hashable<'key, 'id> = module(Hashable with type t = 'key and type identity = 'id) - -module MakeHashableU: ( - M: { - type t - let hash: (. t) => int - let eq: (. t, t) => bool - }, -) => (Hashable with type t = M.t) - -module MakeHashable: ( - M: { - type t - let hash: t => int - let eq: (t, t) => bool - }, -) => (Hashable with type t = M.t) - -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" diff --git a/jscomp/others/belt_Int.res b/jscomp/others/belt_Int.res deleted file mode 100644 index ad8e9fea520..00000000000 --- a/jscomp/others/belt_Int.res +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** [`Belt.Int`]() - Utililites for Int -*/ - -@val external isNaN: int => bool = "isNaN" - -external toFloat: int => float = "%identity" - -external fromFloat: float => int = "%intoffloat" - -@val external fromString: (string, @as(10) _) => int = "parseInt" - -let fromString = i => - switch fromString(i) { - | i if isNaN(i) => None - | i => Some(i) - } - -@val external toString: int => string = "String" - -external \"+": (int, int) => int = "%addint" - -external \"-": (int, int) => int = "%subint" - -external \"*": (int, int) => int = "%mulint" - -external \"/": (int, int) => int = "%divint" diff --git a/jscomp/others/belt_Int.resi b/jscomp/others/belt_Int.resi deleted file mode 100644 index 0d64b764583..00000000000 --- a/jscomp/others/belt_Int.resi +++ /dev/null @@ -1,120 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -This module includes convenience methods for handling `int` types. -*/ - -/** -Converts a given `int` to a `float`. - -## Examples - -```rescript -Js.log(Belt.Int.toFloat(1) === 1.0) /* true */ -``` -*/ -external toFloat: int => float = "%identity" - -/** -Converts a given `float` to an `int`. - -## Examples - -```rescript -Js.log(Belt.Int.fromFloat(1.0) === 1) /* true */ -``` -*/ -external fromFloat: float => int = "%intoffloat" - -/** -Converts a given `string` to an `int`. Returns `Some(int)` when the input is a number, `None` otherwise. - -## Examples - -```rescript -Js.log(Belt.Int.fromString("1") === Some(1)) /* true */ -``` -*/ -let fromString: string => option - -/** -Converts a given `int` to a `string`. Uses the JavaScript `String` constructor under the hood. - -## Examples - -```rescript -Js.log(Belt.Int.toString(1) === "1") /* true */ -``` -*/ -@val -external toString: int => string = "String" - -/** -Addition of two `int` values. Same as the addition from `Pervasives`. - -## Examples - -```rescript -open Belt.Int -Js.log(2 + 2 === 4) /* true */ -``` -*/ -external \"+": (int, int) => int = "%addint" - -/** -Subtraction of two `int` values. Same as the subtraction from `Pervasives`. - -## Examples - -```rescript -open Belt.Int -Js.log(2 - 1 === 1) /* true */ -``` -*/ -external \"-": (int, int) => int = "%subint" - -/** -Multiplication of two `int` values. Same as the multiplication from `Pervasives`. - -## Examples - -```rescript -open Belt.Int -Js.log(2 * 2 === 4) /* true */ -``` -*/ -external \"*": (int, int) => int = "%mulint" - -/** -Division of two `int` values. Same as the division from `Pervasives`. - -## Examples - -```rescript -open Belt.Int -Js.log(4 / 2 === 2); /* true */ -``` -*/ -external \"/": (int, int) => int = "%divint" diff --git a/jscomp/others/belt_List.res b/jscomp/others/belt_List.res deleted file mode 100644 index e3f73fd71b7..00000000000 --- a/jscomp/others/belt_List.res +++ /dev/null @@ -1,909 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/* - perf is not everything, there are better memory represenations - - ``` - type 'a cell = { - mutable head : 'a; - mutable tail : 'a opt_cell - } - - and 'a opt_cell = 'a cell Js.null - - and 'a t = { - length : int ; - data : 'a opt_cell - } - ``` - However, - - people use List not because of its perf, but its - convenience, in that case, pattern match and compatibility seems - more attractive, we could keep a mutable list - - The built in types would indicate that - its construtor is immutable, a better optimizer would break such code - - ``` - type 'a t = { - head : 'a; - mutable tail : 'a t | int - } - ``` - In the future, we could come up with a safer version - ``` - type 'a t = - | Nil - | Cons of { hd : 'a ; mutable tail : 'a t } - ``` -*/ - -@@bs.config({flags: ["-bs-noassertfalse"]}) - -type t<'a> = list<'a> - -module A = Belt_Array - -external mutableCell: ('a, t<'a>) => t<'a> = "#makemutablelist" - -/* - `mutableCell x []` == `x` - but tell the compiler that is a mutable cell, so it wont - be mis-inlined in the future - dont inline a binding to mutable cell, it is mutable -*/ -/* INVARIANT: relies on Literals.tl (internal representation) */ -@set external unsafeMutateTail: (t<'a>, t<'a>) => unit = "tl" - -/* - - the cell is not empty -*/ - -let head = x => - switch x { - | list{} => None - | list{x, ..._} => Some(x) - } - -let headExn = x => - switch x { - | list{} => raise(Not_found) - | list{x, ..._} => x - } - -let tail = x => - switch x { - | list{} => None - | list{_, ...xs} => Some(xs) - } - -let tailExn = x => - switch x { - | list{} => raise(Not_found) - | list{_, ...t} => t - } - -let add = (xs, x) => list{x, ...xs} - -/* Assume `n >=0` */ -let rec nthAux = (x, n) => - switch x { - | list{h, ...t} => - if n == 0 { - Some(h) - } else { - nthAux(t, n - 1) - } - | _ => None - } - -let rec nthAuxAssert = (x, n) => - switch x { - | list{h, ...t} => - if n == 0 { - h - } else { - nthAuxAssert(t, n - 1) - } - | _ => raise(Not_found) - } - -let get = (x, n) => - if n < 0 { - None - } else { - nthAux(x, n) - } - -let getExn = (x, n) => - if n < 0 { - raise(Not_found) - } else { - nthAuxAssert(x, n) - } - -let rec partitionAux = (p, cell, precX, precY) => - switch cell { - | list{} => () - | list{h, ...t} => - let next = mutableCell(h, list{}) - if p(. h) { - unsafeMutateTail(precX, next) - partitionAux(p, t, next, precY) - } else { - unsafeMutateTail(precY, next) - partitionAux(p, t, precX, next) - } - } - -let rec splitAux = (cell, precX, precY) => - switch cell { - | list{} => () - | list{(a, b), ...t} => - let nextA = mutableCell(a, list{}) - let nextB = mutableCell(b, list{}) - unsafeMutateTail(precX, nextA) - unsafeMutateTail(precY, nextB) - splitAux(t, nextA, nextB) - } - -/* return the tail pointer so it can continue copy other - list -*/ -let rec copyAuxCont = (cellX, prec) => - switch cellX { - | list{} => prec - | list{h, ...t} => - let next = mutableCell(h, list{}) - unsafeMutateTail(prec, next) - copyAuxCont(t, next) - } - -let rec copyAuxWitFilter = (f, cellX, prec) => - switch cellX { - | list{} => () - | list{h, ...t} => - if f(. h) { - let next = mutableCell(h, list{}) - unsafeMutateTail(prec, next) - copyAuxWitFilter(f, t, next) - } else { - copyAuxWitFilter(f, t, prec) - } - } - -let rec copyAuxWithFilterIndex = (f, cellX, prec, i) => - switch cellX { - | list{} => () - | list{h, ...t} => - if f(. h, i) { - let next = mutableCell(h, list{}) - unsafeMutateTail(prec, next) - copyAuxWithFilterIndex(f, t, next, i + 1) - } else { - copyAuxWithFilterIndex(f, t, prec, i + 1) - } - } - -let rec copyAuxWitFilterMap = (f, cellX, prec) => - switch cellX { - | list{} => () - | list{h, ...t} => - switch f(. h) { - | Some(h) => - let next = mutableCell(h, list{}) - unsafeMutateTail(prec, next) - copyAuxWitFilterMap(f, t, next) - | None => copyAuxWitFilterMap(f, t, prec) - } - } - -let rec removeAssocAuxWithMap = (cellX, x, prec, f) => - switch cellX { - | list{} => false - | list{(a, _) as h, ...t} => - if f(. a, x) { - unsafeMutateTail(prec, t) - true - } else { - let next = mutableCell(h, list{}) - unsafeMutateTail(prec, next) - removeAssocAuxWithMap(t, x, next, f) - } - } - -let rec setAssocAuxWithMap = (cellX, x, k, prec, eq) => - switch cellX { - | list{} => false - | list{(a, _) as h, ...t} => - if eq(. a, x) { - unsafeMutateTail(prec, list{(x, k), ...t}) - true - } else { - let next = mutableCell(h, list{}) - unsafeMutateTail(prec, next) - setAssocAuxWithMap(t, x, k, next, eq) - } - } - -let rec copyAuxWithMap = (cellX, prec, f) => - switch cellX { - | list{} => () - | list{h, ...t} => - let next = mutableCell(f(. h), list{}) - unsafeMutateTail(prec, next) - copyAuxWithMap(t, next, f) - } - -let rec zipAux = (cellX, cellY, prec) => - switch (cellX, cellY) { - | (list{h1, ...t1}, list{h2, ...t2}) => - let next = mutableCell((h1, h2), list{}) - unsafeMutateTail(prec, next) - zipAux(t1, t2, next) - | (list{}, _) | (_, list{}) => () - } - -let rec copyAuxWithMap2 = (f, cellX, cellY, prec) => - switch (cellX, cellY) { - | (list{h1, ...t1}, list{h2, ...t2}) => - let next = mutableCell(f(. h1, h2), list{}) - unsafeMutateTail(prec, next) - copyAuxWithMap2(f, t1, t2, next) - | (list{}, _) | (_, list{}) => () - } - -let rec copyAuxWithMapI = (f, i, cellX, prec) => - switch cellX { - | list{h, ...t} => - let next = mutableCell(f(. i, h), list{}) - unsafeMutateTail(prec, next) - copyAuxWithMapI(f, i + 1, t, next) - | list{} => () - } - -let rec takeAux = (n, cell, prec) => - if n == 0 { - true - } else { - switch cell { - | list{} => false - | list{x, ...xs} => - let cell = mutableCell(x, list{}) - unsafeMutateTail(prec, cell) - takeAux(n - 1, xs, cell) - } - } - -let rec splitAtAux = (n, cell, prec) => - if n == 0 { - Some(cell) - } else { - switch cell { - | list{} => None - | list{x, ...xs} => - let cell = mutableCell(x, list{}) - unsafeMutateTail(prec, cell) - splitAtAux(n - 1, xs, cell) - } - } - -/* invarint `n >= 0` */ -let take = (lst, n) => - if n < 0 { - None - } else if n == 0 { - Some(list{}) - } else { - switch lst { - | list{} => None - | list{x, ...xs} => - let cell = mutableCell(x, list{}) - let has = takeAux(n - 1, xs, cell) - if has { - Some(cell) - } else { - None - } - } - } -/* invariant `n >= 0 ` */ -let rec dropAux = (l, n) => - if n == 0 { - Some(l) - } else { - switch l { - | list{_, ...tl} => dropAux(tl, n - 1) - | list{} => None - } - } - -let drop = (lst, n) => - if n < 0 { - None - } else { - dropAux(lst, n) - } - -let splitAt = (lst, n) => - if n < 0 { - None - } else if n == 0 { - Some(list{}, lst) - } else { - switch lst { - | list{} => None - | list{x, ...xs} => - let cell = mutableCell(x, list{}) - let rest = splitAtAux(n - 1, xs, cell) - switch rest { - | Some(rest) => Some(cell, rest) - | None => None - } - } - } - -let concat = (xs, ys) => - switch xs { - | list{} => ys - | list{h, ...t} => - let cell = mutableCell(h, list{}) - unsafeMutateTail(copyAuxCont(t, cell), ys) - cell - } - -let mapU = (xs, f) => - switch xs { - | list{} => list{} - | list{h, ...t} => - let cell = mutableCell(f(. h), list{}) - copyAuxWithMap(t, cell, f) - cell - } - -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{}) - copyAuxWithMap2(f, l1, l2, cell) - cell - | (list{}, _) | (_, list{}) => list{} - } - -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{}) - copyAuxWithMapI(f, 1, t, cell) - cell - } - -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 cur = ref(headX) - let i = ref(1) - while i.contents < n { - let v = mutableCell(f(. i.contents), list{}) - unsafeMutateTail(cur.contents, v) - cur.contents = v - i.contents = i.contents + 1 - } - - headX - } - -let makeBy = (n, f) => makeByU(n, (. x) => f(x)) - -let make = (type a, n, v: a): list => - if n <= 0 { - list{} - } else { - let headX = mutableCell(v, list{}) - let cur = ref(headX) - let i = ref(1) - while i.contents < n { - let v = mutableCell(v, list{}) - unsafeMutateTail(cur.contents, v) - cur.contents = v - i.contents = i.contents + 1 - } - - headX - } - -let rec lengthAux = (x, acc) => - switch x { - | list{} => acc - | list{_, ...t} => lengthAux(t, acc + 1) - } - -let length = xs => lengthAux(xs, 0) -let size = length - -let rec fillAux = (arr, i, x) => - switch x { - | list{} => () - | list{h, ...t} => - A.setUnsafe(arr, i, h) - fillAux(arr, i + 1, t) - } - -let rec fromArrayAux = (a, i, res) => - if i < 0 { - res - } else { - fromArrayAux(a, i - 1, list{A.getUnsafe(a, i), ...res}) - } - -let fromArray = a => fromArrayAux(a, A.length(a) - 1, list{}) - -let toArray = (x: t<_>) => { - let len = length(x) - let arr = A.makeUninitializedUnsafe(len) - fillAux(arr, 0, x) - arr -} - -let shuffle = xs => { - let v = toArray(xs) - A.shuffleInPlace(v) - fromArray(v) -} - -/* let rec fillAuxMap arr i x f = - match x with - | [] -> () - | h::t -> - A.setUnsafe arr i (f h [@bs]) ; - fillAuxMap arr (i + 1) t f */ - -/* module J = Js_json */ -/* type json = J.t */ -/* let toJson x f = */ -/* let len = length x in */ -/* let arr = Belt_Array.makeUninitializedUnsafe len in */ -/* fillAuxMap arr 0 x f; */ -/* J.array arr */ - -/* TODO: best practice about raising excpetion - 1. raise OCaml exception, no stacktrace - 2. raise JS exception, how to pattern match -*/ - -let rec reverseConcat = (l1, l2) => - switch l1 { - | list{} => l2 - | list{a, ...l} => reverseConcat(l, list{a, ...l2}) - } - -let reverse = l => reverseConcat(l, list{}) - -let rec flattenAux = (prec, xs) => - switch xs { - | list{} => unsafeMutateTail(prec, list{}) - | list{h, ...r} => flattenAux(copyAuxCont(h, prec), r) - } - -let rec flatten = xs => - switch xs { - | list{} => list{} - | list{list{}, ...xs} => flatten(xs) - | list{list{h, ...t}, ...r} => - let cell = mutableCell(h, list{}) - flattenAux(copyAuxCont(t, cell), r) - cell - } - -let concatMany = xs => - switch xs { - | [] => list{} - | [x] => x - | _ => - let len = A.length(xs) - let v = ref(A.getUnsafe(xs, len - 1)) - for i in len - 2 downto 0 { - v.contents = concat(A.getUnsafe(xs, i), v.contents) - } - v.contents - } - -let rec mapRevAux = (f, accu, xs) => - switch xs { - | list{} => accu - | 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 rec forEachU = (xs, f) => - switch xs { - | list{} => () - | list{a, ...l} => - f(. a)->ignore - forEachU(l, f) - } - -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 - 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 rec reduceU = (l, accu, f) => - switch l { - | list{} => accu - | list{a, ...l} => reduceU(l, f(. accu, a), f) - } - -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) - } - -let reduceReverseU = (type a b, l: list, acc: b, f) => { - let len = length(l) - if len < 1000 { - reduceReverseUnsafeU(l, acc, f) - } else { - A.reduceReverseU(toArray(l), acc, f) - } -} - -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) - } - -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 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{}) | (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 rec forEach2U = (l1, l2, f) => - switch (l1, l2) { - | (list{a1, ...l1}, list{a2, ...l2}) => - f(. a1, a2)->ignore - forEach2U(l1, l2, f) - | (list{}, _) | (_, list{}) => () - } - -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{}, _) | (_, list{}) => accu - } - -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{}) | (list{}, _) => accu - } - -let reduceReverse2U = (type a b c, l1: list, l2: list, acc: c, f) => { - let len = length(l1) - if len < 1000 { - reduceReverse2UnsafeU(l1, l2, acc, f) - } else { - A.reduceReverse2U(toArray(l1), toArray(l2), acc, f) - } -} - -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) - } - -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) - } - -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) - } - -let every2 = (l1, l2, p) => every2U(l1, l2, (. a, b) => p(a, b)) - -let rec cmpByLength = (l1, l2) => - switch (l1, l2) { - | (list{}, list{}) => 0 - | (_, list{}) => 1 - | (list{}, _) => -1 - | (list{_, ...l1s}, list{_, ...l2s}) => cmpByLength(l1s, l2s) - } - -let rec cmpU = (l1, l2, p) => - switch (l1, l2) { - | (list{}, list{}) => 0 - | (_, list{}) => 1 - | (list{}, _) => -1 - | (list{a1, ...l1}, list{a2, ...l2}) => - let c = p(. a1, a2) - if c == 0 { - cmpU(l1, l2, p) - } else { - c - } - } - -let cmp = (l1, l2, f) => cmpU(l1, l2, (. x, y) => f(x, y)) - -let rec eqU = (l1, l2, p) => - switch (l1, l2) { - | (list{}, list{}) => true - | (_, list{}) - | (list{}, _) => false - | (list{a1, ...l1}, list{a2, ...l2}) => - if p(. a1, a2) { - eqU(l1, l2, p) - } else { - false - } - } -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) - } - -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) - } - -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) { - Some(b) - } else { - getAssocU(l, x, eq) - } - } - -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) - } - -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) { - l - } else { - let cell = mutableCell(pair, list{}) - let removed = removeAssocAuxWithMap(l, x, cell, eq) - if removed { - cell - } else { - xs - } - } - } - -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) { - list{(x, k), ...l} - } else { - let cell = mutableCell(pair, list{}) - let replaced = setAssocAuxWithMap(l, x, k, cell, eq) - if replaced { - cell - } else { - list{(x, k), ...xs} - } - } - } - -let setAssoc = (xs, x, k, eq) => setAssocU(xs, x, k, (. a, b) => eq(a, b)) - -let sortU = (xs, cmp) => { - let arr = toArray(xs) - Belt_SortArray.stableSortInPlaceByU(arr, cmp) - fromArray(arr) -} - -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) { - Some(x) - } else { - getByU(l, p) - } - } - -let getBy = (xs, p) => getByU(xs, (. a) => p(a)) - -let rec keepU = (xs, p) => - switch xs { - | list{} => list{} - | list{h, ...t} => - if p(. h) { - let cell = mutableCell(h, list{}) - copyAuxWitFilter(p, t, cell) - cell - } else { - keepU(t, p) - } - } - -let keep = (xs, p) => keepU(xs, (. x) => p(x)) - -let filter = keep - -let keepWithIndexU = (xs, p) => { - let rec auxKeepWithIndex = (xs, p, i) => - switch xs { - | list{} => list{} - | list{h, ...t} => - if p(. h, i) { - let cell = mutableCell(h, list{}) - copyAuxWithFilterIndex(p, t, cell, i + 1) - cell - } else { - auxKeepWithIndex(t, p, i + 1) - } - } - auxKeepWithIndex(xs, p, 0) -} - -let keepWithIndex = (xs, p) => keepWithIndexU(xs, (. x, i) => p(x, i)) - -let filterWithIndex = keepWithIndex - -let rec keepMapU = (xs, p) => - switch xs { - | list{} => list{} - | list{h, ...t} => - switch p(. h) { - | Some(h) => - let cell = mutableCell(h, list{}) - copyAuxWitFilterMap(p, t, cell) - cell - | None => keepMapU(t, p) - } - } - -let keepMap = (xs, p) => keepMapU(xs, (. x) => p(x)) - -let partitionU = (l, p) => - switch l { - | list{} => (list{}, list{}) - | list{h, ...t} => - let nextX = mutableCell(h, list{}) - let nextY = mutableCell(h, list{}) - let b = p(. h) - partitionAux(p, t, nextX, nextY) - if b { - ( - nextX, - switch nextY { - | list{_, ...tail} => tail - | list{} => assert(false) - }, - ) - } else { - ( - switch nextX { - | list{_, ...tail} => tail - | list{} => assert(false) - }, - nextY, - ) - } - } - -let partition = (l, p) => partitionU(l, (. x) => p(x)) - -let unzip = xs => - switch xs { - | list{} => (list{}, list{}) - | list{(x, y), ...l} => - let cellX = mutableCell(x, list{}) - let cellY = mutableCell(y, list{}) - splitAux(l, cellX, cellY) - (cellX, cellY) - } - -let zip = (l1, l2) => - switch (l1, l2) { - | (_, list{}) | (list{}, _) => list{} - | (list{a1, ...l1}, list{a2, ...l2}) => - let cell = mutableCell((a1, a2), list{}) - zipAux(l1, l2, cell) - cell - } diff --git a/jscomp/others/belt_List.resi b/jscomp/others/belt_List.resi deleted file mode 100644 index 15811ed7d08..00000000000 --- a/jscomp/others/belt_List.resi +++ /dev/null @@ -1,955 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -Collection functions for manipulating the `list` data structures, a singly-linked list. - -**Prefer Array** if you need any of the following: - -- Random access of element -- Better interop with JavaScript -- Better memory usage & performance. -*/ - -/** `'a t` is compatible with built-in `list` type */ -type t<'a> = list<'a> - -/** -Returns the length of a list. - -## Examples - -```rescript -Belt.List.length(list{1, 2, 3}) // 3 -``` -*/ -let length: t<'a> => int - -/** See `Belt.List.length` */ -let size: t<'a> => int - -/** -Returns `Some(value)` where `value` is the first element in the list, or -`None` if `someList` is an empty list. - -## Examples - -```rescript -Belt.List.head(list{}) // None -Belt.List.head(list{1, 2, 3}) // Some(1) -``` -*/ -let head: t<'a> => option<'a> - -/** -Same as `Belt.List.head` but raises an exception if `someList` is empty. Use -with care. - -## Examples - -```rescript -Belt.List.headExn(list{1, 2, 3}) // 1 - -Belt.List.headExn(list{}) // Raises an Error -``` -*/ -let headExn: t<'a> => 'a - -/** -Returns `None` if `someList` is empty, otherwise it returns `Some(tail)` -where `tail` is everything except the first element of `someList`. - -## Examples - -```rescript -Belt.List.tail(list{1, 2, 3}) // Some(list{2, 3}) - -Belt.List.tail(list{}) // None -``` -*/ -let tail: t<'a> => option> - -/** -Same as `Belt.List.tail` but raises an exception if `someList` is empty. Use -with care. - -## Examples - -```rescript -Belt.List.tailExn(list{1, 2, 3}) // list{2, 3} - -Belt.List.tailExn(list{}) // Raises an Error -``` -*/ -let tailExn: t<'a> => t<'a> - -/** -Adds `value` to the beginning of `someList`. - -## Examples - -```rescript -Belt.List.add(list{2, 3}, 1) // list{1, 2, 3} - -Belt.List.add(list{"World", "!"}, "Hello") // list{"Hello", "World", "!"} -``` -*/ -let add: (t<'a>, 'a) => t<'a> - -/** -Return the nth element in `someList`, or `None` if `index` is larger than the -length. - -## Examples - -```rescript -let abc = list{"A", "B", "C"} - -abc->Belt.List.get(1) // Some("B") - -abc->Belt.List.get(4) // None -``` -*/ -let get: (t<'a>, int) => option<'a> - -/** -Same as `Belt.List.get` but raises an exception if `index` is larger than the -length. Use with care. - -## Examples - -```rescript -let abc = list{"A", "B", "C"} - -abc->Belt.List.getExn(1) // "B" - -abc->Belt.List.getExn(4) // Raises an Error -``` -*/ -let getExn: (t<'a>, int) => 'a - -/** -Returns a list of length `numItems` with each element filled with value `v`. Returns an empty list if `numItems` is negative. - -## Examples - -```rescript -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> - -/** -Return a list of length `numItems` with element `i` initialized with `f(i)`. -Returns an empty list if `numItems` is negative. - -## Examples - -```rescript -Belt.List.makeBy(5, i => i) // list{0, 1, 2, 3, 4} - -Belt.List.makeBy(5, i => i * i) // list{0, 1, 4, 9, 16} -``` -*/ -let makeBy: (int, int => 'a) => t<'a> - -/** -Returns a new list in random order. - -## Examples - -```rescript -Belt.List.shuffle(list{1, 2, 3}) // list{2, 1, 3} -``` -*/ -let shuffle: t<'a> => t<'a> - -/** -Return a new list, dropping the first `n` elements. Returns `None` if `someList` has fewer than `n` elements. - -## Examples - -```rescript -list{1, 2, 3}->Belt.List.drop(2) // Some(list{3}) - -list{1, 2, 3}->Belt.List.drop(3) // Some(list{}) - -list{1, 2, 3}->Belt.List.drop(4) // None -``` -*/ -let drop: (t<'a>, int) => option> - -/** -Returns a list with the first `n` elements from `someList`, or `None` if `someList` has fewer than `n` elements. - -## Examples - -```rescript -list{1, 2, 3}->Belt.List.take(1) // Some(list{1}) - -list{1, 2, 3}->Belt.List.take(2) // Some(list{1, 2}) - -list{1, 2, 3}->Belt.List.take(4) // None -``` -*/ -let take: (t<'a>, int) => option> - -/** -Split the list `someList` at `index`. Returns `None` when the length of `someList` is less than `index`. - -## Examples - -```rescript -list{"Hello", "World"}->Belt.List.splitAt(1) // Some((list{"Hello"}, list{"World"})) - -list{0, 1, 2, 3, 4}->Belt.List.splitAt(2) // Some((list{0, 1}, list{2, 3, 4})) -``` -*/ -let splitAt: (t<'a>, int) => option<(list<'a>, list<'a>)> - -/** -Returns the list obtained by adding `secondList` after `firstList`. - -## Examples - -```rescript -Belt.List.concat(list{1, 2, 3}, list{4, 5}) // list{1, 2, 3, 4, 5} -``` -*/ -let concat: (t<'a>, t<'a>) => t<'a> - -/** -Returns the list obtained by concatenating all the lists in array `a`, in -order. - -## Examples - -```rescript -Belt.List.concatMany([list{1, 2, 3}, list{}, list{3}]) // list{1, 2, 3, 3} -``` -*/ -let concatMany: array> => t<'a> - -/** -Equivalent to writing: `concat(reverse(firstList, secondList)` - -## Examples - -```rescript -Belt.List.reverseConcat(list{1, 2}, list{3, 4}) // list{2, 1, 3, 4} -``` -*/ -let reverseConcat: (t<'a>, t<'a>) => t<'a> - -/** -Return the list obtained by concatenating all the lists in list `ls`, in order. - -## Examples - -```rescript -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> - -/** -Returns a new list with `f` applied to each element of `someList`. - -## Examples - -```rescript -list{1, 2}->Belt.List.map(x => x + 1) // list{3, 4} -``` -*/ -let map: (t<'a>, 'a => 'b) => t<'b> - -/** -Returns a list of pairs from the two lists with the length of the shorter list. - -## Examples - -```rescript -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> - -/** -See [Belt.List.zip](#zip) - -## Examples - -```rescript -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> - -/** -Applies `f` to each element of `someList`. -Function `f` takes two arguments: the index starting from 0 and the element from `someList`, in that order. - -## Examples - -```rescript -list{1, 2, 3}->Belt.List.mapWithIndex((index, x) => index + x) // list{1, 3, 5} -``` -*/ -let mapWithIndex: (t<'a>, (int, 'a) => 'b) => t<'b> - -/** -Converts the given array to a list. - -## Examples - -```rescript -Belt.List.fromArray([1, 2, 3]) // list{1, 2, 3} -``` -*/ -let fromArray: array<'a> => t<'a> - -/** -Converts the given list to an array. - -## Examples - -```rescript -Belt.List.toArray(list{1, 2, 3}) // [1, 2, 3] -``` -*/ -let toArray: t<'a> => array<'a> - -/* type json = Js_json.t */ - -/* val toJson : 'a t -> ('a -> json [@bs]) -> json */ -/* val fromJson : json -> (json -> 'a [@bs]) -> 'a t */ - -/** -Returns a new list whose elements are those of `someList` in reversed order. - -## Examples - -```rescript -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> - -/** -Equivalent to: - -```res -map(someList, f)->reverse -``` - -## Examples - -```rescript -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 - -/** -Call `f` on each element of `someList` from the beginning to end. -`f` returns `unit`, so no new array is created. Use `forEach` when you are primarily concerned with repetitively creating side effects. - -## Examples - -```rescript -Belt.List.forEach(list{"a", "b", "c"}, x => Js.log("Item: " ++ x)) -/* - prints: - Item: a - Item: b - Item: c -*/ -``` -*/ -let forEach: (t<'a>, 'a => 'b) => unit - -/** Uncurried version of [forEachWithIndex](#forEachWithIndex). */ -let forEachWithIndexU: (t<'a>, (. int, 'a) => 'b) => unit - -/** -Call `f` on each element of `someList` from beginning to end. -Function `f` takes two arguments: the index starting from 0 and the element from `someList`. `f` returns `unit`. - -## Examples - -```rescript -Belt.List.forEachWithIndex(list{"a", "b", "c"}, (index, x) => { - Js.log("Item " ++ Belt.Int.toString(index) ++ " is " ++ x) -}) -/* - prints: - Item 0 is a - Item 1 is b - Item 2 is cc -*/ -``` -*/ -let forEachWithIndex: (t<'a>, (int, 'a) => 'b) => unit - -/** Uncurried version of [reduce](#reduce). */ -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. - -## Examples - -```rescript -list{1, 2, 3, 4}->Belt.List.reduce(0, (a, b) => a + b) /* 10 */ - -/* same as */ - -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 - -/** -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. - -## Examples - -```rescript -list{1, 2, 3, 4}->Belt.List.reduceWithIndex(0, (acc, item, index) => acc + item + index) /* 16 */ -``` -*/ -let reduceWithIndex: (t<'a>, 'b, ('b, 'a, int) => 'b) => 'b - -/** Uncurried version of [reduceReverse](#reduceReverse). */ -let reduceReverseU: (t<'a>, 'b, (. 'b, 'a) => 'b) => 'b - -/** -Works like [reduce](#reduce), except that function `f` is applied to each -item of `someList` from the last back to the first. - -## Examples - -```rescript -list{1, 2, 3, 4}->Belt.List.reduceReverse(0, (a, b) => a + b) /* 10 */ - -list{1, 2, 3, 4}->Belt.List.reduceReverse(10, (a, b) => a - b) /* 0 */ - -list{1, 2, 3, 4}->Belt.List.reduceReverse(list{}, Belt.List.add) // list{1, 2, 3, 4} -``` -*/ -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> - -/** -Equivalent to: `zipBy(xs, ys, f)->reverse` - -## Examples - -```rescript - -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 - -/** -Stops at the length of the shorter list. - -## Examples - -```rescript -Belt.List.forEach2(list{"Z", "Y"}, list{"A", "B", "C"}, (x, y) => Js.log2(x, y)) - -/* - prints: - "Z" "A" - "Y" "B" -*/ -``` -*/ -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 - -/** -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. - -## Examples - -```rescript -Belt.List.reduce2(list{1, 2, 3}, list{4, 5}, 0, (acc, x, y) => acc + x * x + y) /* 0 + (1 * 1 + 4) + (2 * 2 + 5) */ -``` -*/ -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 - -/** -Applies `f` to each element of `firstList` and `secondList` from end to -beginning. Stops with the shorter list. Function `f` has three parameters: an -“accumulator” which starts with a value of init, an item from `firstList`, -and an item from `secondList`. `reduce2` returns the final value of the -accumulator. - -## Examples - -```rescript -Belt.List.reduceReverse2(list{1, 2, 3}, list{4, 5}, 0, (acc, x, y) => acc + x * x + y) /* + (1 * 1 + 4) + (2 * 2 + 5) */ -``` -*/ -let reduceReverse2: (t<'a>, t<'b>, 'c, ('c, 'a, 'b) => 'c) => 'c - -/** Uncurried version of [every](#every). */ -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. - -## Examples - -```rescript -let isBelow10 = value => value < 10 - -list{1, 9, 8, 2}->Belt.List.every(isBelow10) /* true */ - -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 - -/** -Returns `true` if at least _one_ of the elements in `someList` satisfies -`pred`, where `pred` is a predicate: a function taking an element and -returning a bool. - -## Examples - -```rescript -let isAbove100 = value => value > 100 - -list{101, 1, 2, 3}->Belt.List.some(isAbove100) /* true */ - -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 - -/** -Returns `true` if predicate `pred(a, b)` is `true` for all pairs of elements -up to the shorter length (i.e. `min(length(firstList), length(secondList))`) - -## Examples - -```rescript -Belt.List.every2(list{1, 2, 3}, list{0, 1}, (a, b) => a > b) /* true */ - -Belt.List.every2(list{}, list{1}, (a, b) => a > b) /* true */ - -Belt.List.every2(list{2, 3}, list{1}, (a, b) => a > b) /* true */ - -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 - -/** -Returns `true` if predicate `pred(a, b)` is true for any pair of elements up -to the shorter length (i.e. `min(length(firstList), length(secondList))`) - -## Examples - -```rescript -Belt.List.some2(list{1, 2, 3}, list{0, 1}, (a, b) => a > b) /* true */ - -Belt.List.some2(list{}, list{1}, (a, b) => a > b) /* false */ - -Belt.List.some2(list{2, 3}, list{1}, (a, b) => a > b) /* true */ - -Belt.List.some2(list{0, 1}, list{5, 0}, (a, b) => a > b) /* true */ -``` -*/ -let some2: (t<'a>, t<'b>, ('a, 'b) => bool) => bool - -/** -Compare two lists solely by length. Returns `-1` if `length(firstList)` is -less than `length(secondList)`, `0` if `length(firstList)` equals -`length(secondList)`, and `1` if `length(firstList)` is greater than -`length(secondList)`. - -## Examples - -```rescript -Belt.List.cmpByLength(list{1, 2}, list{3, 4, 5, 6}) /* -1 */ - -Belt.List.cmpByLength(list{1, 2, 3}, list{4, 5, 6}) /* = 0 */ - -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 - -/** -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`. - -The comparison returns the first non-zero result of `compareFn`, or zero if `compareFn` returns zero for all `a` and `b`. - -If all items have compared equal, but `firstList` is exhausted first, return `-1`. (`firstList` is shorter). -If all items have compared equal, but `secondList` is exhausted first, return `1` (`firstList` is longer). - -## Examples - -```rescript -Belt.List.cmp(list{3}, list{3, 7}, (a, b) => compare(a, b)) /* (-1) */ - -Belt.List.cmp(list{5, 3}, list{5}, (a, b) => compare(a, b)) /* 1 */ - -Belt.List.cmp(list{1, 3, 5}, list{1, 4, 2}, (a, b) => compare(a, b)) /* (-1) */ - -Belt.List.cmp(list{1, 3, 5}, list{1, 2, 3}, (a, b) => compare(a, b)) /* 1 */ - -Belt.List.cmp(list{1, 3, 5}, list{1, 3, 5}, (a, b) => compare(a, b)) /* 0 */ -``` - -**Please note:** The total ordering of List is different from Array, -for Array, we compare the length first and, only if the lengths are equal, elements one by one. -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 - -/** -Check equality of `firstList` and `secondList` using `eqElem` for equality on -elements, where `eqElem` is a function that returns `true` if items `x` and -`y` meet some criterion for equality, `false` otherwise. eq `false` if length -of `firstList` and `secondList` are not the same. - -## Examples - -```rescript -Belt.List.eq(list{1, 2, 3}, list{1, 2}, (a, b) => a == b) /* false */ - -Belt.List.eq(list{1, 2}, list{1, 2}, (a, b) => a == b) /* true */ - -Belt.List.eq(list{1, 2, 3}, list{(-1), (-2), (-3)}, (a, b) => abs(a) == abs(b)) /* true */ -``` -*/ -let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool - -/** Uncurried version of [has](#has). */ -let hasU: (t<'a>, 'b, (. 'a, 'b) => bool) => bool - -/** -Returns `true` if the list contains at least one element for which -`eqFunction(x)` returns true. - -## Examples - -```rescript -list{1, 2, 3}->Belt.List.has(2, (a, b) => a == b) /* true */ - -list{1, 2, 3}->Belt.List.has(4, (a, b) => a == b) /* false */ - -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> - -/** -Returns `Some(value)` for the first value in `someList` that satisfies the -predicate function `pred`. Returns `None` if no element satisfies the function. - -## Examples - -```rescript -Belt.List.getBy(list{1, 4, 3, 2}, x => x > 3) /* Some(4) */ - -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> - -/** -Returns a list of all elements in `someList` which satisfy the predicate function `pred`. - -## Examples - -```rescript -let isEven = x => mod(x, 2) == 0 - -Belt.List.keep(list{1, 2, 3, 4}, isEven) /* list{2, 4} */ - -Belt.List.keep(list{None, Some(2), Some(3), None}, Belt.Option.isSome) /* list{Some(2), Some(3)} */ -``` -*/ -let keep: (t<'a>, 'a => bool) => t<'a> - -@deprecated("This function will soon be deprecated. Please, use `List.keep` instead.") -/** -Returns a list of all elements in `someList` which satisfy the predicate function `pred`. - -## Examples - -```rescript -let isEven = x => mod(x, 2) == 0 - -Belt.List.filter(list{1, 2, 3, 4}, isEven) /* list{2, 4} */ - -Belt.List.filter(list{None, Some(2), Some(3), None}, Belt.Option.isSome) /* list{Some(2), Some(3)} */ -``` -*/ -let filter: (t<'a>, 'a => bool) => t<'a> - -/** Uncurried version of [keepWithIndex](#keepWithIndex). */ -let keepWithIndexU: (t<'a>, (. 'a, int) => bool) => t<'a> - -/** -Returns a list of all elements in `someList` which satisfy the predicate function `pred`. - -## Examples - -```rescript -let isEven = x => mod(x, 2) == 0 - -Belt.List.keepWithIndex(list{1, 2, 3, 4}, (_x, index) => isEven(index)) /* list{1, 3} */ -``` -*/ -let keepWithIndex: (t<'a>, ('a, int) => bool) => t<'a> - -@deprecated( - "This function will soon be deprecated. Please, use `List.keepWithIndex` \ - instead." -) -/** -Returns a list of all elements in `someList` which satisfy the predicate function `pred`. - -## Examples - -```rescript -let isEven = x => mod(x, 2) == 0 - -Belt.List.filterWithIndex(list{1, 2, 3, 4}, (_x, index) => isEven(index)) /* list{1, 3} */ -``` -*/ -let filterWithIndex: (t<'a>, ('a, int) => bool) => t<'a> - -/** Uncurried version of [keepMap](#keepMap). */ -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. -If `f(x)` returns `None`, the element is _not_ retained in the result. - -## Examples - -```rescript -let isEven = x => mod(x, 2) == 0 - -list{1, 2, 3, 4} -->Belt.List.keepMap(x => - if (isEven(x)) { - Some(x) - } else { - None - } - ) /* list{2, 4} */ - -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>) - -/** -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. - -In other words: - -```rescript -(elementsThatSatisfies, elementsThatDoesNotSatisfy) -``` - -## Examples - -```rescript -Belt.List.partition(list{1, 2, 3, 4}, x => x > 2) /* (list{3, 4}, list{1, 2}) */ -``` -*/ -let partition: (t<'a>, 'a => bool) => (t<'a>, t<'a>) - -/** -Takes a list of pairs and creates a pair of lists. The first list contains all the first items of the pairs; the second list contains all the second items. - -## Examples - -```rescript -Belt.List.unzip(list{(1, 2), (3, 4)}) /* (list{1, 3}, list{2, 4}) */ - -Belt.List.unzip(list{("H", "W"), ("e", "o"), ("l", "r"), ("l", "l"), ("o", "d"), (" ", "!")}) -/* (list{"H", "e", "l", "l", "o", " "}, list{"W", "o", "r", "l", "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> - -/** -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. - -## Examples - -```rescript -list{(1, "a"), (2, "b"), (3, "c")}->Belt.List.getAssoc(3, (a, b) => a == b) /* Some("c") */ - -list{(9, "morning"), (15, "afternoon"), (22, "night")} -->Belt.List.getAssoc(15, (k, item) => k /* 15 */ == item /* 9, 5, 22 */) -/* Some("afternoon") */ -``` -*/ -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 - -/** -Returns `true` if there is a pair in `someList` where the first element equals `k` as per the predicate function `eqFunction`. - -## Examples - -```rescript -list{(1, "a"), (2, "b"), (3, "c")}->Belt.List.hasAssoc(1, (a, b) => a == b) /* true */ - -list{(9, "morning"), (15, "afternoon"), (22, "night")} -->Belt.List.hasAssoc(25, (k, item) => k /* 25 */ == item /* 9, 5, 22 */) /* false */ -``` -*/ -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)> - -/** -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`. - -## Examples - -```rescript -list{(1, "a"), (2, "b"), (3, "c")}->Belt.List.removeAssoc(1, (a, b) => a == b) /* list{(2, "b"), (3, "c")} */ - -list{(9, "morning"), (15, "afternoon"), (22, "night")} -->Belt.List.removeAssoc(9, (k, item) => k /* 9 */ == item /* 9, 5, 22 */) -/* list{(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)> - -/** -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`. - -## Examples - -```rescript -list{(1, "a"), (2, "b"), (3, "c")}->Belt.List.setAssoc(2, "x", (a, b) => a == b) /* list{(1, "a"), (2, "x"), (3, "c")} */ - -list{(1, "a"), (3, "c")}->Belt.List.setAssoc(2, "b", (a, b) => a == b) /* list{(2, "b"), (1, "a"), (3, "c")} */ - -list{(9, "morning"), (3, "morning?!"), (22, "night")} -->Belt.List.setAssoc(15, "afternoon", (a, b) => mod(a, 12) == mod(b, 12)) -/* list{(9, "morning"), (15, "afternoon"), (22, "night")} */ -``` - -**Please note** - -In the last example, since: `15 mod 12` equals `3 mod 12` - -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> - -/** -Returns a sorted list. - -## Examples - -```rescript -Belt.List.sort(list{5, 4, 9, 3, 7}, (a, b) => a - b) // list{3, 4, 5, 7, 9} -``` -*/ -let sort: (t<'a>, ('a, 'a) => int) => t<'a> diff --git a/jscomp/others/belt_Map.res b/jscomp/others/belt_Map.res deleted file mode 100644 index cfd9edf8397..00000000000 --- a/jscomp/others/belt_Map.res +++ /dev/null @@ -1,164 +0,0 @@ -/* ********************************************************************* */ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1996 Institut National de Recherche en Informatique et */ -/* en Automatique. All rights reserved. This file is distributed */ -/* under the terms of the GNU Library General Public License, with */ -/* the special exception on linking described in file ../LICENSE. */ -/* */ -/* Adapted by authors of ReScript without using functors */ -/* ********************************************************************* */ - -/** specalized when key type is `int`, more efficient - than the generic type -*/ -module Int = Belt_MapInt - -/** specalized when key type is `string`, more efficient - than the generic type */ -module String = Belt_MapString - -/** seprate function from data, a more verboe but slightly - more efficient -*/ -module Dict = Belt_MapDict - -type id<'key, 'id> = Belt_Id.comparable<'key, 'id> -type cmp<'key, 'id> = Belt_Id.cmp<'key, 'id> - -type t<'k, 'v, 'id> = { - cmp: cmp<'k, 'id>, - data: Dict.t<'k, 'v, 'id>, -} - -let fromArray = (type k idx, data, ~id: id) => { - module M = unpack(id) - let cmp = M.cmp - {cmp, data: Dict.fromArray(~cmp, data)} -} - -let remove = (m, x) => { - let {cmp, data: odata} = m - let newData = Dict.remove(odata, x, ~cmp) - if newData === odata { - m - } else { - {cmp, data: newData} - } -} - -let removeMany = (m, x) => { - let {cmp, data: odata} = m - let newData = Dict.removeMany(odata, x, ~cmp) - {cmp, data: newData} -} - -let set = (m, key, d) => { - let cmp = m.cmp - {cmp, data: Dict.set(~cmp, m.data, key, d)} -} - -let mergeMany = (m, e) => { - let cmp = m.cmp - {cmp, data: Dict.mergeMany(~cmp, m.data, e)} -} - -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 split = (m, x) => { - let cmp = m.cmp - let ((l, r), b) = Dict.split(~cmp, m.data, x) - (({cmp, data: l}, {cmp, data: r}), b) -} - -let mergeU = (s1, s2, f) => { - let cmp = s1.cmp - {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 make = (type key idx, ~id: id) => { - module M = unpack(id) - {cmp: M.cmp, data: Dict.empty} -} - -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 forEachU = (m, f) => Dict.forEachU(m.data, f) -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 everyU = (m, f) => Dict.everyU(m.data, f) -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 keepU = (m, f) => {cmp: m.cmp, data: Dict.keepU(m.data, f)} -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 mapU = (m, f) => {cmp: m.cmp, data: Dict.mapU(m.data, f)} -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 size = map => Dict.size(map.data) -let toList = map => Dict.toList(map.data) -let toArray = m => Dict.toArray(m.data) -let keysToArray = m => Dict.keysToArray(m.data) -let valuesToArray = m => Dict.valuesToArray(m.data) -let minKey = m => Dict.minKey(m.data) -let minKeyUndefined = m => Dict.minKeyUndefined(m.data) -let maxKey = m => Dict.maxKey(m.data) -let maxKeyUndefined = m => Dict.maxKeyUndefined(m.data) -let minimum = m => Dict.minimum(m.data) -let minUndefined = m => Dict.minUndefined(m.data) -let maximum = m => Dict.maximum(m.data) -let maxUndefined = m => Dict.maxUndefined(m.data) - -let get = (map, x) => Dict.get(~cmp=map.cmp, map.data, x) - -let getUndefined = (map, x) => Dict.getUndefined(~cmp=map.cmp, map.data, x) - -let getWithDefault = (map, x, def) => Dict.getWithDefault(~cmp=map.cmp, map.data, x, def) - -let getExn = (map, x) => Dict.getExn(~cmp=map.cmp, map.data, x) - -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 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 getData = m => m.data - -let getId = (type key identity, m: t): id => { - module T = { - type identity = identity - type t = key - let cmp = m.cmp - } - module(T) -} - -let packIdData = (type key idx, ~id: id, ~data) => { - module M = unpack(id) - {cmp: M.cmp, data} -} diff --git a/jscomp/others/belt_Map.resi b/jscomp/others/belt_Map.resi deleted file mode 100644 index ae5638d82f1..00000000000 --- a/jscomp/others/belt_Map.resi +++ /dev/null @@ -1,520 +0,0 @@ -/* ********************************************************************* */ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1996 Institut National de Recherche en Informatique et */ -/* en Automatique. All rights reserved. This file is distributed */ -/* under the terms of the GNU Library General Public License, with */ -/* the special exception on linking described in file ../LICENSE. */ -/* */ -/* Adapted by authors of ReScript without using functors */ -/* ********************************************************************* */ - -/*** -The top level provides generic immutable map operations. - -It also has three specialized inner modules `Belt.Map.Int`, `Belt.Map.String` -and `Belt.Map.Dict`. -*/ - -/** -## Examples - -```rescript -type t<'key, 'value, 'identity> -type id<'key, 'id> = Belt_Id.comparable<'key, 'id> -``` -*/ - -module Int = Belt_MapInt - -module String = Belt_MapString - -module Dict = Belt_MapDict - -/** -`'key` is the field type - -`'value` is the element type - -`'identity` the identity of the collection -*/ -type t<'key, 'value, 'identity> - -/** The identity needed for making an empty map. */ -type id<'key, 'id> = Belt_Id.comparable<'key, 'id> - -/** -`make(~id)` creates a new map by taking in the comparator. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let m = Belt.Map.make(~id=module(IntCmp)) - -Belt.Map.set(m, 0, "a") -``` -*/ -let make: (~id: id<'k, 'id>) => t<'k, 'v, 'id> - -/** - -`isEmpty(m)` checks whether a map m is empty. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.isEmpty(Belt.Map.fromArray([(1, "1")], ~id=module(IntCmp))) == false -``` -*/ -let isEmpty: t<_> => bool - -/** -`has(m, k)` checks whether `m` has the key `k`. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -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 -/** -`cmp(m0, m1, vcmp);` - -Total ordering of map given total ordering of value function. - -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 -/** -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 -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)> -/** ` -findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let s0 = Belt.Map.fromArray(~id=module(IntCmp), [(4, "4"), (1, "1"), (2, "2"), (3, "")]) - -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 -/** - `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 -bindings are passed to `f` in increasing order with respect to the ordering -over the type of the keys. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let s0 = Belt.Map.fromArray(~id=module(IntCmp), [(4, "4"), (1, "1"), (2, "2"), (3, "")]) - -let acc = ref(list{}) - -Belt.Map.forEach(s0, (k, v) => acc := list{(k, v), ...acc.contents}) - -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 -/** - `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` are the associated data. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let s0 = Belt.Map.fromArray(~id=module(IntCmp), [(4, "4"), (1, "1"), (2, "2"), (3, "3")]) - -Belt.Map.reduce(s0, list{}, (acc, k, v) => list{ - (k, v), - ...acc, -}) /* [(4, "4"), (3, "3"), (2, "2"), (1, "1"), 0] */ -``` -*/ -let reduce: (t<'k, 'v, 'id>, 'acc, ('acc, 'k, 'v) => 'acc) => 'acc - -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 -/** -`some(m, p)` checks if at least one binding of the map satisfy the predicate -`p`. Order unspecified */ -let some: (t<'k, 'v, 'id>, ('k, 'v) => bool) => bool - -/** - `size(s)` - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.size(Belt.Map.fromArray([(2, "2"), (2, "1"), (3, "3")], ~id=module(IntCmp))) == 2 -``` -*/ -let size: t<'k, 'v, 'id> => int - -/** - `toArray(s)` - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.toArray(Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp))) == [ - (1, "1"), - (2, "2"), - (3, "3"), - ] -``` -*/ -let toArray: t<'k, 'v, 'id> => array<('k, 'v)> - -/** In increasing order. See `Belt.Map.toArray`*/ -let toList: t<'k, 'v, 'id> => list<('k, 'v)> - -/** -`fromArray(kvs, ~id);` - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.toArray(Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp))) == [ - (1, "1"), - (2, "2"), - (3, "3"), - ] -``` -*/ -let fromArray: (array<('k, 'v)>, ~id: id<'k, 'id>) => t<'k, 'v, 'id> - -/** -`keysToArray(s);` - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.keysToArray(Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp))) == [ - 1, - 2, - 3, - ] -``` -*/ -let keysToArray: t<'k, 'v, 'id> => array<'k> - -/** - `valuesToArray(s);` - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.valuesToArray( - Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp)), -) == ["1", "2", "3"] -``` -*/ -let valuesToArray: t<'k, 'v, 'id> => array<'v> - -/** `minKey(s)` returns the minimum key, None if not exist. */ -let minKey: t<'k, _, _> => option<'k> - -/** See `Belt.Map.minKey` */ -let minKeyUndefined: t<'k, _, _> => Js.undefined<'k> - -/** `maxKey(s)` returns the maximum key, None if not exist. */ -let maxKey: t<'k, _, _> => option<'k> - -/** See `Belt.Map.maxKey` */ -let maxKeyUndefined: t<'k, _, _> => Js.undefined<'k> - -/** `minimum(s)` returns the minimum key value pair, None if not exist. */ -let minimum: t<'k, 'v, _> => option<('k, 'v)> - -/** See `Belt.Map.minimum` */ -let minUndefined: t<'k, 'v, _> => Js.undefined<('k, 'v)> - -/** `maximum(s)` returns the maximum key value pair, None if not exist. */ -let maximum: t<'k, 'v, _> => option<('k, 'v)> - -/** See `Belt.Map.maximum` */ -let maxUndefined: t<'k, 'v, _> => Js.undefined<('k, 'v)> - -/** - `get(s, k)` - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -Belt.Map.get(Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp)), 2) == - Some("2") - -Belt.Map.get(Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp)), 2) == None -``` -*/ -let get: (t<'k, 'v, 'id>, 'k) => option<'v> - -/** See `Belt.Map.get`. Returns `undefined` when not found*/ -let getUndefined: (t<'k, 'v, 'id>, 'k) => Js.undefined<'v> - -/** -`getWithDefault(s, k, default)` - -See `Belt.Map.get` - -Returns default when `k` is not found. -*/ -let getWithDefault: (t<'k, 'v, 'id>, 'k, 'v) => 'v - -/** -`getExn(s, k)` - -See `Belt.Map.getExn` - -raise when `k` not exist -*/ -let getExn: (t<'k, 'v, 'id>, 'k) => 'v - -/* ************************************************************************** */ - -/** -`remove(m, x)` when `x` is not in `m`, `m` is returned reference unchanged. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let s0 = Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp)) - -let s1 = Belt.Map.remove(s0, 1) - -let s2 = Belt.Map.remove(s1, 1) - -s1 === s2 - -Belt.Map.keysToArray(s1) == [2, 3] -``` -*/ -let remove: (t<'k, 'v, 'id>, 'k) => t<'k, 'v, 'id> - -/** -`removeMany(s, xs)` - -Removing each of `xs` to `s`, note unlike `Belt.Map.remove`, the reference -of return value might be changed even if none in `xs` exists `s`. -*/ -let removeMany: (t<'k, 'v, 'id>, array<'k>) => t<'k, 'v, 'id> - -/** -`set(m, x, y)` returns a map containing the same bindings as `m`, with a -new binding of `x` to `y`. If `x` was already bound in `m`, its previous -binding disappears. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = (a, b) => Pervasives.compare(a, b) -}) - -let s0 = Belt.Map.fromArray([(2, "2"), (1, "1"), (3, "3")], ~id=module(IntCmp)) - -let s1 = Belt.Map.set(s0, 2, "3") - -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> -/** -`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 -`f(get(m, x))`, the binding of `x` is added, removed or updated. If `y` is -`None`, the binding is removed if it exists; otherwise, if `y` is `Some(z)` -then `x` is associated to `z` in the resulting map. -*/ -let update: (t<'k, 'v, 'id>, 'k, option<'v> => option<'v>) => t<'k, 'v, 'id> - -/** - `mergeMany(s, xs)` - -Adding each of `xs` to `s`, note unlike `add`, the reference of return -value might be changed even if all values in `xs` exist `s`. -*/ -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>, -) => t<'k, 'v3, 'id> -/** -`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` -and of `m2`. The presence of each such binding, and the corresponding -value, is determined with the function `f`. -*/ -let merge: ( - t<'k, 'v, 'id>, - t<'k, 'v2, 'id>, - ('k, option<'v>, option<'v2>) => option<'v3>, -) => t<'k, 'v3, '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>) -/** -`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 -with all the bindings of `s` that do not satisfy `p`. -*/ -let partition: (t<'k, 'v, 'id>, ('k, 'v) => bool) => (t<'k, 'v, 'id>, t<'k, 'v, 'id>) - -/** -`split(x, m)` returns a tuple `(l, r)`, data, where `l` is the map with all -the bindings of `m` whose 'k is strictly less than `x`; `r` is the map with -all the bindings of m whose 'k is strictly greater than `x`; `data` is -`None` if `m` contains no binding for `x`, or `Some(v)` if `m` binds `v` to -`x`. -*/ -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> -/** -`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 -application of`f`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<'k, 'v, 'id>, 'v => 'v2) => t<'k, 'v2, 'id> - -let mapWithKeyU: (t<'k, 'v, 'id>, (. 'k, 'v) => 'v2) => t<'k, 'v2, 'id> -/** -`mapWithKey(m, f)` - -The same as `Belt.Map.map` except that `f` is supplied with one more -argument: the key. -*/ -let mapWithKey: (t<'k, 'v, 'id>, ('k, 'v) => 'v2) => t<'k, 'v2, 'id> - -/** -`getData(s0)` - -Advanced usage only - -Returns the raw data (detached from comparator), but its type is still -manifested, so that user can pass identity directly without boxing. -*/ -let getData: t<'k, 'v, 'id> => Belt_MapDict.t<'k, 'v, 'id> - -/** -Advanced usage only. Returns the identity of s0. -*/ -let getId: t<'k, 'v, 'id> => id<'k, 'id> - -/** -`packIdData(~id, ~data)` - -Advanced usage only - -Returns the packed collection. -*/ -let packIdData: (~id: id<'k, 'id>, ~data: Belt_MapDict.t<'k, 'v, 'id>) => t<'k, 'v, 'id> - -/** -**raise** when invariant is not held -*/ -let checkInvariantInternal: t<_> => unit diff --git a/jscomp/others/belt_MapDict.res b/jscomp/others/belt_MapDict.res deleted file mode 100644 index 0b9dff9f0ee..00000000000 --- a/jscomp/others/belt_MapDict.res +++ /dev/null @@ -1,294 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -module N = Belt_internalAVLtree -module A = Belt_Array - -type t<'key, 'a, 'id> = N.t<'key, 'a> - -type cmp<'key, 'id> = Belt_Id.cmp<'key, 'id> - -let empty = None -let fromArray = N.fromArray -let isEmpty = N.isEmpty -let cmp = N.cmp -let cmpU = N.cmpU -let eq = N.eq -let eqU = N.eqU -let has = N.has - -let forEach = N.forEach -let forEachU = N.forEachU -let reduce = N.reduce -let reduceU = N.reduceU -let every = N.every -let everyU = N.everyU -let some = N.some -let someU = N.someU - -let size = N.size -let toList = N.toList -let toArray = N.toArray -let keysToArray = N.keysToArray -let valuesToArray = N.valuesToArray - -let minimum = N.minimum -let maximum = N.maximum -let minKey = N.minKey -let maxKey = N.maxKey -let minKeyUndefined = N.minKeyUndefined -let maxKeyUndefined = N.maxKeyUndefined -let minUndefined = N.minUndefined -let maxUndefined = N.maxUndefined -let get = N.get -let getUndefined = N.getUndefined -let getWithDefault = N.getWithDefault -let getExn = N.getExn - -let mapWithKey = N.mapWithKey -let mapWithKeyU = N.mapWithKeyU - -let mapU = N.mapU -let map = N.map -let keep = N.keepShared -let keepU = N.keepSharedU -let partitionU = N.partitionSharedU -let partition = N.partitionShared -let checkInvariantInternal = N.checkInvariantInternal -let rec set = (t: t<_>, newK, newD, ~cmp) => - switch t { - | None => N.singleton(newK, newD) - | Some(n) => - let k = n.N.key - let c = Belt_Id.getCmpInternal(cmp)(. newK, k) - if c == 0 { - Some(N.updateValue(n, newD)) - } else { - let (l, r, v) = (n.N.left, n.N.right, n.N.value) - if c < 0 { - /* Worth optimize for reference equality? */ - N.bal(set(~cmp, l, newK, newD), k, v, r) - } else { - N.bal(l, k, v, set(~cmp, r, newK, newD)) - } - } - } - -let rec updateU = (t: t<_>, newK, f, ~cmp): t<_> => - switch t { - | 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) - if c == 0 { - switch f(. Some(n.N.value)) { - | None => - let (l, r) = (n.N.left, n.N.right) - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (_, Some(rn)) => - let (kr, vr) = (ref(rn.key), ref(rn.value)) - let r = N.removeMinAuxWithRef(rn, kr, vr) - N.bal(l, kr.contents, vr.contents, r) - } - | Some(newD) => Some(N.updateValue(n, newD)) - } - } else { - let (l, r, v) = (n.N.left, n.N.right, n.N.value) - if c < 0 { - let ll = updateU(~cmp, l, newK, f) - if l === ll { - t - } else { - N.bal(ll, k, v, r) - } - } else { - let rr = updateU(~cmp, r, newK, f) - if r === rr { - t - } else { - N.bal(l, k, v, rr) - } - } - } - } - -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 - `bool -> 'k Js.null -> ('a Js.null * bool)` - even for specialized `k` the first `bool` can - be erased, maybe the perf boost does not justify the inclusion of such API - - `updateWithNull m x f` - the callback to `f exist v` - when `v` is non-null, - `exist` is guaranteed to be true - `v` is guranteed to be `null`, - when `exist` is `true`, `v` could be `null`, - since `'a` is polymorphic -*/ - -let rec removeAux0 = (n, x, ~cmp) => { - let {N.left: l, key: v, right: r} = n - let c = Belt_Id.getCmpInternal(cmp)(. x, v) - if c == 0 { - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (_, Some(rn)) => - let (kr, vr) = (ref(rn.key), ref(rn.value)) - let r = N.removeMinAuxWithRef(rn, kr, vr) - N.bal(l, kr.contents, vr.contents, r) - } - } else if c < 0 { - switch l { - | None => Some(n) /* Nothing to remove */ - | Some(left) => - let ll = removeAux0(left, x, ~cmp) - if ll === l { - Some(n) - } else { - N.bal(ll, v, n.N.value, r) - } - } - } else { - switch r { - | None => Some(n) /* Nothing to remove */ - | Some(right) => - let rr = removeAux0(~cmp, right, x) - if rr === r { - Some(n) - } else { - N.bal(l, v, n.N.value, rr) - } - } - } -} - -let remove = (n, x, ~cmp) => - switch n { - | None => None - | Some(n) => removeAux0(n, x, ~cmp) - } - -let mergeMany = (h, arr, ~cmp) => { - let len = A.length(arr) - let v = ref(h) - for i in 0 to len - 1 { - let (key, value) = A.getUnsafe(arr, i) - v.contents = set(v.contents, ~cmp, key, value) - } - v.contents -} - -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) - if c == 0 { - pres.contents = Some(d) - (l, r) - } else if c < 0 { - switch l { - | None => (None, Some(n)) - | Some(l) => - let (ll, rl) = splitAuxPivot(~cmp, l, x, pres) - (ll, N.join(rl, v, d, r)) - } - } else { - switch r { - | None => (Some(n), None) - | Some(r) => - let (lr, rr) = splitAuxPivot(~cmp, r, x, pres) - (N.join(l, v, d, lr), rr) - } - } -} - -let split = (n, x, ~cmp) => - switch n { - | None => ((None, None), None) - | Some(n) => - let pres = ref(None) - let v = splitAuxPivot(~cmp, n, x, pres) - (v, pres.contents) - } - -let findFirstByU = N.findFirstByU -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(s1n), Some(s2n)) => - if s1n.height >= s2n.height { - let {N.left: l1, key: v1, value: d1, right: r1} = s1n - let d2 = ref(None) - 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 newRight = mergeU(~cmp, r1, r2, f) - N.concatOrJoin(newLeft, v1, newD, newRight) - } else { - let {N.left: l2, key: v2, value: d2, right: r2} = s2n - let d1 = ref(None) - 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 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 rec removeMany0 = (t, xs, i, len, ~cmp) => - if i < len { - let ele = A.getUnsafe(xs, i) - let u = removeAux0(t, ele, ~cmp) - switch u { - | None => u - | Some(t) => removeMany0(t, xs, i + 1, len, ~cmp) - } - } else { - Some(t) - } - -let removeMany = (t, keys, ~cmp) => { - let len = A.length(keys) - switch t { - | None => None - | Some(t) => removeMany0(t, keys, 0, len, ~cmp) - } -} diff --git a/jscomp/others/belt_MapDict.resi b/jscomp/others/belt_MapDict.resi deleted file mode 100644 index 7dafef606fc..00000000000 --- a/jscomp/others/belt_MapDict.resi +++ /dev/null @@ -1,234 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -This module separates identity from data, it is a bit more verbose but -slightly more efficient due to the fact that there is no need to pack -identity and data back after each operation. - -**_Advanced usage only_** -*/ - -/* -## Examples - -```rescript -type t<'key, 'value, 'id> -type cmp<'key, 'id> = Belt_Id.cmp<'key, 'id> -``` -*/ - -type t<'key, 'value, 'id> - -type cmp<'key, 'id> = Belt_Id.cmp<'key, 'id> - -let empty: t<'k, 'v, 'id> - -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 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 -/** -`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 -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)> -/** -`findFirstBy(m, p)` uses function `f` to find the first key value pair to -match predicate `p`. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Map.Dict.fromArray([(4, "4"), (1, "1"), (2, "2"), (3, "3")], ~cmp=IntCmp.cmp) - -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 -/** -`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 -bindings are passed to `f` in increasing order with respect to the ordering -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 -/** -`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` -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 -/** -`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 -/** -`some(m, p)` checks if at least one binding of the map satisfy the -predicate `p`. Order unspecified -*/ -let some: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool - -let size: t<'k, 'a, 'id> => int - -/** In increasing order. */ -let toList: t<'k, 'a, 'id> => list<('k, 'a)> - -let toArray: t<'k, 'a, 'id> => array<('k, 'a)> - -let fromArray: (array<('k, 'a)>, ~cmp: cmp<'k, 'id>) => t<'k, 'a, 'id> - -let keysToArray: t<'k, 'a, 'id> => array<'k> - -let valuesToArray: t<'k, 'a, 'id> => array<'a> - -let minKey: t<'k, _, _> => option<'k> - -let minKeyUndefined: t<'k, _, _> => Js.undefined<'k> - -let maxKey: t<'k, _, _> => option<'k> - -let maxKeyUndefined: t<'k, _, _> => Js.undefined<'k> - -let minimum: t<'k, 'a, _> => option<('k, 'a)> - -let minUndefined: t<'k, 'a, _> => Js.undefined<('k, 'a)> - -let maximum: t<'k, 'a, _> => option<('k, 'a)> - -let maxUndefined: t<'k, 'a, _> => Js.undefined<('k, 'a)> - -let get: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => option<'a> - -let getUndefined: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => Js.undefined<'a> - -let getWithDefault: (t<'k, 'a, 'id>, 'k, 'a, ~cmp: cmp<'k, 'id>) => 'a - -let getExn: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => 'a - -let checkInvariantInternal: t<_> => unit - -/** -`remove(m, x)` returns a map containing the same bindings as `m`, except -for `x` which is unbound in the returned map. -*/ -let remove: (t<'a, 'b, 'id>, 'a, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> - -let removeMany: (t<'a, 'b, 'id>, array<'a>, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> - -/** -`set(m, x, y)` returns a map containing the same bindings as `m`, plus a -binding of `x` to `y`. If `x` was already bound in `m`, its previous -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 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>, - ~cmp: cmp<'a, 'id>, -) => t<'a, 'd, 'id> -/** -`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` -and of `m2`. The presence of each such binding, and the corresponding -value, is determined with the function `f`. -*/ -let merge: ( - t<'a, 'b, 'id>, - t<'a, 'c, 'id>, - ('a, option<'b>, option<'c>) => option<'d>, - ~cmp: cmp<'a, 'id>, -) => t<'a, 'd, 'id> - -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> -/** -`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>) -/** -`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 -with all the bindings of `s` that do not satisfy `p`. -*/ -let partition: (t<'k, 'a, 'id>, ('k, 'a) => bool) => (t<'k, 'a, 'id>, t<'k, 'a, 'id>) - -/** -`split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with -all the bindings of `m` whose key is strictly less than `x`; `r` is the map -with all the bindings of `m` whose key is strictly greater than `x`; `data` -is `None` if `m` contains no binding for `x`, or `Some(v)` if `m` binds `v` -to `x`. -*/ -let split: ( - t<'a, 'b, 'id>, - 'a, - ~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> -/** -`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 -application of `f` 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<'k, 'a, 'id>, '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/jscomp/others/belt_MapInt.res b/jscomp/others/belt_MapInt.res deleted file mode 100644 index d56016414d3..00000000000 --- a/jscomp/others/belt_MapInt.res +++ /dev/null @@ -1,192 +0,0 @@ -type key = int -module I = Belt_internalMapInt - -module N = Belt_internalAVLtree -module A = Belt_Array - -type t<'a> = N.t - -let empty = None -let isEmpty = N.isEmpty -/* let singleton = N.singleton */ - -let minKey = N.minKey -let minKeyUndefined = N.minKeyUndefined -let maxKey = N.maxKey -let maxKeyUndefined = N.maxKeyUndefined -let minimum = N.minimum -let minUndefined = N.minUndefined -let maximum = N.maximum -let maxUndefined = N.maxUndefined -let forEachU = N.forEachU -let forEach = N.forEach -let mapU = N.mapU -let map = N.map -let mapWithKeyU = N.mapWithKeyU -let mapWithKey = N.mapWithKey -let reduceU = N.reduceU -let reduce = N.reduce -let everyU = N.everyU -let every = N.every -let someU = N.someU -let some = N.some -let keepU = N.keepSharedU -let keep = N.keepShared -let partitionU = N.partitionSharedU -let partition = N.partitionShared -let size = N.size -let toList = N.toList -let toArray = N.toArray -let keysToArray = N.keysToArray -let valuesToArray = N.valuesToArray -let checkInvariantInternal = N.checkInvariantInternal - -let rec set = (t, newK: key, newD: _) => - switch t { - | None => N.singleton(newK, newD) - | Some(n) => - let k = n.N.key - if newK == k { - Some(N.updateValue(n, newD)) - } else { - let v = n.N.value - if newK < k { - N.bal(set(n.N.left, newK, newD), k, v, n.N.right) - } else { - N.bal(n.N.left, k, v, set(n.N.right, newK, newD)) - } - } - } - -let rec updateU = (t, x: key, f) => - switch t { - | 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)) { - | None => - let {N.left: l, right: r} = n - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (_, Some(rn)) => - let (kr, vr) = (ref(rn.N.key), ref(rn.N.value)) - let r = N.removeMinAuxWithRef(rn, kr, vr) - N.bal(l, kr.contents, vr.contents, r) - } - | Some(data) => Some(N.updateValue(n, data)) - } - } else { - let {N.left: l, right: r, value: v} = n - if x < k { - let ll = updateU(l, x, f) - if l === ll { - t - } else { - N.bal(ll, k, v, r) - } - } else { - let rr = updateU(r, x, f) - if r === rr { - t - } else { - N.bal(l, k, v, rr) - } - } - } - } - -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 - if x == v { - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (_, Some(rn)) => - let (kr, vr) = (ref(rn.N.key), ref(rn.N.value)) - let r = N.removeMinAuxWithRef(rn, kr, vr) - N.bal(l, kr.contents, vr.contents, r) - } - } else if x < v { - switch l { - | None => Some(n) - | Some(left) => - let ll = removeAux(left, x) - if ll === l { - Some(n) - } else { - open N - bal(ll, v, n.value, r) - } - } - } else { - switch r { - | None => Some(n) - | Some(right) => - let rr = removeAux(right, x) - N.bal(l, v, n.N.value, rr) - } - } -} - -let remove = (n, x) => - switch n { - | None => None - | Some(n) => removeAux(n, x) - } - -let rec removeMany0 = (t, xs, i, len) => - if i < len { - let ele = A.getUnsafe(xs, i) - let u = removeAux(t, ele) - switch u { - | None => u - | Some(t) => removeMany0(t, xs, i + 1, len) - } - } else { - Some(t) - } - -let removeMany = (t, keys) => { - let len = A.length(keys) - switch t { - | None => None - | Some(t) => removeMany0(t, keys, 0, len) - } -} - -let findFirstByU = N.findFirstByU -let findFirstBy = N.findFirstBy - -let mergeMany = (h, arr) => { - let len = A.length(arr) - let v = ref(h) - for i in 0 to len - 1 { - let (key, value) = A.getUnsafe(arr, i) - v.contents = set(v.contents, key, value) - } - v.contents -} - -/* let mergeArray = mergeMany */ - -let has = I.has -let cmpU = I.cmpU -let cmp = I.cmp -let eqU = I.eqU -let eq = I.eq -let get = I.get -let getUndefined = I.getUndefined -let getWithDefault = I.getWithDefault -let getExn = I.getExn -let split = I.split -let mergeU = I.mergeU -let merge = I.merge -let fromArray = I.fromArray diff --git a/jscomp/others/belt_MapInt.resi b/jscomp/others/belt_MapInt.resi deleted file mode 100644 index a4c1f608d69..00000000000 --- a/jscomp/others/belt_MapInt.resi +++ /dev/null @@ -1,175 +0,0 @@ -type key = int - -/** The type of maps from type `key` to type `'value`. */ -type t<'value> - -let empty: t<'v> - -let isEmpty: t<'v> => bool - -let has: (t<'v>, key) => bool - -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 - -/** -`eq(m1, m2)` tests whether the maps `m1` and `m2` are -equal, that is, contain equal keys and associate them with -equal data. -*/ -let eq: (t<'v>, t<'v>, ('v, 'v) => bool) => bool - -let findFirstByU: (t<'v>, (. key, 'v) => bool) => option<(key, 'v)> - -/** -`findFirstBy(m, p)` uses funcion `f` to find the first key value pair -to match predicate `p`. - -```rescript -let s0 = fromArray(~id=module(IntCmp), [(4, "4"), (1, "1"), (2, "2,"(3, ""))]) -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 - -/** -`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 bindings are passed to `f` in increasing -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 - -/** -`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` are the associated data. -*/ -let reduce: (t<'v>, 'v2, ('v2, key, 'v) => 'v2) => 'v2 - -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 - -/** -`some(m, p)` checks if at least one binding of the map satisfy the predicate -`p`. Order unspecified */ -let some: (t<'v>, (key, 'v) => bool) => bool - -let size: t<'v> => int - -/** In increasing order. */ -let toList: t<'v> => list<(key, 'v)> - -let toArray: t<'v> => array<(key, 'v)> - -let fromArray: array<(key, 'v)> => t<'v> - -let keysToArray: t<'v> => array - -let valuesToArray: t<'v> => array<'v> - -let minKey: t<_> => option - -let minKeyUndefined: t<_> => Js.undefined - -let maxKey: t<_> => option - -let maxKeyUndefined: t<_> => Js.undefined - -let minimum: t<'v> => option<(key, 'v)> - -let minUndefined: t<'v> => Js.undefined<(key, 'v)> - -let maximum: t<'v> => option<(key, 'v)> - -let maxUndefined: t<'v> => Js.undefined<(key, 'v)> - -let get: (t<'v>, key) => option<'v> - -let getUndefined: (t<'v>, key) => Js.undefined<'v> - -let getWithDefault: (t<'v>, key, 'v) => 'v - -let getExn: (t<'v>, key) => 'v - -/** -**raise** when invariant is not held -*/ -let checkInvariantInternal: t<_> => unit - -/** `remove m x` returns a map containing the same bindings as - `m`, except for `x` which is unbound in the returned map. */ -let remove: (t<'v>, key) => t<'v> - -let removeMany: (t<'v>, array) => t<'v> - -/** -`set(m, x, y)` returns a map containing the same bindings as -`m`, plus a binding of `x` to `y`. If `x` was already bound -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 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> - -/** -`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` -and of `m2`. The presence of each such binding, and the corresponding -value, is determined with the function `f`. -*/ -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> - -/** -`keep(m, p)` returns the map with all the bindings in `m` that satisfy predicate -`p`. -*/ -let keep: (t<'v>, (key, 'v) => bool) => 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 -bindings of `s` that satisfy the predicate `p`, and `m2` is the map with all the -bindings of `s` that do not satisfy `p`. -*/ -let partition: (t<'v>, (key, 'v) => bool) => (t<'v>, t<'v>) - -/** -`split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with all the -bindings of `m` whose key is strictly less than `x`; `r` is the map with all the -bindings of `m` whose key is strictly greater than `x`; `data` is `None` if `m` -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> - -/** -`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 application of `f` -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<'v>, '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/jscomp/others/belt_MapString.res b/jscomp/others/belt_MapString.res deleted file mode 100644 index 460e6a41a56..00000000000 --- a/jscomp/others/belt_MapString.res +++ /dev/null @@ -1,192 +0,0 @@ -type key = string -module I = Belt_internalMapString - -module N = Belt_internalAVLtree -module A = Belt_Array - -type t<'a> = N.t - -let empty = None -let isEmpty = N.isEmpty -/* let singleton = N.singleton */ - -let minKey = N.minKey -let minKeyUndefined = N.minKeyUndefined -let maxKey = N.maxKey -let maxKeyUndefined = N.maxKeyUndefined -let minimum = N.minimum -let minUndefined = N.minUndefined -let maximum = N.maximum -let maxUndefined = N.maxUndefined -let forEachU = N.forEachU -let forEach = N.forEach -let mapU = N.mapU -let map = N.map -let mapWithKeyU = N.mapWithKeyU -let mapWithKey = N.mapWithKey -let reduceU = N.reduceU -let reduce = N.reduce -let everyU = N.everyU -let every = N.every -let someU = N.someU -let some = N.some -let keepU = N.keepSharedU -let keep = N.keepShared -let partitionU = N.partitionSharedU -let partition = N.partitionShared -let size = N.size -let toList = N.toList -let toArray = N.toArray -let keysToArray = N.keysToArray -let valuesToArray = N.valuesToArray -let checkInvariantInternal = N.checkInvariantInternal - -let rec set = (t, newK: key, newD: _) => - switch t { - | None => N.singleton(newK, newD) - | Some(n) => - let k = n.N.key - if newK == k { - Some(N.updateValue(n, newD)) - } else { - let v = n.N.value - if newK < k { - N.bal(set(n.N.left, newK, newD), k, v, n.N.right) - } else { - N.bal(n.N.left, k, v, set(n.N.right, newK, newD)) - } - } - } - -let rec updateU = (t, x: key, f) => - switch t { - | 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)) { - | None => - let {N.left: l, right: r} = n - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (_, Some(rn)) => - let (kr, vr) = (ref(rn.N.key), ref(rn.N.value)) - let r = N.removeMinAuxWithRef(rn, kr, vr) - N.bal(l, kr.contents, vr.contents, r) - } - | Some(data) => Some(N.updateValue(n, data)) - } - } else { - let {N.left: l, right: r, value: v} = n - if x < k { - let ll = updateU(l, x, f) - if l === ll { - t - } else { - N.bal(ll, k, v, r) - } - } else { - let rr = updateU(r, x, f) - if r === rr { - t - } else { - N.bal(l, k, v, rr) - } - } - } - } - -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 - if x == v { - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (_, Some(rn)) => - let (kr, vr) = (ref(rn.N.key), ref(rn.N.value)) - let r = N.removeMinAuxWithRef(rn, kr, vr) - N.bal(l, kr.contents, vr.contents, r) - } - } else if x < v { - switch l { - | None => Some(n) - | Some(left) => - let ll = removeAux(left, x) - if ll === l { - Some(n) - } else { - open N - bal(ll, v, n.value, r) - } - } - } else { - switch r { - | None => Some(n) - | Some(right) => - let rr = removeAux(right, x) - N.bal(l, v, n.N.value, rr) - } - } -} - -let remove = (n, x) => - switch n { - | None => None - | Some(n) => removeAux(n, x) - } - -let rec removeMany0 = (t, xs, i, len) => - if i < len { - let ele = A.getUnsafe(xs, i) - let u = removeAux(t, ele) - switch u { - | None => u - | Some(t) => removeMany0(t, xs, i + 1, len) - } - } else { - Some(t) - } - -let removeMany = (t, keys) => { - let len = A.length(keys) - switch t { - | None => None - | Some(t) => removeMany0(t, keys, 0, len) - } -} - -let findFirstByU = N.findFirstByU -let findFirstBy = N.findFirstBy - -let mergeMany = (h, arr) => { - let len = A.length(arr) - let v = ref(h) - for i in 0 to len - 1 { - let (key, value) = A.getUnsafe(arr, i) - v.contents = set(v.contents, key, value) - } - v.contents -} - -/* let mergeArray = mergeMany */ - -let has = I.has -let cmpU = I.cmpU -let cmp = I.cmp -let eqU = I.eqU -let eq = I.eq -let get = I.get -let getUndefined = I.getUndefined -let getWithDefault = I.getWithDefault -let getExn = I.getExn -let split = I.split -let mergeU = I.mergeU -let merge = I.merge -let fromArray = I.fromArray diff --git a/jscomp/others/belt_MapString.resi b/jscomp/others/belt_MapString.resi deleted file mode 100644 index 5cd87922bcc..00000000000 --- a/jscomp/others/belt_MapString.resi +++ /dev/null @@ -1,175 +0,0 @@ -type key = string - -/** The type of maps from type `key` to type `'value`. */ -type t<'value> - -let empty: t<'v> - -let isEmpty: t<'v> => bool - -let has: (t<'v>, key) => bool - -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 - -/** -`eq(m1, m2)` tests whether the maps `m1` and `m2` are -equal, that is, contain equal keys and associate them with -equal data. -*/ -let eq: (t<'v>, t<'v>, ('v, 'v) => bool) => bool - -let findFirstByU: (t<'v>, (. key, 'v) => bool) => option<(key, 'v)> - -/** -`findFirstBy(m, p)` uses funcion `f` to find the first key value pair -to match predicate `p`. - -```rescript -let s0 = fromArray(~id=module(IntCmp), [(4, "4"), (1, "1"), (2, "2,"(3, ""))]) -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 - -/** -`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 bindings are passed to `f` in increasing -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 - -/** -`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` are the associated data. -*/ -let reduce: (t<'v>, 'v2, ('v2, key, 'v) => 'v2) => 'v2 - -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 - -/** -`some(m, p)` checks if at least one binding of the map satisfy the predicate -`p`. Order unspecified */ -let some: (t<'v>, (key, 'v) => bool) => bool - -let size: t<'v> => int - -/** In increasing order. */ -let toList: t<'v> => list<(key, 'v)> - -let toArray: t<'v> => array<(key, 'v)> - -let fromArray: array<(key, 'v)> => t<'v> - -let keysToArray: t<'v> => array - -let valuesToArray: t<'v> => array<'v> - -let minKey: t<_> => option - -let minKeyUndefined: t<_> => Js.undefined - -let maxKey: t<_> => option - -let maxKeyUndefined: t<_> => Js.undefined - -let minimum: t<'v> => option<(key, 'v)> - -let minUndefined: t<'v> => Js.undefined<(key, 'v)> - -let maximum: t<'v> => option<(key, 'v)> - -let maxUndefined: t<'v> => Js.undefined<(key, 'v)> - -let get: (t<'v>, key) => option<'v> - -let getUndefined: (t<'v>, key) => Js.undefined<'v> - -let getWithDefault: (t<'v>, key, 'v) => 'v - -let getExn: (t<'v>, key) => 'v - -/** -**raise** when invariant is not held -*/ -let checkInvariantInternal: t<_> => unit - -/** `remove m x` returns a map containing the same bindings as - `m`, except for `x` which is unbound in the returned map. */ -let remove: (t<'v>, key) => t<'v> - -let removeMany: (t<'v>, array) => t<'v> - -/** -`set(m, x, y)` returns a map containing the same bindings as -`m`, plus a binding of `x` to `y`. If `x` was already bound -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 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> - -/** -`merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` -and of `m2`. The presence of each such binding, and the corresponding -value, is determined with the function `f`. -*/ -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> - -/** -`keep(m, p)` returns the map with all the bindings in `m` that satisfy predicate -`p`. -*/ -let keep: (t<'v>, (key, 'v) => bool) => 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 -bindings of `s` that satisfy the predicate `p`, and `m2` is the map with all the -bindings of `s` that do not satisfy `p`. -*/ -let partition: (t<'v>, (key, 'v) => bool) => (t<'v>, t<'v>) - -/** -`split(x, m)` returns a triple `(l, data, r)`, where `l` is the map with all the -bindings of `m` whose key is strictly less than `x`; `r` is the map with all the -bindings of `m` whose key is strictly greater than `x`; `data` is `None` if `m` -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> - -/** -`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 application of `f` -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<'v>, '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/jscomp/others/belt_MutableMap.res b/jscomp/others/belt_MutableMap.res deleted file mode 100644 index ba367b455d0..00000000000 --- a/jscomp/others/belt_MutableMap.res +++ /dev/null @@ -1,235 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -module Int = Belt_MutableMapInt -module String = Belt_MutableMapString - -module N = Belt_internalAVLtree -module A = Belt_Array - -type id<'key, 'id> = Belt_Id.comparable<'key, 'id> -type cmp<'key, 'id> = Belt_Id.cmp<'key, 'id> - -type t<'k, 'v, 'id> = { - cmp: cmp<'k, 'id>, - mutable data: N.t<'k, 'v>, -} - -let rec removeMutateAux = (nt, x, ~cmp) => { - let k = nt.N.key - let c = Belt_Id.getCmpInternal(cmp)(. x, k) - if c == 0 { - let {N.left: l, right: r} = nt - switch (l, r) { - | (Some(_), Some(nr)) => - nt.right = N.removeMinAuxWithRootMutate(nt, nr) - Some(N.balMutate(nt)) - | (None, Some(_)) => r - | (Some(_) | None, None) => l - } - } else if c < 0 { - switch nt.N.left { - | None => Some(nt) - | Some(l) => - nt.left = removeMutateAux(~cmp, l, x) - Some(N.balMutate(nt)) - } - } else { - switch nt.right { - | None => Some(nt) - | Some(r) => - nt.right = removeMutateAux(~cmp, r, x) - Some(N.balMutate(nt)) - } - } -} - -let remove = (d, k) => { - let oldRoot = d.data - switch oldRoot { - | None => () - | Some(oldRoot2) => - let newRoot = removeMutateAux(~cmp=d.cmp, oldRoot2, k) - if newRoot !== oldRoot { - d.data = newRoot - } - } -} - -let rec removeArrayMutateAux = (t, xs, i, len, ~cmp) => - if i < len { - let ele = A.getUnsafe(xs, i) - let u = removeMutateAux(t, ele, ~cmp) - switch u { - | None => None - | Some(t) => removeArrayMutateAux(t, xs, i + 1, len, ~cmp) - } - } else { - Some(t) - } - -let removeMany = (d, xs) => { - let oldRoot = d.data - switch oldRoot { - | None => () - | Some(nt) => - let len = A.length(xs) - let newRoot = removeArrayMutateAux(nt, xs, 0, len, ~cmp=d.cmp) - if newRoot !== oldRoot { - d.data = newRoot - } - } -} - -let rec updateDone = (t, x, f, ~cmp) => - switch t { - | 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) - if c == 0 { - switch f(. Some(nt.value)) { - | None => - let {N.left: l, right: r} = nt - switch (l, r) { - | (Some(_), Some(nr)) => - nt.right = N.removeMinAuxWithRootMutate(nt, nr) - Some(N.balMutate(nt)) - | (None, Some(_)) => r - | (Some(_) | None, None) => l - } - | Some(data) => - nt.value = data - Some(nt) - } - } else { - if c < 0 { - nt.left = updateDone(nt.left, x, f, ~cmp) - } else { - nt.right = updateDone(nt.right, x, f, ~cmp) - } - Some(N.balMutate(nt)) - } - } -let updateU = (t, x, f) => { - let oldRoot = t.data - let newRoot = updateDone(oldRoot, x, f, ~cmp=t.cmp) - if newRoot !== oldRoot { - t.data = newRoot - } -} -let update = (t, x, f) => updateU(t, x, (. a) => f(a)) - -let make = (type key identity, ~id: id) => { - module M = unpack(id) - {cmp: M.cmp, data: None} -} - -let clear = m => m.data = None - -let isEmpty = d => N.isEmpty(d.data) - -let minKey = m => N.minKey(m.data) -let minKeyUndefined = m => N.minKeyUndefined(m.data) -let maxKey = m => N.maxKey(m.data) -let maxKeyUndefined = m => N.maxKeyUndefined(m.data) -let minimum = m => N.minimum(m.data) -let minUndefined = m => N.minUndefined(m.data) -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 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 everyU = (d, p) => N.everyU(d.data, p) -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 size = d => N.size(d.data) -let toList = d => N.toList(d.data) -let toArray = d => N.toArray(d.data) -let keysToArray = d => N.keysToArray(d.data) -let valuesToArray = d => N.valuesToArray(d.data) - -/* let fromSortedArrayUnsafe (type key) (type identity) ~(id : (key,identity) id) xs : _ t = - let module M = (val id) in - S.t ~data:(N.fromSortedArrayUnsafe xs) ~cmp:M.cmp */ - -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 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 mapU = (m, f) => {cmp: m.cmp, data: N.mapU(m.data, f)} -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 get = (m, x) => N.get(~cmp=m.cmp, m.data, x) - -let getUndefined = (m, x) => N.getUndefined(~cmp=m.cmp, m.data, x) - -let getWithDefault = (m, x, def) => N.getWithDefault(~cmp=m.cmp, m.data, x, def) - -let getExn = (m, x) => N.getExn(~cmp=m.cmp, m.data, x) - -let has = (m, x) => N.has(~cmp=m.cmp, m.data, x) - -let fromArray = (type k identity, data, ~id: id) => { - module M = unpack(id) - let cmp = M.cmp - {cmp, data: N.fromArray(~cmp, data)} -} - -let set = (m, e, v) => { - let oldRoot = m.data - let newRoot = N.updateMutate(~cmp=m.cmp, oldRoot, e, v) - if newRoot !== oldRoot { - m.data = newRoot - } -} - -let mergeManyAux = (t, xs, ~cmp) => { - let v = ref(t) - for i in 0 to A.length(xs) - 1 { - let (key, value) = A.getUnsafe(xs, i) - v.contents = N.updateMutate(v.contents, key, value, ~cmp) - } - v.contents -} - -let mergeMany = (d, xs) => { - let oldRoot = d.data - let newRoot = mergeManyAux(oldRoot, xs, ~cmp=d.cmp) - if newRoot !== oldRoot { - d.data = newRoot - } -} diff --git a/jscomp/others/belt_MutableMap.resi b/jscomp/others/belt_MutableMap.resi deleted file mode 100644 index 5451272de07..00000000000 --- a/jscomp/others/belt_MutableMap.resi +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -module Int = Belt_MutableMapInt - -module String = Belt_MutableMapString - -/*** -A mutable sorted map module which allows customize compare behavior. - -Same as `Belt.Map`, but mutable. -*/ - -/* -## Examples - -```rescript -type t<'k, 'v, 'id> -type id<'key, 'id> = Belt_Id.comparable<'key, 'id> -``` -*/ - -type t<'k, 'v, 'id> -type id<'key, 'id> = Belt_Id.comparable<'key, 'id> - -let make: (~id: id<'k, 'id>) => t<'k, 'a, 'id> -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 -/** -`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 -/** -`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 -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 -/** -`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 -bindings are passed to `f` in increasing order with respect to the ordering -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 -/** -`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` -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 -/** -`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 -/** -`some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. -*/ -let some: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool - -let size: t<'k, 'a, 'id> => int - -/** In increasing order. */ -let toList: t<'k, 'a, 'id> => list<('k, 'a)> - -let toArray: t<'k, 'a, 'id> => array<('k, 'a)> - -let fromArray: (array<('k, 'a)>, ~id: id<'k, 'id>) => t<'k, 'a, 'id> -let keysToArray: t<'k, _, _> => array<'k> -let valuesToArray: t<_, 'a, _> => array<'a> -let minKey: t<'k, _, _> => option<'k> -let minKeyUndefined: t<'k, _, _> => Js.undefined<'k> -let maxKey: t<'k, _, _> => option<'k> -let maxKeyUndefined: t<'k, _, _> => Js.undefined<'k> -let minimum: t<'k, 'a, _> => option<('k, 'a)> -let minUndefined: t<'k, 'a, _> => Js.undefined<('k, 'a)> -let maximum: t<'k, 'a, _> => option<('k, 'a)> -let maxUndefined: t<'k, 'a, _> => Js.undefined<('k, 'a)> -let get: (t<'k, 'a, 'id>, 'k) => option<'a> -let getUndefined: (t<'k, 'a, 'id>, 'k) => Js.undefined<'a> -let getWithDefault: (t<'k, 'a, 'id>, 'k, 'a) => 'a -let getExn: (t<'k, 'a, 'id>, 'k) => 'a -/** Raise when invariant is not held. */ -let checkInvariantInternal: t<_> => unit - -/* ************************************************************************** */ - -/* TODO: add functional `merge, partition, keep, split` */ - -/** `remove(m, x)` do the in-place modification. */ -let remove: (t<'k, 'a, 'id>, 'k) => unit - -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 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> -/** -`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 -application of `f` 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<'k, 'a, 'id>, '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/jscomp/others/belt_MutableMapInt.res b/jscomp/others/belt_MutableMapInt.res deleted file mode 100644 index a8e7d69b641..00000000000 --- a/jscomp/others/belt_MutableMapInt.res +++ /dev/null @@ -1,176 +0,0 @@ -module I = Belt_internalMapInt -type key = int - -module N = Belt_internalAVLtree -module A = Belt_Array - -type t<'a> = {mutable data: I.t<'a>} - -let make = () => {data: None} -let isEmpty = m => N.isEmpty(m.data) -let clear = m => m.data = None -/* let singleton k v = t ~data:(N.singleton k v) */ - -let minKeyUndefined = m => N.minKeyUndefined(m.data) -let minKey = m => N.minKey(m.data) -let maxKeyUndefined = m => N.maxKeyUndefined(m.data) -let maxKey = m => N.maxKey(m.data) -let minimum = m => N.minimum(m.data) -let minUndefined = m => N.minUndefined(m.data) -let maximum = m => N.maximum(m.data) -let maxUndefined = m => N.maxUndefined(m.data) - -let set = (m: t<_>, k, v) => { - let old_data = m.data - let v = I.addMutate(old_data, k, v) - if v !== old_data { - m.data = v - } -} - -let forEachU = (d, f) => N.forEachU(d.data, f) -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 mapWithKeyU = (d, f) => {data: N.mapWithKeyU(d.data, f)} -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 everyU = (d, f) => N.everyU(d.data, f) -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 size = d => N.size(d.data) -let toList = d => N.toList(d.data) -let toArray = d => N.toArray(d.data) -let keysToArray = d => N.keysToArray(d.data) -let valuesToArray = d => N.valuesToArray(d.data) -let checkInvariantInternal = d => N.checkInvariantInternal(d.data) -let has = (d, v) => I.has(d.data, v) - -let rec removeMutateAux = (nt, x: key) => { - let k = nt.N.key - if x == k { - let {N.left: l, right: r} = nt - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (_, Some(nr)) => - nt.right = N.removeMinAuxWithRootMutate(nt, nr) - Some(N.balMutate(nt)) - } - } else if x < k { - switch nt.left { - | None => Some(nt) - | Some(l) => - nt.left = removeMutateAux(l, x) - Some(N.balMutate(nt)) - } - } else { - switch nt.right { - | None => Some(nt) - | Some(r) => - nt.right = removeMutateAux(r, x) - Some(N.balMutate(nt)) - } - } -} - -let remove = (d, v) => { - let oldRoot = d.data - switch oldRoot { - | None => () - | Some(root) => - let newRoot = removeMutateAux(root, v) - if newRoot !== oldRoot { - d.data = newRoot - } - } -} - -let rec updateDone = (t, x: key, f) => - switch t { - | None => - switch f(. None) { - | Some(data) => N.singleton(x, data) - | None => t - } - | Some(nt) => - let k = nt.N.key - - /* let c = (Belt_Cmp.getCmpInternal cmp) x k [@bs] in */ - if k == x { - switch f(. Some(nt.value)) { - | None => - let {N.left: l, right: r} = nt - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (_, Some(nr)) => - nt.right = N.removeMinAuxWithRootMutate(nt, nr) - Some(N.balMutate(nt)) - } - | Some(data) => - nt.value = data - Some(nt) - } - } else { - let {N.left: l, right: r} = nt - if x < k { - let ll = updateDone(l, x, f) - nt.left = ll - } else { - nt.right = updateDone(r, x, f) - } - Some(N.balMutate(nt)) - } - } - -let updateU = (t, x, f) => { - let oldRoot = t.data - let newRoot = updateDone(oldRoot, x, f) - if newRoot !== oldRoot { - t.data = newRoot - } -} -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) - let u = removeMutateAux(t, ele) - switch u { - | None => None - | Some(t) => removeArrayMutateAux(t, xs, i + 1, len) - } - } else { - Some(t) - } - -let removeMany = (d: t<_>, xs) => { - let oldRoot = d.data - switch oldRoot { - | None => () - | Some(nt) => - let len = A.length(xs) - let newRoot = removeArrayMutateAux(nt, xs, 0, len) - if newRoot !== oldRoot { - d.data = newRoot - } - } -} - -/* let split = I.split */ -/* let merge = I.merge */ - -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 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 get = (d, x) => I.get(d.data, x) -let getUndefined = (d, x) => I.getUndefined(d.data, x) -let getWithDefault = (d, x, def) => I.getWithDefault(d.data, x, def) -let getExn = (d, x) => I.getExn(d.data, x) diff --git a/jscomp/others/belt_MutableMapInt.resi b/jscomp/others/belt_MutableMapInt.resi deleted file mode 100644 index 6f1b66a97a3..00000000000 --- a/jscomp/others/belt_MutableMapInt.resi +++ /dev/null @@ -1,137 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -type key = int - -type t<'a> - -let make: unit => t<'a> -let clear: t<'a> => unit -let isEmpty: t<'a> => bool - -let has: (t<'a>, key) => bool - -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, -value pair -*/ -let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int - -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 - -/** -`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 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 - -/** -`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` are the -associated data. */ -let reduce: (t<'a>, 'b, ('b, key, 'a) => 'b) => 'b - -let everyU: (t<'a>, (. key, 'a) => bool) => bool - -/** -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. -The application order of `p` is unspecified. -*/ -let every: (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`. -The application order of `p` is unspecified. -*/ -let some: (t<'a>, (key, 'a) => bool) => bool - -let size: t<'a> => int - -/** In increasing order */ -let toList: t<'a> => list<(key, 'a)> - -/** In increasing order */ -let toArray: t<'a> => array<(key, 'a)> - -let fromArray: array<(key, 'a)> => t<'a> -let keysToArray: t<'a> => array -let valuesToArray: t<'a> => array<'a> -let minKey: t<_> => option -let minKeyUndefined: t<_> => Js.undefined -let maxKey: t<_> => option -let maxKeyUndefined: t<_> => Js.undefined -let minimum: t<'a> => option<(key, 'a)> -let minUndefined: t<'a> => Js.undefined<(key, 'a)> -let maximum: t<'a> => option<(key, 'a)> -let maxUndefined: t<'a> => Js.undefined<(key, 'a)> -let get: (t<'a>, key) => option<'a> -let getUndefined: (t<'a>, key) => Js.undefined<'a> -let getWithDefault: (t<'a>, key, 'a) => 'a -let getExn: (t<'a>, key) => 'a - -/** - **raise** when invariant is not held -*/ -let checkInvariantInternal: t<_> => unit - -/* ************************************************************************** */ - -/* TODO: add functional `merge, partition, keep, split` */ - -/** `remove(m, x)` do the in-place modification */ -let remove: (t<'a>, key) => unit - -let removeMany: (t<'a>, array) => unit - -/** -`set(m, x, y)` do the in-place modification, return `m` for chaining. If `x` was -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 update: (t<'a>, key, option<'a> => option<'a>) => unit - -let mapU: (t<'a>, (. 'a) => 'b) => t<'b> - -/** -`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 application of `f` -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 mapWithKey: (t<'a>, (key, 'a) => 'b) => t<'b> diff --git a/jscomp/others/belt_MutableMapString.res b/jscomp/others/belt_MutableMapString.res deleted file mode 100644 index 3bbb2c0993e..00000000000 --- a/jscomp/others/belt_MutableMapString.res +++ /dev/null @@ -1,176 +0,0 @@ -module I = Belt_internalMapString -type key = string - -module N = Belt_internalAVLtree -module A = Belt_Array - -type t<'a> = {mutable data: I.t<'a>} - -let make = () => {data: None} -let isEmpty = m => N.isEmpty(m.data) -let clear = m => m.data = None -/* let singleton k v = t ~data:(N.singleton k v) */ - -let minKeyUndefined = m => N.minKeyUndefined(m.data) -let minKey = m => N.minKey(m.data) -let maxKeyUndefined = m => N.maxKeyUndefined(m.data) -let maxKey = m => N.maxKey(m.data) -let minimum = m => N.minimum(m.data) -let minUndefined = m => N.minUndefined(m.data) -let maximum = m => N.maximum(m.data) -let maxUndefined = m => N.maxUndefined(m.data) - -let set = (m: t<_>, k, v) => { - let old_data = m.data - let v = I.addMutate(old_data, k, v) - if v !== old_data { - m.data = v - } -} - -let forEachU = (d, f) => N.forEachU(d.data, f) -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 mapWithKeyU = (d, f) => {data: N.mapWithKeyU(d.data, f)} -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 everyU = (d, f) => N.everyU(d.data, f) -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 size = d => N.size(d.data) -let toList = d => N.toList(d.data) -let toArray = d => N.toArray(d.data) -let keysToArray = d => N.keysToArray(d.data) -let valuesToArray = d => N.valuesToArray(d.data) -let checkInvariantInternal = d => N.checkInvariantInternal(d.data) -let has = (d, v) => I.has(d.data, v) - -let rec removeMutateAux = (nt, x: key) => { - let k = nt.N.key - if x == k { - let {N.left: l, right: r} = nt - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (_, Some(nr)) => - nt.right = N.removeMinAuxWithRootMutate(nt, nr) - Some(N.balMutate(nt)) - } - } else if x < k { - switch nt.left { - | None => Some(nt) - | Some(l) => - nt.left = removeMutateAux(l, x) - Some(N.balMutate(nt)) - } - } else { - switch nt.right { - | None => Some(nt) - | Some(r) => - nt.right = removeMutateAux(r, x) - Some(N.balMutate(nt)) - } - } -} - -let remove = (d, v) => { - let oldRoot = d.data - switch oldRoot { - | None => () - | Some(root) => - let newRoot = removeMutateAux(root, v) - if newRoot !== oldRoot { - d.data = newRoot - } - } -} - -let rec updateDone = (t, x: key, f) => - switch t { - | None => - switch f(. None) { - | Some(data) => N.singleton(x, data) - | None => t - } - | Some(nt) => - let k = nt.N.key - - /* let c = (Belt_Cmp.getCmpInternal cmp) x k [@bs] in */ - if k == x { - switch f(. Some(nt.value)) { - | None => - let {N.left: l, right: r} = nt - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (_, Some(nr)) => - nt.right = N.removeMinAuxWithRootMutate(nt, nr) - Some(N.balMutate(nt)) - } - | Some(data) => - nt.value = data - Some(nt) - } - } else { - let {N.left: l, right: r} = nt - if x < k { - let ll = updateDone(l, x, f) - nt.left = ll - } else { - nt.right = updateDone(r, x, f) - } - Some(N.balMutate(nt)) - } - } - -let updateU = (t, x, f) => { - let oldRoot = t.data - let newRoot = updateDone(oldRoot, x, f) - if newRoot !== oldRoot { - t.data = newRoot - } -} -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) - let u = removeMutateAux(t, ele) - switch u { - | None => None - | Some(t) => removeArrayMutateAux(t, xs, i + 1, len) - } - } else { - Some(t) - } - -let removeMany = (d: t<_>, xs) => { - let oldRoot = d.data - switch oldRoot { - | None => () - | Some(nt) => - let len = A.length(xs) - let newRoot = removeArrayMutateAux(nt, xs, 0, len) - if newRoot !== oldRoot { - d.data = newRoot - } - } -} - -/* let split = I.split */ -/* let merge = I.merge */ - -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 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 get = (d, x) => I.get(d.data, x) -let getUndefined = (d, x) => I.getUndefined(d.data, x) -let getWithDefault = (d, x, def) => I.getWithDefault(d.data, x, def) -let getExn = (d, x) => I.getExn(d.data, x) diff --git a/jscomp/others/belt_MutableMapString.resi b/jscomp/others/belt_MutableMapString.resi deleted file mode 100644 index fc4fcb321cd..00000000000 --- a/jscomp/others/belt_MutableMapString.resi +++ /dev/null @@ -1,137 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -type key = string - -type t<'a> - -let make: unit => t<'a> -let clear: t<'a> => unit -let isEmpty: t<'a> => bool - -let has: (t<'a>, key) => bool - -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, -value pair -*/ -let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int - -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 - -/** -`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 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 - -/** -`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` are the -associated data. */ -let reduce: (t<'a>, 'b, ('b, key, 'a) => 'b) => 'b - -let everyU: (t<'a>, (. key, 'a) => bool) => bool - -/** -`every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. -The application order of `p` is unspecified. -*/ -let every: (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`. -The application order of `p` is unspecified. -*/ -let some: (t<'a>, (key, 'a) => bool) => bool - -let size: t<'a> => int - -/** In increasing order */ -let toList: t<'a> => list<(key, 'a)> - -/** In increasing order */ -let toArray: t<'a> => array<(key, 'a)> - -let fromArray: array<(key, 'a)> => t<'a> -let keysToArray: t<'a> => array -let valuesToArray: t<'a> => array<'a> -let minKey: t<_> => option -let minKeyUndefined: t<_> => Js.undefined -let maxKey: t<_> => option -let maxKeyUndefined: t<_> => Js.undefined -let minimum: t<'a> => option<(key, 'a)> -let minUndefined: t<'a> => Js.undefined<(key, 'a)> -let maximum: t<'a> => option<(key, 'a)> -let maxUndefined: t<'a> => Js.undefined<(key, 'a)> -let get: (t<'a>, key) => option<'a> -let getUndefined: (t<'a>, key) => Js.undefined<'a> -let getWithDefault: (t<'a>, key, 'a) => 'a -let getExn: (t<'a>, key) => 'a - -/** - **raise** when invariant is not held -*/ -let checkInvariantInternal: t<_> => unit - -/* ************************************************************************** */ - -/* TODO: add functional `merge, partition, keep, split` */ - -/** `remove(m, x)` do the in-place modification */ -let remove: (t<'a>, key) => unit - -let removeMany: (t<'a>, array) => unit - -/** -`set(m, x, y)` do the in-place modification, return `m` for chaining. If `x` was -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 update: (t<'a>, key, option<'a> => option<'a>) => unit - -let mapU: (t<'a>, (. 'a) => 'b) => t<'b> - -/** -`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 application of `f` -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 mapWithKey: (t<'a>, (key, 'a) => 'b) => t<'b> diff --git a/jscomp/others/belt_MutableQueue.res b/jscomp/others/belt_MutableQueue.res deleted file mode 100644 index 86dd07f26e4..00000000000 --- a/jscomp/others/belt_MutableQueue.res +++ /dev/null @@ -1,230 +0,0 @@ -/* ************************************************************************ */ -/* */ -/* OCaml */ -/* */ -/* Francois Pottier, projet Cristal, INRIA Rocquencourt */ -/* Jeremie Dimino, Jane Street Europe */ -/* */ -/* Copyright 2002 Institut National de Recherche en Informatique et */ -/* en Automatique. */ -/* */ -/* All rights reserved. This file is distributed under the terms of */ -/* the GNU Lesser General Public License version 2.1, with the */ -/* special exception on linking described in the file LICENSE. */ -/* */ -/* ************************************************************************ */ -/* Adapted significantly by ReScript Authors */ -module A = Belt_Array - -type rec node<'a> = { - content: 'a, - mutable next: cell<'a>, -} -and cell<'a> = option> -and t<'a> = { - mutable length: int, - mutable first: cell<'a>, - mutable last: cell<'a>, -} - -let make = () => { - length: 0, - first: None, - last: None, -} - -let clear = q => { - q.length = 0 - q.first = None - q.last = None -} - -let add = (q, x) => { - let cell = Some({ - content: x, - next: None, - }) - switch q.last { - | None => - /* TODO: better names for intermediate var */ - q.length = 1 - q.first = cell - q.last = cell - | Some(last) => - q.length = q.length + 1 - last.next = cell - q.last = cell - } -} - -let peek = q => - switch q.first { - /* same here could be v */ - | None => None - | Some(v) => Some(v.content) - } - -let peekUndefined = q => - switch q.first { - | None => Js.undefined - | Some(v) => Js.Undefined.return(v.content) - } - -let peekExn = q => - switch q.first { - | None => raise(Not_found) - | Some(v) => v.content - } - -let pop = q => - switch q.first { - | None => None - | Some(x) => - let next = x.next - if next == None { - /* only one element */ - clear(q) - Some(x.content) - } else { - q.length = q.length - 1 - q.first = next - Some(x.content) - } - } - -let popExn = q => - /* TO fix */ - switch q.first { - | None => raise(Not_found) - | Some(x) => - let next = x.next - if next == None { - /* only one element */ - clear(q) - x.content - } else { - q.length = q.length - 1 - q.first = next - x.content - } - } - -let popUndefined = q => - switch q.first { - | None => Js.undefined - | Some(x) => - let next = x.next - if next == None { - /* only one element */ - clear(q) - Js.Undefined.return(x.content) - } else { - q.length = q.length - 1 - q.first = next - Js.Undefined.return(x.content) - } - } - -let rec copyAux = (qRes, prev, cell) => - switch cell { - | None => - qRes.last = prev - qRes - | Some(x) => - let content = x.content - let res = Some({content, next: None}) - switch prev { - | None => qRes.first = res - | Some(p) => p.next = res - } - copyAux(qRes, res, x.next) - } - -let copy = q => copyAux({length: q.length, first: None, last: None}, None, q.first) - -let rec copyMapAux = (qRes, prev, cell, f) => - switch cell { - | None => - qRes.last = prev - qRes - | Some(x) => - let content = f(. x.content) - let res = Some({content, next: None}) - switch prev { - /* TODO: optimize to remove such check */ - | None => qRes.first = res - | Some(p) => p.next = res - } - copyMapAux(qRes, res, x.next, 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 isEmpty = q => q.length == 0 - -let size = q => q.length - -let rec iterAux = (cell, f) => - switch cell { - | None => () - | Some(x) => - 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 rec foldAux = (f, accu, cell) => - switch cell { - | None => accu - | Some(x) => - 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 transfer = (q1, q2) => - if q1.length > 0 { - switch q2.last { - | None => - q2.length = q1.length - q2.first = q1.first - q2.last = q1.last - clear(q1) - | Some(l) => - q2.length = q2.length + q1.length - l.next = q1.first - q2.last = q1.last - clear(q1) - } - } - -let rec fillAux = (i, arr, cell) => - switch cell { - | None => () - | Some(x) => - A.setUnsafe(arr, i, x.content) - fillAux(i + 1, arr, x.next) - } - -let toArray = x => { - let v = A.makeUninitializedUnsafe(x.length) - fillAux(0, v, x.first) - v -} - -/* TODO: optimize */ -let fromArray = arr => { - let q = make() - for i in 0 to A.length(arr) - 1 { - add(q, A.getUnsafe(arr, i)) - } - q -} diff --git a/jscomp/others/belt_MutableQueue.resi b/jscomp/others/belt_MutableQueue.resi deleted file mode 100644 index 1bc2f8c4dcb..00000000000 --- a/jscomp/others/belt_MutableQueue.resi +++ /dev/null @@ -1,120 +0,0 @@ -/* ************************************************************************ */ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1996 Institut National de Recherche en Informatique et */ -/* en Automatique. */ -/* */ -/* All rights reserved. This file is distributed under the terms of */ -/* the GNU Lesser General Public License version 2.1, with the */ -/* special exception on linking described in the file LICENSE. */ -/* */ -/* ************************************************************************ */ -/* Adapted significantly by ReScript Authors */ - -/*** -A FIFO (first in first out) queue data structure. -*/ - -/** -The type of queues containing elements of `type('a)`. -*/ -type t<'a> - -/** -Returns a new queue, initially empty. -*/ -let make: unit => t<'a> - -/** -Discard all elements from the queue. -*/ -let clear: t<'a> => unit - -/** -Returns `true` if the given queue is empty, `false` otherwise. -*/ -let isEmpty: t<'a> => bool - -/** -`fromArray` a is equivalent to `Array.forEach(a, add(q, a));` -*/ -let fromArray: array<'a> => t<'a> - -/** -`add(q, x)` adds the element `x` at the end of the queue `q`. -*/ -let add: (t<'a>, 'a) => unit - -/** -`peekOpt(q)` returns the first element in queue `q`, without removing it from the queue. -*/ -let peek: t<'a> => option<'a> - -/** -`peekUndefined(q)` returns `undefined` if not found. -*/ -let peekUndefined: t<'a> => Js.undefined<'a> - -/** -raise an exception if `q` is empty -*/ -let peekExn: t<'a> => 'a - -/** -`pop(q)` removes and returns the first element in queue `q`. -*/ -let pop: t<'a> => option<'a> - -/** -`popUndefined(q)` removes and returns the first element in queue `q`. it will -return `undefined` if it is already empty. -*/ -let popUndefined: t<'a> => Js.undefined<'a> - -/** -`popExn(q)` raise an exception if q is empty. -*/ -let popExn: t<'a> => 'a - -/** -`copy(q)` returns a fresh queue. -*/ -let copy: t<'a> => t<'a> - -/** -Returns the number of elements in a queue. -*/ -let size: t<'a> => int - -let mapU: (t<'a>, (. 'a) => 'b) => t<'b> -let map: (t<'a>, 'a => 'b) => t<'b> -let forEachU: (t<'a>, (. 'a) => unit) => unit - -/** -`forEach(q, f) applies`f`in turn to all elements of`q`, from the least -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 - -/** -`reduce(q, accu, f)` is equivalent to `List.reduce(l, accu, f)`, where `l` is the -list of `q`'s elements. The queue remains unchanged. -*/ -let reduce: (t<'a>, 'b, ('b, 'a) => 'b) => 'b - -/** -`transfer(q1, q2)` adds all of `q1`'s elements at the end of the queue `q2`, -then clears `q1`. It is equivalent to the sequence `forEach((x) => add(x, q2), q1)`; -clear `q1`, but runs in constant time. -*/ -let transfer: (t<'a>, t<'a>) => unit - -/** -First added will be in the beginning of the array. -*/ -let toArray: t<'a> => array<'a> diff --git a/jscomp/others/belt_MutableSet.res b/jscomp/others/belt_MutableSet.res deleted file mode 100644 index e48b6a04312..00000000000 --- a/jscomp/others/belt_MutableSet.res +++ /dev/null @@ -1,374 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -module Int = Belt_MutableSetInt -module String = Belt_MutableSetString - -module N = Belt_internalAVLset -module A = Belt_Array -module Sort = Belt_SortArray - -type id<'k, 'id> = Belt_Id.comparable<'k, 'id> -type cmp<'key, 'id> = Belt_Id.cmp<'key, 'id> - -type t<'value, 'id> = { - cmp: cmp<'value, 'id>, - mutable data: N.t<'value>, -} - -let rec remove0 = (nt, x, ~cmp) => { - let k = nt.N.value - let c = cmp(. x, k) - if c == 0 { - let {N.left: l, right: r} = nt - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (Some(_), Some(nr)) => - nt.right = N.removeMinAuxWithRootMutate(nt, nr) - Some(N.balMutate(nt)) - } - } else if c < 0 { - switch nt.left { - | None => Some(nt) - | Some(l) => - nt.left = remove0(~cmp, l, x) - Some(N.balMutate(nt)) - } - } else { - switch nt.right { - | None => Some(nt) - | Some(r) => - nt.right = remove0(~cmp, r, x) - Some(N.balMutate(nt)) - } - } -} - -let remove = (d, v) => { - let oldRoot = d.data - switch oldRoot { - | None => () - | Some(oldRoot2) => - let newRoot = remove0(~cmp=Belt_Id.getCmpInternal(d.cmp), oldRoot2, v) - if newRoot !== oldRoot { - d.data = newRoot - } - } -} - -let rec removeMany0 = (t, xs, i, len, ~cmp) => - if i < len { - let ele = A.getUnsafe(xs, i) - let u = remove0(t, ele, ~cmp) - switch u { - | None => None - | Some(t) => removeMany0(t, xs, i + 1, len, ~cmp) - } - } else { - Some(t) - } - -let removeMany = (d, xs) => { - let oldRoot = d.data - switch oldRoot { - | None => () - | Some(nt) => - let len = A.length(xs) - d.data = removeMany0(nt, xs, 0, len, ~cmp=Belt_Id.getCmpInternal(d.cmp)) - } -} - -let rec removeCheck0 = (nt, x, removed, ~cmp) => { - let k = nt.N.value - let c = Belt_Id.getCmpInternal(cmp)(. x, k) - if c == 0 { - let () = removed.contents = true - let {N.left: l, right: r} = nt - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (Some(_), Some(nr)) => - nt.right = N.removeMinAuxWithRootMutate(nt, nr) - Some(N.balMutate(nt)) - } - } else if c < 0 { - switch nt.left { - | None => Some(nt) - | Some(l) => - nt.left = removeCheck0(~cmp, l, x, removed) - Some(N.balMutate(nt)) - } - } else { - switch nt.right { - | None => Some(nt) - | Some(r) => - nt.right = removeCheck0(~cmp, r, x, removed) - Some(N.balMutate(nt)) - } - } -} - -let removeCheck = (d, v) => { - let oldRoot = d.data - switch oldRoot { - | None => false - | Some(oldRoot2) => - let removed = ref(false) - let newRoot = removeCheck0(~cmp=d.cmp, oldRoot2, v, removed) - if newRoot !== oldRoot { - d.data = newRoot - } - removed.contents - } -} - -let rec addCheck0 = (t, x, added, ~cmp) => - switch t { - | None => - added.contents = true - N.singleton(x) - | Some(nt) => - let k = nt.N.value - let c = cmp(. x, k) - if c == 0 { - t - } else { - let {N.left: l, right: r} = nt - if c < 0 { - let ll = addCheck0(~cmp, l, x, added) - nt.left = ll - } else { - nt.right = addCheck0(~cmp, r, x, added) - } - Some(N.balMutate(nt)) - } - } - -let addCheck = (m, e) => { - let oldRoot = m.data - let added = ref(false) - let newRoot = addCheck0(~cmp=Belt_Id.getCmpInternal(m.cmp), oldRoot, e, added) - if newRoot !== oldRoot { - m.data = newRoot - } - added.contents -} - -let add = (m, e) => { - let oldRoot = m.data - let newRoot = N.addMutate(~cmp=m.cmp, oldRoot, e) - if newRoot !== oldRoot { - m.data = newRoot - } -} - -let addArrayMutate = (t, xs, ~cmp) => { - let v = ref(t) - for i in 0 to A.length(xs) - 1 { - v.contents = N.addMutate(v.contents, A.getUnsafe(xs, i), ~cmp) - } - v.contents -} - -let mergeMany = (d, xs) => d.data = addArrayMutate(d.data, xs, ~cmp=d.cmp) - -let make = (type value identity, ~id: id) => { - module M = unpack(id) - {cmp: M.cmp, data: None} -} - -let isEmpty = d => N.isEmpty(d.data) - -let minimum = d => N.minimum(d.data) -let minUndefined = d => N.minUndefined(d.data) -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 reduceU = (d, acc, cb) => N.reduceU(d.data, acc, cb) -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 someU = (d, p) => N.someU(d.data, p) -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) - -let fromSortedArrayUnsafe = (type value identity, xs, ~id: id): t<_> => { - module M = unpack(id) - {data: N.fromSortedArrayUnsafe(xs), cmp: M.cmp} -} - -let checkInvariantInternal = d => N.checkInvariantInternal(d.data) - -let fromArray = (type value identity, data, ~id: id) => { - module M = unpack(id) - let cmp = M.cmp - {cmp, data: N.fromArray(~cmp, data)} -} - -let cmp = (d0, d1) => N.cmp(~cmp=d0.cmp, d0.data, d1.data) - -let eq = (d0, d1) => N.eq(~cmp=d0.cmp, d0.data, d1.data) - -let get = (d, x) => N.get(~cmp=d.cmp, d.data, x) - -let getUndefined = (d, x) => N.getUndefined(~cmp=d.cmp, d.data, x) - -let getExn = (d, x) => N.getExn(~cmp=d.cmp, d.data, x) - -let split = (d, key) => { - let arr = N.toArray(d.data) - let cmp = d.cmp - let i = Sort.binarySearchByU(arr, key, Belt_Id.getCmpInternal(cmp)) - let len = A.length(arr) - if i < 0 { - let next = -i - 1 - ( - ( - { - data: N.fromSortedArrayAux(arr, 0, next), - cmp, - }, - { - data: N.fromSortedArrayAux(arr, next, len - next), - cmp, - }, - ), - false, - ) - } else { - ( - ( - { - data: N.fromSortedArrayAux(arr, 0, i), - cmp, - }, - { - data: N.fromSortedArrayAux(arr, i + 1, len - i - 1), - cmp, - }, - ), - true, - ) - } -} - -let keepU = (d, p) => {data: N.keepCopyU(d.data, p), cmp: d.cmp} - -let keep = (d, p) => keepU(d, (. a) => p(a)) - -let partitionU = (d, p) => { - let cmp = d.cmp - let (a, b) = N.partitionCopyU(d.data, p) - ({data: a, cmp}, {data: b, cmp}) -} - -let partition = (d, p) => partitionU(d, (. a) => p(a)) - -let subset = (a, b) => N.subset(~cmp=a.cmp, a.data, b.data) - -let intersect = (a, b): t<_> => { - let cmp = a.cmp - switch (a.data, b.data) { - | (None, _) => {cmp, data: None} - | (_, None) => {cmp, data: None} - | (Some(dataa0), Some(datab0)) => - let (sizea, sizeb) = (N.lengthNode(dataa0), N.lengthNode(datab0)) - let totalSize = sizea + sizeb - let tmp = A.makeUninitializedUnsafe(totalSize) - 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 || - p(. A.getUnsafe(tmp, totalSize - 1), A.getUnsafe(tmp, 0)) < 0 - ) { - {cmp, data: None} - } else { - let tmp2 = A.makeUninitializedUnsafe(Pervasives.min(sizea, sizeb)) - let k = Sort.intersectU(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0, p) - { - data: N.fromSortedArrayAux(tmp2, 0, k), - cmp, - } - } - } -} - -let diff = (a, b): t<_> => { - let cmp = a.cmp - let dataa = a.data - switch (dataa, b.data) { - | (None, _) => {cmp, data: None} - | (_, None) => {data: N.copy(dataa), cmp} - | (Some(dataa0), Some(datab0)) => - let (sizea, sizeb) = (N.lengthNode(dataa0), N.lengthNode(datab0)) - let totalSize = sizea + sizeb - let tmp = A.makeUninitializedUnsafe(totalSize) - 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 || - p(. A.getUnsafe(tmp, totalSize - 1), A.getUnsafe(tmp, 0)) < 0 - ) { - {data: N.copy(dataa), cmp} - } else { - let tmp2 = A.makeUninitializedUnsafe(sizea) - let k = Sort.diffU(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0, p) - {data: N.fromSortedArrayAux(tmp2, 0, k), cmp} - } - } -} - -let union = (a, b) => { - let cmp = a.cmp - let (dataa, datab) = (a.data, b.data) - switch (dataa, datab) { - | (None, _) => {data: N.copy(datab), cmp} - | (_, None) => {data: N.copy(dataa), cmp} - | (Some(dataa0), Some(datab0)) => - let (sizea, sizeb) = (N.lengthNode(dataa0), N.lengthNode(datab0)) - let totalSize = sizea + sizeb - let tmp = A.makeUninitializedUnsafe(totalSize) - 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 { - {data: N.fromSortedArrayAux(tmp, 0, totalSize), cmp} - } else { - let tmp2 = A.makeUninitializedUnsafe(totalSize) - let k = Sort.unionU(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0, p) - {data: N.fromSortedArrayAux(tmp2, 0, k), cmp} - } - } -} - -let has = (d, x) => N.has(~cmp=d.cmp, d.data, x) - -let copy = d => {data: N.copy(d.data), cmp: d.cmp} diff --git a/jscomp/others/belt_MutableSet.resi b/jscomp/others/belt_MutableSet.resi deleted file mode 100644 index 8a52652025d..00000000000 --- a/jscomp/others/belt_MutableSet.resi +++ /dev/null @@ -1,666 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -A **mutable** sorted set module which allows customized compare behavior. -The implementation uses balanced binary trees, and therefore searching and insertion take time logarithmic in the size of the map. - -It also has two specialized inner modules [Belt.MutableSet.Int](mutable-set-int) and [Belt.MutableSet.String](mutable-set-string) - This module separates data from function which is more verbose but slightly more efficient - -## Examples - -```rescript -module PairComparator = Belt.Id.MakeComparable({ - type t = (int, int) - let cmp = ((a0, a1), (b0, b1)) => - switch Pervasives.compare(a0, b0) { - | 0 => Pervasives.compare(a1, b1) - | c => c - } -}) - -let mySet = Belt.MutableSet.make(~id=module(PairComparator)) -mySet->Belt.MutableSet.add((1, 2)) -``` -*/ - -/** Specialized when key type is `int`, more efficient than the generic type */ -module Int = Belt_MutableSetInt - -/** Specialized when key type is `string`, more efficient than the generic type */ -module String = Belt_MutableSetString - -/** -`'value` is the element type - -`'identity` the identity of the collection -*/ -type t<'value, 'identity> - -/** -The identity needed for making a set from scratch -*/ -type id<'value, 'id> = Belt_Id.comparable<'value, 'id> - -/** -Creates a new set by taking in the comparator -*/ -let make: (~id: id<'value, 'id>) => t<'value, 'id> - -/** -Creates new set from array of elements. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([1, 3, 2, 4], ~id=module(IntCmp)) - -s0->Belt.MutableSet.toArray /* [1, 2, 3, 4] */ -``` -*/ -let fromArray: (array<'value>, ~id: id<'value, 'id>) => t<'value, 'id> - -/** -The same as [fromArray][#fromarray] except it is after assuming the input array is already sorted. -*/ -let fromSortedArrayUnsafe: (array<'value>, ~id: id<'value, 'id>) => t<'value, 'id> - -/** -Returns copy of a set. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([1, 3, 2, 4], ~id=module(IntCmp)) - -let copied = s0->Belt.MutableSet.copy -copied->Belt.MutableSet.toArray /* [1, 2, 3, 4] */ -``` -*/ -let copy: t<'value, 'id> => t<'value, 'id> - -/** -Checks if set is empty. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let empty = Belt.MutableSet.fromArray([], ~id=module(IntCmp)) -let notEmpty = Belt.MutableSet.fromArray([1], ~id=module(IntCmp)) - -Belt.MutableSet.isEmpty(empty) /* true */ -Belt.MutableSet.isEmpty(notEmpty) /* false */ -``` -*/ -let isEmpty: t<_> => bool - -/** -Checks if element exists in set. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.MutableSet.fromArray([1, 4, 2, 5], ~id=module(IntCmp)) - -set->Belt.MutableSet.has(3) /* false */ -set->Belt.MutableSet.has(1) /* true */ -``` -*/ -let has: (t<'value, 'id>, 'value) => bool - -/** -Adds element to set. If element existed in set, value is unchanged. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.make(~id=module(IntCmp)) -s0->Belt.MutableSet.add(1) -s0->Belt.MutableSet.add(2) -s0->Belt.MutableSet.add(2) - -s0->Belt.MutableSet.toArray /* [1, 2] */ -``` -*/ -let add: (t<'value, 'id>, 'value) => unit - -let addCheck: (t<'value, 'id>, 'value) => bool - -/** -Adds each element of array to set. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.MutableSet.make(~id=module(IntCmp)) - -set->Belt.MutableSet.mergeMany([5, 4, 3, 2, 1]) -set->Belt.MutableSet.toArray /* [1, 2, 3, 4, 5] */ -``` -*/ -let mergeMany: (t<'value, 'id>, array<'value>) => unit - -/** -Removes element from set. If element did not exist in set, value is unchanged. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([2, 3, 1, 4, 5], ~id=module(IntCmp)) -s0->Belt.MutableSet.remove(1) -s0->Belt.MutableSet.remove(3) -s0->Belt.MutableSet.remove(3) - -s0->Belt.MutableSet.toArray /* [2,4,5] */ -``` -*/ -let remove: (t<'value, 'id>, 'value) => unit - -let removeCheck: (t<'value, 'id>, 'value) => bool -/* `b = removeCheck s e` `b` is true means one element removed */ - -/** -Removes each element of array from set. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.MutableSet.fromArray([1, 2, 3, 4], ~id=module(IntCmp)) - -set->Belt.MutableSet.removeMany([5, 4, 3, 2, 1]) -set->Belt.MutableSet.toArray /* [] */ -``` -*/ -let removeMany: (t<'value, 'id>, array<'value>) => unit - -/** -Returns union of two sets. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([5, 2, 3, 1, 5, 4], ~id=module(IntCmp)) -let union = Belt.MutableSet.union(s0, s1) -union->Belt.MutableSet.toArray /* [1,2,3,4,5,6] */ -``` -*/ -let union: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> - -/** -Returns intersection of two sets. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([5, 2, 3, 1, 5, 4], ~id=module(IntCmp)) -let intersect = Belt.MutableSet.intersect(s0, s1) -intersect->Belt.MutableSet.toArray /* [2,3,5] */ -``` -*/ -let intersect: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> - -/** -Returns elements from first set, not existing in second set. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([5, 2, 3, 1, 5, 4], ~id=module(IntCmp)) -Belt.MutableSet.toArray(Belt.MutableSet.diff(s0, s1)) /* [6] */ -Belt.MutableSet.toArray(Belt.MutableSet.diff(s1, s0)) /* [1,4] */ -``` -*/ -let diff: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> - -/** -Checks if second set is subset of first set. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([5, 2, 3, 1, 5, 4], ~id=module(IntCmp)) -let s2 = Belt.MutableSet.intersect(s0, s1) -Belt.MutableSet.subset(s2, s0) /* true */ -Belt.MutableSet.subset(s2, s1) /* true */ -Belt.MutableSet.subset(s1, s0) /* false */ -``` -*/ -let subset: (t<'value, 'id>, t<'value, 'id>) => bool - -/** -Total ordering between sets. Can be used as the ordering function for doing sets of sets. -It compares size first and then iterates over each element following the order of elements. -*/ -let cmp: (t<'value, 'id>, t<'value, 'id>) => int - -/** -Checks if two sets are equal. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3], ~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([3, 2, 5], ~id=module(IntCmp)) - -Belt.MutableSet.eq(s0, s1) /* true */ -``` -*/ -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 - -/** -Applies function `f` in turn to all elements of set in increasing order. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -let acc = ref(list{}) -s0->Belt.MutableSet.forEach(x => acc := Belt.List.add(acc.contents, x)) -acc /* [6,5,3,2] */ -``` -*/ -let forEach: (t<'value, 'id>, 'value => unit) => unit - -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. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([5, 2, 3, 5, 6], ~id=module(IntCmp)) -s0->Belt.MutableSet.reduce(list{}, (acc, element) => acc->Belt.List.add(element)) /* [6,5,3,2] */ -``` -*/ -let reduce: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a - -let everyU: (t<'value, 'id>, (. 'value) => bool) => bool - -/** -Checks if all elements of the set satisfy the predicate. Order unspecified. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.MutableSet.fromArray([2, 4, 6, 8], ~id=module(IntCmp)) -s0->Belt.MutableSet.every(isEven) /* true */ -``` -*/ -let every: (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. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.MutableSet.fromArray([1, 2, 4, 6, 8], ~id=module(IntCmp)) -s0->Belt.MutableSet.some(isOdd) /* true */ -``` -*/ -let some: (t<'value, 'id>, 'value => bool) => bool - -let keepU: (t<'value, 'id>, (. 'value) => bool) => t<'value, 'id> - -/** -Returns the set of all elements that satisfy the predicate. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.MutableSet.fromArray([1, 2, 3, 4, 5], ~id=module(IntCmp)) -let s1 = s0->Belt.MutableSet.keep(isEven) - -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>) - -/** -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.MutableSet.fromArray([1, 2, 3, 4, 5], ~id=module(IntCmp)) -let (s1, s2) = s0->Belt.MutableSet.partition(isOdd) - -s1->Belt.MutableSet.toArray /* [1,3,5] */ -s2->Belt.MutableSet.toArray /* [2,4] */ -``` -*/ -let partition: (t<'value, 'id>, 'value => bool) => (t<'value, 'id>, t<'value, 'id>) - -/** -Returns size of the set. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([1, 2, 3, 4], ~id=module(IntCmp)) - -s0->Belt.MutableSet.size /* 4 */ -``` -*/ -let size: t<'value, 'id> => int - -/** -Returns list of ordered set elements. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.toList /* [1,2,3,5] */ -``` -*/ -let toList: t<'value, 'id> => list<'value> - -/** -Returns array of ordered set elements. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.toArray /* [1,2,3,5] */ -``` -*/ -let toArray: t<'value, 'id> => array<'value> - -/** -Returns minimum value of the collection. `None` if collection is empty. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.make(~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.minimum /* None */ -s1->Belt.MutableSet.minimum /* Some(1) */ -``` -*/ -let minimum: t<'value, 'id> => option<'value> - -/** -Returns minimum value of the collection. `undefined` if collection is empty. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.make(~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.minUndefined /* undefined */ -s1->Belt.MutableSet.minUndefined /* 1 */ -``` -*/ -let minUndefined: t<'value, 'id> => Js.undefined<'value> - -/** -Returns maximum value of the collection. `None` if collection is empty. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.make(~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.maximum /* None */ -s1->Belt.MutableSet.maximum /* Some(5) */ -``` -*/ -let maximum: t<'value, 'id> => option<'value> - -/** -Returns maximum value of the collection. `undefined` if collection is empty. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.make(~id=module(IntCmp)) -let s1 = Belt.MutableSet.fromArray([3, 2, 1, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.maxUndefined /* undefined */ -s1->Belt.MutableSet.maxUndefined /* 5 */ -``` -*/ -let maxUndefined: t<'value, 'id> => Js.undefined<'value> - -/** -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([1, 2, 3, 4, 5], ~id=module(IntCmp)) - -s0->Belt.MutableSet.get(3) /* Some(3) */ -s0->Belt.MutableSet.get(20) /* None */ -``` -*/ -let get: (t<'value, 'id>, 'value) => option<'value> - -/** -Same as `Belt.MutableSet.get` but returns `undefined` when element does not exist. -*/ -let getUndefined: (t<'value, 'id>, 'value) => Js.undefined<'value> - -/** -Same as `Belt.MutableSet.get` but raise when element does not exist. -*/ -let getExn: (t<'value, 'id>, 'value) => 'value - -/** -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.MutableSet.fromArray([1, 2, 3, 4, 5], ~id=module(IntCmp)) - -let ((smaller, larger), present) = s0->Belt.MutableSet.split(3) - -present /* true */ -smaller->Belt.MutableSet.toArray /* [1,2] */ -larger->Belt.MutableSet.toArray /* [4,5] */ -``` -*/ -let split: (t<'value, 'id>, 'value) => ((t<'value, 'id>, t<'value, 'id>), bool) - -/** -**raise** when invariant is not held -*/ -let checkInvariantInternal: t<_> => unit - -/* - `add0` was not exposed for various reasons: - 1. such api is dangerious - [ cmp: ('value,'id) Belt_Cmp.cmp -> - ('value, 'id) t0 -> 'value -> - ('value, 'id) t0] - 2. It is not really significantly more */ diff --git a/jscomp/others/belt_MutableSetInt.res b/jscomp/others/belt_MutableSetInt.res deleted file mode 100644 index 4c50fcdfa58..00000000000 --- a/jscomp/others/belt_MutableSetInt.res +++ /dev/null @@ -1,339 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** This module is [`Belt.MutableSet`]() specialized with key type to be a primitive type. - It is more efficient in general, the API is the same with [`Belt_MutableSet`]() except its key type is fixed, - and identity is not needed(using the built-in one) -*/ - -module I = Belt_internalSetInt -module S = Belt_SortArrayInt - -module N = Belt_internalAVLset -module A = Belt_Array - -/** The type of the set elements. */ -type value = I.value - -/** The type of sets. */ -type t = {mutable data: I.t} - -let rec remove0 = (nt, x: value) => { - let k = nt.N.value - if x == k { - let {N.left: l, right: r} = nt - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (Some(_), Some(nr)) => - nt.right = N.removeMinAuxWithRootMutate(nt, nr) - Some(N.balMutate(nt)) - } - } else if x < k { - switch nt.left { - | None => Some(nt) - | Some(l) => - nt.left = remove0(l, x) - Some(N.balMutate(nt)) - } - } else { - switch nt.right { - | None => Some(nt) - | Some(r) => - nt.right = remove0(r, x) - Some(N.balMutate(nt)) - } - } -} - -let remove = (d, v) => { - let oldRoot = d.data - switch oldRoot { - | None => () - | Some(oldRoot2) => - let newRoot = remove0(oldRoot2, v) - if newRoot !== oldRoot { - d.data = newRoot - } - } -} - -let rec removeMany0 = (t, xs, i, len) => - if i < len { - let ele = A.getUnsafe(xs, i) - let u = remove0(t, ele) - switch u { - | None => None - | Some(t) => removeMany0(t, xs, i + 1, len) - } - } else { - Some(t) - } - -let removeMany = (d: t, xs) => { - let oldRoot = d.data - switch oldRoot { - | None => () - | Some(nt) => - let len = A.length(xs) - d.data = removeMany0(nt, xs, 0, len) - } -} - -let rec removeCheck0 = (nt, x: value, removed) => { - let k = nt.N.value - if x == k { - let () = removed.contents = true - let {N.left: l, right: r} = nt - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (Some(_), Some(nr)) => - nt.right = N.removeMinAuxWithRootMutate(nt, nr) - Some(N.balMutate(nt)) - } - } else if x < k { - switch nt.left { - | None => Some(nt) - | Some(l) => - nt.left = removeCheck0(l, x, removed) - Some(N.balMutate(nt)) - } - } else { - switch nt.right { - | None => Some(nt) - | Some(r) => - nt.right = removeCheck0(r, x, removed) - Some(N.balMutate(nt)) - } - } -} - -let removeCheck = (d: t, v) => { - let oldRoot = d.data - switch oldRoot { - | None => false - | Some(oldRoot2) => - let removed = ref(false) - let newRoot = removeCheck0(oldRoot2, v, removed) - if newRoot !== oldRoot { - d.data = newRoot - } - removed.contents - } -} - -let rec addCheck0 = (t, x: value, added) => - switch t { - | None => - added.contents = true - N.singleton(x) - | Some(nt) => - let k = nt.N.value - if x == k { - t - } else { - let {N.left: l, right: r} = nt - if x < k { - let ll = addCheck0(l, x, added) - nt.left = ll - } else { - nt.right = addCheck0(r, x, added) - } - Some(N.balMutate(nt)) - } - } - -let addCheck = (m: t, e) => { - let oldRoot = m.data - let added = ref(false) - let newRoot = addCheck0(oldRoot, e, added) - if newRoot !== oldRoot { - m.data = newRoot - } - added.contents -} - -let add = (d, k) => { - let oldRoot = d.data - let v = I.addMutate(oldRoot, k) - if v !== oldRoot { - d.data = v - } -} - -let addArrayMutate = (t, xs) => { - let v = ref(t) - for i in 0 to A.length(xs) - 1 { - v.contents = I.addMutate(v.contents, A.getUnsafe(xs, i)) - } - v.contents -} - -let mergeMany = (d, arr) => d.data = addArrayMutate(d.data, arr) - -let make = () => {data: None} - -let isEmpty = d => N.isEmpty(d.data) - -let minimum = d => N.minimum(d.data) - -let minUndefined = d => N.minUndefined(d.data) - -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 reduceU = (d, acc, cb) => N.reduceU(d.data, acc, cb) -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 someU = (d, p) => N.someU(d.data, p) -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) - -let fromSortedArrayUnsafe = xs => {data: N.fromSortedArrayUnsafe(xs)} - -let checkInvariantInternal = d => N.checkInvariantInternal(d.data) - -let fromArray = xs => {data: I.fromArray(xs)} - -let cmp = (d0, d1) => I.cmp(d0.data, d1.data) -let eq = (d0, d1) => I.eq(d0.data, d1.data) -let get = (d, x) => I.get(d.data, x) -let getUndefined = (d, x) => I.getUndefined(d.data, x) -let getExn = (d, x) => I.getExn(d.data, x) - -let split = (d, key) => { - let arr = N.toArray(d.data) - let i = S.binarySearch(arr, key) - let len = A.length(arr) - if i < 0 { - let next = -i - 1 - ( - ( - {data: N.fromSortedArrayAux(arr, 0, next)}, - {data: N.fromSortedArrayAux(arr, next, len - next)}, - ), - false, - ) - } else { - ( - ( - {data: N.fromSortedArrayAux(arr, 0, i)}, - {data: N.fromSortedArrayAux(arr, i + 1, len - i - 1)}, - ), - true, - ) - } -} - -let keepU = (d, p) => {data: N.keepCopyU(d.data, p)} -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 subset = (a, b) => I.subset(a.data, b.data) -let intersect = (dataa, datab) => { - let (dataa, datab) = (dataa.data, datab.data) - switch (dataa, datab) { - | (None, _) => make() - | (_, None) => make() - | (Some(dataa0), Some(datab0)) => - let (sizea, sizeb) = (N.lengthNode(dataa0), N.lengthNode(datab0)) - let totalSize = sizea + sizeb - let tmp = A.makeUninitializedUnsafe(totalSize) - ignore(N.fillArray(dataa0, 0, tmp)) - ignore(N.fillArray(datab0, sizea, tmp)) - if ( - A.getUnsafe(tmp, sizea - 1) < A.getUnsafe(tmp, sizea) || - A.getUnsafe(tmp, totalSize - 1) < A.getUnsafe(tmp, 0) - ) { - make() - } else { - let tmp2 = A.makeUninitializedUnsafe(Pervasives.min(sizea, sizeb)) - let k = S.intersect(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0) - {data: N.fromSortedArrayAux(tmp2, 0, k)} - } - } -} - -let diff = (dataa, datab): t => { - let (dataa, datab) = (dataa.data, datab.data) - switch (dataa, datab) { - | (None, _) => make() - | (_, None) => {data: N.copy(dataa)} - | (Some(dataa0), Some(datab0)) => - let (sizea, sizeb) = (N.lengthNode(dataa0), N.lengthNode(datab0)) - let totalSize = sizea + sizeb - let tmp = A.makeUninitializedUnsafe(totalSize) - ignore(N.fillArray(dataa0, 0, tmp)) - ignore(N.fillArray(datab0, sizea, tmp)) - if ( - A.getUnsafe(tmp, sizea - 1) < A.getUnsafe(tmp, sizea) || - A.getUnsafe(tmp, totalSize - 1) < A.getUnsafe(tmp, 0) - ) { - {data: N.copy(dataa)} - } else { - let tmp2 = A.makeUninitializedUnsafe(sizea) - let k = S.diff(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0) - {data: N.fromSortedArrayAux(tmp2, 0, k)} - } - } -} - -let union = (dataa: t, datab: t): t => { - let (dataa, datab) = (dataa.data, datab.data) - switch (dataa, datab) { - | (None, _) => {data: N.copy(datab)} - | (_, None) => {data: N.copy(dataa)} - | (Some(dataa0), Some(datab0)) => - let (sizea, sizeb) = (N.lengthNode(dataa0), N.lengthNode(datab0)) - let totalSize = sizea + sizeb - let tmp = A.makeUninitializedUnsafe(totalSize) - ignore(N.fillArray(dataa0, 0, tmp)) - ignore(N.fillArray(datab0, sizea, tmp)) - if A.getUnsafe(tmp, sizea - 1) < A.getUnsafe(tmp, sizea) { - {data: N.fromSortedArrayAux(tmp, 0, totalSize)} - } else { - let tmp2 = A.makeUninitializedUnsafe(totalSize) - let k = S.union(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0) - {data: N.fromSortedArrayAux(tmp2, 0, k)} - } - } -} - -let has = (d, x) => I.has(d.data, x) - -let copy = d => {data: N.copy(d.data)} diff --git a/jscomp/others/belt_MutableSetInt.resi b/jscomp/others/belt_MutableSetInt.resi deleted file mode 100644 index e7dc512685e..00000000000 --- a/jscomp/others/belt_MutableSetInt.resi +++ /dev/null @@ -1,131 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -This module is [`Belt.MutableSet`]() specialized with key type to be a primitive type. - -It is more efficient in general, the API is the same with [`Belt.MutableSet`]() except its key type is fixed, -and identity is not needed(using the built-in one) - -**See** [`Belt.MutableSet`]() -*/ - -/** The type of the set elements. */ -type value = int - -/** The type of sets. */ -type t - -let make: unit => t - -let fromArray: array => t -let fromSortedArrayUnsafe: array => t - -let copy: t => t -let isEmpty: t => bool -let has: (t, value) => bool - -let add: (t, value) => unit -let addCheck: (t, value) => bool -let mergeMany: (t, array) => unit -let remove: (t, value) => unit -let removeCheck: (t, value) => bool -let removeMany: (t, array) => unit - -let union: (t, t) => t -let intersect: (t, t) => t -let diff: (t, t) => t -let subset: (t, t) => bool - -let cmp: (t, t) => int -let eq: (t, t) => bool - -let forEachU: (t, (. value) => unit) => unit - -/** In increasing order*/ -let forEach: (t, value => unit) => unit - -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 - -/** -`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 - -/** -`some(p, s)` checks if at least one element of the set satisfies the predicate -`p`. Oder unspecified. -*/ -let some: (t, value => bool) => bool - -let keepU: (t, (. value) => bool) => t - -/** -`keep(s, p)` returns a fresh copy of the set of all elements in `s` that satisfy -predicate `p`. -*/ -let keep: (t, value => bool) => t - -let partitionU: (t, (. value) => bool) => (t, t) - -/** -`partition(s, p)` returns a fresh copy pair of sets `(s1, s2)`, where `s1` is -the set of all the elements of `s` that satisfy the predicate `p`, and `s2` is -the set of all the elements of `s` that do not satisfy `p`. -*/ -let partition: (t, value => bool) => (t, t) - -let size: t => int - -/** In increasing order with respect */ -let toList: t => list - -/** In increasing order with respect */ -let toArray: t => array - -let minimum: t => option -let minUndefined: t => Js.undefined -let maximum: t => option -let maxUndefined: t => Js.undefined - -let get: (t, value) => option -let getUndefined: (t, value) => Js.undefined -let getExn: (t, value) => value - -/** -`split(s, key)` return a fresh copy of each -*/ -let split: (t, value) => ((t, t), bool) - -/** -**raise** when invariant is not held -*/ -let checkInvariantInternal: t => unit diff --git a/jscomp/others/belt_MutableSetString.res b/jscomp/others/belt_MutableSetString.res deleted file mode 100644 index eb0cb4f58c3..00000000000 --- a/jscomp/others/belt_MutableSetString.res +++ /dev/null @@ -1,339 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** This module is [`Belt.MutableSet`]() specialized with key type to be a primitive type. - It is more efficient in general, the API is the same with [`Belt_MutableSet`]() except its key type is fixed, - and identity is not needed(using the built-in one) -*/ - -module I = Belt_internalSetString -module S = Belt_SortArrayString - -module N = Belt_internalAVLset -module A = Belt_Array - -/** The type of the set elements. */ -type value = I.value - -/** The type of sets. */ -type t = {mutable data: I.t} - -let rec remove0 = (nt, x: value) => { - let k = nt.N.value - if x == k { - let {N.left: l, right: r} = nt - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (Some(_), Some(nr)) => - nt.right = N.removeMinAuxWithRootMutate(nt, nr) - Some(N.balMutate(nt)) - } - } else if x < k { - switch nt.left { - | None => Some(nt) - | Some(l) => - nt.left = remove0(l, x) - Some(N.balMutate(nt)) - } - } else { - switch nt.right { - | None => Some(nt) - | Some(r) => - nt.right = remove0(r, x) - Some(N.balMutate(nt)) - } - } -} - -let remove = (d, v) => { - let oldRoot = d.data - switch oldRoot { - | None => () - | Some(oldRoot2) => - let newRoot = remove0(oldRoot2, v) - if newRoot !== oldRoot { - d.data = newRoot - } - } -} - -let rec removeMany0 = (t, xs, i, len) => - if i < len { - let ele = A.getUnsafe(xs, i) - let u = remove0(t, ele) - switch u { - | None => None - | Some(t) => removeMany0(t, xs, i + 1, len) - } - } else { - Some(t) - } - -let removeMany = (d: t, xs) => { - let oldRoot = d.data - switch oldRoot { - | None => () - | Some(nt) => - let len = A.length(xs) - d.data = removeMany0(nt, xs, 0, len) - } -} - -let rec removeCheck0 = (nt, x: value, removed) => { - let k = nt.N.value - if x == k { - let () = removed.contents = true - let {N.left: l, right: r} = nt - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (Some(_), Some(nr)) => - nt.right = N.removeMinAuxWithRootMutate(nt, nr) - Some(N.balMutate(nt)) - } - } else if x < k { - switch nt.left { - | None => Some(nt) - | Some(l) => - nt.left = removeCheck0(l, x, removed) - Some(N.balMutate(nt)) - } - } else { - switch nt.right { - | None => Some(nt) - | Some(r) => - nt.right = removeCheck0(r, x, removed) - Some(N.balMutate(nt)) - } - } -} - -let removeCheck = (d: t, v) => { - let oldRoot = d.data - switch oldRoot { - | None => false - | Some(oldRoot2) => - let removed = ref(false) - let newRoot = removeCheck0(oldRoot2, v, removed) - if newRoot !== oldRoot { - d.data = newRoot - } - removed.contents - } -} - -let rec addCheck0 = (t, x: value, added) => - switch t { - | None => - added.contents = true - N.singleton(x) - | Some(nt) => - let k = nt.N.value - if x == k { - t - } else { - let {N.left: l, right: r} = nt - if x < k { - let ll = addCheck0(l, x, added) - nt.left = ll - } else { - nt.right = addCheck0(r, x, added) - } - Some(N.balMutate(nt)) - } - } - -let addCheck = (m: t, e) => { - let oldRoot = m.data - let added = ref(false) - let newRoot = addCheck0(oldRoot, e, added) - if newRoot !== oldRoot { - m.data = newRoot - } - added.contents -} - -let add = (d, k) => { - let oldRoot = d.data - let v = I.addMutate(oldRoot, k) - if v !== oldRoot { - d.data = v - } -} - -let addArrayMutate = (t, xs) => { - let v = ref(t) - for i in 0 to A.length(xs) - 1 { - v.contents = I.addMutate(v.contents, A.getUnsafe(xs, i)) - } - v.contents -} - -let mergeMany = (d, arr) => d.data = addArrayMutate(d.data, arr) - -let make = () => {data: None} - -let isEmpty = d => N.isEmpty(d.data) - -let minimum = d => N.minimum(d.data) - -let minUndefined = d => N.minUndefined(d.data) - -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 reduceU = (d, acc, cb) => N.reduceU(d.data, acc, cb) -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 someU = (d, p) => N.someU(d.data, p) -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) - -let fromSortedArrayUnsafe = xs => {data: N.fromSortedArrayUnsafe(xs)} - -let checkInvariantInternal = d => N.checkInvariantInternal(d.data) - -let fromArray = xs => {data: I.fromArray(xs)} - -let cmp = (d0, d1) => I.cmp(d0.data, d1.data) -let eq = (d0, d1) => I.eq(d0.data, d1.data) -let get = (d, x) => I.get(d.data, x) -let getUndefined = (d, x) => I.getUndefined(d.data, x) -let getExn = (d, x) => I.getExn(d.data, x) - -let split = (d, key) => { - let arr = N.toArray(d.data) - let i = S.binarySearch(arr, key) - let len = A.length(arr) - if i < 0 { - let next = -i - 1 - ( - ( - {data: N.fromSortedArrayAux(arr, 0, next)}, - {data: N.fromSortedArrayAux(arr, next, len - next)}, - ), - false, - ) - } else { - ( - ( - {data: N.fromSortedArrayAux(arr, 0, i)}, - {data: N.fromSortedArrayAux(arr, i + 1, len - i - 1)}, - ), - true, - ) - } -} - -let keepU = (d, p) => {data: N.keepCopyU(d.data, p)} -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 subset = (a, b) => I.subset(a.data, b.data) -let intersect = (dataa, datab) => { - let (dataa, datab) = (dataa.data, datab.data) - switch (dataa, datab) { - | (None, _) => make() - | (_, None) => make() - | (Some(dataa0), Some(datab0)) => - let (sizea, sizeb) = (N.lengthNode(dataa0), N.lengthNode(datab0)) - let totalSize = sizea + sizeb - let tmp = A.makeUninitializedUnsafe(totalSize) - ignore(N.fillArray(dataa0, 0, tmp)) - ignore(N.fillArray(datab0, sizea, tmp)) - if ( - A.getUnsafe(tmp, sizea - 1) < A.getUnsafe(tmp, sizea) || - A.getUnsafe(tmp, totalSize - 1) < A.getUnsafe(tmp, 0) - ) { - make() - } else { - let tmp2 = A.makeUninitializedUnsafe(Pervasives.min(sizea, sizeb)) - let k = S.intersect(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0) - {data: N.fromSortedArrayAux(tmp2, 0, k)} - } - } -} - -let diff = (dataa, datab): t => { - let (dataa, datab) = (dataa.data, datab.data) - switch (dataa, datab) { - | (None, _) => make() - | (_, None) => {data: N.copy(dataa)} - | (Some(dataa0), Some(datab0)) => - let (sizea, sizeb) = (N.lengthNode(dataa0), N.lengthNode(datab0)) - let totalSize = sizea + sizeb - let tmp = A.makeUninitializedUnsafe(totalSize) - ignore(N.fillArray(dataa0, 0, tmp)) - ignore(N.fillArray(datab0, sizea, tmp)) - if ( - A.getUnsafe(tmp, sizea - 1) < A.getUnsafe(tmp, sizea) || - A.getUnsafe(tmp, totalSize - 1) < A.getUnsafe(tmp, 0) - ) { - {data: N.copy(dataa)} - } else { - let tmp2 = A.makeUninitializedUnsafe(sizea) - let k = S.diff(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0) - {data: N.fromSortedArrayAux(tmp2, 0, k)} - } - } -} - -let union = (dataa: t, datab: t): t => { - let (dataa, datab) = (dataa.data, datab.data) - switch (dataa, datab) { - | (None, _) => {data: N.copy(datab)} - | (_, None) => {data: N.copy(dataa)} - | (Some(dataa0), Some(datab0)) => - let (sizea, sizeb) = (N.lengthNode(dataa0), N.lengthNode(datab0)) - let totalSize = sizea + sizeb - let tmp = A.makeUninitializedUnsafe(totalSize) - ignore(N.fillArray(dataa0, 0, tmp)) - ignore(N.fillArray(datab0, sizea, tmp)) - if A.getUnsafe(tmp, sizea - 1) < A.getUnsafe(tmp, sizea) { - {data: N.fromSortedArrayAux(tmp, 0, totalSize)} - } else { - let tmp2 = A.makeUninitializedUnsafe(totalSize) - let k = S.union(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0) - {data: N.fromSortedArrayAux(tmp2, 0, k)} - } - } -} - -let has = (d, x) => I.has(d.data, x) - -let copy = d => {data: N.copy(d.data)} diff --git a/jscomp/others/belt_MutableSetString.resi b/jscomp/others/belt_MutableSetString.resi deleted file mode 100644 index 72aa9bebe64..00000000000 --- a/jscomp/others/belt_MutableSetString.resi +++ /dev/null @@ -1,131 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -This module is [`Belt.MutableSet`]() specialized with key type to be a primitive type. - -It is more efficient in general, the API is the same with [`Belt.MutableSet`]() except its key type is fixed, -and identity is not needed(using the built-in one) - -**See** [`Belt.MutableSet`]() -*/ - -/** The type of the set elements. */ -type value = string - -/** The type of sets. */ -type t - -let make: unit => t - -let fromArray: array => t -let fromSortedArrayUnsafe: array => t - -let copy: t => t -let isEmpty: t => bool -let has: (t, value) => bool - -let add: (t, value) => unit -let addCheck: (t, value) => bool -let mergeMany: (t, array) => unit -let remove: (t, value) => unit -let removeCheck: (t, value) => bool -let removeMany: (t, array) => unit - -let union: (t, t) => t -let intersect: (t, t) => t -let diff: (t, t) => t -let subset: (t, t) => bool - -let cmp: (t, t) => int -let eq: (t, t) => bool - -let forEachU: (t, (. value) => unit) => unit - -/** In increasing order*/ -let forEach: (t, value => unit) => unit - -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 - -/** -`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 - -/** -`some(p, s)` checks if at least one element of the set satisfies the predicate -`p`. Oder unspecified. -*/ -let some: (t, value => bool) => bool - -let keepU: (t, (. value) => bool) => t - -/** -`keep(s, p)` returns a fresh copy of the set of all elements in `s` that satisfy -predicate `p`. -*/ -let keep: (t, value => bool) => t - -let partitionU: (t, (. value) => bool) => (t, t) - -/** -`partition(s, p)` returns a fresh copy pair of sets `(s1, s2)`, where `s1` is -the set of all the elements of `s` that satisfy the predicate `p`, and `s2` is -the set of all the elements of `s` that do not satisfy `p`. -*/ -let partition: (t, value => bool) => (t, t) - -let size: t => int - -/** In increasing order with respect */ -let toList: t => list - -/** In increasing order with respect */ -let toArray: t => array - -let minimum: t => option -let minUndefined: t => Js.undefined -let maximum: t => option -let maxUndefined: t => Js.undefined - -let get: (t, value) => option -let getUndefined: (t, value) => Js.undefined -let getExn: (t, value) => value - -/** -`split(s, key)` return a fresh copy of each -*/ -let split: (t, value) => ((t, t), bool) - -/** -**raise** when invariant is not held -*/ -let checkInvariantInternal: t => unit diff --git a/jscomp/others/belt_MutableStack.res b/jscomp/others/belt_MutableStack.res deleted file mode 100644 index 2d7b34f747b..00000000000 --- a/jscomp/others/belt_MutableStack.res +++ /dev/null @@ -1,103 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -type rec t<'a> = {mutable root: opt_cell<'a>} -and opt_cell<'a> = option> -and cell<'a> = { - head: 'a, - tail: opt_cell<'a>, -} - -let make = () => {root: None} - -let clear = s => s.root = None - -let copy = (s: t<_>): t<_> => {root: s.root} - -let push = (s, x) => s.root = Some({head: x, tail: s.root}) - -let topUndefined = (s: t<'a>) => - switch s.root { - | None => Js.undefined - | Some(x) => Js.Undefined.return(x.head) - } - -let top = s => - switch s.root { - | None => None - | Some(x) => Some(x.head) - } - -let isEmpty = s => s.root == None - -let popUndefined = s => - switch s.root { - | None => Js.undefined - | Some(x) => - s.root = x.tail - Js.Undefined.return(x.head) - } - -let pop = s => - switch s.root { - | None => None - | Some(x) => - s.root = x.tail - Some(x.head) - } - -let rec lengthAux = (x: cell<_>, acc) => - switch x.tail { - | None => acc + 1 - | Some(x) => lengthAux(x, acc + 1) - } - -let size = s => - switch s.root { - | None => 0 - | Some(x) => lengthAux(x, 0) - } - -let rec iterAux = (s: opt_cell<_>, f) => - switch s { - | None => () - | Some(x) => - 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 rec dynamicPopIterU = (s, f) => - switch s.root { - | Some({tail, head}) => - s.root = tail - f(. head) - dynamicPopIterU(s, f) /* using root, `f` may change it */ - | None => () - } - -let dynamicPopIter = (s, f) => dynamicPopIterU(s, (. x) => f(x)) diff --git a/jscomp/others/belt_MutableStack.resi b/jscomp/others/belt_MutableStack.resi deleted file mode 100644 index cb11d4afe44..00000000000 --- a/jscomp/others/belt_MutableStack.resi +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -First in last out stack. This module implements stacks, with in-place -modification. -*/ - -type t<'a> - -/** -Returns a new stack, initially empty. -*/ -let make: unit => t<'a> - -/** -Discard all elements from the stack. -*/ -let clear: t<'a> => unit - -/** -`copy(x)` O(1) operation, return a new stack. -*/ -let copy: t<'a> => t<'a> - -let push: (t<'a>, 'a) => unit -let popUndefined: t<'a> => Js.undefined<'a> -let pop: t<'a> => option<'a> -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 forEach: (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 -before applying `f`, `s` will be empty after this opeartion. This function is -useful for worklist algorithm. - */ -let dynamicPopIter: (t<'a>, 'a => unit) => unit diff --git a/jscomp/others/belt_Option.res b/jscomp/others/belt_Option.res deleted file mode 100644 index b7371b4a5f9..00000000000 --- a/jscomp/others/belt_Option.res +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -let keepU = (opt, p) => - switch opt { - | Some(x) as some if p(. x) => some - | _ => None - } - -let keep = (opt, p) => keepU(opt, (. x) => p(x)) - -let forEachU = (opt, f) => - switch opt { - | Some(x) => f(. x) - | None => () - } - -let forEach = (opt, f) => forEachU(opt, (. x) => f(x)) - -let getExn = x => - switch x { - | Some(x) => x - | None => raise(Not_found) - } - -external getUnsafe: option<'a> => 'a = "%identity" - -let mapWithDefaultU = (opt, default, f) => - switch opt { - | Some(x) => f(. x) - | None => default - } - -let mapWithDefault = (opt, default, f) => mapWithDefaultU(opt, default, (. x) => f(x)) - -let mapU = (opt, f) => - switch opt { - | Some(x) => Some(f(. x)) - | None => None - } - -let map = (opt, f) => mapU(opt, (. x) => f(x)) - -let flatMapU = (opt, f) => - switch opt { - | Some(x) => f(. x) - | None => None - } - -let flatMap = (opt, f) => flatMapU(opt, (. x) => f(x)) - -let getWithDefault = (opt, default) => - switch opt { - | Some(x) => x - | None => default - } - -let orElse = (opt, other) => - switch opt { - | Some(_) as some => some - | None => other - } - -let isSome = x => - switch x { - | Some(_) => true - | None => false - } - -let isNone = x => x == None - -let eqU = (a, b, f) => - switch a { - | Some(a) => - switch b { - | None => false - | Some(b) => f(. a, b) - } - | None => b == None - } - -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) - | (None, Some(_)) => -1 - | (Some(_), None) => 1 - | (None, None) => 0 - } - -let cmp = (a, b, f) => cmpU(a, b, (. x, y) => f(x, y)) diff --git a/jscomp/others/belt_Option.resi b/jscomp/others/belt_Option.resi deleted file mode 100644 index 5764811e602..00000000000 --- a/jscomp/others/belt_Option.resi +++ /dev/null @@ -1,295 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -In Belt we represent the existence and nonexistence of a value by wrapping it -with the `option` type. In order to make it a bit more convenient to work with -option-types, Belt provides utility-functions for it. - -The `option` type is a part of the ReScript standard library which is defined like this: - -## Examples - -```rescript -type option<'a> = None | Some('a) -``` - -```rescript -let someString: option = Some("hello") -``` -*/ - -/** Uncurried version of `keep` */ -let keepU: (option<'a>, (. 'a) => bool) => option<'a> - -/** -If `optionValue` is `Some(value)` and `p(value) = true`, it returns `Some(value)`; otherwise returns `None` - -## Examples - -```rescript -Belt.Option.keep(Some(10), x => x > 5) /* returns `Some(10)` */ -Belt.Option.keep(Some(4), x => x > 5) /* returns `None` */ -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 - -/** -If `optionValue` is `Some(value`), it calls `f(value)`; otherwise returns `()` - -## Examples - -```rescript -Belt.Option.forEach(Some("thing"), x => Js.log(x)) /* logs "thing" */ -Belt.Option.forEach(None, x => Js.log(x)) /* returns () */ -``` -*/ -let forEach: (option<'a>, 'a => unit) => unit - -/** -Raises an Error in case `None` is provided. Use with care. - -## Examples - -```rescript -Belt.Option.getExn(Some(3)) /* 3 */ - -Belt.Option.getExn(None) /* Raises an Error */ -``` -*/ -let getExn: option<'a> => 'a - -/** -`getUnsafe(x)` returns `x` - -This is an unsafe operation, it assumes `x` is neither `None` -nor `Some(None(...)))` -*/ -external getUnsafe: option<'a> => 'a = "%identity" - -/** Uncurried version of `mapWithDefault` */ -let mapWithDefaultU: (option<'a>, 'b, (. 'a) => 'b) => 'b - -/** -If `optionValue` is of `Some(value)`, -this function returns that value applied with `f`, in other words `f(value)`. - -If `optionValue` is `None`, the default is returned. - -## Examples - -```rescript -let someValue = Some(3) -someValue->Belt.Option.mapWithDefault(0, x => x + 5) /* 8 */ - -let noneValue = None -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> - -/** -If `optionValue` is `Some(value)` this returns `f(value)`, otherwise it returns `None`. - -## Examples - -```rescript -Belt.Option.map(Some(3), x => x * x) /* Some(9) */ - -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> - -/** -If `optionValue` is `Some(value)`, returns `f(value)`, otherwise returns -`None`.
-The function `f` must have a return type of `option<'b>`. - -## Examples - -```rescript -let addIfAboveOne = value => - if (value > 1) { - Some(value + 1) - } else { - None - } - -Belt.Option.flatMap(Some(2), addIfAboveOne) /* Some(3) */ - -Belt.Option.flatMap(Some(-4), addIfAboveOne) /* None */ - -Belt.Option.flatMap(None, addIfAboveOne) /* None */ -``` -*/ -let flatMap: (option<'a>, 'a => option<'b>) => option<'b> - -/** -If `optionalValue` is `Some(value)`, returns `value`, otherwise default. - -## Examples - -```rescript -Belt.Option.getWithDefault(None, "Banana") /* Banana */ - -Belt.Option.getWithDefault(Some("Apple"), "Banana") /* Apple */ -``` - -```rescript -let greet = (firstName: option) => - "Greetings " ++ firstName->Belt.Option.getWithDefault("Anonymous") - -Some("Jane")->greet /* "Greetings Jane" */ - -None->greet /* "Greetings Anonymous" */ -``` -*/ -let getWithDefault: (option<'a>, 'a) => 'a - -/** -`orElse(optionalValue, otherOptional)` if `optionalValue` is `Some(value)`, -returns `Some(value)`, otherwise `otherOptional` - -## Examples - -```rescript -Belt.Option.orElse(Some(1812), Some(1066)) == Some(1812) -Belt.Option.orElse(None, Some(1066)) == Some(1066) -Belt.Option.orElse(None, None) == None -``` -*/ -let orElse: (option<'a>, option<'a>) => option<'a> - -/** -Returns `true` if the argument is `Some(value)`, `false` otherwise. - -## Examples - -```rescript -Belt.Option.isSome(None) /* false */ - -Belt.Option.isSome(Some(1)) /* true */ -``` -*/ -let isSome: option<'a> => bool - -/** -Returns `true` if the argument is `None`, `false` otherwise. - -## Examples - -```rescript -Belt.Option.isNone(None) /* true */ - -Belt.Option.isNone(Some(1)) /* false */ -``` -*/ -let isNone: option<'a> => bool - -/** -Uncurried version of `eq` -*/ -let eqU: (option<'a>, option<'b>, (. 'a, 'b) => bool) => bool - -/** -Evaluates two optional values for equality with respect to a predicate -function. If both `optValue1` and `optValue2` are `None`, returns `true`. -If one of the arguments is `Some(value)` and the other is `None`, returns -`false`. - -If arguments are `Some(value1)` and `Some(value2)`, returns the result of -`predicate(value1, value2)`; the predicate function must return a bool. - -## Examples - -```rescript -let clockEqual = (a, b) => mod(a, 12) == mod(b, 12) - -open Belt.Option - -eq(Some(3), Some(15), clockEqual) /* true */ - -eq(Some(3), None, clockEqual) /* false */ - -eq(None, Some(3), clockEqual) /* false */ - -eq(None, None, clockEqual) /* true */ -``` -*/ -let eq: (option<'a>, option<'b>, ('a, 'b) => bool) => bool - -/** -Uncurried version of `cmp` -*/ -let cmpU: (option<'a>, option<'b>, (. 'a, 'b) => int) => int - -/** -`cmp(optValue1, optValue2, comparisonFunction)` compares two optional values -with respect to given `comparisonFunction`. - -If both `optValue1` and `optValue2` are `None`, it returns `0`. - -If the first argument is `Some(value1)` and the second is `None`, returns `1` -(something is greater than nothing). - -If the first argument is `None` and the second is `Some(value2)`, returns `-1` -(nothing is less than something). - -If the arguments are `Some(value1)` and `Some(value2)`, returns the result of -`comparisonFunction(value1, value2)`; comparisonFunction takes two arguments -and returns `-1` if the first argument is less than the second, `0` if the -arguments are equal, and `1` if the first argument is greater than the second. - -## Examples - -```rescript -let clockCompare = (a, b) => compare(mod(a, 12), mod(b, 12)) - -open Belt.Option - -cmp(Some(3), Some(15), clockCompare) /* 0 */ - -cmp(Some(3), Some(14), clockCompare) /* 1 */ - -cmp(Some(2), Some(15), clockCompare) /* (-1) */ - -cmp(None, Some(15), clockCompare) /* (-1) */ - -cmp(Some(14), None, clockCompare) /* 1 */ - -cmp(None, None, clockCompare) /* 0 */ -``` -*/ -let cmp: (option<'a>, option<'b>, ('a, 'b) => int) => int diff --git a/jscomp/others/belt_Range.res b/jscomp/others/belt_Range.res deleted file mode 100644 index c8f5d334c3f..00000000000 --- a/jscomp/others/belt_Range.res +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -let forEachU = (s, f, action) => - for i in s to f { - (action(. i): unit) - } - -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) - } - -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) - } - -let everyByU = (s, f, ~step, p) => - if step > 0 { - everyByAux(s, f, ~step, p) - } else { - true - } /* return empty range `true` */ - -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) - } - -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) - } - -let someByU = (s, f, ~step, p) => - if step > 0 { - someByAux(s, f, ~step, p) - } else { - false - } /* return empty range, `false` */ - -let someBy = (s, f, ~step, p) => someByU(s, f, ~step, (. a) => p(a)) diff --git a/jscomp/others/belt_Range.resi b/jscomp/others/belt_Range.resi deleted file mode 100644 index b0ad2f20501..00000000000 --- a/jscomp/others/belt_Range.resi +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -A small utility module to provide inclusive range operations for `[start, finish]`. -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 - -/** -`forEach(start, finish, action)` equivalent to `Belt.Array.forEach(Belt.Array.range(start, finish), action))` - -## Examples - -```rescript -Belt.Range.forEach(0, 4, (i) => Js.log(i)) - -// Prints: -// 0 -// 1 -// 2 -// 3 -// 4 -``` -*/ -let forEach: (int, int, int => unit) => unit - -let everyU: (int, int, (. int) => bool) => bool - -/** -`every(start, finish, p)` equivalent to `Belt.Array.every(Belt.Array.range(start, finish), p)` -## Examples - -```rescript -Belt.Range.every(0, 4, (i) => i < 5) /* true */ - -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 - -/** -`everyBy(start, finish, ~step, p)`. See `Belt.Array.rangeBy`, equivalent to -`Belt.Array.every(Belt.Array.rangeBy(start, finish, ~step), p)` - -## Examples - -```rescript -Belt.Range.everyBy(0, 4, ~step=1, (i) => mod(i, 2) === 0) /* false */ - -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 - -/** -`some(start, finish, p)` equivalent to `Belt.Array.some(Belt.Array.range(start, finish), p)` - -## Examples - -```rescript -Belt.Range.some(0, 4, (i) => i > 5) /* false */ - -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 - -/** -`someBy(start, finish, ~step, p)` See `Belt.Array.rangeBy`, equivalent to -`Belt.Array.some(Belt.Array.rangeBy(start, finish, ~step), p)` - -## Examples - -```rescript -Belt.Range.someBy(1, 5, ~step=2, (i) => mod(i, 2) === 0) /* false */ -Belt.Range.someBy(0, 4, ~step=2, (i) => mod(i, 2) === 0) /* true */ -``` -*/ -let someBy: (int, int, ~step: int, int => bool) => bool diff --git a/jscomp/others/belt_Result.res b/jscomp/others/belt_Result.res deleted file mode 100644 index a1cbba14591..00000000000 --- a/jscomp/others/belt_Result.res +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -type t<'a, 'b> = result<'a, 'b> = - | Ok('a) - | Error('b) - -let getExn = x => - switch x { - | Ok(x) => x - | Error(_) => raise(Not_found) - } - -let mapWithDefaultU = (opt, default, f) => - switch opt { - | Ok(x) => f(. x) - | Error(_) => default - } - -let mapWithDefault = (opt, default, f) => mapWithDefaultU(opt, default, (. x) => f(x)) - -let mapU = (opt, f) => - switch opt { - | Ok(x) => Ok(f(. x)) - | Error(y) => Error(y) - } - -let map = (opt, f) => mapU(opt, (. x) => f(x)) - -let flatMapU = (opt, f) => - switch opt { - | Ok(x) => f(. x) - | Error(y) => Error(y) - } - -let flatMap = (opt, f) => flatMapU(opt, (. x) => f(x)) - -let getWithDefault = (opt, default) => - switch opt { - | Ok(x) => x - | Error(_) => default - } - -let isOk = x => - switch x { - | Ok(_) => true - | Error(_) => false - } - -let isError = x => - switch x { - | Ok(_) => false - | Error(_) => true - } - -let eqU = (a, b, f) => - switch (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 cmpU = (a, b, f) => - switch (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)) diff --git a/jscomp/others/belt_Result.resi b/jscomp/others/belt_Result.resi deleted file mode 100644 index 91e1f66c2b2..00000000000 --- a/jscomp/others/belt_Result.resi +++ /dev/null @@ -1,204 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -Result types are really useful to describe the result of a certain operation -without relying on exceptions or `option` types. - -This module gives you useful utilities to create and combine `Result` data. -*/ - -type t<'a, 'b> = result<'a, 'b> = - | Ok('a) - | Error('b) - -/** -`getExn(res)`: when `res` is `Ok(n)`, returns `n` when `res` is `Error(m)`, raise an exception - -## Examples - -```rescript -Belt.Result.getExn(Belt.Result.Ok(42)) == 42 - -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 -/** -`mapWithDefault(res, default, f)`: When res is `Ok(n)`, returns `f(n)`, -otherwise `default`. - -## Examples - -```rescript -let ok = Belt.Result.Ok(42) -Belt.Result.mapWithDefault(ok, 0, (x) => x / 2) == 21 - -let error = Belt.Result.Error("Invalid data") -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> -/** -`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 -ordinary value. - -## Examples - -```rescript -let f = (x) => sqrt(Belt.Int.toFloat(x)) - -Belt.Result.map(Ok(64), f) == Ok(8.0) - -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> -/** -`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 -`Belt.Result`. - -## Examples - -```rescript -let recip = (x) => - if (x !== 0.0) { - Belt.Result.Ok(1.0 /. x) - } else { - Belt.Result.Error("Divide by zero") - } - -Belt.Result.flatMap(Ok(2.0), recip) == Ok(0.5) - -Belt.Result.flatMap(Ok(0.0), recip) == Error("Divide by zero") - -Belt.Result.flatMap(Error("Already bad"), recip) == Error("Already bad") -``` -*/ -let flatMap: (t<'a, 'c>, 'a => t<'b, 'c>) => t<'b, 'c> - -/** -`getWithDefault(res, defaultValue)`: If `res` is `Ok(n)`, returns `n`, -otherwise `default` - -## Examples - -```rescript -Belt.Result.getWithDefault(Ok(42), 0) == 42 - -Belt.Result.getWithDefault(Error("Invalid Data"), 0) == 0 -``` -*/ -let getWithDefault: (t<'a, 'b>, 'a) => 'a - -/** -`isOk(res)`: Returns `true` if `res` is of the form `Ok(n)`, `false` if it is -the `Error(e)` variant. -*/ -let isOk: t<'a, 'b> => bool - -/** -`isError(res)`: Returns `true` if `res` is of the form `Error(e)`, `false` if -it is the `Ok(n)` variant. -*/ -let isError: t<'a, 'b> => 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)` -and `Ok(m)`, return the result of `f(n, m)`. If one of `res1` and `res2` are of -the form `Error(e)`, return false If both `res1` and `res2` are of the form -`Error(e)`, return true - -## Examples - -```rescript -let good1 = Belt.Result.Ok(42) - -let good2 = Belt.Result.Ok(32) - -let bad1 = Belt.Result.Error("invalid") - -let bad2 = Belt.Result.Error("really invalid") - -let mod10equal = (a, b) => mod(a, 10) === mod(b, 10) - -Belt.Result.eq(good1, good2, mod10equal) == true - -Belt.Result.eq(good1, bad1, mod10equal) == false - -Belt.Result.eq(bad2, good2, mod10equal) == false - -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 -/** -`cmp(res1, res2, f)`: Compare two `Belt.Result` variables with respect to a -comparison function. The comparison function returns -1 if the first variable -is "less than" the second, 0 if the two variables are equal, and 1 if the first -is "greater than" the second. - -If `res1` and `res2` are of the form `Ok(n)` and `Ok(m)`, return the result of -`f(n, m)`. If `res1` is of the form `Error(e)` and `res2` of the form `Ok(n)`, -return -1 (nothing is less than something) If `res1` is of the form `Ok(n)` and -`res2` of the form `Error(e)`, return 1 (something is greater than nothing) If -both `res1` and `res2` are of the form `Error(e)`, return 0 (equal) - -## Examples - -```rescript -let good1 = Belt.Result.Ok(59) - -let good2 = Belt.Result.Ok(37) - -let bad1 = Belt.Result.Error("invalid") - -let bad2 = Belt.Result.Error("really invalid") - -let mod10cmp = (a, b) => Pervasives.compare(mod(a, 10), mod(b, 10)) - -Belt.Result.cmp(Ok(39), Ok(57), mod10cmp) == 1 - -Belt.Result.cmp(Ok(57), Ok(39), mod10cmp) == (-1) - -Belt.Result.cmp(Ok(39), Error("y"), mod10cmp) == 1 - -Belt.Result.cmp(Error("x"), Ok(57), mod10cmp) == (-1) - -Belt.Result.cmp(Error("x"), Error("y"), mod10cmp) == 0 -``` -*/ -let cmp: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => int) => int diff --git a/jscomp/others/belt_Set.cppo.res b/jscomp/others/belt_Set.cppo.res deleted file mode 100644 index 2ef41247f48..00000000000 --- a/jscomp/others/belt_Set.cppo.res +++ /dev/null @@ -1,233 +0,0 @@ -#ifdef TYPE_INT -module I = Belt_internalSetInt -#elif defined TYPE_STRING -module I = Belt_internalSetString -#else -[%error "unknown type"] -#endif - -module N = Belt_internalAVLset -module A = Belt_Array - -type value = I.value -type t = I.t - -let empty = None -let isEmpty = N.isEmpty -let minimum = N.minimum -let minUndefined = N.minUndefined -let maximum = N.maximum -let maxUndefined = N.maxUndefined - -let forEach = N.forEach -let forEachU = N.forEachU -let reduce = N.reduce -let reduceU = N.reduceU -let every = N.every -let everyU = N.everyU -let some = N.some -let someU = N.someU -let keep = N.keepShared -let keepU = N.keepSharedU -let partition = N.partitionShared -let partitionU = N.partitionSharedU - -let size = N.size -let toList = N.toList -let toArray = N.toArray -let fromSortedArrayUnsafe = N.fromSortedArrayUnsafe -let checkInvariantInternal = N.checkInvariantInternal - -let rec add = (t: t, x: value): t => - switch t { - | None => N.singleton(x) - | Some(nt) => - let v = nt.value - if x == v { - t - } else { - let {N.left: l, right: r} = nt - if x < v { - let ll = add(l, x) - if ll === l { - t - } else { - N.bal(ll, v, r) - } - } else { - let rr = add(r, x) - if rr === r { - t - } else { - N.bal(l, v, rr) - } - } - } - } - -let mergeMany = (h, arr) => { - let len = A.length(arr) - let v = ref(h) - for i in 0 to len - 1 { - let key = A.getUnsafe(arr, i) - v.contents = add(v.contents, key) - } - v.contents -} - -let rec remove = (t: t, x: value): t => - switch t { - | None => t - | Some(n) => - let {N.left: l, value: v, right: r} = n - if x == v { - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (_, Some(rn)) => - let v = ref(rn.value) - let r = N.removeMinAuxWithRef(rn, v) - N.bal(l, v.contents, r) - } - } else if x < v { - let ll = remove(l, x) - if ll === l { - t - } else { - N.bal(ll, v, r) - } - } else { - let rr = remove(r, x) - if rr === r { - t - } else { - N.bal(l, v, rr) - } - } - } - -let removeMany = (h, arr) => { - let len = A.length(arr) - let v = ref(h) - for i in 0 to len - 1 { - let key = A.getUnsafe(arr, i) - v.contents = remove(v.contents, key) - } - v.contents -} - -let fromArray = I.fromArray -let cmp = I.cmp -let eq = I.eq -let get = I.get -let getUndefined = I.getUndefined -let getExn = I.getExn -let subset = I.subset -let has = I.has - -let rec splitAuxNoPivot = (n: N.node<_>, x: value): (t, t) => { - let {N.left: l, value: v, right: r} = n - if x == v { - (l, r) - } else if x < v { - switch l { - | None => (None, Some(n)) - | Some(l) => - let (ll, rl) = splitAuxNoPivot(l, x) - (ll, N.joinShared(rl, v, r)) - } - } else { - switch r { - | None => (Some(n), None) - | Some(r) => - let (lr, rr) = splitAuxNoPivot(r, x) - (N.joinShared(l, v, lr), rr) - } - } -} - -let rec splitAuxPivot = (n: N.node<_>, x: value, pres): (t, t) => { - let {N.left: l, value: v, right: r} = n - if x == v { - pres.contents = true - (l, r) - } else if x < v { - switch l { - | None => (None, Some(n)) - | Some(l) => - let (ll, rl) = splitAuxPivot(l, x, pres) - (ll, N.joinShared(rl, v, r)) - } - } else { - switch r { - | None => (Some(n), None) - | Some(r) => - let (lr, rr) = splitAuxPivot(r, x, pres) - (N.joinShared(l, v, lr), rr) - } - } -} - -let split = (t: t, x: value) => - switch t { - | None => ((None, None), false) - | Some(n) => - let pres = ref(false) - let v = splitAuxPivot(n, x, pres) - (v, pres.contents) - } - -let rec union = (s1: t, s2: t) => - switch (s1, s2) { - | (None, _) => s2 - | (_, None) => s1 - | (Some(n1), Some(n2)) /* (Node(l1, v1, r1, h1), Node(l2, v2, r2, h2)) */ => - let (h1, h2) = (n1.height, n2.height) - if h1 >= h2 { - if h2 == 1 { - add(s1, n2.value) - } else { - let {N.left: l1, value: v1, right: r1} = n1 - let (l2, r2) = splitAuxNoPivot(n2, v1) - N.joinShared(union(l1, l2), v1, union(r1, r2)) - } - } else if h1 == 1 { - add(s2, n1.value) - } else { - let {N.left: l2, value: v2, right: r2} = n2 - let (l1, r1) = splitAuxNoPivot(n1, v2) - N.joinShared(union(l1, l2), v2, union(r1, r2)) - } - } - -let rec intersect = (s1: t, s2: t) => - switch (s1, s2) { - | (None, _) | (_, None) => None - | (Some(n1), Some(n2)) /* (Node(l1, v1, r1, _), t2) */ => - let {N.left: l1, value: v1, right: r1} = n1 - let pres = ref(false) - let (l2, r2) = splitAuxPivot(n2, v1, pres) - let ll = intersect(l1, l2) - let rr = intersect(r1, r2) - if pres.contents { - N.joinShared(ll, v1, rr) - } else { - N.concatShared(ll, rr) - } - } - -let rec diff = (s1: t, s2: t) => - switch (s1, s2) { - | (None, _) | (_, None) => s1 - | (Some(n1), Some(n2)) /* (Node(l1, v1, r1, _), t2) */ => - let {N.left: l1, value: v1, right: r1} = n1 - let pres = ref(false) - let (l2, r2) = splitAuxPivot(n2, v1, pres) - let ll = diff(l1, l2) - let rr = diff(r1, r2) - if pres.contents { - N.concatShared(ll, rr) - } else { - N.joinShared(ll, v1, rr) - } - } diff --git a/jscomp/others/belt_Set.cppo.resi b/jscomp/others/belt_Set.cppo.resi deleted file mode 100644 index 60703e4cf68..00000000000 --- a/jscomp/others/belt_Set.cppo.resi +++ /dev/null @@ -1,169 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** - This module is [`Belt.Set`]() specialized with value type to be a primitive type. - It is more efficient in general, the API is the same with [`Belt_Set`]() except its value type is fixed, - and identity is not needed(using the built-in one) - - **See** [`Belt.Set`]() -*/ - -#ifdef TYPE_STRING -/** The type of the set elements. */ -type value = string -#elif defined TYPE_INT -/** The type of the set elements. */ -type value = int -#else -[%error "unknown type"] -#endif - -/** The type of sets. */ -type t - -let empty: t - -let fromArray: array => t - -let fromSortedArrayUnsafe: array => t - -let isEmpty: t => bool - -let has: (t, value) => bool - -/** -`add(s, x)` If `x` was already in `s`, `s` is returned unchanged. -*/ -let add: (t, value) => t - -let mergeMany: (t, array) => t - -/** -`remove(m, x)` If `x` was not in `m`, `m` is returned reference unchanged. -*/ -let remove: (t, value) => t - -let removeMany: (t, array) => t - -let union: (t, t) => t - -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`. -*/ -let subset: (t, t) => bool - -/** -Total ordering between sets. Can be used as the ordering function for doing sets -of sets. -*/ -let cmp: (t, t) => int - -/** -`eq(s1, s2)` tests whether the sets `s1` and `s2` are equal, that is, contain -equal elements. -*/ -let eq: (t, t) => bool - -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 - -/** Iterate in increasing order. */ -let reduce: (t, 'a, ('a, value) => 'a) => 'a - -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 - -/** -`some(p, s)` checks if at least one element of the set satisfies the predicate -`p`. Oder unspecified. -*/ -let some: (t, value => bool) => bool - -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) - -/** -`partition(p, s)` returns a pair of sets `(s1, s2)`, where `s1` is the set of -all the elements of `s` that satisfy the predicate `p`, and `s2` is the set of -all the elements of `s` that do not satisfy `p`. -*/ -let partition: (t, value => bool) => (t, t) - -let size: t => int - -/** In increasing order */ -let toList: t => list - -let toArray: t => array - -let minimum: t => option - -let minUndefined: t => Js.undefined - -let maximum: t => option - -let maxUndefined: t => Js.undefined - -let get: (t, value) => option - -let getUndefined: (t, value) => Js.undefined - -let getExn: (t, value) => value - -/** -`split(x, s)` returns a triple `(l, present, r)`, where `l` is the set of -elements of `s` that are strictly less than `x`;`r` is the set of elements of -`s` that are strictly greater than `x`; `present` is `false` if `s` contains no -element equal to `x`, or `true` if `s` contains an element equal to `x`. -*/ -let split: (t, value) => ((t, t), bool) - -/** -**raise** when invariant is not held -*/ -let checkInvariantInternal: t => unit diff --git a/jscomp/others/belt_Set.res b/jscomp/others/belt_Set.res deleted file mode 100644 index 612a9fd7b89..00000000000 --- a/jscomp/others/belt_Set.res +++ /dev/null @@ -1,164 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -module Int = Belt_SetInt -module String = Belt_SetString -module Dict = Belt_SetDict - -type id<'value, 'id> = Belt_Id.comparable<'value, 'id> -type cmp<'value, 'id> = Belt_Id.cmp<'value, 'id> - -type t<'value, 'id> = { - cmp: cmp<'value, 'id>, - data: Dict.t<'value, 'id>, -} - -let fromArray = (type value identity, data, ~id: id) => { - module M = unpack(id) - let cmp = M.cmp - {cmp, data: Dict.fromArray(~cmp, data)} -} - -let remove = (m, e) => { - let {cmp, data} = m - let newData = Dict.remove(~cmp, data, e) - if newData === data { - m - } else { - {cmp, data: newData} - } -} - -let add = (m, e) => { - let {cmp, data} = m - let newData = Dict.add(~cmp, data, e) - if newData === data { - m - } else { - {cmp, data: newData} - } -} - -let mergeMany = ({cmp} as m, e) => {cmp, data: Dict.mergeMany(~cmp, m.data, e)} - -let removeMany = ({cmp} as m, e) => {cmp, data: Dict.removeMany(~cmp, m.data, e)} - -let union = ({cmp} as m, n) => {data: Dict.union(~cmp, m.data, n.data), cmp} - -let intersect = (m, n) => { - let cmp = m.cmp - {data: Dict.intersect(~cmp, m.data, n.data), cmp} -} - -let diff = (m, n) => { - let cmp = m.cmp - {cmp, data: Dict.diff(~cmp, m.data, n.data)} -} - -let subset = (m, n) => { - let cmp = m.cmp - Dict.subset(~cmp, m.data, n.data) -} - -let split = (m, e) => { - let cmp = m.cmp - let ((l, r), b) = Dict.split(~cmp, m.data, e) - (({cmp, data: l}, {cmp, data: r}), b) -} - -let make = (type value identity, ~id: id) => { - module M = unpack(id) - {cmp: M.cmp, data: Dict.empty} -} - -let isEmpty = m => Dict.isEmpty(m.data) - -let cmp = (m, n) => { - let cmp = m.cmp - Dict.cmp(~cmp, m.data, n.data) -} - -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 reduceU = (m, acc, f) => Dict.reduceU(m.data, acc, f) -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 someU = (m, f) => Dict.someU(m.data, f) -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 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 size = m => Dict.size(m.data) -let toList = m => Dict.toList(m.data) -let toArray = m => Dict.toArray(m.data) - -let minimum = m => Dict.minimum(m.data) -let minUndefined = m => Dict.minUndefined(m.data) -let maximum = m => Dict.maximum(m.data) -let maxUndefined = m => Dict.maxUndefined(m.data) - -let get = (m, e) => Dict.get(~cmp=m.cmp, m.data, e) - -let getUndefined = (m, e) => Dict.getUndefined(~cmp=m.cmp, m.data, e) - -let getExn = (m, e) => Dict.getExn(~cmp=m.cmp, m.data, e) - -let has = (m, e) => Dict.has(~cmp=m.cmp, m.data, e) - -let fromSortedArrayUnsafe = (type value identity, xs, ~id: id) => { - module M = unpack(id) - {cmp: M.cmp, data: Dict.fromSortedArrayUnsafe(xs)} -} - -let getData = m => m.data - -let getId = (type value identity, m: t): id => { - module T = { - type identity = identity - type t = value - let cmp = m.cmp - } - module(T) -} - -let packIdData = (type value identity, ~id: id, ~data) => { - module M = unpack(id) - {cmp: M.cmp, data} -} - -let checkInvariantInternal = d => Dict.checkInvariantInternal(d.data) diff --git a/jscomp/others/belt_Set.resi b/jscomp/others/belt_Set.resi deleted file mode 100644 index a7b8e007313..00000000000 --- a/jscomp/others/belt_Set.resi +++ /dev/null @@ -1,575 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -An _immutable_ sorted set module which allows customized _compare_ behavior. - -The implementation uses balanced binary trees, and therefore searching -and insertion take time logarithmic in the size of the map. - -For more info on this module's usage of identity, `make` and others, please see -the top level documentation of Belt, **A special encoding for collection safety**. - -## Examples - -```rescript -module PairComparator = - Belt.Id.MakeComparable({ - type t = (int, int) - let cmp = ((a0, a1), (b0, b1)) => - switch (Pervasives.compare(a0, b0)) { - | 0 => Pervasives.compare(a1, b1) - | c => c - } - }) - -let mySet = Belt.Set.make(~id=module(PairComparator)) -let mySet2 = Belt.Set.add(mySet, (1, 2)) -``` - -**Note:** This module's examples will assume a predeclared module for integers -called `IntCmp`. It is declared like this: - -```rescript -module IntCmp = - Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare - }) -``` -*/ - -/** -Specialized when value type is `int`, more efficient than the generic type, its -compare behavior is fixed using the built-in comparison -*/ -module Int = Belt_SetInt - -/** -Specialized when value type is `string`, more efficient than the generic type, -its compare behavior is fixed using the built-in comparison -*/ -module String = Belt_SetString - -/** -This module separates identity from data, it is a bit more verbose but slightly -more efficient due to the fact that there is no need to pack identity and data back -after each operation -*/ -module Dict = Belt_SetDict - -/** -`'value` is the element type - -`'identity` the identity of the collection -*/ -type t<'value, 'identity> - -/** -The identity needed for making a set from scratch -*/ -type id<'value, 'id> = Belt_Id.comparable<'value, 'id> - -/** -Creates a new set by taking in the comparator - -## Examples - -```rescript -let set = Belt.Set.make(~id=module(IntCmp)) -``` -*/ -let make: (~id: id<'value, 'id>) => t<'value, 'id> - -/** -Creates new set from array of elements. - -## Examples - -```rescript -let s0 = Belt.Set.fromArray([1, 3, 2, 4], ~id=module(IntCmp)) - -s0->Belt.Set.toArray /* [1, 2, 3, 4] */ -``` -*/ -let fromArray: (array<'value>, ~id: id<'value, 'id>) => t<'value, 'id> - -/** -The same as [fromArray][#fromarray] except it is after assuming the input array -is already sorted. -*/ -let fromSortedArrayUnsafe: (array<'value>, ~id: id<'value, 'id>) => t<'value, 'id> - -/** -Checks if set is empty. - -## Examples - -```rescript -let empty = Belt.Set.fromArray([], ~id=module(IntCmp)) -let notEmpty = Belt.Set.fromArray([1],~id=module(IntCmp)) - -Belt.Set.isEmpty(empty) /* true */ -Belt.Set.isEmpty(notEmpty) /* false */ -``` -*/ -let isEmpty: t<_> => bool - -/** -Checks if element exists in set. - -## Examples - -```rescript -let set = Belt.Set.fromArray([1, 4, 2, 5], ~id=module(IntCmp)) - -set->Belt.Set.has(3) /* false */ -set->Belt.Set.has(1) /* true */ -``` -*/ -let has: (t<'value, 'id>, 'value) => bool - -/** -Adds element to set. If element existed in set, value is unchanged. - -## Examples - -```rescript -let s0 = Belt.Set.make(~id=module(IntCmp)) -let s1 = s0->Belt.Set.add(1) -let s2 = s1->Belt.Set.add(2) -let s3 = s2->Belt.Set.add(2) -s0->Belt.Set.toArray /* [] */ -s1->Belt.Set.toArray /* [1] */ -s2->Belt.Set.toArray /* [1, 2] */ -s3->Belt.Set.toArray /* [1,2 ] */ -s2 == s3 /* true */ -``` -*/ -let add: (t<'value, 'id>, 'value) => t<'value, 'id> - -/** -Adds each element of array to set. Unlike `Belt.Set.add`](#add), the reference of return value might be changed even if all values in array already exist in set - -## Examples - -```rescript -let set = Belt.Set.make(~id=module(IntCmp)) - -let newSet = set->Belt.Set.mergeMany([5, 4, 3, 2, 1]) -newSet->Belt.Set.toArray /* [1, 2, 3, 4, 5] */ -``` -*/ -let mergeMany: (t<'value, 'id>, array<'value>) => t<'value, 'id> - -/** -Removes element from set. If element did not exist in set, value is unchanged. - -## Examples - -```rescript -let s0 = Belt.Set.fromArray([2,3,1,4,5], ~id=module(IntCmp)) -let s1 = s0->Belt.Set.remove(1) -let s2 = s1->Belt.Set.remove(3) -let s3 = s2->Belt.Set.remove(3) - -s1->Belt.Set.toArray /* [2,3,4,5] */ -s2->Belt.Set.toArray /* [2,4,5] */ -s2 == s3 /* true */ -``` -*/ -let remove: (t<'value, 'id>, 'value) => t<'value, 'id> - -/** -Removes each element of array from set. Unlike [remove](#remove), the reference of return value might be changed even if none of values in array existed in set. - -## Examples - -```rescript -let set = Belt.Set.fromArray([1, 2, 3, 4],~id=module(IntCmp)) - -let newSet = set->Belt.Set.removeMany([5, 4, 3, 2, 1]) -newSet->Belt.Set.toArray /* [] */ -``` -*/ -let removeMany: (t<'value, 'id>, array<'value>) => t<'value, 'id> - -/** - Returns union of two sets. - -## Examples - -```rescript -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([5,2,3,1,5,4], ~id=module(IntCmp)) -let union = Belt.Set.union(s0, s1) -union->Belt.Set.toArray /* [1,2,3,4,5,6] */ -``` -*/ -let union: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> - -/** -Returns intersection of two sets. - -## Examples - -```rescript -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([5,2,3,1,5,4], ~id=module(IntCmp)) -let intersect = Belt.Set.intersect(s0, s1) -intersect->Belt.Set.toArray /* [2,3,5] */ -``` -*/ -let intersect: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> - -/** -Returns elements from first set, not existing in second set. - -## Examples - -```rescript -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([5,2,3,1,5,4], ~id=module(IntCmp)) -Belt.Set.toArray(Belt.Set.diff(s0, s1)) /* [6] */ -Belt.Set.toArray(Belt.Set.diff(s1,s0)) /* [1,4] */ -``` -*/ -let diff: (t<'value, 'id>, t<'value, 'id>) => t<'value, 'id> - -/** -Checks if second set is subset of first set. - -## Examples - -```rescript -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([5,2,3,1,5,4], ~id=module(IntCmp)) -let s2 = Belt.Set.intersect(s0, s1) -Belt.Set.subset(s2, s0) /* true */ -Belt.Set.subset(s2, s1) /* true */ -Belt.Set.subset(s1, s0) /* false */ -``` -*/ -let subset: (t<'value, 'id>, t<'value, 'id>) => bool - -/** -Total ordering between sets. Can be used as the ordering function for doing sets -of sets. It compares size first and then iterates over each element following -the order of elements. -*/ -let cmp: (t<'value, 'id>, t<'value, 'id>) => int - -/** -Checks if two sets are equal. - -## Examples - -```rescript -let s0 = Belt.Set.fromArray([5,2,3], ~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([3,2,5], ~id=module(IntCmp)) - -Belt.Set.eq(s0, s1) /* true */ -``` -*/ -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 - -/** -Applies function `f` in turn to all elements of set in increasing order. - -## Examples - -```rescript -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -let acc = ref(list{}) -s0->Belt.Set.forEach(x => { - acc := Belt.List.add(acc.contents, x) -}) -acc /* [6,5,3,2] */ -``` -*/ -let forEach: (t<'value, 'id>, 'value => unit) => unit - -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. - -## Examples - -```rescript -let s0 = Belt.Set.fromArray([5,2,3,5,6], ~id=module(IntCmp)) -s0->Belt.Set.reduce(list{}, (acc, element) => - acc->Belt.List.add(element) -) /* [6,5,3,2] */ -``` -*/ -let reduce: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a - -let everyU: (t<'value, 'id>, (. 'value) => bool) => bool - -/** -Checks if all elements of the set satisfy the predicate. Order unspecified. - -## Examples - -```rescript -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.Set.fromArray([2,4,6,8], ~id=module(IntCmp)) -s0->Belt.Set.every(isEven) /* true */ -``` -*/ -let every: (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. - -## Examples - -```rescript -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.Set.fromArray([1,2,4,6,8], ~id=module(IntCmp)) -s0->Belt.Set.some(isOdd) /* true */ -``` -*/ -let some: (t<'value, 'id>, 'value => bool) => bool - -let keepU: (t<'value, 'id>, (. 'value) => bool) => t<'value, 'id> - -/** -Returns the set of all elements that satisfy the predicate. - -## Examples - -```rescript -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.Set.fromArray([1,2,3,4,5], ~id=module(IntCmp)) -let s1 = s0->Belt.Set.keep(isEven) - -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>) - -/** -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. - -## Examples - -```rescript -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.Set.fromArray([1,2,3,4,5], ~id=module(IntCmp)) -let (s1, s2) = s0->Belt.Set.partition(isOdd) - -s1->Belt.Set.toArray /* [1,3,5] */ -s2->Belt.Set.toArray /* [2,4] */ -``` -*/ -let partition: (t<'value, 'id>, 'value => bool) => (t<'value, 'id>, t<'value, 'id>) - -/** -Returns size of the set. - -## Examples - -```rescript -let s0 = Belt.Set.fromArray([1,2,3,4], ~id=module(IntCmp)) - -s0->Belt.Set.size /* 4 */ -``` -*/ -let size: t<'value, 'id> => int - -/** -Returns array of ordered set elements. - -## Examples - -```rescript -let s0 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.toArray /* [1,2,3,5] */ -``` -*/ -let toArray: t<'value, 'id> => array<'value> - -/** -Returns list of ordered set elements. - -## Examples - -```rescript -let s0 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.toList /* [1,2,3,5] */ -``` -*/ -let toList: t<'value, 'id> => list<'value> - -/** -Returns minimum value of the collection. `None` if collection is empty. - -## Examples - -```rescript -let s0 = Belt.Set.make(~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.minimum /* None */ -s1->Belt.Set.minimum /* Some(1) */ -``` -*/ -let minimum: t<'value, 'id> => option<'value> - -/** -Returns minimum value of the collection. `undefined` if collection is empty. - -## Examples - -```rescript -let s0 = Belt.Set.make(~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.minUndefined /* undefined */ -s1->Belt.Set.minUndefined /* 1 */ -``` -*/ -let minUndefined: t<'value, 'id> => Js.undefined<'value> - -/** -Returns maximum value of the collection. `None` if collection is empty. - -## Examples - -```rescript -let s0 = Belt.Set.make(~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.maximum /* None */ -s1->Belt.Set.maximum /* Some(5) */ -``` -*/ -let maximum: t<'value, 'id> => option<'value> - -/** -Returns maximum value of the collection. `undefined` if collection is empty. - -## Examples - -```rescript -let s0 = Belt.Set.make(~id=module(IntCmp)) -let s1 = Belt.Set.fromArray([3,2,1,5], ~id=module(IntCmp)) - -s0->Belt.Set.maxUndefined /* undefined */ -s1->Belt.Set.maxUndefined /* 5 */ -``` -*/ -let maxUndefined: t<'value, 'id> => Js.undefined<'value> - -/** -Returns the reference of the value which is equivalent to value using the comparator specifiecd by this collection. Returns `None` if element does not exist. - -## Examples - -```rescript -let s0 = Belt.Set.fromArray([1,2,3,4,5], ~id=module(IntCmp)) - -s0->Belt.Set.get(3) /* Some(3) */ -s0->Belt.Set.get(20) /* None */ -``` -*/ -let get: (t<'value, 'id>, 'value) => option<'value> - -/** -Same as [get](#get) but returns `undefined` when element does not exist. -*/ -let getUndefined: (t<'value, 'id>, 'value) => Js.undefined<'value> - -/** -Same as [get](#get) but raise when element does not exist. -*/ -let getExn: (t<'value, 'id>, 'value) => 'value - -/** -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -## Examples - -```rescript -let s0 = Belt.Set.fromArray([1,2,3,4,5], ~id=module(IntCmp)) - -let ((smaller, larger), present) = s0->Belt.Set.split(3) - -present /* true */ -smaller->Belt.Set.toArray /* [1,2] */ -larger->Belt.Set.toArray /* [4,5] */ - -``` -*/ -let split: (t<'value, 'id>, 'value) => ((t<'value, 'id>, t<'value, 'id>), bool) - -/** -**raise** when invariant is not held -*/ -let checkInvariantInternal: t<_> => unit - -/* ************************************************************************** - Below are operations only when better performance needed, - it is still safe API but more verbose. - More API will be exposed by needs -*/ - -/** -**Advanced usage only** - -Returns the raw data (detached from comparator), but its type is still manifested, -so that user can pass identity directly without boxing. -*/ -let getData: t<'value, 'id> => Belt_SetDict.t<'value, 'id> - -/** -**Advanced usage only** - -Returns the identity of set. -*/ -let getId: t<'value, 'id> => id<'value, 'id> - -/** -**Advanced usage only** - -Returns the packed collection. -*/ -let packIdData: (~id: id<'value, 'id>, ~data: Belt_SetDict.t<'value, 'id>) => t<'value, 'id> diff --git a/jscomp/others/belt_SetDict.res b/jscomp/others/belt_SetDict.res deleted file mode 100644 index 0a9a59b97c8..00000000000 --- a/jscomp/others/belt_SetDict.res +++ /dev/null @@ -1,264 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -module N = Belt_internalAVLset -module A = Belt_Array - -type t<'k, 'id> = N.t<'k> - -type cmp<'key, 'id> = Belt_Id.cmp<'key, 'id> - -/* here we relies on reference transparence - address equality means everything equal across time - no need to call `bal` again -*/ -let rec add = (t: t<_>, x, ~cmp): t<_> => - switch t { - | None => N.singleton(x) - | Some(nt) => - let k = nt.value - let c = Belt_Id.getCmpInternal(cmp)(. x, k) - if c == 0 { - t - } else { - let {N.left: l, right: r} = nt - if c < 0 { - let ll = add(~cmp, l, x) - if ll === l { - t - } else { - N.bal(ll, k, r) - } - } else { - let rr = add(~cmp, r, x) - if rr === r { - t - } else { - N.bal(l, k, rr) - } - } - } - } - -let rec remove = (t: t<_>, x, ~cmp): t<_> => - switch t { - | None => t - | Some(n) => - let {N.left: l, value: v, right: r} = n - let c = Belt_Id.getCmpInternal(cmp)(. x, v) - if c == 0 { - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (_, Some(rn)) => - let v = ref(rn.value) - let r = N.removeMinAuxWithRef(rn, v) - N.bal(l, v.contents, r) - } - } else if c < 0 { - let ll = remove(~cmp, l, x) - if ll === l { - t - } else { - N.bal(ll, v, r) - } - } else { - let rr = remove(~cmp, r, x) - if rr === r { - t - } else { - N.bal(l, v, rr) - } - } - } - -let mergeMany = (h, arr, ~cmp) => { - let len = A.length(arr) - let v = ref(h) - for i in 0 to len - 1 { - let key = A.getUnsafe(arr, i) - v.contents = add(v.contents, ~cmp, key) - } - v.contents -} - -let removeMany = (h, arr, ~cmp) => { - let len = A.length(arr) - let v = ref(h) - for i in 0 to len - 1 { - let key = A.getUnsafe(arr, i) - v.contents = remove(v.contents, ~cmp, key) - } - v.contents -} - -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) - if c == 0 { - (l, r) - } else if c < 0 { - switch l { - | None => (None, Some(n)) - | Some(l) => - let (ll, rl) = splitAuxNoPivot(~cmp, l, x) - (ll, N.joinShared(rl, v, r)) - } - } else { - switch r { - | None => (Some(n), None) - | Some(r) => - let (lr, rr) = splitAuxNoPivot(~cmp, r, x) - (N.joinShared(l, v, lr), rr) - } - } -} - -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) - if c == 0 { - pres.contents = true - (l, r) - } else if c < 0 { - switch l { - | None => (None, Some(n)) - | Some(l) => - let (ll, rl) = splitAuxPivot(~cmp, l, x, pres) - (ll, N.joinShared(rl, v, r)) - } - } else { - switch r { - | None => (Some(n), None) - | Some(r) => - let (lr, rr) = splitAuxPivot(~cmp, r, x, pres) - (N.joinShared(l, v, lr), rr) - } - } -} - -let split = (t: t<_>, x, ~cmp) => - switch t { - | None => ((None, None), false) - | Some(n) => - let pres = ref(false) - let v = splitAuxPivot(~cmp, n, x, pres) - (v, pres.contents) - } - -/* `union s1 s2` - Use the pivot to split the smaller collection -*/ -let rec union = (s1: t<_>, s2: t<_>, ~cmp): t<_> => - switch (s1, s2) { - | (None, _) => s2 - | (_, None) => s1 - | (Some(n1), Some(n2)) => - let (h1, h2) = (n1.height, n2.height) - if h1 >= h2 { - if h2 == 1 { - add(~cmp, s1, n2.value) - } else { - let {N.left: l1, value: v1, right: r1} = n1 - let (l2, r2) = splitAuxNoPivot(~cmp, n2, v1) - N.joinShared(union(~cmp, l1, l2), v1, union(~cmp, r1, r2)) - } - } else if h1 == 1 { - add(s2, ~cmp, n1.value) - } else { - let {N.left: l2, value: v2, right: r2} = n2 - let (l1, r1) = splitAuxNoPivot(~cmp, n1, v2) - N.joinShared(union(~cmp, l1, l2), v2, union(~cmp, r1, r2)) - } - } - -let rec intersect = (s1: t<_>, s2: t<_>, ~cmp) => - switch (s1, s2) { - | (None, _) - | (_, None) => - None - | (Some(n1), Some(n2)) => - let {N.left: l1, value: v1, right: r1} = n1 - let pres = ref(false) - let (l2, r2) = splitAuxPivot(~cmp, n2, v1, pres) - let ll = intersect(~cmp, l1, l2) - let rr = intersect(~cmp, r1, r2) - if pres.contents { - N.joinShared(ll, v1, rr) - } else { - N.concatShared(ll, rr) - } - } - -let rec diff = (s1, s2, ~cmp) => - switch (s1, s2) { - | (None, _) - | (_, None) => s1 - | (Some(n1), Some(n2)) => - let {N.left: l1, value: v1, right: r1} = n1 - let pres = ref(false) - let (l2, r2) = splitAuxPivot(~cmp, n2, v1, pres) - let ll = diff(~cmp, l1, l2) - let rr = diff(~cmp, r1, r2) - if pres.contents { - N.concatShared(ll, rr) - } else { - N.joinShared(ll, v1, rr) - } - } - -let empty = None -let fromArray = N.fromArray -let isEmpty = N.isEmpty - -let cmp = N.cmp -let eq = N.eq -let has = N.has -let forEachU = N.forEachU -let forEach = N.forEach -let reduceU = N.reduceU -let reduce = N.reduce -let everyU = N.everyU -let every = N.every -let someU = N.someU -let some = N.some -let size = N.size -let toList = N.toList -let toArray = N.toArray -let minimum = N.minimum -let maximum = N.maximum -let maxUndefined = N.maxUndefined -let minUndefined = N.minUndefined -let get = N.get -let getExn = N.getExn -let getUndefined = N.getUndefined - -let fromSortedArrayUnsafe = N.fromSortedArrayUnsafe -let subset = N.subset -let keep = N.keepShared -let keepU = N.keepSharedU -let partitionU = N.partitionSharedU -let partition = N.partitionShared - -let checkInvariantInternal = N.checkInvariantInternal diff --git a/jscomp/others/belt_SetDict.resi b/jscomp/others/belt_SetDict.resi deleted file mode 100644 index 4f740a63f49..00000000000 --- a/jscomp/others/belt_SetDict.resi +++ /dev/null @@ -1,633 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -This module separates identity from data. It is a bit more verbose but slightly -more efficient due to the fact that there is no need to pack identity and data -back after each operation. -*/ - -/** -`'value` is the element type - -`'identity` the identity of the collection -*/ -type t<'value, 'identity> - -/** -Type of compare function. -*/ -type cmp<'value, 'id> = Belt_Id.cmp<'value, 'id> - -/** -## Examples - -```rescript -let s0 = Belt.Set.Dict.empty -``` -*/ -let empty: t<'value, 'id> - -/** -Creates new set from array of elements. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([1, 3, 2, 4], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.toArray /* [1, 2, 3, 4] */ -``` -*/ -let fromArray: (array<'value>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> - -/** -The same as [fromArray][#fromarray] except it is after assuming the input array -is already sorted. -*/ -let fromSortedArrayUnsafe: array<'value> => t<'value, 'id> - -/** -Checks if set is empty. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let empty = Belt.Set.Dict.fromArray([], ~cmp=IntCmp.cmp) -let notEmpty = Belt.Set.Dict.fromArray([1], ~cmp=IntCmp.cmp) - -Belt.Set.Dict.isEmpty(empty) /* true */ -Belt.Set.Dict.isEmpty(notEmpty) /* false */ -``` -*/ -let isEmpty: t<_> => bool - -/** -Checks if an element exists in the set. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.Set.Dict.fromArray([1, 4, 2, 5], ~cmp=IntCmp.cmp) - -set->Belt.Set.Dict.has(3, ~cmp=IntCmp.cmp) /* false */ -set->Belt.Set.Dict.has(1, ~cmp=IntCmp.cmp) /* true */ -``` -*/ -let has: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => bool - -/** -Adds element to set. If element existed in set, value is unchanged. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.empty -let s1 = s0->Belt.Set.Dict.add(1, ~cmp=IntCmp.cmp) -let s2 = s1->Belt.Set.Dict.add(2, ~cmp=IntCmp.cmp) -let s3 = s2->Belt.Set.Dict.add(2, ~cmp=IntCmp.cmp) -s0->Belt.Set.Dict.toArray /* [] */ -s1->Belt.Set.Dict.toArray /* [1] */ -s2->Belt.Set.Dict.toArray /* [1, 2] */ -s3->Belt.Set.Dict.toArray /* [1,2 ] */ -s2 == s3 /* true */ -``` -*/ -let add: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => t<'value, 'id> - -/** -Adds each element of array to set. Unlike [add](#add), the reference of return value might be changed even if all values in array already exist in set - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.Set.Dict.empty - -let newSet = set->Belt.Set.Dict.mergeMany([5, 4, 3, 2, 1], ~cmp=IntCmp.cmp) -newSet->Belt.Set.Dict.toArray /* [1, 2, 3, 4, 5] */ -``` -*/ -let mergeMany: (t<'value, 'id>, array<'value>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> - -/** -Removes element from set. If element did not exist in set, value is unchanged. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([2, 3, 1, 4, 5], ~cmp=IntCmp.cmp) -let s1 = s0->Belt.Set.Dict.remove(1, ~cmp=IntCmp.cmp) -let s2 = s1->Belt.Set.Dict.remove(3, ~cmp=IntCmp.cmp) -let s3 = s2->Belt.Set.Dict.remove(3, ~cmp=IntCmp.cmp) - -s1->Belt.Set.Dict.toArray /* [2,3,4,5] */ -s2->Belt.Set.Dict.toArray /* [2,4,5] */ -s2 == s3 /* true */ -``` -*/ -let remove: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => t<'value, 'id> - -/** -Removes each element of array from set. Unlike [remove](#remove), the reference of return value might be changed even if any values in array not existed in set. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let set = Belt.Set.Dict.fromArray([1, 2, 3, 4], ~cmp=IntCmp.cmp) - -let newSet = set->Belt.Set.Dict.removeMany([5, 4, 3, 2, 1], ~cmp=IntCmp.cmp) -newSet->Belt.Set.Dict.toArray /* [] */ -``` -*/ -let removeMany: (t<'value, 'id>, array<'value>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> - -/** -Returns union of two sets. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -let s1 = Belt.Set.Dict.fromArray([5, 2, 3, 1, 5, 4], ~cmp=IntCmp.cmp) -let union = Belt.Set.Dict.union(s0, s1, ~cmp=IntCmp.cmp) -union->Belt.Set.Dict.toArray /* [1,2,3,4,5,6] */ -``` -*/ -let union: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> - -/** -Returns intersection of two sets. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -let s1 = Belt.Set.Dict.fromArray([5, 2, 3, 1, 5, 4], ~cmp=IntCmp.cmp) -let intersect = Belt.Set.Dict.intersect(s0, s1, ~cmp=IntCmp.cmp) -intersect->Belt.Set.Dict.toArray /* [2,3,5] */ -``` -*/ -let intersect: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> - -/** -Returns elements from first set, not existing in second set. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -let s1 = Belt.Set.Dict.fromArray([5, 2, 3, 1, 5, 4], ~cmp=IntCmp.cmp) - -let diff1 = Belt.Set.Dict.diff(s0, s1, ~cmp=IntCmp.cmp) -let diff2 = Belt.Set.Dict.diff(s1, s0, ~cmp=IntCmp.cmp) - -diff1->Belt.Set.Dict.toArray /* [6] */ -diff2->Belt.Set.Dict.toArray /* [1,4] */ -``` -*/ -let diff: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => t<'value, 'id> - -/** -Checks if second set is subset of first set. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -let s1 = Belt.Set.Dict.fromArray([5, 2, 3, 1, 5, 4], ~cmp=IntCmp.cmp) -let s2 = Belt.Set.Dict.intersect(s0, s1, ~cmp=IntCmp.cmp) -Belt.Set.Dict.subset(s2, s0, ~cmp=IntCmp.cmp) /* true */ -Belt.Set.Dict.subset(s2, s1, ~cmp=IntCmp.cmp) /* true */ -Belt.Set.Dict.subset(s1, s0, ~cmp=IntCmp.cmp) /* false */ -``` -*/ -let subset: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => bool - -/** -Total ordering between sets. Can be used as the ordering function for doing sets -of sets. It compares size first and then iterates over each element following the -order of elements. -*/ -let cmp: (t<'value, 'id>, t<'value, 'id>, ~cmp: cmp<'value, 'id>) => int - -/** -Checks if two sets are equal. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3], ~cmp=IntCmp.cmp) -let s1 = Belt.Set.Dict.fromArray([3, 2, 5], ~cmp=IntCmp.cmp) - -Belt.Set.Dict.eq(s0, s1, ~cmp=IntCmp.cmp) /* true */ -``` -*/ -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 - -/** -Applies function `f` in turn to all elements of set in increasing order. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -let acc = ref(list{}) -s0->Belt.Set.Dict.forEach(x => acc := Belt.List.add(acc.contents, x)) -acc /* [6,5,3,2] */ -``` -*/ -let forEach: (t<'value, 'id>, 'value => unit) => unit - -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. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([5, 2, 3, 5, 6], ~cmp=IntCmp.cmp) -s0->Belt.Set.Dict.reduce(list{}, (acc, element) => acc->Belt.List.add(element)) /* [6,5,3,2] */ -``` -*/ -let reduce: (t<'value, 'id>, 'a, ('a, 'value) => 'a) => 'a - -let everyU: (t<'value, 'id>, (. 'value) => bool) => bool - -/** -Checks if all elements of the set satisfy the predicate. Order unspecified. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.Set.Dict.fromArray([2, 4, 6, 8], ~cmp=IntCmp.cmp) -s0->Belt.Set.Dict.every(isEven) /* true */ -``` -*/ -let every: (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. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.Set.Dict.fromArray([1, 2, 4, 6, 8], ~cmp=IntCmp.cmp) -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> - -/** -Returns the set of all elements that satisfy the predicate. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isEven = x => mod(x, 2) == 0 - -let s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4, 5], ~cmp=IntCmp.cmp) -let s1 = s0->Belt.Set.Dict.keep(isEven) - -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>) - -/** -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. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let isOdd = x => mod(x, 2) != 0 - -let s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4, 5], ~cmp=IntCmp.cmp) -let (s1, s2) = s0->Belt.Set.Dict.partition(isOdd) - -s1->Belt.Set.Dict.toArray /* [1,3,5] */ -s2->Belt.Set.Dict.toArray /* [2,4] */ -``` -*/ -let partition: (t<'value, 'id>, 'value => bool) => (t<'value, 'id>, t<'value, 'id>) - -/** -Returns size of the set. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.size /* 4 */ -``` -*/ -let size: t<'value, 'id> => int - -/** -Returns list of ordered set elements. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.toList /* [1,2,3,5] */ -``` -*/ -let toList: t<'value, 'id> => list<'value> - -/** -Returns array of ordered set elements. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.toArray /* [1,2,3,5] */ -``` -*/ -let toArray: t<'value, 'id> => array<'value> - -/** -Returns minimum value of the collection. `None` if collection is empty. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.empty -let s1 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.minimum /* None */ -s1->Belt.Set.Dict.minimum /* Some(1) */ -``` -*/ -let minimum: t<'value, 'id> => option<'value> - -/** -Returns minimum value of the collection. `undefined` if collection is empty. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.empty -let s1 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.minUndefined /* undefined */ -s1->Belt.Set.Dict.minUndefined /* 1 */ -``` -*/ -let minUndefined: t<'value, 'id> => Js.undefined<'value> - -/** -Returns maximum value of the collection. `None` if collection is empty. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.empty -let s1 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.maximum /* None */ -s1->Belt.Set.Dict.maximum /* Some(5) */ -``` -*/ -let maximum: t<'value, 'id> => option<'value> - -/** -Returns maximum value of the collection. `undefined` if collection is empty. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.empty -let s1 = Belt.Set.Dict.fromArray([3, 2, 1, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.maxUndefined /* undefined */ -s1->Belt.Set.Dict.maxUndefined /* 5 */ -``` -*/ -let maxUndefined: t<'value, 'id> => Js.undefined<'value> - -/** -Returns the reference of the value which is equivalent to value using the comparator -specifiecd by this collection. Returns `None` if element does not exist. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4, 5], ~cmp=IntCmp.cmp) - -s0->Belt.Set.Dict.get(3, ~cmp=IntCmp.cmp) /* Some(3) */ -s0->Belt.Set.Dict.get(20, ~cmp=IntCmp.cmp) /* None */ -``` -*/ -let get: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => option<'value> - -/** -Same as [get](#get) but returns `undefined` when element does not exist. -*/ -let getUndefined: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => Js.undefined<'value> - -/** -Same as [get](#get) but raise when element does not exist. -*/ -let getExn: (t<'value, 'id>, 'value, ~cmp: cmp<'value, 'id>) => 'value - -/** -Returns a tuple `((smaller, larger), present)`, `present` is true when element exist in set. - -## Examples - -```rescript -module IntCmp = Belt.Id.MakeComparable({ - type t = int - let cmp = Pervasives.compare -}) - -let s0 = Belt.Set.Dict.fromArray([1, 2, 3, 4, 5], ~cmp=IntCmp.cmp) - -let ((smaller, larger), present) = s0->Belt.Set.Dict.split(3, ~cmp=IntCmp.cmp) - -present /* true */ -smaller->Belt.Set.Dict.toArray /* [1,2] */ -larger->Belt.Set.Dict.toArray /* [4,5] */ -``` -*/ -let split: ( - t<'value, 'id>, - 'value, - ~cmp: cmp<'value, 'id>, -) => ((t<'value, 'id>, t<'value, 'id>), bool) - -/** -**raise** when invariant is not held -*/ -let checkInvariantInternal: t<_> => unit diff --git a/jscomp/others/belt_SetInt.res b/jscomp/others/belt_SetInt.res deleted file mode 100644 index 8d75c14a3ad..00000000000 --- a/jscomp/others/belt_SetInt.res +++ /dev/null @@ -1,227 +0,0 @@ -module I = Belt_internalSetInt - -module N = Belt_internalAVLset -module A = Belt_Array - -type value = I.value -type t = I.t - -let empty = None -let isEmpty = N.isEmpty -let minimum = N.minimum -let minUndefined = N.minUndefined -let maximum = N.maximum -let maxUndefined = N.maxUndefined - -let forEach = N.forEach -let forEachU = N.forEachU -let reduce = N.reduce -let reduceU = N.reduceU -let every = N.every -let everyU = N.everyU -let some = N.some -let someU = N.someU -let keep = N.keepShared -let keepU = N.keepSharedU -let partition = N.partitionShared -let partitionU = N.partitionSharedU - -let size = N.size -let toList = N.toList -let toArray = N.toArray -let fromSortedArrayUnsafe = N.fromSortedArrayUnsafe -let checkInvariantInternal = N.checkInvariantInternal - -let rec add = (t: t, x: value): t => - switch t { - | None => N.singleton(x) - | Some(nt) => - let v = nt.value - if x == v { - t - } else { - let {N.left: l, right: r} = nt - if x < v { - let ll = add(l, x) - if ll === l { - t - } else { - N.bal(ll, v, r) - } - } else { - let rr = add(r, x) - if rr === r { - t - } else { - N.bal(l, v, rr) - } - } - } - } - -let mergeMany = (h, arr) => { - let len = A.length(arr) - let v = ref(h) - for i in 0 to len - 1 { - let key = A.getUnsafe(arr, i) - v.contents = add(v.contents, key) - } - v.contents -} - -let rec remove = (t: t, x: value): t => - switch t { - | None => t - | Some(n) => - let {N.left: l, value: v, right: r} = n - if x == v { - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (_, Some(rn)) => - let v = ref(rn.value) - let r = N.removeMinAuxWithRef(rn, v) - N.bal(l, v.contents, r) - } - } else if x < v { - let ll = remove(l, x) - if ll === l { - t - } else { - N.bal(ll, v, r) - } - } else { - let rr = remove(r, x) - if rr === r { - t - } else { - N.bal(l, v, rr) - } - } - } - -let removeMany = (h, arr) => { - let len = A.length(arr) - let v = ref(h) - for i in 0 to len - 1 { - let key = A.getUnsafe(arr, i) - v.contents = remove(v.contents, key) - } - v.contents -} - -let fromArray = I.fromArray -let cmp = I.cmp -let eq = I.eq -let get = I.get -let getUndefined = I.getUndefined -let getExn = I.getExn -let subset = I.subset -let has = I.has - -let rec splitAuxNoPivot = (n: N.node<_>, x: value): (t, t) => { - let {N.left: l, value: v, right: r} = n - if x == v { - (l, r) - } else if x < v { - switch l { - | None => (None, Some(n)) - | Some(l) => - let (ll, rl) = splitAuxNoPivot(l, x) - (ll, N.joinShared(rl, v, r)) - } - } else { - switch r { - | None => (Some(n), None) - | Some(r) => - let (lr, rr) = splitAuxNoPivot(r, x) - (N.joinShared(l, v, lr), rr) - } - } -} - -let rec splitAuxPivot = (n: N.node<_>, x: value, pres): (t, t) => { - let {N.left: l, value: v, right: r} = n - if x == v { - pres.contents = true - (l, r) - } else if x < v { - switch l { - | None => (None, Some(n)) - | Some(l) => - let (ll, rl) = splitAuxPivot(l, x, pres) - (ll, N.joinShared(rl, v, r)) - } - } else { - switch r { - | None => (Some(n), None) - | Some(r) => - let (lr, rr) = splitAuxPivot(r, x, pres) - (N.joinShared(l, v, lr), rr) - } - } -} - -let split = (t: t, x: value) => - switch t { - | None => ((None, None), false) - | Some(n) => - let pres = ref(false) - let v = splitAuxPivot(n, x, pres) - (v, pres.contents) - } - -let rec union = (s1: t, s2: t) => - switch (s1, s2) { - | (None, _) => s2 - | (_, None) => s1 - | (Some(n1), Some(n2)) /* (Node(l1, v1, r1, h1), Node(l2, v2, r2, h2)) */ => - let (h1, h2) = (n1.height, n2.height) - if h1 >= h2 { - if h2 == 1 { - add(s1, n2.value) - } else { - let {N.left: l1, value: v1, right: r1} = n1 - let (l2, r2) = splitAuxNoPivot(n2, v1) - N.joinShared(union(l1, l2), v1, union(r1, r2)) - } - } else if h1 == 1 { - add(s2, n1.value) - } else { - let {N.left: l2, value: v2, right: r2} = n2 - let (l1, r1) = splitAuxNoPivot(n1, v2) - N.joinShared(union(l1, l2), v2, union(r1, r2)) - } - } - -let rec intersect = (s1: t, s2: t) => - switch (s1, s2) { - | (None, _) | (_, None) => None - | (Some(n1), Some(n2)) /* (Node(l1, v1, r1, _), t2) */ => - let {N.left: l1, value: v1, right: r1} = n1 - let pres = ref(false) - let (l2, r2) = splitAuxPivot(n2, v1, pres) - let ll = intersect(l1, l2) - let rr = intersect(r1, r2) - if pres.contents { - N.joinShared(ll, v1, rr) - } else { - N.concatShared(ll, rr) - } - } - -let rec diff = (s1: t, s2: t) => - switch (s1, s2) { - | (None, _) | (_, None) => s1 - | (Some(n1), Some(n2)) /* (Node(l1, v1, r1, _), t2) */ => - let {N.left: l1, value: v1, right: r1} = n1 - let pres = ref(false) - let (l2, r2) = splitAuxPivot(n2, v1, pres) - let ll = diff(l1, l2) - let rr = diff(r1, r2) - if pres.contents { - N.concatShared(ll, rr) - } else { - N.joinShared(ll, v1, rr) - } - } diff --git a/jscomp/others/belt_SetInt.resi b/jscomp/others/belt_SetInt.resi deleted file mode 100644 index 2c5a60636d2..00000000000 --- a/jscomp/others/belt_SetInt.resi +++ /dev/null @@ -1,165 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -This module is [`Belt.Set`]() specialized with value type to be a primitive type. -It is more efficient in general, the API is the same with [`Belt_Set`]() except its value type is fixed, -and identity is not needed(using the built-in one) - -**See** [`Belt.Set`]() -*/ - -/** The type of the set elements. */ -type value = int - -/** The type of sets. */ -type t - -let empty: t - -let fromArray: array => t - -let fromSortedArrayUnsafe: array => t - -let isEmpty: t => bool - -let has: (t, value) => bool - -/** -`add(s, x)` if `x` was already in `s`, `s` is returned unchanged. -*/ -let add: (t, value) => t - -let mergeMany: (t, array) => t - -/** -`remove(m, x)` if `x` was not in `m`, `m` is returned reference unchanged. -*/ -let remove: (t, value) => t - -let removeMany: (t, array) => t - -let union: (t, t) => t - -let intersect: (t, t) => t - -let diff: (t, t) => t - -/** -`subset(s1, s2)` tests whether the set `s1` is a subset of the set `s2`. -*/ -let subset: (t, t) => bool - -/** -Total ordering between sets. Can be used as the ordering function for doing sets -of sets. -*/ -let cmp: (t, t) => int - -/** -`eq(s1, s2)` tests whether the sets `s1` and `s2` are equal, that is, contain -equal elements. -*/ -let eq: (t, t) => bool - -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 - -/** Iterate in increasing order. */ -let reduce: (t, 'a, ('a, value) => 'a) => 'a - -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 - -/** -`some(p, s)` checks if at least one element of the set satisfies the predicate -`p`. Oder unspecified. -*/ -let some: (t, value => bool) => bool - -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) - -/** -`partition(p, s)` returns a pair of sets `(s1, s2)`, where `s1` is the set of -all the elements of `s` that satisfy the predicate `p`, and `s2` is the set of -all the elements of `s` that do not satisfy `p`. -*/ -let partition: (t, value => bool) => (t, t) - -let size: t => int - -/** In increasing order */ -let toList: t => list - -let toArray: t => array - -let minimum: t => option - -let minUndefined: t => Js.undefined - -let maximum: t => option - -let maxUndefined: t => Js.undefined - -let get: (t, value) => option - -let getUndefined: (t, value) => Js.undefined - -let getExn: (t, value) => value - -/** -`split(x, s)` returns a triple `(l, present, r)`, where -`l` is the set of elements of `s` that are -strictly less than `x`; -`r` is the set of elements of `s` that are -strictly greater than `x`; -`present` is `false` if `s` contains no element equal to `x`, -or `true` if `s` contains an element equal to `x`. -*/ -let split: (t, value) => ((t, t), bool) - -/** -**raise** when invariant is not held -*/ -let checkInvariantInternal: t => unit diff --git a/jscomp/others/belt_SetString.res b/jscomp/others/belt_SetString.res deleted file mode 100644 index 972aa539cba..00000000000 --- a/jscomp/others/belt_SetString.res +++ /dev/null @@ -1,227 +0,0 @@ -module I = Belt_internalSetString - -module N = Belt_internalAVLset -module A = Belt_Array - -type value = I.value -type t = I.t - -let empty = None -let isEmpty = N.isEmpty -let minimum = N.minimum -let minUndefined = N.minUndefined -let maximum = N.maximum -let maxUndefined = N.maxUndefined - -let forEach = N.forEach -let forEachU = N.forEachU -let reduce = N.reduce -let reduceU = N.reduceU -let every = N.every -let everyU = N.everyU -let some = N.some -let someU = N.someU -let keep = N.keepShared -let keepU = N.keepSharedU -let partition = N.partitionShared -let partitionU = N.partitionSharedU - -let size = N.size -let toList = N.toList -let toArray = N.toArray -let fromSortedArrayUnsafe = N.fromSortedArrayUnsafe -let checkInvariantInternal = N.checkInvariantInternal - -let rec add = (t: t, x: value): t => - switch t { - | None => N.singleton(x) - | Some(nt) => - let v = nt.value - if x == v { - t - } else { - let {N.left: l, right: r} = nt - if x < v { - let ll = add(l, x) - if ll === l { - t - } else { - N.bal(ll, v, r) - } - } else { - let rr = add(r, x) - if rr === r { - t - } else { - N.bal(l, v, rr) - } - } - } - } - -let mergeMany = (h, arr) => { - let len = A.length(arr) - let v = ref(h) - for i in 0 to len - 1 { - let key = A.getUnsafe(arr, i) - v.contents = add(v.contents, key) - } - v.contents -} - -let rec remove = (t: t, x: value): t => - switch t { - | None => t - | Some(n) => - let {N.left: l, value: v, right: r} = n - if x == v { - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (_, Some(rn)) => - let v = ref(rn.value) - let r = N.removeMinAuxWithRef(rn, v) - N.bal(l, v.contents, r) - } - } else if x < v { - let ll = remove(l, x) - if ll === l { - t - } else { - N.bal(ll, v, r) - } - } else { - let rr = remove(r, x) - if rr === r { - t - } else { - N.bal(l, v, rr) - } - } - } - -let removeMany = (h, arr) => { - let len = A.length(arr) - let v = ref(h) - for i in 0 to len - 1 { - let key = A.getUnsafe(arr, i) - v.contents = remove(v.contents, key) - } - v.contents -} - -let fromArray = I.fromArray -let cmp = I.cmp -let eq = I.eq -let get = I.get -let getUndefined = I.getUndefined -let getExn = I.getExn -let subset = I.subset -let has = I.has - -let rec splitAuxNoPivot = (n: N.node<_>, x: value): (t, t) => { - let {N.left: l, value: v, right: r} = n - if x == v { - (l, r) - } else if x < v { - switch l { - | None => (None, Some(n)) - | Some(l) => - let (ll, rl) = splitAuxNoPivot(l, x) - (ll, N.joinShared(rl, v, r)) - } - } else { - switch r { - | None => (Some(n), None) - | Some(r) => - let (lr, rr) = splitAuxNoPivot(r, x) - (N.joinShared(l, v, lr), rr) - } - } -} - -let rec splitAuxPivot = (n: N.node<_>, x: value, pres): (t, t) => { - let {N.left: l, value: v, right: r} = n - if x == v { - pres.contents = true - (l, r) - } else if x < v { - switch l { - | None => (None, Some(n)) - | Some(l) => - let (ll, rl) = splitAuxPivot(l, x, pres) - (ll, N.joinShared(rl, v, r)) - } - } else { - switch r { - | None => (Some(n), None) - | Some(r) => - let (lr, rr) = splitAuxPivot(r, x, pres) - (N.joinShared(l, v, lr), rr) - } - } -} - -let split = (t: t, x: value) => - switch t { - | None => ((None, None), false) - | Some(n) => - let pres = ref(false) - let v = splitAuxPivot(n, x, pres) - (v, pres.contents) - } - -let rec union = (s1: t, s2: t) => - switch (s1, s2) { - | (None, _) => s2 - | (_, None) => s1 - | (Some(n1), Some(n2)) /* (Node(l1, v1, r1, h1), Node(l2, v2, r2, h2)) */ => - let (h1, h2) = (n1.height, n2.height) - if h1 >= h2 { - if h2 == 1 { - add(s1, n2.value) - } else { - let {N.left: l1, value: v1, right: r1} = n1 - let (l2, r2) = splitAuxNoPivot(n2, v1) - N.joinShared(union(l1, l2), v1, union(r1, r2)) - } - } else if h1 == 1 { - add(s2, n1.value) - } else { - let {N.left: l2, value: v2, right: r2} = n2 - let (l1, r1) = splitAuxNoPivot(n1, v2) - N.joinShared(union(l1, l2), v2, union(r1, r2)) - } - } - -let rec intersect = (s1: t, s2: t) => - switch (s1, s2) { - | (None, _) | (_, None) => None - | (Some(n1), Some(n2)) /* (Node(l1, v1, r1, _), t2) */ => - let {N.left: l1, value: v1, right: r1} = n1 - let pres = ref(false) - let (l2, r2) = splitAuxPivot(n2, v1, pres) - let ll = intersect(l1, l2) - let rr = intersect(r1, r2) - if pres.contents { - N.joinShared(ll, v1, rr) - } else { - N.concatShared(ll, rr) - } - } - -let rec diff = (s1: t, s2: t) => - switch (s1, s2) { - | (None, _) | (_, None) => s1 - | (Some(n1), Some(n2)) /* (Node(l1, v1, r1, _), t2) */ => - let {N.left: l1, value: v1, right: r1} = n1 - let pres = ref(false) - let (l2, r2) = splitAuxPivot(n2, v1, pres) - let ll = diff(l1, l2) - let rr = diff(r1, r2) - if pres.contents { - N.concatShared(ll, rr) - } else { - N.joinShared(ll, v1, rr) - } - } diff --git a/jscomp/others/belt_SetString.resi b/jscomp/others/belt_SetString.resi deleted file mode 100644 index c8d1843a578..00000000000 --- a/jscomp/others/belt_SetString.resi +++ /dev/null @@ -1,166 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -This module is [`Belt.Set`]() specialized with value type to be a primitive type. -It is more efficient in general, the API is the same with [`Belt_Set`]() except its value type is fixed, -and identity is not needed(using the built-in one) - -**See** [`Belt.Set`]() -*/ - -/** The type of the set elements. */ -type value = string - -/** The type of sets. */ -type t - -let empty: t - -let fromArray: array => t - -let fromSortedArrayUnsafe: array => t - -let isEmpty: t => bool - -let has: (t, value) => bool - -/** -`add(s, x)` If `x` was already in `s`, `s` is returned unchanged. -*/ -let add: (t, value) => t - -let mergeMany: (t, array) => t - -/** -`remove(m, x)` If `x` was not in `m`, `m` is returned reference unchanged. -*/ -let remove: (t, value) => t - -let removeMany: (t, array) => t - -let union: (t, t) => t - -let intersect: (t, t) => t - -let diff: (t, t) => t - -/** -`subset(s1, s2)` tests whether the set `s1` is a subset of the set `s2`. -*/ -let subset: (t, t) => bool - -/** -Total ordering between sets. Can be used as the ordering function for doing sets -of sets. -*/ -let cmp: (t, t) => int - -/** -`eq(s1, s2)` tests whether the sets `s1` and `s2` are equal, that is, contain -equal elements. -*/ -let eq: (t, t) => bool - -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 - -/** Iterate in increasing order. */ -let reduce: (t, 'a, ('a, value) => 'a) => 'a - -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 - -/** -`some(p, s)` checks if at least one element of the set satisfies the predicate -`p`. Oder unspecified. -*/ -let some: (t, value => bool) => bool - -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) - -/** -`partition(p, s)` returns a pair of sets `(s1, s2)`, where -`s1` is the set of all the elements of `s` that satisfy the -predicate `p`, and `s2` is the set of all the elements of -`s` that do not satisfy `p`. -*/ -let partition: (t, value => bool) => (t, t) - -let size: t => int - -/** In increasing order */ -let toList: t => list - -let toArray: t => array - -let minimum: t => option - -let minUndefined: t => Js.undefined - -let maximum: t => option - -let maxUndefined: t => Js.undefined - -let get: (t, value) => option - -let getUndefined: (t, value) => Js.undefined - -let getExn: (t, value) => value - -/** -`split(x, s)` returns a triple `(l, present, r)`, where -`l` is the set of elements of `s` that are -strictly less than `x`; -`r` is the set of elements of `s` that are -strictly greater than `x`; -`present` is `false` if `s` contains no element equal to `x`, -or `true` if `s` contains an element equal to `x`. -*/ -let split: (t, value) => ((t, t), bool) - -/** -**raise** when invariant is not held -*/ -let checkInvariantInternal: t => unit diff --git a/jscomp/others/belt_SortArray.res b/jscomp/others/belt_SortArray.res deleted file mode 100644 index 462b468bcd5..00000000000 --- a/jscomp/others/belt_SortArray.res +++ /dev/null @@ -1,354 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -module Int = Belt_SortArrayInt - -module String = Belt_SortArrayString - -module A = Belt_Array - -let rec sortedLengthAuxMore = (xs, prec, acc, len, lt) => - if acc >= len { - acc - } else { - let v = A.getUnsafe(xs, acc) - if lt(. v, prec) { - sortedLengthAuxMore(xs, v, acc + 1, len, lt) - } else { - acc - } - } - -let rec sortedLengthAuxLess = (xs, prec, acc, len, lt) => - if acc >= len { - acc - } else { - let v = A.getUnsafe(xs, acc) - if lt(. prec, v) { - sortedLengthAuxLess(xs, v, acc + 1, len, lt) - } else { - acc - } - } - -let strictlySortedLengthU = (xs, lt) => { - let len = A.length(xs) - switch len { - | 0 | 1 => len - | _ => - let (x0, x1) = (A.getUnsafe(xs, 0), A.getUnsafe(xs, 1)) - - /* let c = cmp x0 x1 [@bs] in */ - if lt(. x0, x1) { - sortedLengthAuxLess(xs, x1, 2, len, lt) - } else if lt(. x1, x0) { - -sortedLengthAuxMore(xs, x1, 2, len, lt) - } else { - 1 - } - } -} - -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 { - isSortedAux(a, i + 1, cmp, last_bound) - } else { - false - } - -let isSortedU = (a, cmp) => { - let len = A.length(a) - if len == 0 { - true - } else { - isSortedAux(a, 0, cmp, len - 1) - } -} - -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 { - A.setUnsafe(dst, d, s1) - let i1 = i1 + 1 - if i1 < src1r { - loop(i1, A.getUnsafe(src, i1), i2, s2, d + 1) - } else { - A.blitUnsafe(~src=src2, ~srcOffset=i2, ~dst, ~dstOffset=d + 1, ~len=src2r - i2) - } - } else { - A.setUnsafe(dst, d, s2) - let i2 = i2 + 1 - if i2 < src2r { - loop(i1, s1, i2, A.getUnsafe(src2, i2), d + 1) - } else { - A.blitUnsafe(~src, ~srcOffset=i1, ~dst, ~dstOffset=d + 1, ~len=src1r - i1) - } - } - - loop(src1ofs, A.getUnsafe(src, src1ofs), src2ofs, A.getUnsafe(src2, src2ofs), dstofs) -} - -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) - if c < 0 { - /* `s1` is larger than all elements in `d` */ - A.setUnsafe(dst, d, s1) - let i1 = i1 + 1 - let d = d + 1 - if i1 < src1r { - loop(i1, A.getUnsafe(src, i1), i2, s2, d) - } else { - A.blitUnsafe(~src=src2, ~srcOffset=i2, ~dst, ~dstOffset=d, ~len=src2r - i2) - d + src2r - i2 - } - } else if c == 0 { - A.setUnsafe(dst, d, s1) - let i1 = i1 + 1 - let i2 = i2 + 1 - let d = d + 1 - if i1 < src1r && i2 < src2r { - loop(i1, A.getUnsafe(src, i1), i2, A.getUnsafe(src2, i2), d) - } else if i1 == src1r { - A.blitUnsafe(~src=src2, ~srcOffset=i2, ~dst, ~dstOffset=d, ~len=src2r - i2) - d + src2r - i2 - } else { - A.blitUnsafe(~src, ~srcOffset=i1, ~dst, ~dstOffset=d, ~len=src1r - i1) - d + src1r - i1 - } - } else { - A.setUnsafe(dst, d, s2) - let i2 = i2 + 1 - let d = d + 1 - if i2 < src2r { - loop(i1, s1, i2, A.getUnsafe(src2, i2), d) - } else { - A.blitUnsafe(~src, ~srcOffset=i1, ~dst, ~dstOffset=d, ~len=src1r - i1) - d + src1r - i1 - } - } - } - - loop(src1ofs, A.getUnsafe(src, src1ofs), src2ofs, A.getUnsafe(src2, src2ofs), dstofs) -} - -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)) - -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) - if c < 0 { - /* A.setUnsafe dst d s1; */ - let i1 = i1 + 1 - if i1 < src1r { - loop(i1, A.getUnsafe(src, i1), i2, s2, d) - } else { - d - } - } else if c == 0 { - A.setUnsafe(dst, d, s1) - let i1 = i1 + 1 - let i2 = i2 + 1 - let d = d + 1 - if i1 < src1r && i2 < src2r { - loop(i1, A.getUnsafe(src, i1), i2, A.getUnsafe(src2, i2), d) - } else { - d - } - } else { - /* A.setUnsafe dst d s2; */ - let i2 = i2 + 1 - if i2 < src2r { - loop(i1, s1, i2, A.getUnsafe(src2, i2), d) - } else { - d - } - } - } - - loop(src1ofs, A.getUnsafe(src, src1ofs), src2ofs, A.getUnsafe(src2, src2ofs), dstofs) -} - -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)) - -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) - if c < 0 { - A.setUnsafe(dst, d, s1) - let d = d + 1 - let i1 = i1 + 1 - if i1 < src1r { - loop(i1, A.getUnsafe(src, i1), i2, s2, d) - } else { - d - } - } else if c == 0 { - let i1 = i1 + 1 - let i2 = i2 + 1 - if i1 < src1r && i2 < src2r { - loop(i1, A.getUnsafe(src, i1), i2, A.getUnsafe(src2, i2), d) - } else if i1 == src1r { - d - } else { - A.blitUnsafe(~src, ~srcOffset=i1, ~dst, ~dstOffset=d, ~len=src1r - i1) - d + src1r - i1 - } - } else { - let i2 = i2 + 1 - if i2 < src2r { - loop(i1, s1, i2, A.getUnsafe(src2, i2), d) - } else { - A.blitUnsafe(~src, ~srcOffset=i1, ~dst, ~dstOffset=d, ~len=src1r - i1) - d + src1r - i1 - } - } - } - - loop(src1ofs, A.getUnsafe(src, src1ofs), src2ofs, A.getUnsafe(src2, src2ofs), dstofs) -} - -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)) - -/* `<=` 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 { - A.setUnsafe(dst, j.contents + 1, A.getUnsafe(dst, j.contents)) - j.contents = j.contents - 1 - } - A.setUnsafe(dst, j.contents + 1, e) - } - -let rec sortTo = (src, srcofs, dst, dstofs, len, cmp) => - if len <= cutoff { - insertionSort(src, srcofs, dst, dstofs, len, cmp) - } else { - let l1 = len / 2 - let l2 = len - l1 - sortTo(src, srcofs + l1, dst, dstofs + l1, l2, cmp) - sortTo(src, srcofs, src, srcofs + l2, l1, cmp) - merge(src, srcofs + l2, l1, dst, dstofs + l1, l2, dst, dstofs, cmp) - } - -let stableSortInPlaceByU = (a, cmp) => { - let l = A.length(a) - if l <= cutoff { - insertionSort(a, 0, a, 0, l, cmp) - } else { - let l1 = l / 2 - let l2 = l - l1 - let t = Belt_Array.makeUninitializedUnsafe(l2) - sortTo(a, l1, t, 0, l2, cmp) - sortTo(a, 0, a, l2, l1, cmp) - merge(a, l2, l1, t, 0, l2, a, 0, cmp) - } -} - -let stableSortInPlaceBy = (a, cmp) => stableSortInPlaceByU(a, (. x, y) => cmp(x, y)) - -let stableSortByU = (a, cmp) => { - let b = A.copy(a) - stableSortInPlaceByU(b, cmp) - b -} - -let stableSortBy = (a, cmp) => stableSortByU(a, (. x, y) => cmp(x, y)) -/* - `binarySearchAux arr lo hi key cmp` - range [lo, hi] - input (lo <= hi) - `arr[lo] <= key <= arr[hi]` */ -let rec binarySearchAux = (arr, lo, hi, key, cmp) => { - let mid = (lo + hi) / 2 - let midVal = A.getUnsafe(arr, mid) - 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 { - lo - } else { - -(hi + 1) - } - } else { - binarySearchAux(arr, lo, mid, key, cmp) - } - } /* a[lo] =< a[mid] < key <= a[hi] */ - else if lo == mid { - if cmp(. A.getUnsafe(arr, hi), key) == 0 { - hi - } else { - -(hi + 1) - } - } else { - binarySearchAux(arr, mid, hi, key, cmp) - } -} - -let binarySearchByU = (sorted, key, cmp): int => { - let len = A.length(sorted) - if len == 0 { - -1 - } else { - let lo = A.getUnsafe(sorted, 0) - let c = cmp(. key, lo) - if c < 0 { - -1 - } else { - let hi = A.getUnsafe(sorted, len - 1) - let c2 = cmp(. key, hi) - if c2 > 0 { - -(len + 1) - } else { - binarySearchAux(sorted, 0, len - 1, key, cmp) - } - } - } -} - -let binarySearchBy = (sorted, key, cmp) => binarySearchByU(sorted, key, (. x, y) => cmp(x, y)) diff --git a/jscomp/others/belt_SortArray.resi b/jscomp/others/belt_SortArray.resi deleted file mode 100644 index ced18fc3352..00000000000 --- a/jscomp/others/belt_SortArray.resi +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -A module for Array sort relevant utiliites -*/ - -/** -Specalized when key type is `int`, more efficient than the generic type -*/ -module Int = Belt_SortArrayInt - -/** -Specalized when key type is `string`, more efficient than the generic type -*/ -module String = Belt_SortArrayString - -let strictlySortedLengthU: (array<'a>, (. 'a, 'a) => bool) => int - -/** -`strictlySortedLenght(xs, cmp);` return `+n` means increasing order `-n` means negative order - -## Examples - -```rescript -Belt.SortArray.strictlySortedLength([1, 2, 3, 4, 3], (x, y) => x < y) == 4 - -Belt.SortArray.strictlySortedLength([], (x, y) => x < y) == 0 - -Belt.SortArray.strictlySortedLength([1], (x, y) => x < y) == 1 - -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 -/** -`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 stableSortInPlaceBy: (array<'a>, ('a, 'a) => int) => unit - -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 -be preserved -*/ -let stableSortBy: (array<'a>, ('a, 'a) => int) => array<'a> - -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 -negative number returned is the bitwise complement of the index of the first -element that is larger than value. - -If value is not found and value is greater -than all elements in array, the negative number returned is the bitwise -complement of (the index of the last element plus 1)for example, if `key` is -smaller than all elements return `-1` since `lnot(-1) == 0` if `key` is larger -than all elements return `lnot(-1) == 0` since `lnot(- (len + 1)) == len` - -## Examples - -```rescript -Belt.SortArray.binarySearchBy([1, 2, 3, 4, 33, 35, 36], 33, Pervasives.compare) == 4 - -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 -/** -`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` -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 -/** -`union src src1ofs src1len src2 src2ofs src2len dst dstofs cmp` - -**return** the `offset` in the output array -*/ -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 diff: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, ('a, 'a) => int) => int diff --git a/jscomp/others/belt_SortArrayInt.res b/jscomp/others/belt_SortArrayInt.res deleted file mode 100644 index 40215dfecfb..00000000000 --- a/jscomp/others/belt_SortArrayInt.res +++ /dev/null @@ -1,304 +0,0 @@ -type element = int - -module A = Belt_Array - -let rec sortedLengthAuxMore = (xs: array, prec, acc, len) => - if acc >= len { - acc - } else { - let v = A.getUnsafe(xs, acc) - if prec > v { - sortedLengthAuxMore(xs, v, acc + 1, len) - } else { - acc - } - } - -let rec sortedLengthAuxLess = (xs: array, prec, acc, len) => - if acc >= len { - acc - } else { - let v = A.getUnsafe(xs, acc) - if prec < v { - sortedLengthAuxLess(xs, v, acc + 1, len) - } else { - acc - } - } - -let strictlySortedLength = (xs: array) => { - let len = A.length(xs) - switch len { - | 0 | 1 => len - | _ => - let (x0, x1) = (A.getUnsafe(xs, 0), A.getUnsafe(xs, 1)) - - /* let c = cmp x0 x1 [@bs] in */ - if x0 < x1 { - sortedLengthAuxLess(xs, x1, 2, len) - } else if x0 > x1 { - -sortedLengthAuxMore(xs, x1, 2, len) - } else { - 1 - } - } -} - -let rec isSortedAux = (a: array, i, last_bound) => - /* when `i = len - 1`, it reaches the last element */ - if i == last_bound { - true - } else if A.getUnsafe(a, i) <= A.getUnsafe(a, i + 1) { - isSortedAux(a, i + 1, last_bound) - } else { - false - } - -let isSorted = a => { - let len = A.length(a) - if len == 0 { - true - } else { - isSortedAux(a, 0, len - 1) - } -} - -let cutoff = 5 - -let merge = (src: array, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { - let src1r = src1ofs + src1len and src2r = src2ofs + src2len - let rec loop = (i1, s1, i2, s2, d) => - if s1 <= s2 { - A.setUnsafe(dst, d, s1) - let i1 = i1 + 1 - if i1 < src1r { - loop(i1, A.getUnsafe(src, i1), i2, s2, d + 1) - } else { - A.blitUnsafe(~src=src2, ~srcOffset=i2, ~dst, ~dstOffset=d + 1, ~len=src2r - i2) - } - } else { - A.setUnsafe(dst, d, s2) - let i2 = i2 + 1 - if i2 < src2r { - loop(i1, s1, i2, A.getUnsafe(src2, i2), d + 1) - } else { - A.blitUnsafe(~src, ~srcOffset=i1, ~dst, ~dstOffset=d + 1, ~len=src1r - i1) - } - } - - loop(src1ofs, A.getUnsafe(src, src1ofs), src2ofs, A.getUnsafe(src2, src2ofs), dstofs) -} - -let union = (src: array, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { - let src1r = src1ofs + src1len - let src2r = src2ofs + src2len - let rec loop = (i1, s1, i2, s2, d) => - /* let c = cmp s1 s2 [@bs] in */ - if s1 < s2 { - /* `s1` is larger than all elements in `d` */ - A.setUnsafe(dst, d, s1) - let i1 = i1 + 1 - let d = d + 1 - if i1 < src1r { - loop(i1, A.getUnsafe(src, i1), i2, s2, d) - } else { - A.blitUnsafe(~src=src2, ~srcOffset=i2, ~dst, ~dstOffset=d, ~len=src2r - i2) - d + src2r - i2 - } - } else if s1 == s2 { - A.setUnsafe(dst, d, s1) - let i1 = i1 + 1 - let i2 = i2 + 1 - let d = d + 1 - if i1 < src1r && i2 < src2r { - loop(i1, A.getUnsafe(src, i1), i2, A.getUnsafe(src2, i2), d) - } else if i1 == src1r { - A.blitUnsafe(~src=src2, ~srcOffset=i2, ~dst, ~dstOffset=d, ~len=src2r - i2) - d + src2r - i2 - } else { - A.blitUnsafe(~src, ~srcOffset=i1, ~dst, ~dstOffset=d, ~len=src1r - i1) - d + src1r - i1 - } - } else { - A.setUnsafe(dst, d, s2) - let i2 = i2 + 1 - let d = d + 1 - if i2 < src2r { - loop(i1, s1, i2, A.getUnsafe(src2, i2), d) - } else { - A.blitUnsafe(~src, ~srcOffset=i1, ~dst, ~dstOffset=d, ~len=src1r - i1) - d + src1r - i1 - } - } - - loop(src1ofs, A.getUnsafe(src, src1ofs), src2ofs, A.getUnsafe(src2, src2ofs), dstofs) -} - -let intersect = (src: array, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { - let src1r = src1ofs + src1len - let src2r = src2ofs + src2len - let rec loop = (i1, s1, i2, s2, d) => - /* let c = cmp s1 s2 [@bs] in */ - if s1 < s2 { - /* A.setUnsafe dst d s1; */ - let i1 = i1 + 1 - if i1 < src1r { - loop(i1, A.getUnsafe(src, i1), i2, s2, d) - } else { - d - } - } else if s1 == s2 { - A.setUnsafe(dst, d, s1) - let i1 = i1 + 1 - let i2 = i2 + 1 - let d = d + 1 - if i1 < src1r && i2 < src2r { - loop(i1, A.getUnsafe(src, i1), i2, A.getUnsafe(src2, i2), d) - } else { - d - } - } else { - /* A.setUnsafe dst d s2; */ - let i2 = i2 + 1 - if i2 < src2r { - loop(i1, s1, i2, A.getUnsafe(src2, i2), d) - } else { - d - } - } - - loop(src1ofs, A.getUnsafe(src, src1ofs), src2ofs, A.getUnsafe(src2, src2ofs), dstofs) -} - -let diff = (src: array, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { - let src1r = src1ofs + src1len - let src2r = src2ofs + src2len - let rec loop = (i1, s1, i2, s2, d) => - /* let c = cmp s1 s2 [@bs] in */ - if s1 < s2 { - A.setUnsafe(dst, d, s1) - let d = d + 1 - let i1 = i1 + 1 - if i1 < src1r { - loop(i1, A.getUnsafe(src, i1), i2, s2, d) - } else { - d - } - } else if s1 == s2 { - let i1 = i1 + 1 - let i2 = i2 + 1 - if i1 < src1r && i2 < src2r { - loop(i1, A.getUnsafe(src, i1), i2, A.getUnsafe(src2, i2), d) - } else if i1 == src1r { - d - } else { - A.blitUnsafe(~src, ~srcOffset=i1, ~dst, ~dstOffset=d, ~len=src1r - i1) - d + src1r - i1 - } - } else { - let i2 = i2 + 1 - if i2 < src2r { - loop(i1, s1, i2, A.getUnsafe(src2, i2), d) - } else { - A.blitUnsafe(~src, ~srcOffset=i1, ~dst, ~dstOffset=d, ~len=src1r - i1) - d + src1r - i1 - } - } - - loop(src1ofs, A.getUnsafe(src, src1ofs), src2ofs, A.getUnsafe(src2, src2ofs), dstofs) -} - -let insertionSort = (src: array, srcofs, dst, dstofs, len) => - for i in 0 to len - 1 { - let e = A.getUnsafe(src, srcofs + i) - let j = ref(dstofs + i - 1) - while j.contents >= dstofs && A.getUnsafe(dst, j.contents) > e { - A.setUnsafe(dst, j.contents + 1, A.getUnsafe(dst, j.contents)) - j.contents = j.contents - 1 - } - A.setUnsafe(dst, j.contents + 1, e) - } - -let rec sortTo = (src: array, srcofs, dst, dstofs, len) => - if len <= cutoff { - insertionSort(src, srcofs, dst, dstofs, len) - } else { - let l1 = len / 2 - let l2 = len - l1 - sortTo(src, srcofs + l1, dst, dstofs + l1, l2) - sortTo(src, srcofs, src, srcofs + l2, l1) - merge(src, srcofs + l2, l1, dst, dstofs + l1, l2, dst, dstofs) - } - -let stableSortInPlace = (a: array) => { - let l = A.length(a) - if l <= cutoff { - insertionSort(a, 0, a, 0, l) - } else { - let l1 = l / 2 - let l2 = l - l1 - let t = Belt_Array.makeUninitializedUnsafe(l2) - sortTo(a, l1, t, 0, l2) - sortTo(a, 0, a, l2, l1) - merge(a, l2, l1, t, 0, l2, a, 0) - } -} - -let stableSort = a => { - let b = A.copy(a) - stableSortInPlace(b) - b -} - -let rec binarySearchAux = (arr: array, lo, hi, key) => { - let mid = (lo + hi) / 2 - let midVal = A.getUnsafe(arr, mid) - - /* let c = cmp key midVal [@bs] in */ - if key == midVal { - mid - } else if key < midVal { - /* a[lo] =< key < a[mid] <= a[hi] */ - if hi == mid { - if A.getUnsafe(arr, lo) == key { - lo - } else { - -(hi + 1) - } - } else { - binarySearchAux(arr, lo, mid, key) - } - } /* a[lo] =< a[mid] < key <= a[hi] */ - else if lo == mid { - if A.getUnsafe(arr, hi) == key { - hi - } else { - -(hi + 1) - } - } else { - binarySearchAux(arr, mid, hi, key) - } -} - -let binarySearch = (sorted: array, key): int => { - let len = A.length(sorted) - if len == 0 { - -1 - } else { - let lo = A.getUnsafe(sorted, 0) - - /* let c = cmp key lo [@bs] in */ - if key < lo { - -1 - } else { - let hi = A.getUnsafe(sorted, len - 1) - - /* let c2 = cmp key hi [@bs]in */ - if key > hi { - -(len + 1) - } else { - binarySearchAux(sorted, 0, len - 1, key) - } - } - } -} diff --git a/jscomp/others/belt_SortArrayInt.resi b/jscomp/others/belt_SortArrayInt.resi deleted file mode 100644 index ce1c48c6f11..00000000000 --- a/jscomp/others/belt_SortArrayInt.resi +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -This is a specialized module for [`Belt_SortArray`](), the docs in that module also -applies here, except the comparator is fixed and inlined -*/ - -type element = int - -/** -The same as [`Belt_SortArray.strictlySortedLength`]() except the comparator is fixed - -**return** `+n` means increasing order `-n` means negative order -*/ -let strictlySortedLength: array => int - -/** `sorted(xs)` return true if `xs` is in non strict increasing order */ -let isSorted: array => bool - -/** -The same as [`Belt_SortArray.stableSortInPlaceBy`]() except the comparator is fixed -*/ -let stableSortInPlace: array => unit - -/** -The same as [`Belt_SortArray.stableSortBy`]() except the comparator is fixed -*/ -let stableSort: array => array - -/** -If value is not found and value is less than one or more elements in array, -the negative number returned is the bitwise complement of the index of the first element -that is larger than value. - -If value is not found and value is greater than all elements in array, -the negative number returned is the bitwise complement of -(the index of the last element plus 1) - -for example, if `key` is smaller than all elements return `-1` since `lnot (-1) = 0` -if `key` is larger than all elements return `- (len + 1)` since `lnot (-(len+1)) = len` -*/ -let binarySearch: (array, element) => 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` also assume that `dst` is large enough to store all elements -*/ -let union: (array, int, int, array, int, int, array, int) => int - -let intersect: (array, int, int, array, int, int, array, int) => int - -let diff: (array, int, int, array, int, int, array, int) => int diff --git a/jscomp/others/belt_SortArrayString.res b/jscomp/others/belt_SortArrayString.res deleted file mode 100644 index 08f55e1d02c..00000000000 --- a/jscomp/others/belt_SortArrayString.res +++ /dev/null @@ -1,304 +0,0 @@ -type element = string - -module A = Belt_Array - -let rec sortedLengthAuxMore = (xs: array, prec, acc, len) => - if acc >= len { - acc - } else { - let v = A.getUnsafe(xs, acc) - if prec > v { - sortedLengthAuxMore(xs, v, acc + 1, len) - } else { - acc - } - } - -let rec sortedLengthAuxLess = (xs: array, prec, acc, len) => - if acc >= len { - acc - } else { - let v = A.getUnsafe(xs, acc) - if prec < v { - sortedLengthAuxLess(xs, v, acc + 1, len) - } else { - acc - } - } - -let strictlySortedLength = (xs: array) => { - let len = A.length(xs) - switch len { - | 0 | 1 => len - | _ => - let (x0, x1) = (A.getUnsafe(xs, 0), A.getUnsafe(xs, 1)) - - /* let c = cmp x0 x1 [@bs] in */ - if x0 < x1 { - sortedLengthAuxLess(xs, x1, 2, len) - } else if x0 > x1 { - -sortedLengthAuxMore(xs, x1, 2, len) - } else { - 1 - } - } -} - -let rec isSortedAux = (a: array, i, last_bound) => - /* when `i = len - 1`, it reaches the last element */ - if i == last_bound { - true - } else if A.getUnsafe(a, i) <= A.getUnsafe(a, i + 1) { - isSortedAux(a, i + 1, last_bound) - } else { - false - } - -let isSorted = a => { - let len = A.length(a) - if len == 0 { - true - } else { - isSortedAux(a, 0, len - 1) - } -} - -let cutoff = 5 - -let merge = (src: array, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { - let src1r = src1ofs + src1len and src2r = src2ofs + src2len - let rec loop = (i1, s1, i2, s2, d) => - if s1 <= s2 { - A.setUnsafe(dst, d, s1) - let i1 = i1 + 1 - if i1 < src1r { - loop(i1, A.getUnsafe(src, i1), i2, s2, d + 1) - } else { - A.blitUnsafe(~src=src2, ~srcOffset=i2, ~dst, ~dstOffset=d + 1, ~len=src2r - i2) - } - } else { - A.setUnsafe(dst, d, s2) - let i2 = i2 + 1 - if i2 < src2r { - loop(i1, s1, i2, A.getUnsafe(src2, i2), d + 1) - } else { - A.blitUnsafe(~src, ~srcOffset=i1, ~dst, ~dstOffset=d + 1, ~len=src1r - i1) - } - } - - loop(src1ofs, A.getUnsafe(src, src1ofs), src2ofs, A.getUnsafe(src2, src2ofs), dstofs) -} - -let union = (src: array, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { - let src1r = src1ofs + src1len - let src2r = src2ofs + src2len - let rec loop = (i1, s1, i2, s2, d) => - /* let c = cmp s1 s2 [@bs] in */ - if s1 < s2 { - /* `s1` is larger than all elements in `d` */ - A.setUnsafe(dst, d, s1) - let i1 = i1 + 1 - let d = d + 1 - if i1 < src1r { - loop(i1, A.getUnsafe(src, i1), i2, s2, d) - } else { - A.blitUnsafe(~src=src2, ~srcOffset=i2, ~dst, ~dstOffset=d, ~len=src2r - i2) - d + src2r - i2 - } - } else if s1 == s2 { - A.setUnsafe(dst, d, s1) - let i1 = i1 + 1 - let i2 = i2 + 1 - let d = d + 1 - if i1 < src1r && i2 < src2r { - loop(i1, A.getUnsafe(src, i1), i2, A.getUnsafe(src2, i2), d) - } else if i1 == src1r { - A.blitUnsafe(~src=src2, ~srcOffset=i2, ~dst, ~dstOffset=d, ~len=src2r - i2) - d + src2r - i2 - } else { - A.blitUnsafe(~src, ~srcOffset=i1, ~dst, ~dstOffset=d, ~len=src1r - i1) - d + src1r - i1 - } - } else { - A.setUnsafe(dst, d, s2) - let i2 = i2 + 1 - let d = d + 1 - if i2 < src2r { - loop(i1, s1, i2, A.getUnsafe(src2, i2), d) - } else { - A.blitUnsafe(~src, ~srcOffset=i1, ~dst, ~dstOffset=d, ~len=src1r - i1) - d + src1r - i1 - } - } - - loop(src1ofs, A.getUnsafe(src, src1ofs), src2ofs, A.getUnsafe(src2, src2ofs), dstofs) -} - -let intersect = (src: array, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { - let src1r = src1ofs + src1len - let src2r = src2ofs + src2len - let rec loop = (i1, s1, i2, s2, d) => - /* let c = cmp s1 s2 [@bs] in */ - if s1 < s2 { - /* A.setUnsafe dst d s1; */ - let i1 = i1 + 1 - if i1 < src1r { - loop(i1, A.getUnsafe(src, i1), i2, s2, d) - } else { - d - } - } else if s1 == s2 { - A.setUnsafe(dst, d, s1) - let i1 = i1 + 1 - let i2 = i2 + 1 - let d = d + 1 - if i1 < src1r && i2 < src2r { - loop(i1, A.getUnsafe(src, i1), i2, A.getUnsafe(src2, i2), d) - } else { - d - } - } else { - /* A.setUnsafe dst d s2; */ - let i2 = i2 + 1 - if i2 < src2r { - loop(i1, s1, i2, A.getUnsafe(src2, i2), d) - } else { - d - } - } - - loop(src1ofs, A.getUnsafe(src, src1ofs), src2ofs, A.getUnsafe(src2, src2ofs), dstofs) -} - -let diff = (src: array, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { - let src1r = src1ofs + src1len - let src2r = src2ofs + src2len - let rec loop = (i1, s1, i2, s2, d) => - /* let c = cmp s1 s2 [@bs] in */ - if s1 < s2 { - A.setUnsafe(dst, d, s1) - let d = d + 1 - let i1 = i1 + 1 - if i1 < src1r { - loop(i1, A.getUnsafe(src, i1), i2, s2, d) - } else { - d - } - } else if s1 == s2 { - let i1 = i1 + 1 - let i2 = i2 + 1 - if i1 < src1r && i2 < src2r { - loop(i1, A.getUnsafe(src, i1), i2, A.getUnsafe(src2, i2), d) - } else if i1 == src1r { - d - } else { - A.blitUnsafe(~src, ~srcOffset=i1, ~dst, ~dstOffset=d, ~len=src1r - i1) - d + src1r - i1 - } - } else { - let i2 = i2 + 1 - if i2 < src2r { - loop(i1, s1, i2, A.getUnsafe(src2, i2), d) - } else { - A.blitUnsafe(~src, ~srcOffset=i1, ~dst, ~dstOffset=d, ~len=src1r - i1) - d + src1r - i1 - } - } - - loop(src1ofs, A.getUnsafe(src, src1ofs), src2ofs, A.getUnsafe(src2, src2ofs), dstofs) -} - -let insertionSort = (src: array, srcofs, dst, dstofs, len) => - for i in 0 to len - 1 { - let e = A.getUnsafe(src, srcofs + i) - let j = ref(dstofs + i - 1) - while j.contents >= dstofs && A.getUnsafe(dst, j.contents) > e { - A.setUnsafe(dst, j.contents + 1, A.getUnsafe(dst, j.contents)) - j.contents = j.contents - 1 - } - A.setUnsafe(dst, j.contents + 1, e) - } - -let rec sortTo = (src: array, srcofs, dst, dstofs, len) => - if len <= cutoff { - insertionSort(src, srcofs, dst, dstofs, len) - } else { - let l1 = len / 2 - let l2 = len - l1 - sortTo(src, srcofs + l1, dst, dstofs + l1, l2) - sortTo(src, srcofs, src, srcofs + l2, l1) - merge(src, srcofs + l2, l1, dst, dstofs + l1, l2, dst, dstofs) - } - -let stableSortInPlace = (a: array) => { - let l = A.length(a) - if l <= cutoff { - insertionSort(a, 0, a, 0, l) - } else { - let l1 = l / 2 - let l2 = l - l1 - let t = Belt_Array.makeUninitializedUnsafe(l2) - sortTo(a, l1, t, 0, l2) - sortTo(a, 0, a, l2, l1) - merge(a, l2, l1, t, 0, l2, a, 0) - } -} - -let stableSort = a => { - let b = A.copy(a) - stableSortInPlace(b) - b -} - -let rec binarySearchAux = (arr: array, lo, hi, key) => { - let mid = (lo + hi) / 2 - let midVal = A.getUnsafe(arr, mid) - - /* let c = cmp key midVal [@bs] in */ - if key == midVal { - mid - } else if key < midVal { - /* a[lo] =< key < a[mid] <= a[hi] */ - if hi == mid { - if A.getUnsafe(arr, lo) == key { - lo - } else { - -(hi + 1) - } - } else { - binarySearchAux(arr, lo, mid, key) - } - } /* a[lo] =< a[mid] < key <= a[hi] */ - else if lo == mid { - if A.getUnsafe(arr, hi) == key { - hi - } else { - -(hi + 1) - } - } else { - binarySearchAux(arr, mid, hi, key) - } -} - -let binarySearch = (sorted: array, key): int => { - let len = A.length(sorted) - if len == 0 { - -1 - } else { - let lo = A.getUnsafe(sorted, 0) - - /* let c = cmp key lo [@bs] in */ - if key < lo { - -1 - } else { - let hi = A.getUnsafe(sorted, len - 1) - - /* let c2 = cmp key hi [@bs]in */ - if key > hi { - -(len + 1) - } else { - binarySearchAux(sorted, 0, len - 1, key) - } - } - } -} diff --git a/jscomp/others/belt_SortArrayString.resi b/jscomp/others/belt_SortArrayString.resi deleted file mode 100644 index 3742ce22291..00000000000 --- a/jscomp/others/belt_SortArrayString.resi +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/*** -This is a specialized module for [`Belt_SortArray`](), the docs in that module also -applies here, except the comparator is fixed and inlined -*/ - -type element = string - -/** -The same as [`Belt_SortArray.strictlySortedLength`]() except the comparator is fixed - -**return** `+n` means increasing order `-n` means negative order -*/ -let strictlySortedLength: array => int - -/** `sorted(xs)` return true if `xs` is in non strict increasing order */ -let isSorted: array => bool - -/** -The same as [`Belt_SortArray.stableSortInPlaceBy`]() except the comparator is fixed -*/ -let stableSortInPlace: array => unit - -/** -The same as [`Belt_SortArray.stableSortBy`]() except the comparator is fixed -*/ -let stableSort: array => array - -/** -If value is not found and value is less than one or more elements in array, -the negative number returned is the bitwise complement of the index of the first element -that is larger than value. - -If value is not found and value is greater than all elements in array, -the negative number returned is the bitwise complement of -(the index of the last element plus 1) - -for example, if `key` is smaller than all elements return `-1` since `lnot (-1) = 0` -if `key` is larger than all elements return `- (len + 1)` since `lnot (-(len+1)) = len` -*/ -let binarySearch: (array, element) => 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` also assume that `dst` is large enough to store all elements -*/ -let union: (array, int, int, array, int, int, array, int) => int - -let intersect: (array, int, int, array, int, int, array, int) => int - -let diff: (array, int, int, array, int, int, array, int) => int diff --git a/jscomp/others/belt_internalAVLset.res b/jscomp/others/belt_internalAVLset.res deleted file mode 100644 index 1fedc4ff4c6..00000000000 --- a/jscomp/others/belt_internalAVLset.res +++ /dev/null @@ -1,765 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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"]}) -type rec node<'value> = { - @as("v") mutable value: 'value, - @as("h") mutable height: int, - @as("l") mutable left: t<'value>, - @as("r") mutable right: t<'value>, -} -and t<'value> = option> - -module A = Belt_Array -module S = Belt_SortArray - -type cmp<'a, 'b> = Belt_Id.cmp<'a, 'b> - -/* Sets are represented by balanced binary trees (the heights of the - children differ by at most 2 */ - -@inline -let height = (n: t<_>) => - switch n { - | None => 0 - | Some(n) => n.height - } - -let rec copy = n => - switch n { - | None => n - | Some(n) => - Some({ - left: copy(n.left), - right: copy(n.right), - value: n.value, - height: n.height, - }) - } - -/* Creates a new node with leftGet son l, value v and right son r. - We must have all elements of l < v < all elements of r. - l and r must be balanced and | treeHeight l - treeHeight r | <= 2. - Inline expansion of treeHeight for better speed. */ - -@inline -let calcHeight = (hl: int, hr) => - if hl >= hr { - hl - } else { - hr - } + 1 - -let create = (l: t<_>, v, r: t<_>) => { - let hl = height(l) - let hr = height(r) - Some({left: l, value: v, right: r, height: calcHeight(hl, hr)}) -} - -let singleton = x => Some({left: None, value: x, right: None, height: 1}) - -let heightGe = (l, r) => - switch (l, r) { - | (_, None) => true - | (Some(hl), Some(hr)) => hl.height >= hr.height - | (None, Some(_)) => false - } -/* Same as create, but performs one step of rebalancing if necessary. - Assumes l and r balanced and | treeHeight l - treeHeight r | <= 3. - Inline expansion of create for better speed in the most frequent case - where no rebalancing is required. */ -/* TODO: inline all `create` operation, save duplicated `heightGet` calcuation */ -let bal = (l, v, r) => { - let (hl, hr) = (height(l), height(r)) - if hl > hr + 2 { - switch l { - | None => assert(false) - | Some({left: ll, right: lr} as l) => - if heightGe(ll, lr) { - create(ll, l.value, create(lr, v, r)) - } else { - switch lr { - | None => assert(false) - | Some(lr) => create(create(ll, l.value, lr.left), lr.value, create(lr.right, v, r)) - } - } - } - } else if hr > hl + 2 { - switch r { - | None => assert(false) - | Some({left: rl, right: rr} as r) => - if heightGe(rr, rl) { - create(create(l, v, rl), r.value, rr) - } else { - switch rl { - | None => assert(false) - | Some(rl) => create(create(l, v, rl.left), rl.value, create(rl.right, r.value, rr)) - } - } - } - } else { - Some({left: l, value: v, right: r, height: calcHeight(hl, hr)}) - } -} - -let rec min0Aux = n => - switch n.left { - | None => n.value - | Some(n) => min0Aux(n) - } - -let minimum = n => - switch n { - | None => None - | Some(n) => Some(min0Aux(n)) - } - -let minUndefined = n => - switch n { - | None => Js.undefined - | Some(n) => Js.Undefined.return(min0Aux(n)) - } - -let rec max0Aux = n => - switch n.right { - | None => n.value - | Some(n) => max0Aux(n) - } - -let maximum = n => - switch n { - | None => None - | Some(n) => Some(max0Aux(n)) - } - -let maxUndefined = n => - switch n { - | None => Js.undefined - | Some(n) => Js.Undefined.return(max0Aux(n)) - } - -let rec removeMinAuxWithRef = (n, v) => - switch n.left { - | None => - v.contents = n.value - n.right - | Some(ln) => bal(removeMinAuxWithRef(ln, v), n.value, n.right) - } - -/* Implementation of the set operations */ - -let isEmpty = n => - switch n { - | Some(_) => false - | None => true - } - -let rec stackAllLeft = (v, s) => - switch v { - | None => s - | Some(x) => stackAllLeft(x.left, list{x, ...s}) - } - -let rec forEachU = (n, f) => - switch n { - | None => () - | Some(n) => - forEachU(n.left, f) - f(. n.value) - forEachU(n.right, f) - } - -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) - } - -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)) - } - -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)) - } - -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. - They are only used during the "join" operation which - respects this precondition. -*/ - -let rec addMinElement = (n, v) => - switch n { - | None => singleton(v) - | Some(n) => bal(addMinElement(n.left, v), n.value, n.right) - } - -let rec addMaxElement = (n, v) => - switch n { - | None => singleton(v) - | Some(n) => bal(n.left, n.value, addMaxElement(n.right, v)) - } - -/* `join ln v rn` Some a balanced tree simliar to `create ln v rn` - bal, but no assumptions are made on the - relative heights of `ln` and `rn`. */ - -let rec joinShared = (ln, v, rn) => - switch (ln, rn) { - | (None, _) => addMinElement(rn, v) - | (_, None) => addMaxElement(ln, v) - | (Some(l), Some(r)) => - let lh = l.height - let rh = r.height - if lh > rh + 2 { - bal(l.left, l.value, joinShared(l.right, v, rn)) - } else if rh > lh + 2 { - bal(joinShared(ln, v, r.left), r.value, r.right) - } else { - create(ln, v, rn) - } - } - -/* `concat l r` - No assumption on the heights of l and r. */ - -let concatShared = (t1, t2) => - switch (t1, t2) { - | (None, _) => t2 - | (_, None) => t1 - | (_, Some(t2n)) => - let v = ref(t2n.value) - let t2r = removeMinAuxWithRef(t2n, v) - joinShared(t1, v.contents, t2r) - } - -let rec partitionSharedU = (n, p) => - switch n { - | None => (None, None) - | Some(n) => - let value = n.value - let (lt, lf) = partitionSharedU(n.left, p) - let pv = p(. value) - let (rt, rf) = partitionSharedU(n.right, p) - if pv { - (joinShared(lt, value, rt), concatShared(lf, rf)) - } else { - (concatShared(lt, rt), joinShared(lf, value, rf)) - } - } - -let partitionShared = (n, p) => partitionSharedU(n, (. a) => p(a)) - -let rec lengthNode = n => { - let {left: l, right: r} = n - let sizeL = switch l { - | None => 0 - | Some(l) => lengthNode(l) - } - let sizeR = switch r { - | None => 0 - | Some(r) => lengthNode(r) - } - 1 + sizeL + sizeR -} - -let size = n => - switch n { - | None => 0 - | Some(n) => lengthNode(n) - } - -let rec toListAux = (n, accu) => - switch n { - | None => accu - | Some(n) => toListAux(n.left, list{n.value, ...toListAux(n.right, accu)}) - } - -let toList = s => toListAux(s, list{}) - -let rec checkInvariantInternal = (v: t<_>) => - switch v { - | None => () - | Some(n) => - let {left: l, right: r} = n - let diff = height(l) - height(r) - assert(diff <= 2 && diff >= -2) - checkInvariantInternal(l) - checkInvariantInternal(r) - } - -let rec fillArray = (n, i, arr) => { - let {left: l, value: v, right: r} = n - let next = switch l { - | None => i - | Some(l) => fillArray(l, i, arr) - } - A.setUnsafe(arr, next, v) - let rnext = next + 1 - switch r { - | None => rnext - | Some(r) => fillArray(r, rnext, arr) - } -} - -type cursor = {mutable forward: int, mutable backward: int} - -let rec fillArrayWithPartition = (n, cursor, arr, p) => { - let {left: l, value: v, right: r} = n - switch l { - | None => () - | Some(l) => fillArrayWithPartition(l, cursor, arr, p) - } - if p(. v) { - let c = cursor.forward - A.setUnsafe(arr, c, v) - cursor.forward = c + 1 - } else { - let c = cursor.backward - A.setUnsafe(arr, c, v) - cursor.backward = c - 1 - } - switch r { - | None => () - | Some(r) => fillArrayWithPartition(r, cursor, arr, p) - } -} - -let rec fillArrayWithFilter = (n, i, arr, p) => { - let {left: l, value: v, right: r} = n - let next = switch l { - | None => i - | Some(l) => fillArrayWithFilter(l, i, arr, p) - } - let rnext = if p(. v) { - A.setUnsafe(arr, next, v) - next + 1 - } else { - next - } - switch r { - | None => rnext - | Some(r) => fillArrayWithFilter(r, rnext, arr, p) - } -} - -let toArray = n => - switch n { - | None => [] - | Some(n) => - let size = lengthNode(n) - let v = A.makeUninitializedUnsafe(size) - ignore((fillArray(n, 0, v): int)) /* may add assertion */ - v - } - -let rec fromSortedArrayRevAux = (arr, off, len) => - switch len { - | 0 => None - | 1 => singleton(A.getUnsafe(arr, off)) - | 2 => - let (x0, x1) = { - open A - (getUnsafe(arr, off), getUnsafe(arr, off - 1)) - } - - Some({left: singleton(x0), value: x1, height: 2, right: None}) - | 3 => - let (x0, x1, x2) = { - open A - (getUnsafe(arr, off), getUnsafe(arr, off - 1), getUnsafe(arr, off - 2)) - } - Some({ - left: singleton(x0), - right: singleton(x2), - value: x1, - height: 2, - }) - | _ => - let nl = len / 2 - let left = fromSortedArrayRevAux(arr, off, nl) - let mid = A.getUnsafe(arr, off - nl) - let right = fromSortedArrayRevAux(arr, off - nl - 1, len - nl - 1) - create(left, mid, right) - } - -let rec fromSortedArrayAux = (arr, off, len) => - switch len { - | 0 => None - | 1 => singleton(A.getUnsafe(arr, off)) - | 2 => - let (x0, x1) = { - open A - (getUnsafe(arr, off), getUnsafe(arr, off + 1)) - } - - Some({left: singleton(x0), value: x1, height: 2, right: None}) - | 3 => - let (x0, x1, x2) = { - open A - (getUnsafe(arr, off), getUnsafe(arr, off + 1), getUnsafe(arr, off + 2)) - } - Some({ - left: singleton(x0), - right: singleton(x2), - value: x1, - height: 2, - }) - | _ => - let nl = len / 2 - let left = fromSortedArrayAux(arr, off, nl) - let mid = A.getUnsafe(arr, off + nl) - let right = fromSortedArrayAux(arr, off + nl + 1, len - nl - 1) - create(left, mid, right) - } - -let fromSortedArrayUnsafe = arr => fromSortedArrayAux(arr, 0, A.length(arr)) - -let rec keepSharedU = (n, p) => - switch n { - | None => None - | Some(n) => - let {left: l, value: v, right: r} = n - let newL = keepSharedU(l, p) - let pv = p(. v) - let newR = keepSharedU(r, p) - if pv { - if l === newL && r === newR { - Some(n) - } else { - joinShared(newL, v, newR) - } - } else { - concatShared(newL, newR) - } - } - -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 -*/ - -let keepCopyU = (n, p): t<_> => - switch n { - | None => None - | Some(n) => - let size = lengthNode(n) - let v = A.makeUninitializedUnsafe(size) - let last = fillArrayWithFilter(n, 0, v, p) - fromSortedArrayAux(v, 0, last) - } - -let keepCopy = (n, p) => keepCopyU(n, (. x) => p(x)) - -let partitionCopyU = (n, p) => - switch n { - | None => (None, None) - | Some(n) => - let size = lengthNode(n) - let v = A.makeUninitializedUnsafe(size) - let backward = size - 1 - let cursor = {forward: 0, backward} - fillArrayWithPartition(n, cursor, v, p) - let forwardLen = cursor.forward - (fromSortedArrayAux(v, 0, forwardLen), fromSortedArrayRevAux(v, backward, size - forwardLen)) - } - -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) - c == 0 || - has( - ~cmp, - if c < 0 { - n.left - } else { - n.right - }, - x, - ) - } - -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) - if c == 0 { - compareAux(~cmp, h1.right->stackAllLeft(t1), h2.right->stackAllLeft(t2)) - } else { - c - } - | (_, _) => 0 - } - -let cmp = (s1, s2, ~cmp) => { - let (len1, len2) = (size(s1), size(s2)) - if len1 == len2 { - compareAux(~cmp, stackAllLeft(s1, list{}), stackAllLeft(s2, list{})) - } else if len1 < len2 { - -1 - } else { - 1 - } -} - -let eq = (s1, s2, ~cmp as c) => cmp(~cmp=c, s1, s2) == 0 - -let rec subset = (s1: t<_>, s2: t<_>, ~cmp) => - switch (s1, s2) { - | (None, _) => true - | (_, None) => false - | (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) - if c == 0 { - subset(~cmp, l1, l2) && subset(~cmp, r1, r2) - } else if c < 0 { - subset(~cmp, create(l1, v1, None), l2) && subset(~cmp, r1, s2) - } else { - subset(~cmp, create(None, v1, r1), r2) && subset(~cmp, l1, s2) - } - } - -let rec get = (n: t<_>, x, ~cmp) => - switch n { - | None => None - | Some(t) /* Node(l, v, r, _) */ => - let v = t.value - let c = Belt_Id.getCmpInternal(cmp)(. x, v) - if c == 0 { - Some(v) - } else { - get( - ~cmp, - if c < 0 { - t.left - } else { - t.right - }, - x, - ) - } - } - -let rec getUndefined = (n: t<_>, x, ~cmp) => - switch n { - | None => Js.Undefined.empty - | Some(t) /* Node(l, v, r, _) */ => - let v = t.value - let c = Belt_Id.getCmpInternal(cmp)(. x, v) - if c == 0 { - Js.Undefined.return(v) - } else { - getUndefined( - ~cmp, - if c < 0 { - t.left - } else { - t.right - }, - x, - ) - } - } - -let rec getExn = (n: t<_>, x, ~cmp) => - switch n { - | None => raise(Not_found) - | Some(t) /* Node(l, v, r, _) */ => - let v = t.value - let c = Belt_Id.getCmpInternal(cmp)(. x, v) - if c == 0 { - v - } else { - getExn( - ~cmp, - if c < 0 { - t.left - } else { - t.right - }, - x, - ) - } - } - -/* **************************************************************** */ - -/* - L rotation, Some root node -*/ -let rotateWithLeftChild = k2 => - switch k2.left { - | None => assert(false) - | Some(k1) => - k2.left = k1.right - k1.right = Some(k2) - let (hlk2, hrk2) = (k2.left->height, k2.right->height) - k2.height = Pervasives.max(hlk2, hrk2) + 1 - let (hlk1, hk2) = (k1.left->height, k2.height) - k1.height = Pervasives.max(hlk1, hk2) + 1 - k1 - } -/* right rotation */ -let rotateWithRightChild = k1 => - switch k1.right { - | None => assert(false) - | Some(k2) => - k1.right = k2.left - k2.left = Some(k1) - let (hlk1, hrk1) = (k1.left->height, k1.right->height) - k1.height = Pervasives.max(hlk1, hrk1) + 1 - let (hrk2, hk1) = (k2.right->height, k1.height) - k2.height = Pervasives.max(hrk2, hk1) + 1 - k2 - } - -/* - double l rotation -*/ -/** */ -let doubleWithLeftChild = k3 => - switch k3.left { - | None => assert(false) - | Some(k3l) => - let v = k3l->rotateWithRightChild->Some - k3.left = v - k3->rotateWithLeftChild - } - -let doubleWithRightChild = k2 => - switch k2.right { - | None => assert(false) - | Some(k2r) => - let v = k2r->rotateWithLeftChild->Some - k2.right = v - rotateWithRightChild(k2) - } - -let heightUpdateMutate = t => { - let (hlt, hrt) = (t.left->height, t.right->height) - t.height = Pervasives.max(hlt, hrt) + 1 - t -} - -let balMutate = nt => { - let {left: l, right: r} = nt - let (hl, hr) = (height(l), height(r)) - if hl > 2 + hr { - switch l { - | None => assert(false) - | Some({left: ll, right: lr}) => - if heightGe(ll, lr) { - heightUpdateMutate(rotateWithLeftChild(nt)) - } else { - heightUpdateMutate(doubleWithLeftChild(nt)) - } - } - } else if hr > 2 + hl { - switch r { - | None => assert(false) - | Some({left: rl, right: rr}) => - if heightGe(rr, rl) { - heightUpdateMutate(rotateWithRightChild(nt)) - } else { - heightUpdateMutate(doubleWithRightChild(nt)) - } - } - } else { - nt.height = Pervasives.max(hl, hr) + 1 - nt - } -} - -let rec addMutate = (~cmp, t: t<_>, x) => - switch t { - | None => singleton(x) - | Some(nt) => - let k = nt.value - let c = Belt_Id.getCmpInternal(cmp)(. x, k) - if c == 0 { - t - } else { - let {left: l, right: r} = nt - if c < 0 { - let ll = addMutate(~cmp, l, x) - nt.left = ll - } else { - nt.right = addMutate(~cmp, r, x) - } - Some(balMutate(nt)) - } - } - -let fromArray = (xs: array<_>, ~cmp) => { - let len = A.length(xs) - if len == 0 { - None - } else { - 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) - } else { - next.contents = -next.contents - fromSortedArrayRevAux(xs, next.contents - 1, next.contents) - }, - ) - for i in next.contents to len - 1 { - result.contents = addMutate(~cmp, result.contents, A.getUnsafe(xs, i)) - } - result.contents - } -} - -let rec removeMinAuxWithRootMutate = (nt, n) => { - let {right: rn, left: ln} = n - switch ln { - | None => - nt.value = n.value - rn - | Some(ln) => - n.left = removeMinAuxWithRootMutate(nt, ln) - Some(balMutate(n)) - } -} diff --git a/jscomp/others/belt_internalAVLset.resi b/jscomp/others/belt_internalAVLset.resi deleted file mode 100644 index 0f7ccf5e03b..00000000000 --- a/jscomp/others/belt_internalAVLset.resi +++ /dev/null @@ -1,116 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/* -This internal module contains methods which does not rely on ordering. -Such methods could be shared between `generic set/specalized set` whether mutable -or immutable depends on use cases -*/ -type rec t<'value> = option> -and node<'value> = { - @as("v") mutable value: 'value, - @as("h") mutable height: int, - @as("l") mutable left: t<'value>, - @as("r") mutable right: t<'value>, -} - -type cmp<'a, 'b> = Belt_Id.cmp<'a, 'b> - -let copy: t<'a> => t<'a> -let create: (t<'a>, 'a, t<'a>) => t<'a> -let bal: (t<'a>, 'a, t<'a>) => t<'a> -let singleton: 'a => t<'a> - -let minimum: t<'a> => option<'a> -let minUndefined: t<'a> => Js.undefined<'a> -let maximum: t<'a> => option<'a> -let maxUndefined: t<'a> => Js.undefined<'a> - -let removeMinAuxWithRef: (node<'a>, ref<'a>) => t<'a> -/* `removeMinAuxWithRef n cell` return a new node with - minimum removed and stored in cell */ - -let isEmpty: t<'a> => bool - -let stackAllLeft: (t<'a>, list>) => list> - -let forEachU: (t<'a>, (. 'a) => unit) => unit -let forEach: (t<'a>, 'a => unit) => unit - -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 every: (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 keepShared: (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 partitionShared: (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 -let size: t<'a> => int - -let toList: t<'a> => list<'a> - -/** -**raise** when invariant is not held -*/ -let checkInvariantInternal: t<_> => unit - -let fillArray: (node<'a>, int, array<'a>) => int -let toArray: t<'a> => array<'a> -let fromSortedArrayAux: (array<'a>, int, int) => t<'a> -let fromSortedArrayRevAux: (array<'a>, int, int) => t<'a> -let fromSortedArrayUnsafe: array<'a> => t<'a> -let has: (t<'a>, 'a, ~cmp: cmp<'a, 'b>) => bool -let cmp: (t<'a>, t<'a>, ~cmp: cmp<'a, 'b>) => int -let eq: (t<'a>, t<'a>, ~cmp: cmp<'a, 'b>) => bool -let subset: (t<'a>, t<'a>, ~cmp: cmp<'a, 'b>) => bool -let get: (t<'a>, 'a, ~cmp: cmp<'a, 'b>) => option<'a> -let getUndefined: (t<'a>, 'a, ~cmp: cmp<'a, 'b>) => Js.undefined<'a> -let getExn: (t<'a>, 'a, ~cmp: cmp<'a, 'b>) => 'a - -let fromArray: (array<'a>, ~cmp: cmp<'a, 'b>) => t<'a> - -let addMutate: (~cmp: cmp<'a, 'b>, t<'a>, 'a) => t<'a> -let balMutate: node<'a> => node<'a> -/** -`removeMinAuxWithRootMutate(root, n)` remove the minimum of n in place and store -its value in the `key root` -*/ -let removeMinAuxWithRootMutate: (node<'a>, node<'a>) => t<'a> diff --git a/jscomp/others/belt_internalAVLtree.res b/jscomp/others/belt_internalAVLtree.res deleted file mode 100644 index ff557badf96..00000000000 --- a/jscomp/others/belt_internalAVLtree.res +++ /dev/null @@ -1,945 +0,0 @@ -/* ********************************************************************* */ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1996 Institut National de Recherche en Informatique et */ -/* en Automatique. All rights reserved. This file is distributed */ -/* under the terms of the GNU Library General Public License, with */ -/* the special exception on linking described in file ../LICENSE. */ -/* */ -/* ********************************************************************* */ - -/* Almost rewritten by authors of ReScript */ - -@@bs.config({flags: ["-bs-noassertfalse"]}) -type rec node<'k, 'v> = { - @as("k") mutable key: 'k, - @as("v") mutable value: 'v, - @as("h") mutable height: int, - @as("l") mutable left: t<'k, 'v>, - @as("r") mutable right: t<'k, 'v>, -} -and t<'key, 'a> = option> - -type cmp<'k, 'id> = Belt_Id.cmp<'k, 'id> - -module A = Belt_Array -module S = Belt_SortArray - -let treeHeight = (n: t<_>) => - switch n { - | None => 0 - | Some(n) => n.height - } - -let rec copy = n => - switch n { - | None => n - | Some(n) => Some({...n, left: copy(n.left), right: copy(n.right)}) - } - -let create = (l, x, d, r) => { - let (hl, hr) = (treeHeight(l), treeHeight(r)) - Some({ - left: l, - key: x, - value: d, - right: r, - height: if hl >= hr { - hl + 1 - } else { - hr + 1 - }, - }) -} - -let singleton = (x, d) => Some({left: None, key: x, value: d, right: None, height: 1}) - -let heightGe = (l, r) => - switch (l, r) { - | (_, None) => true - | (Some(hl), Some(hr)) => hl.height >= hr.height - | (None, Some(_)) => false - } - -let updateValue = (n, newValue) => - if n.value === newValue { - n - } else { - { - left: n.left, - right: n.right, - key: n.key, - value: newValue, - height: n.height, - } - } - -let bal = (l, x, d, r) => { - let hl = switch l { - | None => 0 - | Some(n) => n.height - } - let hr = switch r { - | None => 0 - | Some(n) => n.height - } - if hl > hr + 2 { - switch l { - | None => assert(false) - | Some({left: ll, right: lr} as l) => - if treeHeight(ll) >= treeHeight(lr) { - create(ll, l.key, l.value, create(lr, x, d, r)) - } else { - switch lr { - | None => assert(false) - | Some(lr) => - create(create(ll, l.key, l.value, lr.left), lr.key, lr.value, create(lr.right, x, d, r)) - } - } - } - } else if hr > hl + 2 { - switch r { - | None => assert(false) - | Some({left: rl, right: rr} as r) => - if treeHeight(rr) >= treeHeight(rl) { - create(create(l, x, d, rl), r.key, r.value, rr) - } else { - switch rl { - | None => assert(false) - | Some(rl) => - create(create(l, x, d, rl.left), rl.key, rl.value, create(rl.right, r.key, r.value, rr)) - } - } - } - } else { - Some({ - left: l, - key: x, - value: d, - right: r, - height: if hl >= hr { - hl + 1 - } else { - hr + 1 - }, - }) - } -} - -let rec minKey0Aux = n => - switch n.left { - | None => n.key - | Some(n) => minKey0Aux(n) - } - -let minKey = n => - switch n { - | None => None - | Some(n) => Some(minKey0Aux(n)) - } - -let minKeyUndefined = n => - switch n { - | None => Js.undefined - | Some(n) => Js.Undefined.return(minKey0Aux(n)) - } - -let rec maxKey0Aux = n => - switch n.right { - | None => n.key - | Some(n) => maxKey0Aux(n) - } - -let maxKey = n => - switch n { - | None => None - | Some(n) => Some(maxKey0Aux(n)) - } - -let maxKeyUndefined = n => - switch n { - | None => Js.undefined - | Some(n) => Js.Undefined.return(maxKey0Aux(n)) - } - -let rec minKV0Aux = n => - switch n.left { - | None => (n.key, n.value) - | Some(n) => minKV0Aux(n) - } - -let minimum = n => - switch n { - | None => None - | Some(n) => Some(minKV0Aux(n)) - } - -let minUndefined = n => - switch n { - | None => Js.undefined - | Some(n) => Js.Undefined.return(minKV0Aux(n)) - } - -let rec maxKV0Aux = n => - switch n.right { - | None => (n.key, n.value) - | Some(n) => maxKV0Aux(n) - } - -let maximum = n => - switch n { - | None => None - | Some(n) => Some(maxKV0Aux(n)) - } - -let maxUndefined = n => - switch n { - | None => Js.undefined - | Some(n) => Js.Undefined.return(maxKV0Aux(n)) - } - -/* TODO: use kv ref */ -let rec removeMinAuxWithRef = (n, kr, vr) => - switch n.left { - | None => - kr.contents = n.key - vr.contents = n.value - n.right - | Some(ln) => bal(removeMinAuxWithRef(ln, kr, vr), n.key, n.value, n.right) - } - -let isEmpty = x => - switch x { - | None => true - | Some(_) => false - } - -let rec stackAllLeft = (v, s) => - switch v { - | None => s - | Some(x) => stackAllLeft(x.left, list{x, ...s}) - } - -let rec findFirstByU = (n, p) => - switch n { - | None => None - | Some(n) => - let left = findFirstByU(n.left, p) - if left != None { - left - } else { - let {key: v, value: d} = n - let pvd = p(. v, d) - if pvd { - Some(v, d) - } else { - let right = findFirstByU(n.right, p) - if right != None { - right - } else { - None - } - } - } - } - -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) - forEachU(n.right, f) - } - -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 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 rec mapWithKeyU = (n, f) => - switch n { - | None => None - | Some(n) => - let key = n.key - let newLeft = mapWithKeyU(n.left, f) - 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 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) - } - -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)) - } -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)) - } -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. - - Indeed, they are only used during the "join" operation which - respects this precondition. -*/ - -let rec addMinElement = (n, k, v) => - switch n { - | None => singleton(k, v) - | Some(n) => bal(addMinElement(n.left, k, v), n.key, n.value, n.right) - } - -let rec addMaxElement = (n, k, v) => - switch n { - | None => singleton(k, v) - | Some(n) => bal(n.left, n.key, n.value, addMaxElement(n.right, k, v)) - } - -/* Same as create and bal, but no assumptions are made on the - relative heights of l and r. */ - -let rec join = (ln, v, d, rn) => - switch (ln, rn) { - | (None, _) => addMinElement(rn, v, d) - | (_, None) => addMaxElement(ln, v, d) - | (Some(l), Some(r)) => - let {left: ll, key: lv, value: ld, right: lr, height: lh} = l - let {left: rl, key: rv, value: rd, right: rr, height: rh} = r - if lh > rh + 2 { - bal(ll, lv, ld, join(lr, v, d, rn)) - } else if rh > lh + 2 { - bal(join(ln, v, d, rl), rv, rd, rr) - } else { - create(ln, v, d, rn) - } - } - -/* Merge two trees l and r into one. - All elements of l must precede the elements of r. - No assumption on the heights of l and r. */ - -let concat = (t1, t2) => - switch (t1, t2) { - | (None, _) => t2 - | (_, None) => t1 - | (_, Some(t2n)) => - let (kr, vr) = (ref(t2n.key), ref(t2n.value)) - let t2r = removeMinAuxWithRef(t2n, kr, vr) - join(t1, kr.contents, vr.contents, t2r) - } - -let concatOrJoin = (t1, v, d, t2) => - switch d { - | Some(d) => join(t1, v, d, t2) - | None => concat(t1, t2) - } - -let rec keepSharedU = (n, p) => - switch n { - | None => None - | Some(n) => - /* 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 newRight = keepSharedU(n.right, p) - if pvd { - join(newLeft, v, d, newRight) - } else { - concat(newLeft, newRight) - } - } - -let keepShared = (n, p) => keepSharedU(n, (. a, b) => p(a, b)) - -let rec keepMapU = (n, p) => - switch n { - | None => None - | Some(n) => - /* 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 newRight = keepMapU(n.right, p) - switch pvd { - | None => concat(newLeft, newRight) - | Some(d) => join(newLeft, v, d, newRight) - } - } - -let keepMap = (n, p) => keepMapU(n, (. a, b) => p(a, b)) - -let rec partitionSharedU = (n, p) => - switch n { - | None => (None, None) - | Some(n) => - 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 (rt, rf) = partitionSharedU(n.right, p) - if pvd { - (join(lt, key, value, rt), concat(lf, rf)) - } else { - (concat(lt, rt), join(lf, key, value, rf)) - } - } - -let partitionShared = (n, p) => partitionSharedU(n, (. a, b) => p(a, b)) - -let rec lengthNode = n => { - let {left: l, right: r} = n - let sizeL = switch l { - | None => 0 - | Some(l) => lengthNode(l) - } - let sizeR = switch r { - | None => 0 - | Some(r) => lengthNode(r) - } - 1 + sizeL + sizeR -} - -let size = n => - switch n { - | None => 0 - | Some(n) => lengthNode(n) - } - -let rec toListAux = (n, accu) => - switch n { - | None => accu - | Some(n) => - let {left: l, right: r, key: k, value: v} = n - toListAux(l, list{(k, v), ...toListAux(r, accu)}) - } - -let toList = s => toListAux(s, list{}) - -let rec checkInvariantInternal = (v: t<_>) => - switch v { - | None => () - | Some(n) => - let (l, r) = (n.left, n.right) - let diff = treeHeight(l) - treeHeight(r) - assert(diff <= 2 && diff >= -2) - checkInvariantInternal(l) - checkInvariantInternal(r) - } - -let rec fillArrayKey = (n, i, arr) => { - let {left: l, key: v, right: r} = n - let next = switch l { - | None => i - | Some(l) => fillArrayKey(l, i, arr) - } - A.setUnsafe(arr, next, v) - let rnext = next + 1 - switch r { - | None => rnext - | Some(r) => fillArrayKey(r, rnext, arr) - } -} - -let rec fillArrayValue = (n, i, arr) => { - let (l, r) = (n.left, n.right) - let next = switch l { - | None => i - | Some(l) => fillArrayValue(l, i, arr) - } - A.setUnsafe(arr, next, n.value) - let rnext = next + 1 - switch r { - | None => rnext - | Some(r) => fillArrayValue(r, rnext, arr) - } -} - -let rec fillArray = (n, i, arr) => { - let (l, v, r) = (n.left, n.key, n.right) - let next = switch l { - | None => i - | Some(l) => fillArray(l, i, arr) - } - A.setUnsafe(arr, next, (v, n.value)) - let rnext = next + 1 - switch r { - | None => rnext - | Some(r) => fillArray(r, rnext, arr) - } -} - -/* let rec fillArrayWithPartition n cursor arr p = - let l,v,r = n.left, n.key , n.right in - (match l with - | None -> () - | Some l -> - fillArrayWithPartition l cursor arr p); - (if p v [@bs] then begin - let c = forwardGet cursor in - A.setUnsafe arr c (v,n.value); - forwardSet cursor (c + 1) - end - else begin - let c = backwardGet cursor in - A.setUnsafe arr c (v, n.value); - backwardSet cursor (c - 1) - end); - match r with - | None -> () - | Some r -> - fillArrayWithPartition r cursor arr p - -let rec fillArrayWithFilter n i arr p = - let l,v,r = n.left, n.key , n.right in - let next = - match l with - | None -> i - | Some l -> - fillArrayWithFilter l i arr p in - let rnext = - if p v [@bs] then - (A.setUnsafe arr next (v, n.value); - next + 1 - ) - else next in - match r with - | None -> rnext - | Some r -> - fillArrayWithFilter r rnext arr p - */ - -let toArray = n => - switch n { - | None => [] - | Some(n) => - let size = lengthNode(n) - let v = A.makeUninitializedUnsafe(size) - ignore((fillArray(n, 0, v): int)) /* may add assertion */ - v - } - -let keysToArray = n => - switch n { - | None => [] - | Some(n) => - let size = lengthNode(n) - let v = A.makeUninitializedUnsafe(size) - ignore((fillArrayKey(n, 0, v): int)) /* may add assertion */ - v - } - -let valuesToArray = n => - switch n { - | None => [] - | Some(n) => - let size = lengthNode(n) - let v = A.makeUninitializedUnsafe(size) - ignore((fillArrayValue(n, 0, v): int)) /* may add assertion */ - v - } - -let rec fromSortedArrayRevAux = (arr, off, len) => - switch len { - | 0 => None - | 1 => - let (k, v) = A.getUnsafe(arr, off) - singleton(k, v) - | 2 => - let ((x0, y0), (x1, y1)) = { - open A - (getUnsafe(arr, off), getUnsafe(arr, off - 1)) - } - - Some({left: singleton(x0, y0), key: x1, value: y1, height: 2, right: None}) - | 3 => - let ((x0, y0), (x1, y1), (x2, y2)) = { - open A - (getUnsafe(arr, off), getUnsafe(arr, off - 1), getUnsafe(arr, off - 2)) - } - Some({ - left: singleton(x0, y0), - right: singleton(x2, y2), - key: x1, - value: y1, - height: 2, - }) - | _ => - let nl = len / 2 - let left = fromSortedArrayRevAux(arr, off, nl) - let (midK, midV) = A.getUnsafe(arr, off - nl) - let right = fromSortedArrayRevAux(arr, off - nl - 1, len - nl - 1) - create(left, midK, midV, right) - } - -let rec fromSortedArrayAux = (arr, off, len) => - switch len { - | 0 => None - | 1 => - let (k, v) = A.getUnsafe(arr, off) - singleton(k, v) - | 2 => - let ((x0, y0), (x1, y1)) = { - open A - (getUnsafe(arr, off), getUnsafe(arr, off + 1)) - } - - Some({left: singleton(x0, y0), key: x1, value: y1, height: 2, right: None}) - | 3 => - let ((x0, y0), (x1, y1), (x2, y2)) = { - open A - (getUnsafe(arr, off), getUnsafe(arr, off + 1), getUnsafe(arr, off + 2)) - } - Some({ - left: singleton(x0, y0), - right: singleton(x2, y2), - key: x1, - value: y1, - height: 2, - }) - | _ => - let nl = len / 2 - let left = fromSortedArrayAux(arr, off, nl) - let (midK, midV) = A.getUnsafe(arr, off + nl) - let right = fromSortedArrayAux(arr, off + nl + 1, len - nl - 1) - create(left, midK, midV, right) - } - -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) - if c == 0 { - let cx = vcmp(. h1.value, h2.value) - if cx == 0 { - compareAux(~kcmp, ~vcmp, stackAllLeft(h1.right, t1), stackAllLeft(h2.right, t2)) - } else { - cx - } - } else { - c - } - | (_, _) => 0 - } - -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) { - eqAux(~kcmp, ~veq, stackAllLeft(h1.right, t1), stackAllLeft(h2.right, t2)) - } else { - false - } - | (_, _) => true - } - -let cmpU = (s1, s2, ~kcmp, ~vcmp) => { - let (len1, len2) = (size(s1), size(s2)) - if len1 == len2 { - compareAux(stackAllLeft(s1, list{}), stackAllLeft(s2, list{}), ~kcmp, ~vcmp) - } else if len1 < len2 { - -1 - } else { - 1 - } -} - -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)) - if len1 == len2 { - eqAux(stackAllLeft(s1, list{}), stackAllLeft(s2, list{}), ~kcmp, ~veq) - } else { - false - } -} - -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) - if c == 0 { - Some(n.value) - } else { - get( - ~cmp, - if c < 0 { - n.left - } else { - n.right - }, - x, - ) - } - } - -let rec getUndefined = (n, x, ~cmp) => - switch n { - | None => Js.undefined - | Some(n) => - let v = n.key - let c = Belt_Id.getCmpInternal(cmp)(. x, v) - if c == 0 { - Js.Undefined.return(n.value) - } else { - getUndefined( - ~cmp, - if c < 0 { - n.left - } else { - n.right - }, - x, - ) - } - } - -let rec getExn = (n, x, ~cmp) => - switch n { - | None => raise(Not_found) - | Some(n) /* Node(l, v, d, r, _) */ => - let v = n.key - let c = Belt_Id.getCmpInternal(cmp)(. x, v) - if c == 0 { - n.value - } else { - getExn( - ~cmp, - if c < 0 { - n.left - } else { - n.right - }, - x, - ) - } - } - -let rec getWithDefault = (n, x, def, ~cmp) => - switch n { - | None => def - | Some(n) /* Node(l, v, d, r, _) */ => - let v = n.key - let c = Belt_Id.getCmpInternal(cmp)(. x, v) - if c == 0 { - n.value - } else { - getWithDefault( - ~cmp, - if c < 0 { - n.left - } else { - n.right - }, - x, - def, - ) - } - } - -let rec has = (n, x, ~cmp) => - switch n { - | None => false - | Some(n) /* Node(l, v, d, r, _) */ => - let v = n.key - let c = Belt_Id.getCmpInternal(cmp)(. x, v) - c == 0 || - has( - ~cmp, - if c < 0 { - n.left - } else { - n.right - }, - x, - ) - } - -/* **************************************************************** */ - -/* - L rotation, Some root node -*/ -let rotateWithLeftChild = k2 => - switch k2.left { - | None => assert(false) - | Some(k1) => - k2.left = k1.right - k1.right = Some(k2) - let (hlk2, hrk2) = (treeHeight(k2.left), treeHeight(k2.right)) - k2.height = Pervasives.max(hlk2, hrk2) + 1 - let (hlk1, hk2) = (treeHeight(k1.left), k2.height) - k1.height = Pervasives.max(hlk1, hk2) + 1 - k1 - } -/* right rotation */ -let rotateWithRightChild = k1 => - switch k1.right { - | None => assert(false) - | Some(k2) => - k1.right = k2.left - k2.left = Some(k1) - let (hlk1, hrk1) = (treeHeight(k1.left), treeHeight(k1.right)) - k1.height = Pervasives.max(hlk1, hrk1) + 1 - let (hrk2, hk1) = (treeHeight(k2.right), k1.height) - k2.height = Pervasives.max(hrk2, hk1) + 1 - k2 - } - -/* - double l rotation -*/ -let doubleWithLeftChild = k3 => { - let k3l = switch k3.left { - | None => assert(false) - | Some(x) => x - } - let v = rotateWithRightChild(k3l) - k3.left = Some(v) - rotateWithLeftChild(k3) -} - -let doubleWithRightChild = k2 => { - let k2r = switch k2.right { - | None => assert(false) - | Some(x) => x - } - let v = rotateWithLeftChild(k2r) - k2.right = Some(v) - rotateWithRightChild(k2) -} - -let heightUpdateMutate = t => { - let (hlt, hrt) = (treeHeight(t.left), treeHeight(t.right)) - t.height = Pervasives.max(hlt, hrt) + 1 - t -} - -let balMutate = nt => { - let (l, r) = (nt.left, nt.right) - let (hl, hr) = (treeHeight(l), treeHeight(r)) - if hl > 2 + hr { - switch l { - | None => assert(false) - | Some({left: ll, right: lr}) => - if heightGe(ll, lr) { - heightUpdateMutate(rotateWithLeftChild(nt)) - } else { - heightUpdateMutate(doubleWithLeftChild(nt)) - } - } - } else if hr > 2 + hl { - switch r { - | None => assert(false) - | Some({left: rl, right: rr}) => - if heightGe(rr, rl) { - heightUpdateMutate(rotateWithRightChild(nt)) - } else { - heightUpdateMutate(doubleWithRightChild(nt)) - } - } - } else { - nt.height = Pervasives.max(hl, hr) + 1 - nt - } -} - -let rec updateMutate = (t: t<_>, x, data, ~cmp) => - switch t { - | None => singleton(x, data) - | Some(nt) => - let k = nt.key - let c = Belt_Id.getCmpInternal(cmp)(. x, k) - if c == 0 { - nt.value = data - Some(nt) - } else { - let (l, r) = (nt.left, nt.right) - if c < 0 { - let ll = updateMutate(~cmp, l, x, data) - nt.left = ll - } else { - nt.right = updateMutate(~cmp, r, x, data) - } - Some(balMutate(nt)) - } - } - -let fromArray = (xs: array<_>, ~cmp) => { - let len = A.length(xs) - if len == 0 { - None - } else { - let next = ref( - S.strictlySortedLengthU(xs, (. (x0, _), (y0, _)) => - Belt_Id.getCmpInternal(cmp)(. x0, y0) < 0 - ), - ) - - let result = ref( - if next.contents >= 0 { - fromSortedArrayAux(xs, 0, next.contents) - } else { - next.contents = -next.contents - fromSortedArrayRevAux(xs, next.contents - 1, next.contents) - }, - ) - for i in next.contents to len - 1 { - let (k, v) = A.getUnsafe(xs, i) - result.contents = updateMutate(~cmp, result.contents, k, v) - } - result.contents - } -} - -let rec removeMinAuxWithRootMutate = (nt, n) => { - let (rn, ln) = (n.right, n.left) - switch ln { - | None => - nt.key = n.key - nt.value = n.value - rn - | Some(ln) => - n.left = removeMinAuxWithRootMutate(nt, ln) - Some(balMutate(n)) - } -} diff --git a/jscomp/others/belt_internalAVLtree.resi b/jscomp/others/belt_internalAVLtree.resi deleted file mode 100644 index a1b58f3c3e7..00000000000 --- a/jscomp/others/belt_internalAVLtree.resi +++ /dev/null @@ -1,139 +0,0 @@ -/* Copyright (C) 2018 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -type rec t<'key, 'a> = option> - -and node<'k, 'v> = { - @as("k") mutable key: 'k, - @as("v") mutable value: 'v, - @as("h") mutable height: int, - @as("l") mutable left: t<'k, 'v>, - @as("r") mutable right: t<'k, 'v>, -} - -type cmp<'k, 'id> = Belt_Id.cmp<'k, 'id> - -let copy: t<'k, 'v> => t<'k, 'v> -let create: (t<'a, 'b>, 'a, 'b, t<'a, 'b>) => t<'a, 'b> -let bal: (t<'a, 'b>, 'a, 'b, t<'a, 'b>) => t<'a, 'b> - -let singleton: ('a, 'b) => t<'a, 'b> - -let updateValue: (node<'k, 'v>, 'v) => node<'k, 'v> - -let minKey: t<'a, 'b> => option<'a> -let minKeyUndefined: t<'a, 'b> => Js.undefined<'a> - -let maxKey: t<'a, 'b> => option<'a> -let maxKeyUndefined: t<'a, 'b> => Js.undefined<'a> - -let minimum: t<'a, 'b> => option<('a, 'b)> -let minUndefined: t<'a, 'b> => Js.undefined<('a, 'b)> - -let maximum: t<'a, 'b> => option<('a, 'b)> -let maxUndefined: t<'a, 'b> => Js.undefined<('a, 'b)> - -let removeMinAuxWithRef: (node<'a, 'b>, ref<'a>, ref<'b>) => t<'a, 'b> - -let isEmpty: t<_> => bool - -let stackAllLeft: (t<'a, 'b>, list>) => list> - -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 forEach: (t<'a, 'b>, ('a, 'b) => unit) => unit - -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 mapWithKey: (t<'a, 'b>, ('a, 'b) => 'c) => t<'a, '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 every: (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> - -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 keepShared: (t<'a, 'b>, ('a, 'b) => bool) => t<'a, 'b> - -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 partitionShared: (t<'a, 'b>, ('a, 'b) => bool) => (t<'a, 'b>, t<'a, 'b>) - -let lengthNode: node<'a, 'b> => int -let size: t<'a, 'b> => int - -let toList: t<'a, 'b> => list<('a, 'b)> -/** -**raise** when invariant is not held -*/ -let checkInvariantInternal: t<'a, 'b> => unit - -let fillArray: (node<'a, 'b>, int, array<('a, 'b)>) => int - -let toArray: t<'a, 'b> => array<('a, 'b)> -let keysToArray: t<'a, 'b> => array<'a> -let valuesToArray: t<'a, 'b> => array<'b> -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 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 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> - -let getUndefined: (t<'a, 'b>, 'a, ~cmp: cmp<'a, _>) => Js.undefined<'b> - -let getWithDefault: (t<'a, 'b>, 'a, 'b, ~cmp: cmp<'a, _>) => 'b -let getExn: (t<'a, 'b>, 'a, ~cmp: cmp<'a, _>) => 'b - -let has: (t<'a, 'b>, 'a, ~cmp: cmp<'a, _>) => bool - -let fromArray: (array<('a, 'b)>, ~cmp: cmp<'a, 'id>) => t<'a, 'b> - -let updateMutate: (t<'a, 'b>, 'a, 'b, ~cmp: cmp<'a, 'id>) => t<'a, 'b> - -let balMutate: node<'a, 'b> => node<'a, 'b> - -let removeMinAuxWithRootMutate: (node<'a, 'b>, node<'a, 'b>) => t<'a, 'b> diff --git a/jscomp/others/belt_internalBuckets.res b/jscomp/others/belt_internalBuckets.res deleted file mode 100644 index d9eeb7e26e7..00000000000 --- a/jscomp/others/belt_internalBuckets.res +++ /dev/null @@ -1,225 +0,0 @@ -/* ********************************************************************* */ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1996 Institut National de Recherche en Informatique et */ -/* en Automatique. All rights reserved. This file is distributed */ -/* under the terms of the GNU Library General Public License, with */ -/* the special exception on linking described in file ../LICENSE. */ -/* */ -/* ********************************************************************* */ - -/* Adapted by Hongbo Zhang, Authors of ReScript 2017 */ - -/* For JS backends, we use `undefined` as default value, so that buckets - could be allocated lazily -*/ - -/* We do dynamic hashing, and resize the table and rehash the elements - when buckets become too long. */ -module C = Belt_internalBucketsType -/* TODO: - the current implementation relies on the fact that bucket - empty value is `undefined` in both places, - in theory, it can be different - -*/ -type rec bucket<'a, 'b> = { - mutable key: 'a, - mutable value: 'b, - mutable next: C.opt>, -} -and t<'hash, 'eq, 'a, 'b> = C.container<'hash, 'eq, bucket<'a, 'b>> - -module A = Belt_Array - -let rec copy = (x: t<_>): t<_> => { - hash: x.hash, - eq: x.eq, - size: x.size, - buckets: copyBuckets(x.buckets), -} -and copyBuckets = (buckets: array>>) => { - let len = A.length(buckets) - let newBuckets = A.makeUninitializedUnsafe(len) - for i in 0 to len - 1 { - A.setUnsafe(newBuckets, i, copyBucket(A.getUnsafe(buckets, i))) - } - newBuckets -} -and copyBucket = c => - switch C.toOpt(c) { - | None => c - | Some(c) => - let head = { - key: c.key, - value: c.value, - next: C.emptyOpt, - } - copyAuxCont(c.next, head) - C.return(head) - } -and copyAuxCont = (c, prec) => - switch C.toOpt(c) { - | None => () - | Some(nc) => - let ncopy = {key: nc.key, value: nc.value, next: C.emptyOpt} - prec.next = C.return(ncopy) - copyAuxCont(nc.next, ncopy) - } - -let rec bucketLength = (accu, buckets) => - switch C.toOpt(buckets) { - | None => accu - | Some(cell) => bucketLength(accu + 1, cell.next) - } - -let rec do_bucket_iter = (~f, buckets) => - switch C.toOpt(buckets) { - | None => () - | Some(cell) => - f(. cell.key, cell.value)->ignore - do_bucket_iter(~f, cell.next) - } - -let forEachU = (h, f) => { - let d = h.C.buckets - for i in 0 to A.length(d) - 1 { - do_bucket_iter(~f, A.getUnsafe(d, i)) - } -} - -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)) - } - -let reduceU = (h, init, f) => { - let d = h.C.buckets - let accu = ref(init) - for i in 0 to A.length(d) - 1 { - accu.contents = do_bucket_fold(~f, A.getUnsafe(d, i), accu.contents) - } - accu.contents -} - -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) => { - 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 l = bucketLength(0, b) - A.setUnsafe(histo, l, A.getUnsafe(histo, l) + 1) - }) - histo -} - -let logStats = h => { - let histogram = getBucketHistogram(h) - Js.log({ - "bindings": h.C.size, - "buckets": A.length(h.C.buckets), - "histogram": histogram, - }) -} - -/** 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) { - | None => - h.C.size = h.C.size - 1 /* delete */ - switch C.toOpt(n) { - | Some(nextCell) => filterMapInplaceBucket(f, h, i, prec, nextCell) - | None => - switch C.toOpt(prec) { - | None => A.setUnsafe(h.C.buckets, i, prec) - | Some(cell) => cell.next = n - } - } - | Some(data) => - /* replace */ - let bucket = C.return(cell) - switch C.toOpt(prec) { - | None => A.setUnsafe(h.C.buckets, i, bucket) - | Some(_) => cell.next = bucket - } - cell.value = data - switch C.toOpt(n) { - | None => cell.next = n - | Some(nextCell) => filterMapInplaceBucket(f, h, i, bucket, nextCell) - } - } -} - -let keepMapInPlaceU = (h, f) => { - let h_buckets = h.C.buckets - for i in 0 to A.length(h_buckets) - 1 { - let v = A.getUnsafe(h_buckets, i) - switch C.toOpt(v) { - | None => () - | Some(v) => filterMapInplaceBucket(f, h, i, C.emptyOpt, v) - } - } -} - -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)) - switch C.toOpt(cell.next) { - | None => i + 1 - | Some(v) => fillArray(i + 1, arr, v) - } -} - -/* let toArray h = - let d =h.bucketsin - let current = ref 0 in - let arr = A.makeUninitializedUnsafe (C.sizeGet h) in - for i = 0 to A.length d - 1 do - let cell = A.getUnsafe d i in - match C.toOpt cell with - | None -> () - | Some cell -> - current .contents<- fillArray current.contents arr cell - done; - arr */ - -let rec fillArrayMap = (i, arr, cell, f) => { - A.setUnsafe(arr, i, f(. cell)) - switch C.toOpt(cell.next) { - | None => i + 1 - | Some(v) => fillArrayMap(i + 1, arr, v, f) - } -} - -let linear = (h, f) => { - let d = h.C.buckets - let current = ref(0) - let arr = A.makeUninitializedUnsafe(h.C.size) - for i in 0 to A.length(d) - 1 { - let cell = A.getUnsafe(d, i) - switch C.toOpt(cell) { - | None => () - | Some(cell) => current.contents = fillArrayMap(current.contents, arr, cell, 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)) diff --git a/jscomp/others/belt_internalBuckets.resi b/jscomp/others/belt_internalBuckets.resi deleted file mode 100644 index 149309b051a..00000000000 --- a/jscomp/others/belt_internalBuckets.resi +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (C) 2017 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -module C = Belt_internalBucketsType - -type rec bucket<'a, 'b> = { - mutable key: 'a, - mutable value: 'b, - mutable next: C.opt>, -} -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 forEach: (t<_, _, 'a, 'b>, ('a, 'b) => 'c) => unit - -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 keepMapInPlace: (t<_, _, 'a, 'b>, ('a, 'b) => option<'b>) => unit - -let fillArray: (int, array<('a, 'b)>, bucket<'a, 'b>) => int - -let keysToArray: t<_, _, 'a, _> => array<'a> - -let valuesToArray: t<_, _, _, 'b> => array<'b> - -let toArray: t<_, _, 'a, 'b> => array<('a, 'b)> - -let getBucketHistogram: t<_> => array diff --git a/jscomp/others/belt_internalBucketsType.res b/jscomp/others/belt_internalBucketsType.res deleted file mode 100644 index d7d0c686a9f..00000000000 --- a/jscomp/others/belt_internalBucketsType.res +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ -type opt<'a> = Js.undefined<'a> - -type container<'hash, 'eq, 'c> = { - mutable size: int /* number of entries */, - mutable buckets: array> /* the buckets */, - hash: 'hash, - eq: 'eq, -} - -module A = Belt_Array -external toOpt: opt<'a> => option<'a> = "#undefined_to_opt" -external return: 'a => opt<'a> = "%identity" - -let emptyOpt = Js.undefined -let rec power_2_above = (x, n) => - if x >= n { - x - } else if x * 2 < x { - x /* overflow */ - } else { - power_2_above(x * 2, n) - } - -let make = (~hash, ~eq, ~hintSize) => { - let s = power_2_above(16, hintSize) - { - size: 0, - buckets: A.makeUninitialized(s), - hash, - eq, - } -} - -let clear = h => { - h.size = 0 - let h_buckets = h.buckets - let len = A.length(h_buckets) - for i in 0 to len - 1 { - A.setUnsafe(h_buckets, i, emptyOpt) - } -} - -let isEmpty = h => h.size == 0 diff --git a/jscomp/others/belt_internalBucketsType.resi b/jscomp/others/belt_internalBucketsType.resi deleted file mode 100644 index cab76a7d980..00000000000 --- a/jscomp/others/belt_internalBucketsType.resi +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2018 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -type opt<'a> = Js.undefined<'a> -type container<'hash, 'eq, 'c> = { - mutable size: int /* number of entries */, - mutable buckets: array> /* the buckets */, - hash: 'hash, - eq: 'eq, -} - -external toOpt: opt<'a> => option<'a> = "#undefined_to_opt" -external return: 'a => opt<'a> = "%identity" - -let emptyOpt: Js.undefined<'a> -let make: (~hash: 'hash, ~eq: 'eq, ~hintSize: int) => container<'hash, 'eq, _> - -let clear: container<_> => unit - -let isEmpty: container<_> => bool diff --git a/jscomp/others/belt_internalMapInt.res b/jscomp/others/belt_internalMapInt.res deleted file mode 100644 index 86d18f7beab..00000000000 --- a/jscomp/others/belt_internalMapInt.res +++ /dev/null @@ -1,288 +0,0 @@ -@@bs.config({flags: ["-bs-noassertfalse"]}) - -type key = int - -module N = Belt_internalAVLtree -module A = Belt_Array -module S = Belt_SortArray - -type t<'a> = N.t - -let rec add = (t, x: key, data: _) => - switch t { - | None => N.singleton(x, data) - | Some(n) => - let k = n.N.key - if x == k { - Some(N.updateValue(n, data)) - } else { - let v = n.N.value - if x < k { - N.bal(add(n.N.left, x, data), k, v, n.N.right) - } else { - N.bal(n.N.left, k, v, add(n.N.right, x, data)) - } - } - } - -let rec get = (n, x: key) => - switch n { - | None => None - | Some(n) => - let v = n.N.key - if x == v { - Some(n.N.value) - } else { - get( - if x < v { - n.N.left - } else { - n.N.right - }, - x, - ) - } - } - -let rec getUndefined = (n, x: key) => - switch n { - | None => Js.undefined - | Some(n) => - let v = n.N.key - if x == v { - Js.Undefined.return(n.N.value) - } else { - getUndefined( - if x < v { - n.N.left - } else { - n.N.right - }, - x, - ) - } - } - -let rec getExn = (n, x: key) => - switch n { - | None => raise(Not_found) - | Some(n) => - let v = n.N.key - if x == v { - n.N.value - } else { - getExn( - if x < v { - n.N.left - } else { - n.N.right - }, - x, - ) - } - } - -let rec getWithDefault = (n, x: key, def) => - switch n { - | None => def - | Some(n) => - let v = n.N.key - if x == v { - n.N.value - } else { - getWithDefault( - if x < v { - n.N.left - } else { - n.N.right - }, - x, - def, - ) - } - } - -let rec has = (n, x: key) => - switch n { - | None => false - | Some(n) /* Node(l, v, d, r, _) */ => - let v = n.N.key - x == v || - has( - if x < v { - n.N.left - } else { - n.N.right - }, - x, - ) - } - -let rec remove = (n, x: key) => - switch n { - | None => n - | Some(n) => - let {N.left: l, key: v, right: r} = n - if x == v { - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (_, Some(rn)) => - let (kr, vr) = (ref(rn.key), ref(rn.value)) - let r = N.removeMinAuxWithRef(rn, kr, vr) - N.bal(l, kr.contents, vr.contents, r) - } - } else if x < v { - open N - bal(remove(l, x), v, n.value, r) - } else { - open N - bal(l, v, n.value, remove(r, x)) - } - } - -let rec splitAux = (x: key, n: N.node<_>): (t<_>, option<_>, t<_>) => { - let {N.left: l, key: v, value: d, right: r} = n - if x == v { - (l, Some(d), r) - } else if x < v { - switch l { - | None => (None, None, Some(n)) - | Some(l) => - let (ll, pres, rl) = splitAux(x, l) - (ll, pres, N.join(rl, v, d, r)) - } - } else { - switch r { - | None => (Some(n), None, None) - | Some(r) => - let (lr, pres, rr) = splitAux(x, r) - (N.join(l, v, d, lr), pres, rr) - } - } -} - -let split = (x: key, n) => - switch n { - | None => (None, None, None) - | Some(n) => splitAux(x, n) - } - -let rec mergeU = (s1, s2, f) => - switch (s1, s2) { - | (None, None) => None - | (Some(n) /* (Node (l1, v1, d1, r1, h1), _) */, _) - if n.N.height >= - switch s2 { - | None => 0 - | Some(n) => n.N.height - } => - 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)) - | (_, 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)) - | _ => assert(false) - } - -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) - if cx == 0 { - compareAux(N.stackAllLeft(h1.N.right, t1), N.stackAllLeft(h2.N.right, t2), vcmp) - } else { - cx - } - } else { - c - } - | (_, _) => 0 - } - -let cmpU = (s1, s2, cmp) => { - let (len1, len2) = (N.size(s1), N.size(s2)) - if len1 == len2 { - compareAux(N.stackAllLeft(s1, list{}), N.stackAllLeft(s2, list{}), cmp) - } else if len1 < len2 { - -1 - } else { - 1 - } -} - -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) { - eqAux(N.stackAllLeft(h1.N.right, t1), N.stackAllLeft(h2.N.right, t2), eq) - } else { - false - } - | (_, _) => true - } /* end */ - -let eqU = (s1, s2, eq) => { - let (len1, len2) = (N.size(s1), N.size(s2)) - if len1 == len2 { - eqAux(N.stackAllLeft(s1, list{}), N.stackAllLeft(s2, list{}), eq) - } else { - false - } -} - -let eq = (s1, s2, f) => eqU(s1, s2, (. a, b) => f(a, b)) - -let rec addMutate = (t: t<_>, x, data): t<_> => - switch t { - | None => N.singleton(x, data) - | Some(nt) => - let k = nt.N.key - - /* let c = (Belt_Cmp.getCmpInternal cmp) x k [@bs] in */ - if x == k { - nt.N.key = x - nt.value = data - Some(nt) - } else { - let (l, r) = (nt.N.left, nt.N.right) - if x < k { - let ll = addMutate(l, x, data) - nt.left = ll - } else { - nt.right = addMutate(r, x, data) - } - Some(N.balMutate(nt)) - } - } - -let fromArray = (xs: array<(key, _)>) => { - let len = A.length(xs) - if len == 0 { - None - } else { - let next = ref(S.strictlySortedLengthU(xs, (. (x0, _), (y0, _)) => x0 < y0)) - - let result = ref( - if next.contents >= 0 { - N.fromSortedArrayAux(xs, 0, next.contents) - } else { - next.contents = -next.contents - N.fromSortedArrayRevAux(xs, next.contents - 1, next.contents) - }, - ) - for i in next.contents to len - 1 { - let (k, v) = A.getUnsafe(xs, i) - result.contents = addMutate(result.contents, k, v) - } - result.contents - } -} diff --git a/jscomp/others/belt_internalMapString.res b/jscomp/others/belt_internalMapString.res deleted file mode 100644 index e088f697811..00000000000 --- a/jscomp/others/belt_internalMapString.res +++ /dev/null @@ -1,288 +0,0 @@ -@@bs.config({flags: ["-bs-noassertfalse"]}) - -type key = string - -module N = Belt_internalAVLtree -module A = Belt_Array -module S = Belt_SortArray - -type t<'a> = N.t - -let rec add = (t, x: key, data: _) => - switch t { - | None => N.singleton(x, data) - | Some(n) => - let k = n.N.key - if x == k { - Some(N.updateValue(n, data)) - } else { - let v = n.N.value - if x < k { - N.bal(add(n.N.left, x, data), k, v, n.N.right) - } else { - N.bal(n.N.left, k, v, add(n.N.right, x, data)) - } - } - } - -let rec get = (n, x: key) => - switch n { - | None => None - | Some(n) => - let v = n.N.key - if x == v { - Some(n.N.value) - } else { - get( - if x < v { - n.N.left - } else { - n.N.right - }, - x, - ) - } - } - -let rec getUndefined = (n, x: key) => - switch n { - | None => Js.undefined - | Some(n) => - let v = n.N.key - if x == v { - Js.Undefined.return(n.N.value) - } else { - getUndefined( - if x < v { - n.N.left - } else { - n.N.right - }, - x, - ) - } - } - -let rec getExn = (n, x: key) => - switch n { - | None => raise(Not_found) - | Some(n) => - let v = n.N.key - if x == v { - n.N.value - } else { - getExn( - if x < v { - n.N.left - } else { - n.N.right - }, - x, - ) - } - } - -let rec getWithDefault = (n, x: key, def) => - switch n { - | None => def - | Some(n) => - let v = n.N.key - if x == v { - n.N.value - } else { - getWithDefault( - if x < v { - n.N.left - } else { - n.N.right - }, - x, - def, - ) - } - } - -let rec has = (n, x: key) => - switch n { - | None => false - | Some(n) /* Node(l, v, d, r, _) */ => - let v = n.N.key - x == v || - has( - if x < v { - n.N.left - } else { - n.N.right - }, - x, - ) - } - -let rec remove = (n, x: key) => - switch n { - | None => n - | Some(n) => - let {N.left: l, key: v, right: r} = n - if x == v { - switch (l, r) { - | (None, _) => r - | (_, None) => l - | (_, Some(rn)) => - let (kr, vr) = (ref(rn.key), ref(rn.value)) - let r = N.removeMinAuxWithRef(rn, kr, vr) - N.bal(l, kr.contents, vr.contents, r) - } - } else if x < v { - open N - bal(remove(l, x), v, n.value, r) - } else { - open N - bal(l, v, n.value, remove(r, x)) - } - } - -let rec splitAux = (x: key, n: N.node<_>): (t<_>, option<_>, t<_>) => { - let {N.left: l, key: v, value: d, right: r} = n - if x == v { - (l, Some(d), r) - } else if x < v { - switch l { - | None => (None, None, Some(n)) - | Some(l) => - let (ll, pres, rl) = splitAux(x, l) - (ll, pres, N.join(rl, v, d, r)) - } - } else { - switch r { - | None => (Some(n), None, None) - | Some(r) => - let (lr, pres, rr) = splitAux(x, r) - (N.join(l, v, d, lr), pres, rr) - } - } -} - -let split = (x: key, n) => - switch n { - | None => (None, None, None) - | Some(n) => splitAux(x, n) - } - -let rec mergeU = (s1, s2, f) => - switch (s1, s2) { - | (None, None) => None - | (Some(n) /* (Node (l1, v1, d1, r1, h1), _) */, _) - if n.N.height >= - switch s2 { - | None => 0 - | Some(n) => n.N.height - } => - 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)) - | (_, 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)) - | _ => assert(false) - } - -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) - if cx == 0 { - compareAux(N.stackAllLeft(h1.N.right, t1), N.stackAllLeft(h2.N.right, t2), vcmp) - } else { - cx - } - } else { - c - } - | (_, _) => 0 - } - -let cmpU = (s1, s2, cmp) => { - let (len1, len2) = (N.size(s1), N.size(s2)) - if len1 == len2 { - compareAux(N.stackAllLeft(s1, list{}), N.stackAllLeft(s2, list{}), cmp) - } else if len1 < len2 { - -1 - } else { - 1 - } -} - -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) { - eqAux(N.stackAllLeft(h1.N.right, t1), N.stackAllLeft(h2.N.right, t2), eq) - } else { - false - } - | (_, _) => true - } /* end */ - -let eqU = (s1, s2, eq) => { - let (len1, len2) = (N.size(s1), N.size(s2)) - if len1 == len2 { - eqAux(N.stackAllLeft(s1, list{}), N.stackAllLeft(s2, list{}), eq) - } else { - false - } -} - -let eq = (s1, s2, f) => eqU(s1, s2, (. a, b) => f(a, b)) - -let rec addMutate = (t: t<_>, x, data): t<_> => - switch t { - | None => N.singleton(x, data) - | Some(nt) => - let k = nt.N.key - - /* let c = (Belt_Cmp.getCmpInternal cmp) x k [@bs] in */ - if x == k { - nt.N.key = x - nt.value = data - Some(nt) - } else { - let (l, r) = (nt.N.left, nt.N.right) - if x < k { - let ll = addMutate(l, x, data) - nt.left = ll - } else { - nt.right = addMutate(r, x, data) - } - Some(N.balMutate(nt)) - } - } - -let fromArray = (xs: array<(key, _)>) => { - let len = A.length(xs) - if len == 0 { - None - } else { - let next = ref(S.strictlySortedLengthU(xs, (. (x0, _), (y0, _)) => x0 < y0)) - - let result = ref( - if next.contents >= 0 { - N.fromSortedArrayAux(xs, 0, next.contents) - } else { - next.contents = -next.contents - N.fromSortedArrayRevAux(xs, next.contents - 1, next.contents) - }, - ) - for i in next.contents to len - 1 { - let (k, v) = A.getUnsafe(xs, i) - result.contents = addMutate(result.contents, k, v) - } - result.contents - } -} diff --git a/jscomp/others/belt_internalSetBuckets.res b/jscomp/others/belt_internalSetBuckets.res deleted file mode 100644 index 56fcb8c048b..00000000000 --- a/jscomp/others/belt_internalSetBuckets.res +++ /dev/null @@ -1,161 +0,0 @@ -/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -/* We do dynamic hashing, and resize the table and rehash the elements - when buckets become too long. */ -module C = Belt_internalBucketsType -/* TODO: - the current implementation relies on the fact that bucket - empty value is `undefined` in both places, - in theory, it can be different - -*/ -type rec bucket<'a> = { - mutable key: 'a, - mutable next: C.opt>, -} -and t<'hash, 'eq, 'a> = C.container<'hash, 'eq, bucket<'a>> - -module A = Belt_Array - -let rec copy = (x: t<_>): t<_> => { - hash: x.hash, - eq: x.eq, - size: x.size, - buckets: copyBuckets(x.buckets), -} -and copyBuckets = (buckets: array>>) => { - let len = A.length(buckets) - let newBuckets = A.makeUninitializedUnsafe(len) - for i in 0 to len - 1 { - A.setUnsafe(newBuckets, i, copyBucket(A.getUnsafe(buckets, i))) - } - newBuckets -} -and copyBucket = c => - switch C.toOpt(c) { - | None => c - | Some(c) => - let head = { - key: c.key, - next: C.emptyOpt, - } - copyAuxCont(c.next, head) - C.return(head) - } -and copyAuxCont = (c, prec) => - switch C.toOpt(c) { - | None => () - | Some(nc) => - let ncopy = {key: nc.key, next: C.emptyOpt} - prec.next = C.return(ncopy) - copyAuxCont(nc.next, ncopy) - } - -let rec bucketLength = (accu, buckets) => - switch C.toOpt(buckets) { - | None => accu - | Some(cell) => bucketLength(accu + 1, cell.next) - } - -let rec doBucketIter = (~f, buckets) => - switch C.toOpt(buckets) { - | None => () - | Some(cell) => - f(. cell.key) - doBucketIter(~f, cell.next) - } - -let forEachU = (h, f) => { - let d = h.C.buckets - for i in 0 to A.length(d) - 1 { - doBucketIter(~f, A.getUnsafe(d, i)) - } -} - -let forEach = (h, f) => forEachU(h, (. a) => f(a)) - -let rec fillArray = (i, arr, cell) => { - A.setUnsafe(arr, i, cell.key) - switch C.toOpt(cell.next) { - | None => i + 1 - | Some(v) => fillArray(i + 1, arr, v) - } -} - -let toArray = h => { - let d = h.C.buckets - let current = ref(0) - let arr = A.makeUninitializedUnsafe(h.C.size) - for i in 0 to A.length(d) - 1 { - let cell = A.getUnsafe(d, i) - switch C.toOpt(cell) { - | None => () - | Some(cell) => current.contents = fillArray(current.contents, arr, cell) - } - } - arr -} - -let rec doBucketFold = (~f, b, accu) => - switch C.toOpt(b) { - | None => accu - | Some(cell) => doBucketFold(~f, cell.next, f(. accu, cell.key)) - } - -let reduceU = (h, init, f) => { - let d = h.C.buckets - let accu = ref(init) - for i in 0 to A.length(d) - 1 { - accu.contents = doBucketFold(~f, A.getUnsafe(d, i), accu.contents) - } - accu.contents -} - -let reduce = (h, init, f) => reduceU(h, init, (. a, b) => f(a, b)) - -let getMaxBucketLength = h => - 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 l = bucketLength(0, b) - A.setUnsafe(histo, l, A.getUnsafe(histo, l) + 1) - }) - histo -} - -let logStats = h => { - let histogram = getBucketHistogram(h) - Js.log({ - "bindings": h.C.size, - "buckets": A.length(h.C.buckets), - "histogram": histogram, - }) -} diff --git a/jscomp/others/belt_internalSetBuckets.resi b/jscomp/others/belt_internalSetBuckets.resi deleted file mode 100644 index bd71b16923d..00000000000 --- a/jscomp/others/belt_internalSetBuckets.resi +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2018 Authors of ReScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * 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. */ - -module C = Belt_internalBucketsType - -type rec bucket<'a> = { - mutable key: 'a, - mutable next: C.opt>, -} -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 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 reduce: (t<_, _, 'a>, 'b, ('b, 'a) => 'b) => 'b - -let logStats: t<_> => unit - -let getBucketHistogram: t<_> => array diff --git a/jscomp/others/belt_internalSetInt.res b/jscomp/others/belt_internalSetInt.res deleted file mode 100644 index 676e9557782..00000000000 --- a/jscomp/others/belt_internalSetInt.res +++ /dev/null @@ -1,164 +0,0 @@ -type value = int -module S = Belt_SortArrayInt - -module N = Belt_internalAVLset -module A = Belt_Array - -type t = N.t - -let rec has = (t: t, x: value) => - switch t { - | None => false - | Some(n) => - let v = n.value - x == v || - has( - if x < v { - n.left - } else { - n.right - }, - x, - ) - } - -let rec compareAux = (e1, e2) => - switch (e1, e2) { - | (list{h1, ...t1}, list{h2, ...t2}) => - let (k1: value, k2) = (h1.N.value, h2.N.value) - if k1 == k2 { - compareAux(N.stackAllLeft(h1.right, t1), N.stackAllLeft(h2.right, t2)) - } else if k1 < k2 { - -1 - } else { - 1 - } - | (_, _) => 0 - } - -let cmp = (s1, s2) => { - let (len1, len2) = (N.size(s1), N.size(s2)) - if len1 == len2 { - compareAux(N.stackAllLeft(s1, list{}), N.stackAllLeft(s2, list{})) - } else if len1 < len2 { - -1 - } else { - 1 - } -} - -let eq = (s1: t, s2) => cmp(s1, s2) == 0 - -/* This algorithm applies to BST, it does not need to be balanced tree */ -let rec subset = (s1: t, s2: t) => - switch (s1, s2) { - | (None, _) => true - | (_, None) => false - | (Some(t1), Some(t2)) /* Node (l1, v1, r1, _), (Node (l2, v2, r2, _) as t2) */ => - let {N.left: l1, value: v1, right: r1} = t1 - let {N.left: l2, value: v2, right: r2} = t2 - if v1 == v2 { - subset(l1, l2) && subset(r1, r2) - } else if v1 < v2 { - subset(N.create(l1, v1, None), l2) && subset(r1, s2) - } else { - subset(N.create(None, v1, r1), r2) && subset(l1, s2) - } - } - -let rec get = (n: t, x: value) => - switch n { - | None => None - | Some(t) => - let v = t.value - if x == v { - Some(v) - } else { - get( - if x < v { - t.left - } else { - t.right - }, - x, - ) - } - } - -let rec getUndefined = (n: t, x: value) => - switch n { - | None => Js.undefined - | Some(t) => - let v = t.value - if x == v { - Js.Undefined.return(v) - } else { - getUndefined( - if x < v { - t.left - } else { - t.right - }, - x, - ) - } - } - -let rec getExn = (n: t, x: value) => - switch n { - | None => raise(Not_found) - | Some(t) => - let v = t.value - if x == v { - v - } else { - getExn( - if x < v { - t.left - } else { - t.right - }, - x, - ) - } - } - -/* ************************************************************************** */ -let rec addMutate = (t, x: value) => - switch t { - | None => N.singleton(x) - | Some(nt) => - let k = nt.N.value - if x == k { - t - } else { - let {N.left: l, right: r} = nt - if x < k { - nt.left = addMutate(l, x) - } else { - nt.right = addMutate(r, x) - } - Some(N.balMutate(nt)) - } - } - -let fromArray = (xs: array) => { - let len = A.length(xs) - if len == 0 { - None - } else { - let next = ref(S.strictlySortedLength(xs)) - let result = ref( - if next.contents >= 0 { - N.fromSortedArrayAux(xs, 0, next.contents) - } else { - next.contents = -next.contents - N.fromSortedArrayRevAux(xs, next.contents - 1, next.contents) - }, - ) - for i in next.contents to len - 1 { - result.contents = addMutate(result.contents, A.getUnsafe(xs, i)) - } - result.contents - } -} diff --git a/jscomp/others/belt_internalSetString.res b/jscomp/others/belt_internalSetString.res deleted file mode 100644 index ef38792cc86..00000000000 --- a/jscomp/others/belt_internalSetString.res +++ /dev/null @@ -1,164 +0,0 @@ -type value = string -module S = Belt_SortArrayString - -module N = Belt_internalAVLset -module A = Belt_Array - -type t = N.t - -let rec has = (t: t, x: value) => - switch t { - | None => false - | Some(n) => - let v = n.value - x == v || - has( - if x < v { - n.left - } else { - n.right - }, - x, - ) - } - -let rec compareAux = (e1, e2) => - switch (e1, e2) { - | (list{h1, ...t1}, list{h2, ...t2}) => - let (k1: value, k2) = (h1.N.value, h2.N.value) - if k1 == k2 { - compareAux(N.stackAllLeft(h1.right, t1), N.stackAllLeft(h2.right, t2)) - } else if k1 < k2 { - -1 - } else { - 1 - } - | (_, _) => 0 - } - -let cmp = (s1, s2) => { - let (len1, len2) = (N.size(s1), N.size(s2)) - if len1 == len2 { - compareAux(N.stackAllLeft(s1, list{}), N.stackAllLeft(s2, list{})) - } else if len1 < len2 { - -1 - } else { - 1 - } -} - -let eq = (s1: t, s2) => cmp(s1, s2) == 0 - -/* This algorithm applies to BST, it does not need to be balanced tree */ -let rec subset = (s1: t, s2: t) => - switch (s1, s2) { - | (None, _) => true - | (_, None) => false - | (Some(t1), Some(t2)) /* Node (l1, v1, r1, _), (Node (l2, v2, r2, _) as t2) */ => - let {N.left: l1, value: v1, right: r1} = t1 - let {N.left: l2, value: v2, right: r2} = t2 - if v1 == v2 { - subset(l1, l2) && subset(r1, r2) - } else if v1 < v2 { - subset(N.create(l1, v1, None), l2) && subset(r1, s2) - } else { - subset(N.create(None, v1, r1), r2) && subset(l1, s2) - } - } - -let rec get = (n: t, x: value) => - switch n { - | None => None - | Some(t) => - let v = t.value - if x == v { - Some(v) - } else { - get( - if x < v { - t.left - } else { - t.right - }, - x, - ) - } - } - -let rec getUndefined = (n: t, x: value) => - switch n { - | None => Js.undefined - | Some(t) => - let v = t.value - if x == v { - Js.Undefined.return(v) - } else { - getUndefined( - if x < v { - t.left - } else { - t.right - }, - x, - ) - } - } - -let rec getExn = (n: t, x: value) => - switch n { - | None => raise(Not_found) - | Some(t) => - let v = t.value - if x == v { - v - } else { - getExn( - if x < v { - t.left - } else { - t.right - }, - x, - ) - } - } - -/* ************************************************************************** */ -let rec addMutate = (t, x: value) => - switch t { - | None => N.singleton(x) - | Some(nt) => - let k = nt.N.value - if x == k { - t - } else { - let {N.left: l, right: r} = nt - if x < k { - nt.left = addMutate(l, x) - } else { - nt.right = addMutate(r, x) - } - Some(N.balMutate(nt)) - } - } - -let fromArray = (xs: array) => { - let len = A.length(xs) - if len == 0 { - None - } else { - let next = ref(S.strictlySortedLength(xs)) - let result = ref( - if next.contents >= 0 { - N.fromSortedArrayAux(xs, 0, next.contents) - } else { - next.contents = -next.contents - N.fromSortedArrayRevAux(xs, next.contents - 1, next.contents) - }, - ) - for i in next.contents to len - 1 { - result.contents = addMutate(result.contents, A.getUnsafe(xs, i)) - } - result.contents - } -} diff --git a/jscomp/others/release.ninja b/jscomp/others/release.ninja index 116df80fef1..2fb56a64b1d 100644 --- a/jscomp/others/release.ninja +++ b/jscomp/others/release.ninja @@ -75,87 +75,7 @@ o others/jsxPPXReactSupportC.cmi others/jsxPPXReactSupportC.cmj : cc others/jsxP o others/jsxPPXReactSupportU.cmi others/jsxPPXReactSupportU.cmj : cc others/jsxPPXReactSupportU.res | others/belt_internals.cmi others/js.cmi others/jsxU.cmj $bsc o others/jsxU.cmi others/jsxU.cmj : cc others/jsxU.res | others/belt_internals.cmi others/js.cmi $bsc o js_pkg : phony others/js_OO.cmi others/js_OO.cmj others/js_array.cmi others/js_array.cmj others/js_array2.cmi others/js_array2.cmj others/js_bigint.cmi others/js_bigint.cmj others/js_blob.cmi others/js_blob.cmj others/js_cast.cmi others/js_cast.cmj others/js_console.cmi others/js_console.cmj others/js_date.cmi others/js_date.cmj others/js_dict.cmi others/js_dict.cmj others/js_exn.cmi others/js_exn.cmj others/js_file.cmi others/js_file.cmj others/js_float.cmi others/js_float.cmj others/js_global.cmi others/js_global.cmj others/js_int.cmi others/js_int.cmj others/js_json.cmi others/js_json.cmj others/js_list.cmi others/js_list.cmj others/js_map.cmi others/js_map.cmj others/js_mapperRt.cmi others/js_mapperRt.cmj others/js_math.cmi others/js_math.cmj others/js_null.cmi others/js_null.cmj others/js_null_undefined.cmi others/js_null_undefined.cmj others/js_obj.cmi others/js_obj.cmj others/js_option.cmi others/js_option.cmj others/js_promise.cmi others/js_promise.cmj others/js_promise2.cmi others/js_promise2.cmj others/js_re.cmi others/js_re.cmj others/js_result.cmi others/js_result.cmj others/js_set.cmi others/js_set.cmj others/js_string.cmi others/js_string.cmj others/js_string2.cmi others/js_string2.cmj others/js_typed_array.cmi others/js_typed_array.cmj others/js_typed_array2.cmi others/js_typed_array2.cmj others/js_types.cmi others/js_types.cmj others/js_undefined.cmi others/js_undefined.cmj others/js_vector.cmi others/js_vector.cmj others/js_weakmap.cmi others/js_weakmap.cmj others/js_weakset.cmi others/js_weakset.cmj others/jsxC.cmi others/jsxC.cmj others/jsxDOMC.cmi others/jsxDOMC.cmj others/jsxDOMStyle.cmi others/jsxDOMStyle.cmj others/jsxDOMU.cmi others/jsxDOMU.cmj others/jsxEventC.cmi others/jsxEventC.cmj others/jsxEventU.cmi others/jsxEventU.cmj others/jsxPPXReactSupportC.cmi others/jsxPPXReactSupportC.cmj others/jsxPPXReactSupportU.cmi others/jsxPPXReactSupportU.cmj others/jsxU.cmi others/jsxU.cmj -o others/belt_Array.cmj : cc_cmi others/belt_Array.res | others/belt.cmi others/belt_Array.cmi others/belt_internals.cmi others/js.cmi others/js.cmj others/js_math.cmj $bsc js_pkg -o others/belt_Array.cmi : cc others/belt_Array.resi | others/belt.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_Float.cmj : cc_cmi others/belt_Float.res | others/belt.cmi others/belt_Float.cmi others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_Float.cmi : cc others/belt_Float.resi | others/belt_internals.cmi others/js.cmi $bsc -o others/belt_HashMap.cmj : cc_cmi others/belt_HashMap.res | others/belt.cmi others/belt_Array.cmj others/belt_HashMap.cmi others/belt_HashMapInt.cmj others/belt_HashMapString.cmj others/belt_Id.cmj others/belt_internalBuckets.cmj others/belt_internalBucketsType.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_HashMap.cmi : cc others/belt_HashMap.resi | others/belt.cmi others/belt_HashMapInt.cmi others/belt_HashMapString.cmi others/belt_Id.cmi others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_HashMapInt.cmj : cc_cmi others/belt_HashMapInt.res | others/belt.cmi others/belt_Array.cmj others/belt_HashMapInt.cmi others/belt_internalBuckets.cmj others/belt_internalBucketsType.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_HashMapInt.cmi : cc others/belt_HashMapInt.resi | others/belt_internals.cmi others/js.cmi $bsc -o others/belt_HashMapString.cmj : cc_cmi others/belt_HashMapString.res | others/belt.cmi others/belt_Array.cmj others/belt_HashMapString.cmi others/belt_internalBuckets.cmj others/belt_internalBucketsType.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_HashMapString.cmi : cc others/belt_HashMapString.resi | others/belt_internals.cmi others/js.cmi $bsc -o others/belt_HashSet.cmj : cc_cmi others/belt_HashSet.res | others/belt.cmi others/belt_Array.cmj others/belt_HashSet.cmi others/belt_HashSetInt.cmj others/belt_HashSetString.cmj others/belt_Id.cmj others/belt_internalBucketsType.cmj others/belt_internalSetBuckets.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_HashSet.cmi : cc others/belt_HashSet.resi | others/belt.cmi others/belt_HashSetInt.cmi others/belt_HashSetString.cmi others/belt_Id.cmi others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_HashSetInt.cmj : cc_cmi others/belt_HashSetInt.res | others/belt.cmi others/belt_Array.cmj others/belt_HashSetInt.cmi others/belt_internalBucketsType.cmj others/belt_internalSetBuckets.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_HashSetInt.cmi : cc others/belt_HashSetInt.resi | others/belt_internals.cmi others/js.cmi $bsc -o others/belt_HashSetString.cmj : cc_cmi others/belt_HashSetString.res | others/belt.cmi others/belt_Array.cmj others/belt_HashSetString.cmi others/belt_internalBucketsType.cmj others/belt_internalSetBuckets.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_HashSetString.cmi : cc others/belt_HashSetString.resi | others/belt_internals.cmi others/js.cmi $bsc -o others/belt_Id.cmj : cc_cmi others/belt_Id.res | others/belt.cmi others/belt_Id.cmi others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_Id.cmi : cc others/belt_Id.resi | others/belt_internals.cmi others/js.cmi $bsc -o others/belt_Int.cmj : cc_cmi others/belt_Int.res | others/belt.cmi others/belt_Int.cmi others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_Int.cmi : cc others/belt_Int.resi | others/belt_internals.cmi others/js.cmi $bsc -o others/belt_List.cmj : cc_cmi others/belt_List.res | others/belt.cmi others/belt_Array.cmj others/belt_List.cmi others/belt_SortArray.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_List.cmi : cc others/belt_List.resi | others/belt_internals.cmi others/js.cmi $bsc -o others/belt_Map.cmj : cc_cmi others/belt_Map.res | others/belt.cmi others/belt_Id.cmj others/belt_Map.cmi others/belt_MapDict.cmj others/belt_MapInt.cmj others/belt_MapString.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_Map.cmi : cc others/belt_Map.resi | others/belt.cmi others/belt_Id.cmi others/belt_MapDict.cmi others/belt_MapInt.cmi others/belt_MapString.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_MapDict.cmj : cc_cmi others/belt_MapDict.res | others/belt.cmi others/belt_Array.cmj others/belt_Id.cmj others/belt_MapDict.cmi others/belt_internalAVLtree.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_MapDict.cmi : cc others/belt_MapDict.resi | others/belt.cmi others/belt_Id.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_MapInt.cmj : cc_cmi others/belt_MapInt.res | others/belt.cmi others/belt_Array.cmj others/belt_MapInt.cmi others/belt_internalAVLtree.cmj others/belt_internalMapInt.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_MapInt.cmi : cc others/belt_MapInt.resi | others/belt.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_MapString.cmj : cc_cmi others/belt_MapString.res | others/belt.cmi others/belt_Array.cmj others/belt_MapString.cmi others/belt_internalAVLtree.cmj others/belt_internalMapString.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_MapString.cmi : cc others/belt_MapString.resi | others/belt.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_MutableMap.cmj : cc_cmi others/belt_MutableMap.res | others/belt.cmi others/belt_Array.cmj others/belt_Id.cmj others/belt_MutableMap.cmi others/belt_MutableMapInt.cmj others/belt_MutableMapString.cmj others/belt_internalAVLtree.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_MutableMap.cmi : cc others/belt_MutableMap.resi | others/belt.cmi others/belt_Id.cmi others/belt_MutableMapInt.cmi others/belt_MutableMapString.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_MutableMapInt.cmj : cc_cmi others/belt_MutableMapInt.res | others/belt.cmi others/belt_Array.cmj others/belt_MutableMapInt.cmi others/belt_internalAVLtree.cmj others/belt_internalMapInt.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_MutableMapInt.cmi : cc others/belt_MutableMapInt.resi | others/belt.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_MutableMapString.cmj : cc_cmi others/belt_MutableMapString.res | others/belt.cmi others/belt_Array.cmj others/belt_MutableMapString.cmi others/belt_internalAVLtree.cmj others/belt_internalMapString.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_MutableMapString.cmi : cc others/belt_MutableMapString.resi | others/belt.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_MutableQueue.cmj : cc_cmi others/belt_MutableQueue.res | others/belt.cmi others/belt_Array.cmj others/belt_MutableQueue.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_MutableQueue.cmi : cc others/belt_MutableQueue.resi | others/belt.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_MutableSet.cmj : cc_cmi others/belt_MutableSet.res | others/belt.cmi others/belt_Array.cmj others/belt_Id.cmj others/belt_MutableSet.cmi others/belt_MutableSetInt.cmj others/belt_MutableSetString.cmj others/belt_SortArray.cmj others/belt_internalAVLset.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_MutableSet.cmi : cc others/belt_MutableSet.resi | others/belt.cmi others/belt_Id.cmi others/belt_MutableSetInt.cmi others/belt_MutableSetString.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_MutableSetInt.cmj : cc_cmi others/belt_MutableSetInt.res | others/belt.cmi others/belt_Array.cmj others/belt_MutableSetInt.cmi others/belt_SortArrayInt.cmj others/belt_internalAVLset.cmj others/belt_internalSetInt.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_MutableSetInt.cmi : cc others/belt_MutableSetInt.resi | others/belt.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_MutableSetString.cmj : cc_cmi others/belt_MutableSetString.res | others/belt.cmi others/belt_Array.cmj others/belt_MutableSetString.cmi others/belt_SortArrayString.cmj others/belt_internalAVLset.cmj others/belt_internalSetString.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_MutableSetString.cmi : cc others/belt_MutableSetString.resi | others/belt.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_MutableStack.cmj : cc_cmi others/belt_MutableStack.res | others/belt.cmi others/belt_MutableStack.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_MutableStack.cmi : cc others/belt_MutableStack.resi | others/belt.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_Option.cmj : cc_cmi others/belt_Option.res | others/belt.cmi others/belt_Option.cmi others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_Option.cmi : cc others/belt_Option.resi | others/belt_internals.cmi others/js.cmi $bsc -o others/belt_Range.cmj : cc_cmi others/belt_Range.res | others/belt.cmi others/belt_Range.cmi others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_Range.cmi : cc others/belt_Range.resi | others/belt_internals.cmi others/js.cmi $bsc -o others/belt_Result.cmj : cc_cmi others/belt_Result.res | others/belt.cmi others/belt_Result.cmi others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_Result.cmi : cc others/belt_Result.resi | others/belt_internals.cmi others/js.cmi $bsc -o others/belt_Set.cmj : cc_cmi others/belt_Set.res | others/belt.cmi others/belt_Id.cmj others/belt_Set.cmi others/belt_SetDict.cmj others/belt_SetInt.cmj others/belt_SetString.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_Set.cmi : cc others/belt_Set.resi | others/belt.cmi others/belt_Id.cmi others/belt_SetDict.cmi others/belt_SetInt.cmi others/belt_SetString.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_SetDict.cmj : cc_cmi others/belt_SetDict.res | others/belt.cmi others/belt_Array.cmj others/belt_Id.cmj others/belt_SetDict.cmi others/belt_internalAVLset.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_SetDict.cmi : cc others/belt_SetDict.resi | others/belt.cmi others/belt_Id.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_SetInt.cmj : cc_cmi others/belt_SetInt.res | others/belt.cmi others/belt_Array.cmj others/belt_SetInt.cmi others/belt_internalAVLset.cmj others/belt_internalSetInt.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_SetInt.cmi : cc others/belt_SetInt.resi | others/belt.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_SetString.cmj : cc_cmi others/belt_SetString.res | others/belt.cmi others/belt_Array.cmj others/belt_SetString.cmi others/belt_internalAVLset.cmj others/belt_internalSetString.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_SetString.cmi : cc others/belt_SetString.resi | others/belt.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_SortArray.cmj : cc_cmi others/belt_SortArray.res | others/belt.cmi others/belt_Array.cmj others/belt_SortArray.cmi others/belt_SortArrayInt.cmj others/belt_SortArrayString.cmj others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_SortArray.cmi : cc others/belt_SortArray.resi | others/belt.cmi others/belt_SortArrayInt.cmi others/belt_SortArrayString.cmi others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_SortArrayInt.cmj : cc_cmi others/belt_SortArrayInt.res | others/belt.cmi others/belt_Array.cmj others/belt_SortArrayInt.cmi others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_SortArrayInt.cmi : cc others/belt_SortArrayInt.resi | others/belt_internals.cmi others/js.cmi $bsc -o others/belt_SortArrayString.cmj : cc_cmi others/belt_SortArrayString.res | others/belt.cmi others/belt_Array.cmj others/belt_SortArrayString.cmi others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_SortArrayString.cmi : cc others/belt_SortArrayString.resi | others/belt_internals.cmi others/js.cmi $bsc -o others/belt_internalAVLset.cmj : cc_cmi others/belt_internalAVLset.res | others/belt.cmi others/belt_Array.cmj others/belt_Id.cmj others/belt_SortArray.cmj others/belt_internalAVLset.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_internalAVLset.cmi : cc others/belt_internalAVLset.resi | others/belt.cmi others/belt_Id.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_internalAVLtree.cmj : cc_cmi others/belt_internalAVLtree.res | others/belt.cmi others/belt_Array.cmj others/belt_Id.cmj others/belt_SortArray.cmj others/belt_internalAVLtree.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_internalAVLtree.cmi : cc others/belt_internalAVLtree.resi | others/belt.cmi others/belt_Id.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_internalBuckets.cmj : cc_cmi others/belt_internalBuckets.res | others/belt.cmi others/belt_Array.cmj others/belt_internalBuckets.cmi others/belt_internalBucketsType.cmj others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_internalBuckets.cmi : cc others/belt_internalBuckets.resi | others/belt.cmi others/belt_internalBucketsType.cmi others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_internalBucketsType.cmj : cc_cmi others/belt_internalBucketsType.res | others/belt.cmi others/belt_Array.cmj others/belt_internalBucketsType.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_internalBucketsType.cmi : cc others/belt_internalBucketsType.resi | others/belt.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_internalMapInt.cmi others/belt_internalMapInt.cmj : cc others/belt_internalMapInt.res | others/belt.cmi others/belt_Array.cmj others/belt_SortArray.cmj others/belt_internalAVLtree.cmj others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_internalMapString.cmi others/belt_internalMapString.cmj : cc others/belt_internalMapString.res | others/belt.cmi others/belt_Array.cmj others/belt_SortArray.cmj others/belt_internalAVLtree.cmj others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_internalSetBuckets.cmj : cc_cmi others/belt_internalSetBuckets.res | others/belt.cmi others/belt_Array.cmj others/belt_internalBucketsType.cmj others/belt_internalSetBuckets.cmi others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_internalSetBuckets.cmi : cc others/belt_internalSetBuckets.resi | others/belt.cmi others/belt_internalBucketsType.cmi others/belt_internals.cmi others/js.cmi $bsc js_pkg -o others/belt_internalSetInt.cmi others/belt_internalSetInt.cmj : cc others/belt_internalSetInt.res | others/belt.cmi others/belt_Array.cmj others/belt_SortArrayInt.cmj others/belt_internalAVLset.cmj others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg -o others/belt_internalSetString.cmi others/belt_internalSetString.cmj : cc others/belt_internalSetString.res | others/belt.cmi others/belt_Array.cmj others/belt_SortArrayString.cmj others/belt_internalAVLset.cmj others/belt_internals.cmi others/js.cmi others/js.cmj $bsc js_pkg o others/dom.cmi others/dom.cmj : cc others/dom.res | others/belt_internals.cmi others/dom_storage.cmj others/dom_storage2.cmj others/js.cmi $bsc js_pkg o others/dom_storage.cmi others/dom_storage.cmj : cc others/dom_storage.res | others/belt_internals.cmi others/dom_storage2.cmj others/js.cmi $bsc js_pkg o others/dom_storage2.cmi others/dom_storage2.cmj : cc others/dom_storage2.res | others/belt_internals.cmi others/js.cmi $bsc -o others : phony others/belt_Array.cmi others/belt_Array.cmj others/belt_Float.cmi others/belt_Float.cmj others/belt_HashMap.cmi others/belt_HashMap.cmj others/belt_HashMapInt.cmi others/belt_HashMapInt.cmj others/belt_HashMapString.cmi others/belt_HashMapString.cmj others/belt_HashSet.cmi others/belt_HashSet.cmj others/belt_HashSetInt.cmi others/belt_HashSetInt.cmj others/belt_HashSetString.cmi others/belt_HashSetString.cmj others/belt_Id.cmi others/belt_Id.cmj others/belt_Int.cmi others/belt_Int.cmj others/belt_List.cmi others/belt_List.cmj others/belt_Map.cmi others/belt_Map.cmj others/belt_MapDict.cmi others/belt_MapDict.cmj others/belt_MapInt.cmi others/belt_MapInt.cmj others/belt_MapString.cmi others/belt_MapString.cmj others/belt_MutableMap.cmi others/belt_MutableMap.cmj others/belt_MutableMapInt.cmi others/belt_MutableMapInt.cmj others/belt_MutableMapString.cmi others/belt_MutableMapString.cmj others/belt_MutableQueue.cmi others/belt_MutableQueue.cmj others/belt_MutableSet.cmi others/belt_MutableSet.cmj others/belt_MutableSetInt.cmi others/belt_MutableSetInt.cmj others/belt_MutableSetString.cmi others/belt_MutableSetString.cmj others/belt_MutableStack.cmi others/belt_MutableStack.cmj others/belt_Option.cmi others/belt_Option.cmj others/belt_Range.cmi others/belt_Range.cmj others/belt_Result.cmi others/belt_Result.cmj others/belt_Set.cmi others/belt_Set.cmj others/belt_SetDict.cmi others/belt_SetDict.cmj others/belt_SetInt.cmi others/belt_SetInt.cmj others/belt_SetString.cmi others/belt_SetString.cmj others/belt_SortArray.cmi others/belt_SortArray.cmj others/belt_SortArrayInt.cmi others/belt_SortArrayInt.cmj others/belt_SortArrayString.cmi others/belt_SortArrayString.cmj others/belt_internalAVLset.cmi others/belt_internalAVLset.cmj others/belt_internalAVLtree.cmi others/belt_internalAVLtree.cmj others/belt_internalBuckets.cmi others/belt_internalBuckets.cmj others/belt_internalBucketsType.cmi others/belt_internalBucketsType.cmj others/belt_internalMapInt.cmi others/belt_internalMapInt.cmj others/belt_internalMapString.cmi others/belt_internalMapString.cmj others/belt_internalSetBuckets.cmi others/belt_internalSetBuckets.cmj others/belt_internalSetInt.cmi others/belt_internalSetInt.cmj others/belt_internalSetString.cmi others/belt_internalSetString.cmj others/dom.cmi others/dom.cmj others/dom_storage.cmi others/dom_storage.cmj others/dom_storage2.cmi others/dom_storage2.cmj +o others : phony others/dom.cmi others/dom.cmj others/dom_storage.cmi others/dom_storage.cmj others/dom_storage2.cmi others/dom_storage2.cmj diff --git a/jscomp/test/Import.js b/jscomp/test/Import.js deleted file mode 100644 index 4336162e616..00000000000 --- a/jscomp/test/Import.js +++ /dev/null @@ -1,156 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Curry = require("../../lib/js/curry.js"); - -async function eachIntAsync(list, f) { - return Curry._2(await import("../../lib/js/belt_List.js").then(function (m) { - return m.forEach; - }), list, f); -} - -function eachIntLazy(list, f) { - var obj = import("../../lib/js/belt_List.js").then(function (m) { - return m.forEach; - }); - var arg1 = function (each) { - return Promise.resolve(Curry._2(each, list, f)); - }; - return obj.then(arg1); -} - -eachIntLazy({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, (function (n) { - console.log("lazy", n); - })); - -eachIntAsync({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, (function (n) { - console.log("async", n); - })); - -var beltAsModule = await import("../../lib/js/belt_List.js"); - -var M = await import("../../lib/js/belt_List.js"); - -var N0 = await import("../../lib/js/belt_List.js"); - -var O = await import("../../lib/js/belt_List.js"); - -var N1_each = O.forEach; - -var N1 = { - O: O, - each: N1_each -}; - -var N2 = await import("../../lib/js/belt_List.js"); - -var N_each = N2.forEach; - -var N = { - N0: N0, - N1: N1, - N2: N2, - each: N_each -}; - -var M0 = await import("../../lib/js/belt_List.js"); - -var M1 = await import("../../lib/js/belt_List.js"); - -async function f(param) { - return (await import("../../lib/js/belt_List.js")).forEach; -} - -async function f1(param) { - return (await import("../../lib/js/belt_List.js")).forEach; -} - -async function f2(param) { - var M3 = await import("../../lib/js/belt_List.js"); - var M4 = await import("../../lib/js/belt_List.js"); - return [ - M3.forEach, - M4.forEach - ]; -} - -async function f3(param) { - var M3 = await import("../../lib/js/belt_List.js"); - var M4 = await import("../../lib/js/belt_List.js"); - return [ - M3.forEach, - M4.forEach - ]; -} - -async function f4(param) { - return (await import("../../lib/js/belt_Array.js")).forEach; -} - -async function f5(param) { - var A = await import("../../lib/js/belt_Array.js"); - var O = await import("../../lib/js/belt_Option.js"); - return [ - A.forEach, - O.forEach - ]; -} - -async function f6(param) { - var MS = await import("../../lib/js/belt_MapString.js"); - var A = await import("../../lib/js/belt_Array.js"); - return [ - 0, - MS.forEach, - A.forEach - ]; -} - -async function f7(param) { - await import("../../lib/js/belt_MapInt.js"); - return 1; -} - -var each = M1.forEach; - -var M2; - -var each2 = O.forEach; - -exports.eachIntAsync = eachIntAsync; -exports.eachIntLazy = eachIntLazy; -exports.beltAsModule = beltAsModule; -exports.M = M; -exports.N = N; -exports.M0 = M0; -exports.M1 = M1; -exports.each = each; -exports.M2 = M2; -exports.each2 = each2; -exports.f = f; -exports.f1 = f1; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -exports.f5 = f5; -exports.f6 = f6; -exports.f7 = f7; -/* Not a pure module */ diff --git a/jscomp/test/Import.res b/jscomp/test/Import.res deleted file mode 100644 index 5b8097bf64c..00000000000 --- a/jscomp/test/Import.res +++ /dev/null @@ -1,92 +0,0 @@ -let eachIntAsync = async (list: list, f: int => unit) => { - list->(await Js.import(Belt.List.forEach))(f) -} - -let eachIntLazy = (list: list, f: int => unit) => - Js.import(Belt.List.forEach) |> Js.Promise.then_(each => list->each(f)->Js.Promise.resolve) - -let _ = list{1, 2, 3}->eachIntLazy(n => Js.log2("lazy", n)) -let _ = list{1, 2, 3}->eachIntAsync(n => Js.log2("async", n)) - -module type BeltList = module type of Belt.List -let beltAsModule = await Js.import(module(Belt.List: BeltList)) - -// module type BeltList0 = module type of Belt.List -// module M = unpack(@res.await Js.import(module(Belt.List: BeltList0))) -module M = await Belt.List -let each = M.forEach - -module N = { - module N0 = await Belt.List - let each = N0.forEach - - module N1 = { - module O = await Belt.List - let each = O.forEach - } - - module N2 = await Belt.List - let each = N2.forEach -} - -module M0 = await Belt.List -let each = M0.forEach - -module M1 = await Belt.List -let each = M1.forEach - -module M2 = N.N1.O -let each2 = M2.forEach - -let f = async () => { - module M3 = await Belt.List - M3.forEach -} - -let f1 = async () => { - module M3 = await (Belt.List: BeltList) - M3.forEach -} - -let f2 = async () => { - module M3 = await (Belt.List: BeltList) - module M4 = await (Belt.List: BeltList) - (M3.forEach, M4.forEach) -} - -let f3 = async () => { - module M3 = await Belt.List - module M4 = await Belt.List - (M3.forEach, M4.forEach) -} - -let f4 = async () => { - module A = await Belt.Array - A.forEach -} - -let f5 = async () => { - module A = await Belt.Array - module O = await Belt.Option - (A.forEach, O.forEach) -} - -let f6 = async () => { - let a = 0 - and b = { - module MS = await Belt.Map.String - MS.forEach - } - module A = await Belt.Array - (a, b, A.forEach) -} - -let f7 = async () => { - if true { - module MI = await Belt.Map.Int - 1 - } else { - module MI = await Belt.Map.Dict - 0 - } -} diff --git a/jscomp/test/UntaggedVariants.js b/jscomp/test/UntaggedVariants.js index c0299611c4a..c87c90d156d 100644 --- a/jscomp/test/UntaggedVariants.js +++ b/jscomp/test/UntaggedVariants.js @@ -2,7 +2,6 @@ 'use strict'; var Js_dict = require("../../lib/js/js_dict.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); var Caml_array = require("../../lib/js/caml_array.js"); var Caml_option = require("../../lib/js/caml_option.js"); @@ -500,9 +499,7 @@ async function classify$10(a) { return ; } else { if (Array.isArray(a)) { - console.log(function (param) { - return Belt_Array.joinWith(a, "-", param); - }); + console.log(a.join("-")); return ; } if (a instanceof Promise) { @@ -527,9 +524,7 @@ var Arr = { async function classifyAll(t) { if (Array.isArray(t)) { - console.log(function (param) { - return Belt_Array.joinWith(t, "-", param); - }); + console.log(t.join("-")); return ; } if (t instanceof Promise) { diff --git a/jscomp/test/UntaggedVariants.res b/jscomp/test/UntaggedVariants.res index 0bcfe81208f..584de6f9268 100644 --- a/jscomp/test/UntaggedVariants.res +++ b/jscomp/test/UntaggedVariants.res @@ -375,7 +375,7 @@ module Arr = { let classify = async (a: arr) => switch a { - | Array(arr) => Js.log(arr->Belt.Array.joinWith("-")) + | Array(arr) => Js.log(arr->Js.Array2.joinWith("-")) | String(s) => Js.log(s) | Promise(p) => Js.log(await p) | Object({userName}) => Js.log(userName) @@ -408,7 +408,7 @@ module AllInstanceofTypes = { | Object({userName}) => Js.log(userName) | Date(date) => Js.log(date->Js.Date.toString) | RegExp(re) => Js.log(re->Js.Re.test_("test")) - | Array(arr) => Js.log(arr->Belt.Array.joinWith("-")) + | Array(arr) => Js.log(arr->Js.Array2.joinWith("-")) | File(file) => Js.log(file->fileName) | Blob(blob) => Js.log(blob->blobSize) } diff --git a/jscomp/test/array_data_util.js b/jscomp/test/array_data_util.js deleted file mode 100644 index 7a846581e38..00000000000 --- a/jscomp/test/array_data_util.js +++ /dev/null @@ -1,25 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Belt_Array = require("../../lib/js/belt_Array.js"); - -function range(i, j) { - return Belt_Array.makeBy((j - i | 0) + 1 | 0, (function (k) { - return k + i | 0; - })); -} - -function randomRange(i, j) { - var v = Belt_Array.makeBy((j - i | 0) + 1 | 0, (function (k) { - return k + i | 0; - })); - Belt_Array.shuffleInPlace(v); - return v; -} - -var A; - -exports.A = A; -exports.range = range; -exports.randomRange = randomRange; -/* No side effect */ diff --git a/jscomp/test/array_data_util.res b/jscomp/test/array_data_util.res deleted file mode 100644 index 22cb608c5fa..00000000000 --- a/jscomp/test/array_data_util.res +++ /dev/null @@ -1,10 +0,0 @@ -module A = Belt.Array - -/* [] */ -let range = (i, j) => A.makeBy(j - i + 1, k => k + i) - -let randomRange = (i, j) => { - let v = A.makeBy(j - i + 1, k => k + i) - A.shuffleInPlace(v) - v -} diff --git a/jscomp/test/belt_result_alias_test.js b/jscomp/test/belt_result_alias_test.js deleted file mode 100644 index b66a69291e1..00000000000 --- a/jscomp/test/belt_result_alias_test.js +++ /dev/null @@ -1,20 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Belt_Result = require("../../lib/js/belt_Result.js"); - -Belt_Result.map({ - TAG: "Ok", - _0: "Test" - }, (function (r) { - return "Value: " + r; - })); - -Belt_Result.getWithDefault(Belt_Result.map({ - TAG: "Error", - _0: "error" - }, (function (r) { - return "Value: " + r; - })), "success"); - -/* Not a pure module */ diff --git a/jscomp/test/belt_result_alias_test.res b/jscomp/test/belt_result_alias_test.res deleted file mode 100644 index daba7eab05c..00000000000 --- a/jscomp/test/belt_result_alias_test.res +++ /dev/null @@ -1,8 +0,0 @@ -/* Make sure Belt.Result.t / Pervasives.result can be used interchangiably */ - -let _ = Ok("Test")->Belt.Result.map(r => "Value: " ++ r) - -let _ = { - open Belt.Result - Error("error")->map(r => "Value: " ++ r)->getWithDefault("success") -} diff --git a/jscomp/test/bs_MapInt_test.js b/jscomp/test/bs_MapInt_test.js deleted file mode 100644 index 7dea07a710a..00000000000 --- a/jscomp/test/bs_MapInt_test.js +++ /dev/null @@ -1,35 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Js_exn = require("../../lib/js/js_exn.js"); -var Belt_MapInt = require("../../lib/js/belt_MapInt.js"); - -function should(b) { - if (!b) { - return Js_exn.raiseError("IMPOSSIBLE"); - } - -} - -function test(param) { - var m; - for(var i = 0; i <= 999999; ++i){ - m = Belt_MapInt.set(m, i, i); - } - for(var i$1 = 0; i$1 <= 999999; ++i$1){ - should(Belt_MapInt.get(m, i$1) !== undefined); - } - for(var i$2 = 0; i$2 <= 999999; ++i$2){ - m = Belt_MapInt.remove(m, i$2); - } - should(Belt_MapInt.isEmpty(m)); -} - -test(); - -var M; - -exports.should = should; -exports.M = M; -exports.test = test; -/* Not a pure module */ diff --git a/jscomp/test/bs_MapInt_test.res b/jscomp/test/bs_MapInt_test.res deleted file mode 100644 index a09919cdcba..00000000000 --- a/jscomp/test/bs_MapInt_test.res +++ /dev/null @@ -1,23 +0,0 @@ -@@bs.config({flags: ["-bs-no-cross-module-opt"]}) -let should = b => - if !b { - Js.Exn.raiseError("IMPOSSIBLE") - } - -module M = Belt.Map.Int -let test = () => { - let m = ref(M.empty) - let count = 100_0000 - 1 - for i in 0 to count { - m := M.set(m.contents, i, i) - } - for i in 0 to count { - should(M.get(m.contents, i) != None) - } - for i in 0 to count { - m := M.remove(m.contents, i) - } - should(M.isEmpty(m.contents)) -} - -let () = test() diff --git a/jscomp/test/bs_array_test.js b/jscomp/test/bs_array_test.js deleted file mode 100644 index 08205ad63eb..00000000000 --- a/jscomp/test/bs_array_test.js +++ /dev/null @@ -1,1632 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Caml = require("../../lib/js/caml.js"); -var Curry = require("../../lib/js/curry.js"); -var Js_list = require("../../lib/js/js_list.js"); -var Caml_obj = require("../../lib/js/caml_obj.js"); -var Belt_List = require("../../lib/js/belt_List.js"); -var Js_vector = require("../../lib/js/js_vector.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); -var Caml_array = require("../../lib/js/caml_array.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -function $$throw(loc, x) { - Mt.throw_suites(test_id, suites, loc, x); -} - -function neq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + String(test_id.contents)), - (function (param) { - return { - TAG: "Neq", - _0: x, - _1: y - }; - }) - ], - tl: suites.contents - }; -} - -function push(prim0, prim1) { - prim0.push(prim1); -} - -console.log([ - 1, - 2, - 3, - 4 - ].filter(function (x) { - return x > 2; - }).map(function (x, i) { - return x + i | 0; - }).reduce((function (x, y) { - return x + y | 0; - }), 0)); - -var v = [ - 1, - 2 -]; - -eq("File \"bs_array_test.res\", line 31, characters 4-11", [ - Belt_Array.get(v, 0), - Belt_Array.get(v, 1), - Belt_Array.get(v, 2), - Belt_Array.get(v, 3), - Belt_Array.get(v, -1) - ], [ - 1, - 2, - undefined, - undefined, - undefined - ]); - -$$throw("File \"bs_array_test.res\", line 35, characters 8-15", (function (param) { - Belt_Array.getExn([ - 0, - 1 - ], -1); - })); - -$$throw("File \"bs_array_test.res\", line 36, characters 8-15", (function (param) { - Belt_Array.getExn([ - 0, - 1 - ], 2); - })); - -var partial_arg = [ - 0, - 1 -]; - -function f(param) { - return Belt_Array.getExn(partial_arg, param); -} - -b("File \"bs_array_test.res\", line 38, characters 4-11", Caml_obj.equal([ - Curry._1(f, 0), - Curry._1(f, 1) - ], [ - 0, - 1 - ])); - -$$throw("File \"bs_array_test.res\", line 44, characters 8-15", (function (param) { - Belt_Array.setExn([ - 0, - 1 - ], -1, 0); - })); - -$$throw("File \"bs_array_test.res\", line 45, characters 8-15", (function (param) { - Belt_Array.setExn([ - 0, - 1 - ], 2, 0); - })); - -b("File \"bs_array_test.res\", line 46, characters 4-11", !Belt_Array.set([ - 1, - 2 - ], 2, 0)); - -var v$1 = [ - 1, - 2 -]; - -if (!Belt_Array.set(v$1, 0, 0)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_array_test.res", - 51, - 6 - ], - Error: new Error() - }; -} - -b("File \"bs_array_test.res\", line 48, characters 4-11", Belt_Array.getExn(v$1, 0) === 0); - -var v$2 = [ - 1, - 2 -]; - -if (!Belt_Array.set(v$2, 1, 0)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_array_test.res", - 59, - 6 - ], - Error: new Error() - }; -} - -b("File \"bs_array_test.res\", line 56, characters 4-11", Belt_Array.getExn(v$2, 1) === 0); - -var v$3 = [ - 1, - 2 -]; - -b("File \"bs_array_test.res\", line 64, characters 4-11", (Belt_Array.setExn(v$3, 0, 0), Belt_Array.getExn(v$3, 0) === 0)); - -var v$4 = [ - 1, - 2 -]; - -b("File \"bs_array_test.res\", line 72, characters 4-11", (Belt_Array.setExn(v$4, 1, 0), Belt_Array.getExn(v$4, 1) === 0)); - -function id(x) { - eq("File \"bs_array_test.res\", line 81, characters 17-24", Js_vector.toList(Js_list.toVector(x)), x); -} - -eq("File \"bs_array_test.res\", line 84, characters 5-12", Js_list.toVector({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }), [ - 1, - 2, - 3 - ]); - -eq("File \"bs_array_test.res\", line 85, characters 5-12", Js_vector.map((function (x) { - return x + 1 | 0; - }), [ - 1, - 2, - 3 - ]), [ - 2, - 3, - 4 - ]); - -eq("File \"bs_array_test.res\", line 86, characters 5-12", Caml_array.make(5, 3), [ - 3, - 3, - 3, - 3, - 3 - ]); - -var a = Js_vector.init(5, (function (i) { - return i + 1 | 0; - })); - -eq("File \"bs_array_test.res\", line 88, characters 4-11", (Js_vector.filterInPlace((function (j) { - return j % 2 === 0; - }), a), a), [ - 2, - 4 - ]); - -var a$1 = Js_vector.init(5, (function (i) { - return i + 1 | 0; - })); - -eq("File \"bs_array_test.res\", line 98, characters 4-11", (Js_vector.filterInPlace((function (j) { - return j % 2 !== 0; - }), a$1), a$1), [ - 1, - 3, - 5 - ]); - -eq("File \"bs_array_test.res\", line 107, characters 5-12", Js_list.toVector({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }), [ - 1, - 2, - 3 - ]); - -eq("File \"bs_array_test.res\", line 108, characters 5-12", Js_list.toVector({ - hd: 1, - tl: /* [] */0 - }), [1]); - -id(/* [] */0); - -id({ - hd: 1, - tl: /* [] */0 - }); - -id({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: { - hd: 5, - tl: /* [] */0 - } - } - } - } - }); - -id(Js_vector.toList(Js_vector.init(100, (function (i) { - return i; - })))); - -function add(x, y) { - return x + y | 0; -} - -var v$5 = Belt_Array.makeBy(3000, (function (i) { - return i; - })); - -var u = Belt_Array.shuffle(v$5); - -neq("File \"bs_array_test.res\", line 122, characters 6-13", u, v$5); - -eq("File \"bs_array_test.res\", line 124, characters 5-12", Belt_Array.reduce(u, 0, add), Belt_Array.reduce(v$5, 0, add)); - -b("File \"bs_array_test.res\", line 129, characters 4-11", Caml_obj.equal(Belt_Array.range(0, 3), [ - 0, - 1, - 2, - 3 - ])); - -b("File \"bs_array_test.res\", line 130, characters 4-11", Caml_obj.equal(Belt_Array.range(3, 0), [])); - -b("File \"bs_array_test.res\", line 131, characters 4-11", Caml_obj.equal(Belt_Array.range(3, 3), [3])); - -b("File \"bs_array_test.res\", line 133, characters 4-11", Caml_obj.equal(Belt_Array.rangeBy(0, 10, 3), [ - 0, - 3, - 6, - 9 - ])); - -b("File \"bs_array_test.res\", line 134, characters 4-11", Caml_obj.equal(Belt_Array.rangeBy(0, 12, 3), [ - 0, - 3, - 6, - 9, - 12 - ])); - -b("File \"bs_array_test.res\", line 135, characters 4-11", Caml_obj.equal(Belt_Array.rangeBy(33, 0, 1), [])); - -b("File \"bs_array_test.res\", line 136, characters 4-11", Caml_obj.equal(Belt_Array.rangeBy(33, 0, -1), [])); - -b("File \"bs_array_test.res\", line 137, characters 4-11", Caml_obj.equal(Belt_Array.rangeBy(3, 12, -1), [])); - -b("File \"bs_array_test.res\", line 138, characters 4-11", Caml_obj.equal(Belt_Array.rangeBy(3, 3, 0), [])); - -b("File \"bs_array_test.res\", line 139, characters 4-11", Caml_obj.equal(Belt_Array.rangeBy(3, 3, 1), [3])); - -eq("File \"bs_array_test.res\", line 143, characters 5-12", Belt_Array.reduceReverse([], 100, (function (prim0, prim1) { - return prim0 - prim1 | 0; - })), 100); - -eq("File \"bs_array_test.res\", line 144, characters 5-12", Belt_Array.reduceReverse([ - 1, - 2 - ], 100, (function (prim0, prim1) { - return prim0 - prim1 | 0; - })), 97); - -eq("File \"bs_array_test.res\", line 145, characters 5-12", Belt_Array.reduceReverse([ - 1, - 2, - 3, - 4 - ], 100, (function (prim0, prim1) { - return prim0 - prim1 | 0; - })), 90); - -eq("File \"bs_array_test.res\", line 146, characters 5-12", Belt_Array.reduceWithIndex([ - 1, - 2, - 3, - 4 - ], 0, (function (acc, x, i) { - return (acc + x | 0) + i | 0; - })), 16); - -b("File \"bs_array_test.res\", line 147, characters 4-11", Belt_Array.reduceReverse2([ - 1, - 2, - 3 - ], [ - 1, - 2 - ], 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; - })) === 6); - -function addone(x) { - return x + 1 | 0; -} - -function makeMatrixExn(sx, sy, init) { - if (!(sx >= 0 && sy >= 0)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_array_test.res", - 153, - 2 - ], - Error: new Error() - }; - } - var res = new Array(sx); - for(var x = 0; x < sx; ++x){ - var initY = new Array(sy); - for(var y = 0; y < sy; ++y){ - initY[y] = init; - } - res[x] = initY; - } - return res; -} - -eq("File \"bs_array_test.res\", line 166, characters 5-12", Belt_Array.makeBy(0, (function (param) { - return 1; - })), []); - -eq("File \"bs_array_test.res\", line 167, characters 5-12", Belt_Array.makeBy(3, (function (i) { - return i; - })), [ - 0, - 1, - 2 - ]); - -eq("File \"bs_array_test.res\", line 168, characters 5-12", makeMatrixExn(3, 4, 1), [ - [ - 1, - 1, - 1, - 1 - ], - [ - 1, - 1, - 1, - 1 - ], - [ - 1, - 1, - 1, - 1 - ] - ]); - -eq("File \"bs_array_test.res\", line 169, characters 5-12", makeMatrixExn(3, 0, 0), [ - [], - [], - [] - ]); - -eq("File \"bs_array_test.res\", line 170, characters 5-12", makeMatrixExn(0, 3, 1), []); - -eq("File \"bs_array_test.res\", line 171, characters 5-12", makeMatrixExn(1, 1, 1), [[1]]); - -eq("File \"bs_array_test.res\", line 172, characters 5-12", [].slice(0), []); - -eq("File \"bs_array_test.res\", line 173, characters 5-12", Belt_Array.map([], (function (prim) { - return prim + 1 | 0; - })), []); - -eq("File \"bs_array_test.res\", line 174, characters 5-12", Belt_Array.mapWithIndex([], add), []); - -eq("File \"bs_array_test.res\", line 175, characters 5-12", Belt_Array.mapWithIndex([ - 1, - 2, - 3 - ], add), [ - 1, - 3, - 5 - ]); - -eq("File \"bs_array_test.res\", line 176, characters 5-12", Belt_List.fromArray([]), /* [] */0); - -eq("File \"bs_array_test.res\", line 177, characters 5-12", Belt_List.fromArray([1]), { - hd: 1, - tl: /* [] */0 - }); - -eq("File \"bs_array_test.res\", line 178, characters 5-12", Belt_List.fromArray([ - 1, - 2, - 3 - ]), { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }); - -eq("File \"bs_array_test.res\", line 179, characters 5-12", Belt_Array.map([ - 1, - 2, - 3 - ], (function (prim) { - return prim + 1 | 0; - })), [ - 2, - 3, - 4 - ]); - -eq("File \"bs_array_test.res\", line 180, characters 5-12", Belt_List.toArray(/* [] */0), []); - -eq("File \"bs_array_test.res\", line 181, characters 5-12", Belt_List.toArray({ - hd: 1, - tl: /* [] */0 - }), [1]); - -eq("File \"bs_array_test.res\", line 182, characters 5-12", Belt_List.toArray({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }), [ - 1, - 2 - ]); - -eq("File \"bs_array_test.res\", line 183, characters 5-12", Belt_List.toArray({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }), [ - 1, - 2, - 3 - ]); - -var v$6 = Belt_Array.makeBy(10, (function (i) { - return i; - })); - -var v0 = Belt_Array.keep(v$6, (function (x) { - return x % 2 === 0; - })); - -var v1 = Belt_Array.keep(v$6, (function (x) { - return x % 3 === 0; - })); - -var v2 = Belt_Array.keepMap(v$6, (function (x) { - if (x % 2 === 0) { - return x + 1 | 0; - } - - })); - -eq("File \"bs_array_test.res\", line 197, characters 5-12", v0, [ - 0, - 2, - 4, - 6, - 8 - ]); - -eq("File \"bs_array_test.res\", line 198, characters 5-12", v1, [ - 0, - 3, - 6, - 9 - ]); - -eq("File \"bs_array_test.res\", line 199, characters 5-12", v2, [ - 1, - 3, - 5, - 7, - 9 - ]); - -var a$2 = [ - 1, - 2, - 3, - 4, - 5 -]; - -var match = Belt_Array.partition(a$2, (function (x) { - return x % 2 === 0; - })); - -eq("File \"bs_array_test.res\", line 205, characters 5-12", match[0], [ - 2, - 4 - ]); - -eq("File \"bs_array_test.res\", line 206, characters 5-12", match[1], [ - 1, - 3, - 5 - ]); - -var match$1 = Belt_Array.partition(a$2, (function (x) { - return x === 2; - })); - -eq("File \"bs_array_test.res\", line 208, characters 5-12", match$1[0], [2]); - -eq("File \"bs_array_test.res\", line 209, characters 5-12", match$1[1], [ - 1, - 3, - 4, - 5 - ]); - -var match$2 = Belt_Array.partition([], (function (x) { - return false; - })); - -eq("File \"bs_array_test.res\", line 211, characters 5-12", match$2[0], []); - -eq("File \"bs_array_test.res\", line 212, characters 5-12", match$2[1], []); - -var a$3 = [ - 1, - 2, - 3, - 4, - 5 -]; - -eq("File \"bs_array_test.res\", line 217, characters 5-12", Belt_Array.slice(a$3, 0, 2), [ - 1, - 2 - ]); - -eq("File \"bs_array_test.res\", line 218, characters 5-12", Belt_Array.slice(a$3, 0, 5), [ - 1, - 2, - 3, - 4, - 5 - ]); - -eq("File \"bs_array_test.res\", line 219, characters 5-12", Belt_Array.slice(a$3, 0, 15), [ - 1, - 2, - 3, - 4, - 5 - ]); - -eq("File \"bs_array_test.res\", line 220, characters 5-12", Belt_Array.slice(a$3, 5, 1), []); - -eq("File \"bs_array_test.res\", line 221, characters 5-12", Belt_Array.slice(a$3, 4, 1), [5]); - -eq("File \"bs_array_test.res\", line 222, characters 5-12", Belt_Array.slice(a$3, -1, 1), [5]); - -eq("File \"bs_array_test.res\", line 223, characters 5-12", Belt_Array.slice(a$3, -1, 2), [5]); - -eq("File \"bs_array_test.res\", line 224, characters 5-12", Belt_Array.slice(a$3, -2, 1), [4]); - -eq("File \"bs_array_test.res\", line 225, characters 5-12", Belt_Array.slice(a$3, -2, 2), [ - 4, - 5 - ]); - -eq("File \"bs_array_test.res\", line 226, characters 5-12", Belt_Array.slice(a$3, -2, 3), [ - 4, - 5 - ]); - -eq("File \"bs_array_test.res\", line 227, characters 5-12", Belt_Array.slice(a$3, -10, 3), [ - 1, - 2, - 3 - ]); - -eq("File \"bs_array_test.res\", line 228, characters 5-12", Belt_Array.slice(a$3, -10, 4), [ - 1, - 2, - 3, - 4 - ]); - -eq("File \"bs_array_test.res\", line 229, characters 5-12", Belt_Array.slice(a$3, -10, 5), [ - 1, - 2, - 3, - 4, - 5 - ]); - -eq("File \"bs_array_test.res\", line 230, characters 5-12", Belt_Array.slice(a$3, -10, 6), [ - 1, - 2, - 3, - 4, - 5 - ]); - -eq("File \"bs_array_test.res\", line 231, characters 5-12", Belt_Array.slice(a$3, 0, 0), []); - -eq("File \"bs_array_test.res\", line 232, characters 5-12", Belt_Array.slice(a$3, 0, -1), []); - -var a$4 = [ - 1, - 2, - 3, - 4, - 5 -]; - -eq("File \"bs_array_test.res\", line 237, characters 5-12", Belt_Array.sliceToEnd(a$4, 0), [ - 1, - 2, - 3, - 4, - 5 - ]); - -eq("File \"bs_array_test.res\", line 238, characters 5-12", Belt_Array.sliceToEnd(a$4, 5), []); - -eq("File \"bs_array_test.res\", line 239, characters 5-12", Belt_Array.sliceToEnd(a$4, 4), [5]); - -eq("File \"bs_array_test.res\", line 240, characters 5-12", Belt_Array.sliceToEnd(a$4, -1), [5]); - -eq("File \"bs_array_test.res\", line 241, characters 5-12", Belt_Array.sliceToEnd(a$4, -2), [ - 4, - 5 - ]); - -eq("File \"bs_array_test.res\", line 242, characters 5-12", Belt_Array.sliceToEnd(a$4, -10), [ - 1, - 2, - 3, - 4, - 5 - ]); - -eq("File \"bs_array_test.res\", line 243, characters 5-12", Belt_Array.sliceToEnd(a$4, 6), []); - -var a$5 = Belt_Array.makeBy(10, (function (x) { - return x; - })); - -Belt_Array.fill(a$5, 0, 3, 0); - -eq("File \"bs_array_test.res\", line 248, characters 5-12", a$5.slice(0), [ - 0, - 0, - 0, - 3, - 4, - 5, - 6, - 7, - 8, - 9 - ]); - -Belt_Array.fill(a$5, 2, 8, 1); - -eq("File \"bs_array_test.res\", line 250, characters 5-12", a$5.slice(0), [ - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1 - ]); - -Belt_Array.fill(a$5, 8, 1, 9); - -eq("File \"bs_array_test.res\", line 252, characters 5-12", a$5.slice(0), [ - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 9, - 1 - ]); - -Belt_Array.fill(a$5, 8, 2, 9); - -eq("File \"bs_array_test.res\", line 254, characters 5-12", a$5.slice(0), [ - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 9, - 9 - ]); - -Belt_Array.fill(a$5, 8, 3, 12); - -eq("File \"bs_array_test.res\", line 256, characters 5-12", a$5.slice(0), [ - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 12, - 12 - ]); - -Belt_Array.fill(a$5, -2, 3, 11); - -eq("File \"bs_array_test.res\", line 258, characters 5-12", a$5.slice(0), [ - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 1, - 11, - 11 - ]); - -Belt_Array.fill(a$5, -3, 3, 10); - -eq("File \"bs_array_test.res\", line 260, characters 5-12", a$5.slice(0), [ - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 10, - 10, - 10 - ]); - -Belt_Array.fill(a$5, -3, 1, 7); - -eq("File \"bs_array_test.res\", line 262, characters 5-12", a$5.slice(0), [ - 0, - 0, - 1, - 1, - 1, - 1, - 1, - 7, - 10, - 10 - ]); - -Belt_Array.fill(a$5, -13, 1, 7); - -eq("File \"bs_array_test.res\", line 264, characters 5-12", a$5.slice(0), [ - 7, - 0, - 1, - 1, - 1, - 1, - 1, - 7, - 10, - 10 - ]); - -Belt_Array.fill(a$5, -13, 12, 7); - -eq("File \"bs_array_test.res\", line 266, characters 5-12", a$5.slice(0), Belt_Array.make(10, 7)); - -Belt_Array.fill(a$5, 0, -1, 2); - -eq("File \"bs_array_test.res\", line 268, characters 5-12", a$5.slice(0), Belt_Array.make(10, 7)); - -var b$1 = [ - 1, - 2, - 3 -]; - -Belt_Array.fill(b$1, 0, 0, 0); - -eq("File \"bs_array_test.res\", line 271, characters 5-12", b$1, [ - 1, - 2, - 3 - ]); - -Belt_Array.fill(b$1, 4, 1, 0); - -eq("File \"bs_array_test.res\", line 273, characters 5-12", b$1, [ - 1, - 2, - 3 - ]); - -var a0 = Belt_Array.makeBy(10, (function (x) { - return x; - })); - -var b0 = Belt_Array.make(10, 3); - -Belt_Array.blit(a0, 1, b0, 2, 5); - -eq("File \"bs_array_test.res\", line 280, characters 5-12", b0.slice(0), [ - 3, - 3, - 1, - 2, - 3, - 4, - 5, - 3, - 3, - 3 - ]); - -Belt_Array.blit(a0, -1, b0, 2, 5); - -eq("File \"bs_array_test.res\", line 282, characters 5-12", b0.slice(0), [ - 3, - 3, - 9, - 2, - 3, - 4, - 5, - 3, - 3, - 3 - ]); - -Belt_Array.blit(a0, -1, b0, -2, 5); - -eq("File \"bs_array_test.res\", line 284, characters 5-12", b0.slice(0), [ - 3, - 3, - 9, - 2, - 3, - 4, - 5, - 3, - 9, - 3 - ]); - -Belt_Array.blit(a0, -2, b0, -2, 2); - -eq("File \"bs_array_test.res\", line 286, characters 5-12", b0.slice(0), [ - 3, - 3, - 9, - 2, - 3, - 4, - 5, - 3, - 8, - 9 - ]); - -Belt_Array.blit(a0, -11, b0, -11, 100); - -eq("File \"bs_array_test.res\", line 288, characters 5-12", b0.slice(0), a0); - -Belt_Array.blit(a0, -11, b0, -11, 2); - -eq("File \"bs_array_test.res\", line 290, characters 5-12", b0.slice(0), a0); - -var aa = Belt_Array.makeBy(10, (function (x) { - return x; - })); - -Belt_Array.blit(aa, -1, aa, 1, 2); - -eq("File \"bs_array_test.res\", line 293, characters 5-12", aa.slice(0), [ - 0, - 9, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9 - ]); - -Belt_Array.blit(aa, -2, aa, 1, 2); - -eq("File \"bs_array_test.res\", line 295, characters 5-12", aa.slice(0), [ - 0, - 8, - 9, - 3, - 4, - 5, - 6, - 7, - 8, - 9 - ]); - -Belt_Array.blit(aa, -5, aa, 4, 3); - -eq("File \"bs_array_test.res\", line 297, characters 5-12", aa.slice(0), [ - 0, - 8, - 9, - 3, - 5, - 6, - 7, - 7, - 8, - 9 - ]); - -Belt_Array.blit(aa, 4, aa, 5, 3); - -eq("File \"bs_array_test.res\", line 299, characters 5-12", aa.slice(0), [ - 0, - 8, - 9, - 3, - 5, - 5, - 6, - 7, - 8, - 9 - ]); - -eq("File \"bs_array_test.res\", line 300, characters 5-12", Belt_Array.make(0, 3), []); - -eq("File \"bs_array_test.res\", line 301, characters 5-12", Belt_Array.make(-1, 3), []); - -var c = [ - 0, - 1, - 2 -]; - -Belt_Array.blit(c, 4, c, 1, 1); - -eq("File \"bs_array_test.res\", line 304, characters 5-12", c, [ - 0, - 1, - 2 - ]); - -eq("File \"bs_array_test.res\", line 308, characters 5-12", Belt_Array.zip([ - 1, - 2, - 3 - ], [ - 2, - 3, - 4, - 1 - ]), [ - [ - 1, - 2 - ], - [ - 2, - 3 - ], - [ - 3, - 4 - ] - ]); - -eq("File \"bs_array_test.res\", line 309, characters 5-12", Belt_Array.zip([ - 2, - 3, - 4, - 1 - ], [ - 1, - 2, - 3 - ]), [ - [ - 2, - 1 - ], - [ - 3, - 2 - ], - [ - 4, - 3 - ] - ]); - -eq("File \"bs_array_test.res\", line 310, characters 5-12", Belt_Array.zipBy([ - 2, - 3, - 4, - 1 - ], [ - 1, - 2, - 3 - ], (function (prim0, prim1) { - return prim0 - prim1 | 0; - })), [ - 1, - 1, - 1 - ]); - -eq("File \"bs_array_test.res\", line 311, characters 5-12", Belt_Array.zipBy([ - 1, - 2, - 3 - ], [ - 2, - 3, - 4, - 1 - ], (function (prim0, prim1) { - return prim0 - prim1 | 0; - })), Belt_Array.map([ - 1, - 1, - 1 - ], (function (x) { - return -x | 0; - }))); - -eq("File \"bs_array_test.res\", line 312, characters 5-12", Belt_Array.unzip([ - [ - 1, - 2 - ], - [ - 2, - 3 - ], - [ - 3, - 4 - ] - ]), [ - [ - 1, - 2, - 3 - ], - [ - 2, - 3, - 4 - ] - ]); - -function sumUsingForEach(xs) { - var v = { - contents: 0 - }; - Belt_Array.forEach(xs, (function (x) { - v.contents = v.contents + x | 0; - })); - return v.contents; -} - -eq("File \"bs_array_test.res\", line 324, characters 5-12", sumUsingForEach([ - 0, - 1, - 2, - 3, - 4 - ]), 10); - -b("File \"bs_array_test.res\", line 325, characters 4-11", !Belt_Array.every([ - 0, - 1, - 2, - 3, - 4 - ], (function (x) { - return x > 2; - }))); - -b("File \"bs_array_test.res\", line 326, characters 4-11", Belt_Array.some([ - 1, - 3, - 7, - 8 - ], (function (x) { - return x % 2 === 0; - }))); - -b("File \"bs_array_test.res\", line 327, characters 4-11", !Belt_Array.some([ - 1, - 3, - 7 - ], (function (x) { - return x % 2 === 0; - }))); - -b("File \"bs_array_test.res\", line 328, characters 4-11", !Belt_Array.eq([ - 0, - 1 - ], [1], (function (prim0, prim1) { - return prim0 === prim1; - }))); - -var c$1 = { - contents: 0 -}; - -b("File \"bs_array_test.res\", line 330, characters 4-11", (Belt_Array.forEachWithIndex([ - 1, - 1, - 1 - ], (function (i, v) { - c$1.contents = (c$1.contents + i | 0) + v | 0; - })), c$1.contents === 6)); - -function id$1(loc, x) { - var u = x.slice(0); - eq("File \"bs_array_test.res\", line 341, characters 4-11", Belt_Array.reverse(x), (Belt_Array.reverseInPlace(u), u)); -} - -id$1("File \"bs_array_test.res\", line 351, characters 5-12", []); - -id$1("File \"bs_array_test.res\", line 352, characters 5-12", [1]); - -id$1("File \"bs_array_test.res\", line 353, characters 5-12", [ - 1, - 2 - ]); - -id$1("File \"bs_array_test.res\", line 354, characters 5-12", [ - 1, - 2, - 3 - ]); - -id$1("File \"bs_array_test.res\", line 355, characters 5-12", [ - 1, - 2, - 3, - 4 - ]); - -function every2(xs, ys) { - var partial_arg = Belt_List.toArray(ys); - var partial_arg$1 = Belt_List.toArray(xs); - return function (param) { - return Belt_Array.every2(partial_arg$1, partial_arg, param); - }; -} - -function some2(xs, ys) { - var partial_arg = Belt_List.toArray(ys); - var partial_arg$1 = Belt_List.toArray(xs); - return function (param) { - return Belt_Array.some2(partial_arg$1, partial_arg, param); - }; -} - -eq("File \"bs_array_test.res\", line 363, characters 5-12", every2(/* [] */0, { - hd: 1, - tl: /* [] */0 - })(function (x, y) { - return x > y; - }), true); - -eq("File \"bs_array_test.res\", line 364, characters 5-12", every2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: /* [] */0 - })(function (x, y) { - return x > y; - }), true); - -eq("File \"bs_array_test.res\", line 365, characters 5-12", every2({ - hd: 2, - tl: /* [] */0 - }, { - hd: 1, - tl: /* [] */0 - })(function (x, y) { - return x > y; - }), true); - -eq("File \"bs_array_test.res\", line 366, characters 5-12", every2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: { - hd: 4, - tl: /* [] */0 - } - })(function (x, y) { - return x > y; - }), false); - -eq("File \"bs_array_test.res\", line 367, characters 5-12", every2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: { - hd: 0, - tl: /* [] */0 - } - })(function (x, y) { - return x > y; - }), true); - -eq("File \"bs_array_test.res\", line 368, characters 5-12", some2(/* [] */0, { - hd: 1, - tl: /* [] */0 - })(function (x, y) { - return x > y; - }), false); - -eq("File \"bs_array_test.res\", line 369, characters 5-12", some2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: /* [] */0 - })(function (x, y) { - return x > y; - }), true); - -eq("File \"bs_array_test.res\", line 370, characters 5-12", some2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: { - hd: 4, - tl: /* [] */0 - } - })(function (x, y) { - return x > y; - }), true); - -eq("File \"bs_array_test.res\", line 371, characters 5-12", some2({ - hd: 0, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: { - hd: 4, - tl: /* [] */0 - } - })(function (x, y) { - return x > y; - }), false); - -eq("File \"bs_array_test.res\", line 372, characters 5-12", some2({ - hd: 0, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 3, - tl: { - hd: 2, - tl: /* [] */0 - } - })(function (x, y) { - return x > y; - }), true); - -eq("File \"bs_array_test.res\", line 376, characters 5-12", Belt_Array.concat([], [ - 1, - 2, - 3 - ]), [ - 1, - 2, - 3 - ]); - -eq("File \"bs_array_test.res\", line 377, characters 5-12", Belt_Array.concat([], []), []); - -eq("File \"bs_array_test.res\", line 378, characters 5-12", Belt_Array.concat([ - 3, - 2 - ], [ - 1, - 2, - 3 - ]), [ - 3, - 2, - 1, - 2, - 3 - ]); - -eq("File \"bs_array_test.res\", line 379, characters 5-12", Belt_Array.concatMany([ - [ - 3, - 2 - ], - [ - 1, - 2, - 3 - ] - ]), [ - 3, - 2, - 1, - 2, - 3 - ]); - -eq("File \"bs_array_test.res\", line 380, characters 5-12", Belt_Array.concatMany([ - [ - 3, - 2 - ], - [ - 1, - 2, - 3 - ], - [], - [0] - ]), [ - 3, - 2, - 1, - 2, - 3, - 0 - ]); - -eq("File \"bs_array_test.res\", line 381, characters 5-12", Belt_Array.concatMany([ - [], - [ - 3, - 2 - ], - [ - 1, - 2, - 3 - ], - [], - [0] - ]), [ - 3, - 2, - 1, - 2, - 3, - 0 - ]); - -eq("File \"bs_array_test.res\", line 382, characters 5-12", Belt_Array.concatMany([ - [], - [] - ]), []); - -b("File \"bs_array_test.res\", line 386, characters 4-11", Belt_Array.cmp([ - 1, - 2, - 3 - ], [ - 0, - 1, - 2, - 3 - ], Caml.int_compare) < 0); - -b("File \"bs_array_test.res\", line 387, characters 4-11", Belt_Array.cmp([ - 0, - 1, - 2, - 3 - ], [ - 1, - 2, - 3 - ], Caml.int_compare) > 0); - -b("File \"bs_array_test.res\", line 388, characters 4-11", Belt_Array.cmp([ - 1, - 2, - 3 - ], [ - 0, - 1, - 2 - ], Caml.int_compare) > 0); - -b("File \"bs_array_test.res\", line 389, characters 4-11", Belt_Array.cmp([ - 1, - 2, - 3 - ], [ - 1, - 2, - 3 - ], Caml.int_compare) === 0); - -b("File \"bs_array_test.res\", line 390, characters 4-11", Belt_Array.cmp([ - 1, - 2, - 4 - ], [ - 1, - 2, - 3 - ], Caml.int_compare) > 0); - -eq("File \"bs_array_test.res\", line 394, characters 5-12", Belt_Array.getBy([ - 1, - 2, - 3 - ], (function (x) { - return x > 1; - })), 2); - -eq("File \"bs_array_test.res\", line 395, characters 5-12", Belt_Array.getBy([ - 1, - 2, - 3 - ], (function (x) { - return x > 3; - })), undefined); - -eq("File \"bs_array_test.res\", line 399, characters 5-12", Belt_Array.getIndexBy([ - 1, - 2, - 3 - ], (function (x) { - return x > 1; - })), 1); - -eq("File \"bs_array_test.res\", line 400, characters 5-12", Belt_Array.getIndexBy([ - 1, - 2, - 3 - ], (function (x) { - return x > 3; - })), undefined); - -var arr = []; - -arr.push(3); - -arr.push(2); - -arr.push(1); - -eq("File \"bs_array_test.res\", line 408, characters 5-12", arr, [ - 3, - 2, - 1 - ]); - -Mt.from_pair_suites("File \"bs_array_test.res\", line 411, characters 20-27", suites.contents); - -var A; - -var L; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.$$throw = $$throw; -exports.neq = neq; -exports.A = A; -exports.L = L; -exports.push = push; -exports.add = add; -exports.addone = addone; -exports.makeMatrixExn = makeMatrixExn; -exports.sumUsingForEach = sumUsingForEach; -exports.id = id$1; -/* Not a pure module */ diff --git a/jscomp/test/bs_array_test.res b/jscomp/test/bs_array_test.res deleted file mode 100644 index dbb88eb2de3..00000000000 --- a/jscomp/test/bs_array_test.res +++ /dev/null @@ -1,411 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => Mt.eq_suites(loc, x, y, ~test_id, ~suites) -let b = (loc, x) => Mt.bool_suites(loc, x, ~test_id, ~suites) -let throw = (loc, x) => Mt.throw_suites(~test_id, ~suites, loc, x) -let neq = (loc, x, y) => { - incr(test_id) - suites := - list{ - (loc ++ (" id " ++ string_of_int(test_id.contents)), _ => Mt.Neq(x, y)), - ...suites.contents, - } -} - -module A = Belt.Array -module L = Belt.List - -let {push} = module(A) - -type t<'a> = Js.Array2.t<'a> -let () = - [1, 2, 3, 4] - ->Js.Array2.filter(x => x > 2) - ->Js.Array2.mapi((x, i) => x + i) - ->Js.Array2.reduce((x, y) => x + y, 0) - ->Js.log - -let () = { - let v = [1, 2] - eq( - __LOC__, - (A.get(v, 0), A.get(v, 1), A.get(v, 2), A.get(v, 3), A.get(v, -1)), - (Some(1), Some(2), None, None, None), - ) - throw(__LOC__, _ => A.getExn([0, 1], -1) |> ignore) - throw(__LOC__, _ => A.getExn([0, 1], 2) |> ignore) - b( - __LOC__, - { - let f = A.getExn([0, 1]) - (f(0), f(1)) == (0, 1) - }, - ) - throw(__LOC__, _ => A.setExn([0, 1], -1, 0)) - throw(__LOC__, _ => A.setExn([0, 1], 2, 0)) - b(__LOC__, !A.set([1, 2], 2, 0)) - b( - __LOC__, - { - let v = [1, 2] - assert(A.set(v, 0, 0)) - A.getExn(v, 0) == 0 - }, - ) - b( - __LOC__, - { - let v = [1, 2] - assert(A.set(v, 1, 0)) - A.getExn(v, 1) == 0 - }, - ) - b( - __LOC__, - { - let v = [1, 2] - A.setExn(v, 0, 0) - A.getExn(v, 0) == 0 - }, - ) - b( - __LOC__, - { - let v = [1, 2] - A.setExn(v, 1, 0) - A.getExn(v, 1) == 0 - }, - ) -} - -let id = x => eq(__LOC__, \"@@"(Js.Vector.toList, Js.List.toVector(x)), x) - -let () = { - eq(__LOC__, Js.List.toVector(list{1, 2, 3}), [1, 2, 3]) - eq(__LOC__, Js.Vector.map((. x) => x + 1, [1, 2, 3]), [2, 3, 4]) - eq(__LOC__, Js.Vector.make(5, 3), [3, 3, 3, 3, 3]) - eq( - __LOC__, - { - let a = Js.Vector.init(5, (. i) => i + 1) - Js.Vector.filterInPlace((. j) => mod(j, 2) == 0, a) - a - }, - [2, 4], - ) - - eq( - __LOC__, - { - let a = Js.Vector.init(5, (. i) => i + 1) - Js.Vector.filterInPlace((. j) => mod(j, 2) != 0, a) - a - }, - [1, 3, 5], - ) - - eq(__LOC__, Js.List.toVector(list{1, 2, 3}), [1, 2, 3]) - eq(__LOC__, Js.List.toVector(list{1}), [1]) - id(list{}) - id(list{1}) - id(list{1, 2, 3, 4, 5}) - id({ - open Js.Vector - \"@@"(toList, init(100, (. i) => i)) - }) -} - -let add = (x, y) => x + y -let () = { - let v = A.makeBy(3000, i => i) - let u = A.shuffle(v) - neq(__LOC__, u, v) /* unlikely */ - let sum = x => A.reduce(x, 0, add) - eq(__LOC__, sum(u), sum(v)) -} - -let () = { - open A - b(__LOC__, range(0, 3) == [0, 1, 2, 3]) - b(__LOC__, range(3, 0) == []) - b(__LOC__, range(3, 3) == [3]) - - b(__LOC__, rangeBy(0, 10, ~step=3) == [0, 3, 6, 9]) - b(__LOC__, rangeBy(0, 12, ~step=3) == [0, 3, 6, 9, 12]) - b(__LOC__, rangeBy(33, 0, ~step=1) == []) - b(__LOC__, rangeBy(33, 0, ~step=-1) == []) - b(__LOC__, rangeBy(3, 12, ~step=-1) == []) - b(__LOC__, rangeBy(3, 3, ~step=0) == []) - b(__LOC__, rangeBy(3, 3, ~step=1) == [3]) -} - -let () = { - eq(__LOC__, A.reduceReverse([], 100, \"-"), 100) - eq(__LOC__, A.reduceReverse([1, 2], 100, \"-"), 97) - eq(__LOC__, A.reduceReverse([1, 2, 3, 4], 100, \"-"), 90) - eq(__LOC__, A.reduceWithIndex([1, 2, 3, 4], 0, (acc, x, i) => acc + x + i), 16) - b(__LOC__, A.reduceReverse2([1, 2, 3], [1, 2], 0, (acc, x, y) => acc + x + y) == 6) -} -let addone = (. x) => x + 1 - -let makeMatrixExn = (sx, sy, init) => { - /* let open A in */ - assert(sx >= 0 && sy >= 0) - let res = A.makeUninitializedUnsafe(sx) - for x in 0 to sx - 1 { - let initY = A.makeUninitializedUnsafe(sy) - for y in 0 to sy - 1 { - A.setUnsafe(initY, y, init) - } - A.setUnsafe(res, x, initY) - } - res -} - -let () = { - eq(__LOC__, A.makeBy(0, _ => 1), []) - eq(__LOC__, A.makeBy(3, i => i), [0, 1, 2]) - eq(__LOC__, makeMatrixExn(3, 4, 1), [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) - eq(__LOC__, makeMatrixExn(3, 0, 0), [[], [], []]) - eq(__LOC__, makeMatrixExn(0, 3, 1), []) - eq(__LOC__, makeMatrixExn(1, 1, 1), [[1]]) - eq(__LOC__, A.copy([]), []) - eq(__LOC__, A.map([], succ), []) - eq(__LOC__, A.mapWithIndex([], add), []) - eq(__LOC__, A.mapWithIndex([1, 2, 3], add), [1, 3, 5]) - eq(__LOC__, L.fromArray([]), list{}) - eq(__LOC__, L.fromArray([1]), list{1}) - eq(__LOC__, L.fromArray([1, 2, 3]), list{1, 2, 3}) - eq(__LOC__, A.map([1, 2, 3], succ), [2, 3, 4]) - eq(__LOC__, L.toArray(list{}), []) - eq(__LOC__, L.toArray(list{1}), [1]) - eq(__LOC__, L.toArray(list{1, 2}), [1, 2]) - eq(__LOC__, L.toArray(list{1, 2, 3}), [1, 2, 3]) -} - -let () = { - let v = A.makeBy(10, i => i) - let v0 = A.keep(v, x => mod(x, 2) == 0) - let v1 = A.keep(v, x => mod(x, 3) == 0) - let v2 = A.keepMap(v, x => - if mod(x, 2) == 0 { - Some(x + 1) - } else { - None - } - ) - eq(__LOC__, v0, [0, 2, 4, 6, 8]) - eq(__LOC__, v1, [0, 3, 6, 9]) - eq(__LOC__, v2, [1, 3, 5, 7, 9]) -} - -let () = { - let a = [1, 2, 3, 4, 5] - let (v0, v1) = A.partition(a, x => mod(x, 2) == 0) - eq(__LOC__, v0, [2, 4]) - eq(__LOC__, v1, [1, 3, 5]) - let (v0, v1) = A.partition(a, x => x == 2) - eq(__LOC__, v0, [2]) - eq(__LOC__, v1, [1, 3, 4, 5]) - let (v0, v1) = A.partition([], x => false) - eq(__LOC__, v0, []) - eq(__LOC__, v1, []) -} - -let () = { - let a = [1, 2, 3, 4, 5] - eq(__LOC__, A.slice(a, ~offset=0, ~len=2), [1, 2]) - eq(__LOC__, A.slice(a, ~offset=0, ~len=5), [1, 2, 3, 4, 5]) - eq(__LOC__, A.slice(a, ~offset=0, ~len=15), [1, 2, 3, 4, 5]) - eq(__LOC__, A.slice(a, ~offset=5, ~len=1), []) - eq(__LOC__, A.slice(a, ~offset=4, ~len=1), [5]) - eq(__LOC__, A.slice(a, ~offset=-1, ~len=1), [5]) - eq(__LOC__, A.slice(a, ~offset=-1, ~len=2), [5]) - eq(__LOC__, A.slice(a, ~offset=-2, ~len=1), [4]) - eq(__LOC__, A.slice(a, ~offset=-2, ~len=2), [4, 5]) - eq(__LOC__, A.slice(a, ~offset=-2, ~len=3), [4, 5]) - eq(__LOC__, A.slice(a, ~offset=-10, ~len=3), [1, 2, 3]) - eq(__LOC__, A.slice(a, ~offset=-10, ~len=4), [1, 2, 3, 4]) - eq(__LOC__, A.slice(a, ~offset=-10, ~len=5), [1, 2, 3, 4, 5]) - eq(__LOC__, A.slice(a, ~offset=-10, ~len=6), [1, 2, 3, 4, 5]) - eq(__LOC__, A.slice(a, ~offset=0, ~len=0), []) - eq(__LOC__, A.slice(a, ~offset=0, ~len=-1), []) -} - -let () = { - let a = [1, 2, 3, 4, 5] - eq(__LOC__, A.sliceToEnd(a, 0), [1, 2, 3, 4, 5]) - eq(__LOC__, A.sliceToEnd(a, 5), []) - eq(__LOC__, A.sliceToEnd(a, 4), [5]) - eq(__LOC__, A.sliceToEnd(a, -1), [5]) - eq(__LOC__, A.sliceToEnd(a, -2), [4, 5]) - eq(__LOC__, A.sliceToEnd(a, -10), [1, 2, 3, 4, 5]) - eq(__LOC__, A.sliceToEnd(a, 6), []) -} -let () = { - let a = A.makeBy(10, x => x) - A.fill(a, ~offset=0, ~len=3, 0) - eq(__LOC__, A.copy(a), [0, 0, 0, 3, 4, 5, 6, 7, 8, 9]) - A.fill(a, ~offset=2, ~len=8, 1) - eq(__LOC__, A.copy(a), [0, 0, 1, 1, 1, 1, 1, 1, 1, 1]) - A.fill(a, ~offset=8, ~len=1, 9) - eq(__LOC__, A.copy(a), [0, 0, 1, 1, 1, 1, 1, 1, 9, 1]) - A.fill(a, ~offset=8, ~len=2, 9) - eq(__LOC__, A.copy(a), [0, 0, 1, 1, 1, 1, 1, 1, 9, 9]) - A.fill(a, ~offset=8, ~len=3, 12) - eq(__LOC__, A.copy(a), [0, 0, 1, 1, 1, 1, 1, 1, 12, 12]) - A.fill(a, ~offset=-2, ~len=3, 11) - eq(__LOC__, A.copy(a), [0, 0, 1, 1, 1, 1, 1, 1, 11, 11]) - A.fill(a, ~offset=-3, ~len=3, 10) - eq(__LOC__, A.copy(a), [0, 0, 1, 1, 1, 1, 1, 10, 10, 10]) - A.fill(a, ~offset=-3, ~len=1, 7) - eq(__LOC__, A.copy(a), [0, 0, 1, 1, 1, 1, 1, 7, 10, 10]) - A.fill(a, ~offset=-13, ~len=1, 7) - eq(__LOC__, A.copy(a), [7, 0, 1, 1, 1, 1, 1, 7, 10, 10]) - A.fill(a, ~offset=-13, ~len=12, 7) - eq(__LOC__, A.copy(a), A.make(10, 7)) - A.fill(a, ~offset=0, ~len=-1, 2) - eq(__LOC__, A.copy(a), A.make(10, 7)) - let b = [1, 2, 3] - A.fill(b, ~offset=0, ~len=0, 0) - eq(__LOC__, b, [1, 2, 3]) - A.fill(b, ~offset=4, ~len=1, 0) - eq(__LOC__, b, [1, 2, 3]) -} - -let () = { - let a0 = A.makeBy(10, x => x) - let b0 = A.make(10, 3) - A.blit(~src=a0, ~srcOffset=1, ~dst=b0, ~dstOffset=2, ~len=5) - eq(__LOC__, A.copy(b0), [3, 3, 1, 2, 3, 4, 5, 3, 3, 3]) - A.blit(~src=a0, ~srcOffset=-1, ~dst=b0, ~dstOffset=2, ~len=5) - eq(__LOC__, A.copy(b0), [3, 3, 9, 2, 3, 4, 5, 3, 3, 3]) - A.blit(~src=a0, ~srcOffset=-1, ~dst=b0, ~dstOffset=-2, ~len=5) - eq(__LOC__, A.copy(b0), [3, 3, 9, 2, 3, 4, 5, 3, 9, 3]) - A.blit(~src=a0, ~srcOffset=-2, ~dst=b0, ~dstOffset=-2, ~len=2) - eq(__LOC__, A.copy(b0), [3, 3, 9, 2, 3, 4, 5, 3, 8, 9]) - A.blit(~src=a0, ~srcOffset=-11, ~dst=b0, ~dstOffset=-11, ~len=100) - eq(__LOC__, A.copy(b0), a0) - A.blit(~src=a0, ~srcOffset=-11, ~dst=b0, ~dstOffset=-11, ~len=2) - eq(__LOC__, A.copy(b0), a0) - let aa = A.makeBy(10, x => x) - A.blit(~src=aa, ~srcOffset=-1, ~dst=aa, ~dstOffset=1, ~len=2) - eq(__LOC__, A.copy(aa), [0, 9, 2, 3, 4, 5, 6, 7, 8, 9]) - A.blit(~src=aa, ~srcOffset=-2, ~dst=aa, ~dstOffset=1, ~len=2) - eq(__LOC__, A.copy(aa), [0, 8, 9, 3, 4, 5, 6, 7, 8, 9]) - A.blit(~src=aa, ~srcOffset=-5, ~dst=aa, ~dstOffset=4, ~len=3) - eq(__LOC__, A.copy(aa), [0, 8, 9, 3, 5, 6, 7, 7, 8, 9]) - A.blit(~src=aa, ~srcOffset=4, ~dst=aa, ~dstOffset=5, ~len=3) - eq(__LOC__, A.copy(aa), [0, 8, 9, 3, 5, 5, 6, 7, 8, 9]) - eq(__LOC__, A.make(0, 3), []) - eq(__LOC__, A.make(-1, 3), []) - let c = [0, 1, 2] - A.blit(~src=c, ~srcOffset=4, ~dst=c, ~dstOffset=1, ~len=1) - eq(__LOC__, c, [0, 1, 2]) -} - -let () = { - eq(__LOC__, A.zip([1, 2, 3], [2, 3, 4, 1]), [(1, 2), (2, 3), (3, 4)]) - eq(__LOC__, A.zip([2, 3, 4, 1], [1, 2, 3]), [(2, 1), (3, 2), (4, 3)]) - eq(__LOC__, A.zipBy([2, 3, 4, 1], [1, 2, 3], \"-"), [1, 1, 1]) - eq(__LOC__, A.zipBy([1, 2, 3], [2, 3, 4, 1], \"-"), A.map([1, 1, 1], x => -x)) - eq(__LOC__, A.unzip([(1, 2), (2, 3), (3, 4)]), ([1, 2, 3], [2, 3, 4])) -} - -/* Here */ - -let sumUsingForEach = xs => { - let v = ref(0) - A.forEach(xs, x => v := v.contents + x) - v.contents -} - -let () = { - eq(__LOC__, sumUsingForEach([0, 1, 2, 3, 4]), 10) - b(__LOC__, !A.every([0, 1, 2, 3, 4], x => x > 2)) - b(__LOC__, A.some([1, 3, 7, 8], x => mod(x, 2) == 0)) - b(__LOC__, \"@@"(not, A.some([1, 3, 7], x => mod(x, 2) == 0))) - b(__LOC__, \"@@"(not, A.eq([0, 1], [1], \"="))) - b( - __LOC__, - { - let c = ref(0) - A.forEachWithIndex([1, 1, 1], (i, v) => c := c.contents + i + v) - c.contents == 6 - }, - ) -} - -let id = (loc, x) => - eq( - __LOC__, - A.reverse(x), - { - let u = A.copy(x) - A.reverseInPlace(u) - u - }, - ) - -let () = { - id(__LOC__, []) - id(__LOC__, [1]) - id(__LOC__, [1, 2]) - id(__LOC__, [1, 2, 3]) - id(__LOC__, [1, 2, 3, 4]) -} - -let () = { - module N = { - let every2 = (xs, ys) => A.every2(L.toArray(xs), L.toArray(ys)) - let some2 = (xs, ys) => A.some2(L.toArray(xs), L.toArray(ys)) - } - eq(__LOC__, N.every2(list{}, list{1}, (x, y) => x > y), true) - eq(__LOC__, N.every2(list{2, 3}, list{1}, (x, y) => x > y), true) - eq(__LOC__, N.every2(list{2}, list{1}, (x, y) => x > y), true) - eq(__LOC__, N.every2(list{2, 3}, list{1, 4}, (x, y) => x > y), false) - eq(__LOC__, N.every2(list{2, 3}, list{1, 0}, (x, y) => x > y), true) - eq(__LOC__, N.some2(list{}, list{1}, (x, y) => x > y), false) - eq(__LOC__, N.some2(list{2, 3}, list{1}, (x, y) => x > y), true) - eq(__LOC__, N.some2(list{2, 3}, list{1, 4}, (x, y) => x > y), true) - eq(__LOC__, N.some2(list{0, 3}, list{1, 4}, (x, y) => x > y), false) - eq(__LOC__, N.some2(list{0, 3}, list{3, 2}, (x, y) => x > y), true) -} - -let () = { - eq(__LOC__, A.concat([], [1, 2, 3]), [1, 2, 3]) - eq(__LOC__, A.concat([], []), []) - eq(__LOC__, A.concat([3, 2], [1, 2, 3]), [3, 2, 1, 2, 3]) - eq(__LOC__, A.concatMany([[3, 2], [1, 2, 3]]), [3, 2, 1, 2, 3]) - eq(__LOC__, A.concatMany([[3, 2], [1, 2, 3], [], [0]]), [3, 2, 1, 2, 3, 0]) - eq(__LOC__, A.concatMany([[], [3, 2], [1, 2, 3], [], [0]]), [3, 2, 1, 2, 3, 0]) - eq(__LOC__, A.concatMany([[], []]), []) -} - -let () = { - b(__LOC__, A.cmp([1, 2, 3], [0, 1, 2, 3], compare) < 0) - b(__LOC__, A.cmp([0, 1, 2, 3], [1, 2, 3], compare) > 0) - b(__LOC__, A.cmp([1, 2, 3], [0, 1, 2], (x, y) => compare(x, y)) > 0) - b(__LOC__, A.cmp([1, 2, 3], [1, 2, 3], (x, y) => compare(x, y)) == 0) - b(__LOC__, A.cmp([1, 2, 4], [1, 2, 3], (x, y) => compare(x, y)) > 0) -} - -let () = { - eq(__LOC__, A.getBy([1, 2, 3], x => x > 1), Some(2)) - eq(__LOC__, A.getBy([1, 2, 3], x => x > 3), None) -} - -let () = { - eq(__LOC__, A.getIndexBy([1, 2, 3], x => x > 1), Some(1)) - eq(__LOC__, A.getIndexBy([1, 2, 3], x => x > 3), None) -} - -let () = { - let arr = [] - arr->push(3) - arr->push(2) - arr->push(1) - eq(__LOC__, arr, [3, 2, 1]) -} - -Mt.from_pair_suites(__LOC__, suites.contents) diff --git a/jscomp/test/bs_float_test.js b/jscomp/test/bs_float_test.js deleted file mode 100644 index e124c86d489..00000000000 --- a/jscomp/test/bs_float_test.js +++ /dev/null @@ -1,99 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Belt_Float = require("../../lib/js/belt_Float.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -function $$throw(loc, x) { - Mt.throw_suites(test_id, suites, loc, x); -} - -function neq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + String(test_id.contents)), - (function (param) { - return { - TAG: "Neq", - _0: x, - _1: y - }; - }) - ], - tl: suites.contents - }; -} - -eq("File \"bs_float_test.res\", line 18, characters 5-12", 1, 1.0); - -eq("File \"bs_float_test.res\", line 19, characters 5-12", -1, -1.0); - -eq("File \"bs_float_test.res\", line 23, characters 5-12", 1, 1); - -eq("File \"bs_float_test.res\", line 24, characters 5-12", 1, 1); - -eq("File \"bs_float_test.res\", line 25, characters 5-12", 1, 1); - -eq("File \"bs_float_test.res\", line 26, characters 5-12", -1, -1); - -eq("File \"bs_float_test.res\", line 27, characters 5-12", -1, -1); - -eq("File \"bs_float_test.res\", line 28, characters 5-12", -1, -1); - -eq("File \"bs_float_test.res\", line 32, characters 5-12", Belt_Float.fromString("1"), 1.0); - -eq("File \"bs_float_test.res\", line 33, characters 5-12", Belt_Float.fromString("-1"), -1.0); - -eq("File \"bs_float_test.res\", line 34, characters 5-12", Belt_Float.fromString("1.7"), 1.7); - -eq("File \"bs_float_test.res\", line 35, characters 5-12", Belt_Float.fromString("-1.0"), -1.0); - -eq("File \"bs_float_test.res\", line 36, characters 5-12", Belt_Float.fromString("-1.5"), -1.5); - -eq("File \"bs_float_test.res\", line 37, characters 5-12", Belt_Float.fromString("-1.7"), -1.7); - -eq("File \"bs_float_test.res\", line 38, characters 5-12", Belt_Float.fromString("not a float"), undefined); - -eq("File \"bs_float_test.res\", line 42, characters 5-12", String(1.0), "1"); - -eq("File \"bs_float_test.res\", line 43, characters 5-12", String(-1.0), "-1"); - -eq("File \"bs_float_test.res\", line 44, characters 5-12", String(-1.5), "-1.5"); - -eq("File \"bs_float_test.res\", line 49, characters 5-12", 2.0 + 3.0, 5.0); - -eq("File \"bs_float_test.res\", line 50, characters 5-12", 2.0 - 3.0, -1.0); - -eq("File \"bs_float_test.res\", line 51, characters 5-12", 2.0 * 3.0, 6.0); - -eq("File \"bs_float_test.res\", line 52, characters 5-12", 3.0 / 2.0, 1.5); - -Mt.from_pair_suites("File \"bs_float_test.res\", line 55, characters 20-27", suites.contents); - -var F; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.$$throw = $$throw; -exports.neq = neq; -exports.F = F; -/* Not a pure module */ diff --git a/jscomp/test/bs_float_test.res b/jscomp/test/bs_float_test.res deleted file mode 100644 index f1c08d830f5..00000000000 --- a/jscomp/test/bs_float_test.res +++ /dev/null @@ -1,55 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => Mt.eq_suites(loc, x, y, ~test_id, ~suites) -let b = (loc, x) => Mt.bool_suites(loc, x, ~test_id, ~suites) -let throw = (loc, x) => Mt.throw_suites(~test_id, ~suites, loc, x) -let neq = (loc, x, y) => { - incr(test_id) - suites := - list{ - (loc ++ (" id " ++ string_of_int(test_id.contents)), _ => Mt.Neq(x, y)), - ...suites.contents, - } -} - -module F = Belt.Float - -let () = { - eq(__LOC__, F.fromInt(1), 1.0) - eq(__LOC__, F.fromInt(-1), -1.0) -} - -let () = { - eq(__LOC__, F.toInt(1.0), 1) - eq(__LOC__, F.toInt(1.3), 1) - eq(__LOC__, F.toInt(1.7), 1) - eq(__LOC__, F.toInt(-1.0), -1) - eq(__LOC__, F.toInt(-1.5), -1) - eq(__LOC__, F.toInt(-1.7), -1) -} - -let () = { - eq(__LOC__, F.fromString("1"), Some(1.0)) - eq(__LOC__, F.fromString("-1"), Some(-1.0)) - eq(__LOC__, F.fromString("1.7"), Some(1.7)) - eq(__LOC__, F.fromString("-1.0"), Some(-1.0)) - eq(__LOC__, F.fromString("-1.5"), Some(-1.5)) - eq(__LOC__, F.fromString("-1.7"), Some(-1.7)) - eq(__LOC__, F.fromString("not a float"), None) -} - -let () = { - eq(__LOC__, F.toString(1.0), "1") - eq(__LOC__, F.toString(-1.0), "-1") - eq(__LOC__, F.toString(-1.5), "-1.5") -} - -let () = { - open! F - eq(__LOC__, 2.0 + 3.0, 5.0) - eq(__LOC__, 2.0 - 3.0, -1.0) - eq(__LOC__, 2.0 * 3.0, 6.0) - eq(__LOC__, 3.0 / 2.0, 1.5) -} - -Mt.from_pair_suites(__LOC__, suites.contents) diff --git a/jscomp/test/bs_hashmap_test.js b/jscomp/test/bs_hashmap_test.js deleted file mode 100644 index 10c30c94ccb..00000000000 --- a/jscomp/test/bs_hashmap_test.js +++ /dev/null @@ -1,133 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Caml = require("../../lib/js/caml.js"); -var Belt_Id = require("../../lib/js/belt_Id.js"); -var Hashtbl = require("../../lib/js/hashtbl.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); -var Belt_HashMap = require("../../lib/js/belt_HashMap.js"); -var Belt_SortArray = require("../../lib/js/belt_SortArray.js"); -var Array_data_util = require("./array_data_util.js"); -var Belt_internalBucketsType = require("../../lib/js/belt_internalBucketsType.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eqx(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -function eq(x, y) { - return x === y; -} - -var hash = Hashtbl.hash; - -var cmp = Caml.int_compare; - -var Y = Belt_Id.hashable(hash, eq); - -var empty = Belt_internalBucketsType.make(Y.hash, Y.eq, 30); - -function add(prim0, prim1) { - return prim0 + prim1 | 0; -} - -Belt_HashMap.mergeMany(empty, [ - [ - 1, - 1 - ], - [ - 2, - 3 - ], - [ - 3, - 3 - ], - [ - 2, - 2 - ] - ]); - -eqx("File \"bs_hashmap_test.res\", line 30, characters 6-13", Belt_HashMap.get(empty, 2), 2); - -eqx("File \"bs_hashmap_test.res\", line 31, characters 6-13", empty.size, 3); - -var u = Belt_Array.concat(Array_data_util.randomRange(30, 100), Array_data_util.randomRange(40, 120)); - -var v = Belt_Array.zip(u, u); - -var xx = Belt_HashMap.fromArray(v, Y); - -eqx("File \"bs_hashmap_test.res\", line 41, characters 6-13", xx.size, 91); - -eqx("File \"bs_hashmap_test.res\", line 42, characters 6-13", Belt_SortArray.stableSortBy(Belt_HashMap.keysToArray(xx), cmp), Array_data_util.range(30, 120)); - -var u$1 = Belt_Array.concat(Array_data_util.randomRange(0, 100000), Array_data_util.randomRange(0, 100)); - -var v$1 = Belt_internalBucketsType.make(Y.hash, Y.eq, 40); - -Belt_HashMap.mergeMany(v$1, Belt_Array.zip(u$1, u$1)); - -eqx("File \"bs_hashmap_test.res\", line 49, characters 6-13", v$1.size, 100001); - -for(var i = 0; i <= 1000; ++i){ - Belt_HashMap.remove(v$1, i); -} - -eqx("File \"bs_hashmap_test.res\", line 53, characters 6-13", v$1.size, 99000); - -for(var i$1 = 0; i$1 <= 2000; ++i$1){ - Belt_HashMap.remove(v$1, i$1); -} - -eqx("File \"bs_hashmap_test.res\", line 57, characters 6-13", v$1.size, 98000); - -b("File \"bs_hashmap_test.res\", line 58, characters 4-11", Belt_Array.every(Array_data_util.range(2001, 100000), (function (x) { - return Belt_HashMap.has(v$1, x); - }))); - -Mt.from_pair_suites("Bs_hashmap_test", suites.contents); - -var N; - -var S; - -var I; - -var $plus$plus = Belt_Array.concat; - -var A; - -var So; - -exports.suites = suites; -exports.test_id = test_id; -exports.eqx = eqx; -exports.b = b; -exports.N = N; -exports.S = S; -exports.eq = eq; -exports.hash = hash; -exports.cmp = cmp; -exports.Y = Y; -exports.empty = empty; -exports.I = I; -exports.$plus$plus = $plus$plus; -exports.add = add; -exports.A = A; -exports.So = So; -/* Y Not a pure module */ diff --git a/jscomp/test/bs_hashmap_test.res b/jscomp/test/bs_hashmap_test.res deleted file mode 100644 index d525565673a..00000000000 --- a/jscomp/test/bs_hashmap_test.res +++ /dev/null @@ -1,61 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eqx = (loc, x, y) => Mt.eq_suites(~test_id, ~suites, loc, x, y) -let b = (loc, x) => Mt.bool_suites(~test_id, ~suites, loc, x) -module N = Belt.HashMap -module S = Belt.Map.Int -/* module Y = struct - type t = int - - end */ -let eq = (x: int, y) => x == y -let hash = (x: int) => Hashtbl.hash(x) -let cmp = (x: int, y) => compare(x, y) -module Y = unpack(Belt.Id.hashable(~eq, ~hash)) -let empty: N.t = N.make(~id=module(Y), ~hintSize=30) - -/* -[%bs.hash { - eq : - hash : -}] -*/ - -module I = Array_data_util -let \"++" = Belt.Array.concat -let add = \"+" - -let () = { - N.mergeMany(empty, [(1, 1), (2, 3), (3, 3), (2, 2)]) - eqx(__LOC__, N.get(empty, 2), Some(2)) - eqx(__LOC__, N.size(empty), 3) -} - -module A = Belt.Array -module So = Belt.SortArray - -let () = { - let u = \"++"(I.randomRange(30, 100), I.randomRange(40, 120)) - let v = A.zip(u, u) - let xx = N.fromArray(~id=module(Y), v) - eqx(__LOC__, N.size(xx), 91) - eqx(__LOC__, So.stableSortBy(N.keysToArray(xx), cmp), I.range(30, 120)) -} - -let () = { - let u = \"++"(I.randomRange(0, 100_000), I.randomRange(0, 100)) - let v = N.make(~id=module(Y), ~hintSize=40) - N.mergeMany(v, A.zip(u, u)) - eqx(__LOC__, N.size(v), 100_001) - for i in 0 to 1_000 { - N.remove(v, i) - } - eqx(__LOC__, N.size(v), 99_000) - for i in 0 to 2_000 { - N.remove(v, i) - } - eqx(__LOC__, N.size(v), 98_000) - b(__LOC__, A.every(I.range(2_001, 100_000), x => N.has(v, x))) -} - -Mt.from_pair_suites(__MODULE__, suites.contents) diff --git a/jscomp/test/bs_hashset_int_test.js b/jscomp/test/bs_hashset_int_test.js deleted file mode 100644 index f75660f9cc6..00000000000 --- a/jscomp/test/bs_hashset_int_test.js +++ /dev/null @@ -1,132 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); -var Belt_SetInt = require("../../lib/js/belt_SetInt.js"); -var Array_data_util = require("./array_data_util.js"); -var Belt_HashSetInt = require("../../lib/js/belt_HashSetInt.js"); -var Belt_SortArrayInt = require("../../lib/js/belt_SortArrayInt.js"); -var Belt_internalBucketsType = require("../../lib/js/belt_internalBucketsType.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -function add(x, y) { - return x + y | 0; -} - -function sum2(h) { - var v = { - contents: 0 - }; - Belt_HashSetInt.forEach(h, (function (x) { - v.contents = v.contents + x | 0; - })); - return v.contents; -} - -var u = Belt_Array.concat(Array_data_util.randomRange(30, 100), Array_data_util.randomRange(40, 120)); - -var v = Belt_HashSetInt.fromArray(u); - -eq("File \"bs_hashset_int_test.res\", line 20, characters 5-12", v.size, 91); - -var xs = Belt_SetInt.toArray(Belt_SetInt.fromArray(Belt_HashSetInt.toArray(v))); - -eq("File \"bs_hashset_int_test.res\", line 22, characters 5-12", xs, Array_data_util.range(30, 120)); - -eq("File \"bs_hashset_int_test.res\", line 24, characters 5-12", Belt_HashSetInt.reduce(v, 0, add), 6825); - -eq("File \"bs_hashset_int_test.res\", line 25, characters 5-12", sum2(v), 6825); - -var u$1 = Belt_Array.concat(Array_data_util.randomRange(0, 100000), Array_data_util.randomRange(0, 100)); - -var v$1 = Belt_internalBucketsType.make(undefined, undefined, 40); - -Belt_HashSetInt.mergeMany(v$1, u$1); - -eq("File \"bs_hashset_int_test.res\", line 32, characters 5-12", v$1.size, 100001); - -for(var i = 0; i <= 1000; ++i){ - Belt_HashSetInt.remove(v$1, i); -} - -eq("File \"bs_hashset_int_test.res\", line 36, characters 5-12", v$1.size, 99000); - -for(var i$1 = 0; i$1 <= 2000; ++i$1){ - Belt_HashSetInt.remove(v$1, i$1); -} - -eq("File \"bs_hashset_int_test.res\", line 40, characters 5-12", v$1.size, 98000); - -var u0 = Belt_HashSetInt.fromArray(Array_data_util.randomRange(0, 100000)); - -var u1 = Belt_HashSetInt.copy(u0); - -eq("File \"bs_hashset_int_test.res\", line 49, characters 5-12", Belt_HashSetInt.toArray(u0), Belt_HashSetInt.toArray(u1)); - -for(var i$2 = 0; i$2 <= 2000; ++i$2){ - Belt_HashSetInt.remove(u1, i$2); -} - -for(var i$3 = 0; i$3 <= 1000; ++i$3){ - Belt_HashSetInt.remove(u0, i$3); -} - -var v0 = Belt_Array.concat(Array_data_util.range(0, 1000), Belt_HashSetInt.toArray(u0)); - -var v1 = Belt_Array.concat(Array_data_util.range(0, 2000), Belt_HashSetInt.toArray(u1)); - -Belt_SortArrayInt.stableSortInPlace(v0); - -Belt_SortArrayInt.stableSortInPlace(v1); - -eq("File \"bs_hashset_int_test.res\", line 60, characters 5-12", v0, v1); - -var h = Belt_HashSetInt.fromArray(Array_data_util.randomRange(0, 1000000)); - -var histo = Belt_HashSetInt.getBucketHistogram(h); - -b("File \"bs_hashset_int_test.res\", line 66, characters 4-11", histo.length <= 10); - -Mt.from_pair_suites("Bs_hashset_int_test", suites.contents); - -var N; - -var S; - -var I; - -var $plus$plus = Belt_Array.concat; - -var A; - -var SI; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.N = N; -exports.S = S; -exports.I = I; -exports.$plus$plus = $plus$plus; -exports.add = add; -exports.sum2 = sum2; -exports.A = A; -exports.SI = SI; -/* u Not a pure module */ diff --git a/jscomp/test/bs_hashset_int_test.res b/jscomp/test/bs_hashset_int_test.res deleted file mode 100644 index ff89644de2f..00000000000 --- a/jscomp/test/bs_hashset_int_test.res +++ /dev/null @@ -1,68 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => Mt.eq_suites(~test_id, ~suites, loc, x, y) -let b = (loc, x) => Mt.bool_suites(~test_id, ~suites, loc, x) -module N = Belt.HashSet.Int -module S = Belt.Set.Int - -module I = Array_data_util -let \"++" = Belt.Array.concat -let add = (x, y) => x + y - -let sum2 = h => { - let v = ref(0) - N.forEach(h, x => v := v.contents + x) - v.contents -} -let () = { - let u = \"++"(I.randomRange(30, 100), I.randomRange(40, 120)) - let v = N.fromArray(u) - eq(__LOC__, N.size(v), 91) - let xs = S.toArray(S.fromArray(N.toArray(v))) - eq(__LOC__, xs, I.range(30, 120)) - let x = (30 + 120) / 2 * 91 - eq(__LOC__, N.reduce(v, 0, add), x) - eq(__LOC__, sum2(v), x) -} - -let () = { - let u = \"++"(I.randomRange(0, 100_000), I.randomRange(0, 100)) - let v = N.make(~hintSize=40) - N.mergeMany(v, u) - eq(__LOC__, N.size(v), 100_001) - for i in 0 to 1_000 { - N.remove(v, i) - } - eq(__LOC__, N.size(v), 99_000) - for i in 0 to 2_000 { - N.remove(v, i) - } - eq(__LOC__, N.size(v), 98_000) -} -module A = Belt.Array - -module SI = Belt.SortArray.Int - -let () = { - let u0 = N.fromArray(I.randomRange(0, 100_000)) - let u1 = N.copy(u0) - eq(__LOC__, N.toArray(u0), N.toArray(u1)) - for i in 0 to 2000 { - N.remove(u1, i) - } - for i in 0 to 1000 { - N.remove(u0, i) - } - let v0 = A.concat(I.range(0, 1000), N.toArray(u0)) - let v1 = A.concat(I.range(0, 2000), N.toArray(u1)) - SI.stableSortInPlace(v0) - SI.stableSortInPlace(v1) - eq(__LOC__, v0, v1) -} - -let () = { - let h = N.fromArray(I.randomRange(0, 1_000_000)) - let histo = N.getBucketHistogram(h) - b(__LOC__, A.length(histo) <= 10) -} -let () = Mt.from_pair_suites(__MODULE__, suites.contents) diff --git a/jscomp/test/bs_hashtbl_string_test.js b/jscomp/test/bs_hashtbl_string_test.js deleted file mode 100644 index f747ef5b4e3..00000000000 --- a/jscomp/test/bs_hashtbl_string_test.js +++ /dev/null @@ -1,346 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Caml = require("../../lib/js/caml.js"); -var Belt_Id = require("../../lib/js/belt_Id.js"); -var Hashtbl = require("../../lib/js/hashtbl.js"); -var Belt_HashMap = require("../../lib/js/belt_HashMap.js"); -var Belt_MapDict = require("../../lib/js/belt_MapDict.js"); -var Belt_HashMapInt = require("../../lib/js/belt_HashMapInt.js"); -var Belt_HashSetInt = require("../../lib/js/belt_HashSetInt.js"); -var Belt_HashMapString = require("../../lib/js/belt_HashMapString.js"); -var Caml_hash_primitive = require("../../lib/js/caml_hash_primitive.js"); -var Belt_internalBucketsType = require("../../lib/js/belt_internalBucketsType.js"); - -function hash_string(s) { - return Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, s)); -} - -var hashString = (function(str){ - var hash = 5381, - i = str.length | 0; - - while(i !== 0) { - hash = (hash * 33) ^ str.charCodeAt(--i); - } - return hash}); - -var $$String = Belt_Id.hashable(Hashtbl.hash, (function (x, y) { - return x === y; - })); - -var String1 = Belt_Id.hashable(hashString, (function (x, y) { - return x === y; - })); - -var String2 = Belt_Id.hashable((function (x) { - return Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, x)); - }), (function (x, y) { - return x === y; - })); - -var Int = Belt_Id.hashable(Hashtbl.hash, (function (x, y) { - return x === y; - })); - -var empty = Belt_internalBucketsType.make(Int.hash, Int.eq, 500000); - -function bench(param) { - for(var i = 0; i <= 1000000; ++i){ - Belt_HashMap.set(empty, i, i); - } - for(var i$1 = 0; i$1 <= 1000000; ++i$1){ - if (!Belt_HashMap.has(empty, i$1)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_hashtbl_string_test.res", - 37, - 4 - ], - Error: new Error() - }; - } - - } - Belt_HashMap.logStats(empty); -} - -function bench2(m) { - var empty = Belt_internalBucketsType.make(m.hash, m.eq, 1000000); - for(var i = 0; i <= 1000000; ++i){ - Belt_HashMap.set(empty, String(i), i); - } - for(var i$1 = 0; i$1 <= 1000000; ++i$1){ - if (!Belt_HashMap.has(empty, String(i$1))) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_hashtbl_string_test.res", - 61, - 4 - ], - Error: new Error() - }; - } - - } - for(var i$2 = 0; i$2 <= 1000000; ++i$2){ - Belt_HashMap.remove(empty, String(i$2)); - } - if (empty.size === 0) { - return ; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_hashtbl_string_test.res", - 66, - 2 - ], - Error: new Error() - }; -} - -function bench3(m) { - var empty_cmp = m.cmp; - var cmp = m.cmp; - var table = undefined; - for(var i = 0; i <= 1000000; ++i){ - table = Belt_MapDict.set(table, String(i), i, cmp); - } - for(var i$1 = 0; i$1 <= 1000000; ++i$1){ - if (!Belt_MapDict.has(table, String(i$1), cmp)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_hashtbl_string_test.res", - 81, - 4 - ], - Error: new Error() - }; - } - - } - for(var i$2 = 0; i$2 <= 1000000; ++i$2){ - table = Belt_MapDict.remove(table, String(i$2), cmp); - } - if (Belt_MapDict.size(table) === 0) { - return ; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_hashtbl_string_test.res", - 86, - 2 - ], - Error: new Error() - }; -} - -var Sx = Belt_Id.comparable(Caml.string_compare); - -function bench4(param) { - var table = Belt_internalBucketsType.make(undefined, undefined, 1000000); - for(var i = 0; i <= 1000000; ++i){ - Belt_HashMapString.set(table, String(i), i); - } - for(var i$1 = 0; i$1 <= 1000000; ++i$1){ - if (!Belt_HashMapString.has(table, String(i$1))) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_hashtbl_string_test.res", - 98, - 4 - ], - Error: new Error() - }; - } - - } - for(var i$2 = 0; i$2 <= 1000000; ++i$2){ - Belt_HashMapString.remove(table, String(i$2)); - } - if (Belt_HashMapString.isEmpty(table)) { - return ; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_hashtbl_string_test.res", - 103, - 2 - ], - Error: new Error() - }; -} - -function bench5(param) { - var table = Belt_internalBucketsType.make(Int.hash, Int.eq, 1000000); - console.time("bs_hashtbl_string_test.res 112"); - for(var i = 0; i <= 1000000; ++i){ - Belt_HashMap.set(table, i, i); - } - console.timeEnd("bs_hashtbl_string_test.res 112"); - console.time("bs_hashtbl_string_test.res 117"); - for(var i$1 = 0; i$1 <= 1000000; ++i$1){ - if (!Belt_HashMap.has(table, i$1)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_hashtbl_string_test.res", - 119, - 6 - ], - Error: new Error() - }; - } - - } - console.timeEnd("bs_hashtbl_string_test.res 117"); - console.time("bs_hashtbl_string_test.res 122"); - for(var i$2 = 0; i$2 <= 1000000; ++i$2){ - Belt_HashMap.remove(table, i$2); - } - console.timeEnd("bs_hashtbl_string_test.res 122"); - if (Belt_HashMap.isEmpty(table)) { - return ; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_hashtbl_string_test.res", - 127, - 2 - ], - Error: new Error() - }; -} - -function bench6(param) { - var table = Belt_internalBucketsType.make(undefined, undefined, 1000000); - for(var i = 0; i <= 1000000; ++i){ - Belt_HashMapInt.set(table, i, i); - } - for(var i$1 = 0; i$1 <= 1000000; ++i$1){ - if (!Belt_HashMapInt.has(table, i$1)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_hashtbl_string_test.res", - 138, - 4 - ], - Error: new Error() - }; - } - - } - for(var i$2 = 0; i$2 <= 1000000; ++i$2){ - Belt_HashMapInt.remove(table, i$2); - } - if (table.size === 0) { - return ; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_hashtbl_string_test.res", - 143, - 2 - ], - Error: new Error() - }; -} - -function bench7(param) { - var table = Belt_internalBucketsType.make(undefined, undefined, 2000000); - for(var i = 0; i <= 1000000; ++i){ - Belt_HashSetInt.add(table, i); - } - for(var i$1 = 0; i$1 <= 1000000; ++i$1){ - if (!Belt_HashSetInt.has(table, i$1)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_hashtbl_string_test.res", - 160, - 4 - ], - Error: new Error() - }; - } - - } - for(var i$2 = 0; i$2 <= 1000000; ++i$2){ - Belt_HashSetInt.remove(table, i$2); - } - if (table.size === 0) { - return ; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_hashtbl_string_test.res", - 170, - 2 - ], - Error: new Error() - }; -} - -console.time("bs_hashtbl_string_test.res 181"); - -bench7(); - -console.timeEnd("bs_hashtbl_string_test.res 181"); - -var N; - -var count = 1000000; - -var initial_size = 1000000; - -var M; - -var Md; - -var Md0; - -var H; - -var H0; - -var HI; - -var S; - -exports.hash_string = hash_string; -exports.hashString = hashString; -exports.$$String = $$String; -exports.String1 = String1; -exports.String2 = String2; -exports.Int = Int; -exports.N = N; -exports.empty = empty; -exports.bench = bench; -exports.count = count; -exports.initial_size = initial_size; -exports.M = M; -exports.bench2 = bench2; -exports.Md = Md; -exports.Md0 = Md0; -exports.bench3 = bench3; -exports.Sx = Sx; -exports.H = H; -exports.bench4 = bench4; -exports.H0 = H0; -exports.bench5 = bench5; -exports.HI = HI; -exports.bench6 = bench6; -exports.S = S; -exports.bench7 = bench7; -/* String Not a pure module */ diff --git a/jscomp/test/bs_hashtbl_string_test.res b/jscomp/test/bs_hashtbl_string_test.res deleted file mode 100644 index 052c81ecd20..00000000000 --- a/jscomp/test/bs_hashtbl_string_test.res +++ /dev/null @@ -1,186 +0,0 @@ -@@warning("-22") -type seed = int -external caml_hash_mix_string: (seed, string) => seed = "?hash_mix_string" -external final_mix: seed => seed = "?hash_final_mix" - -let hash_string = s => final_mix(caml_hash_mix_string(0, s)) - -let hashString: string => int = %raw(`function(str){ - var hash = 5381, - i = str.length | 0; - - while(i !== 0) { - hash = (hash * 33) ^ str.charCodeAt(--i); - } - return hash} - `) - -module String = unpack(Belt.Id.hashable(~eq=(x: string, y) => x == y, ~hash=Hashtbl.hash)) - -module String1 = unpack(Belt.Id.hashable(~eq=(x: string, y) => x == y, ~hash=hashString)) -module String2 = unpack( - Belt.Id.hashable(~eq=(x: string, y) => x == y, ~hash=(x: string) => hash_string(x)) -) - -module Int = unpack(Belt.Id.hashable(~eq=(x: int, y) => x == y, ~hash=Hashtbl.hash)) -module N = Belt.HashMap -let empty = N.make(~id=module(Int), ~hintSize=500_000) - -let bench = () => { - let count = 1_000_000 - /* let add = N.setDone in */ - let mem = N.has - for i in 0 to count { - N.set(empty, i, i) - } - for i in 0 to count { - assert(mem(empty, i)) - } - N.logStats(empty) -} - -let count = 1_000_000 -let initial_size = 1_000_000 -/* module B = Belt.Bag */ -/* - (empty : _ Belt.HashMap.t) - #.add (string_of_int i) i - #.add (string_of_int i) i -*/ -module M = Belt.HashMap -let bench2 = (type t, m: Belt.Id.hashable) => { - let empty = M.make(~id=m, ~hintSize=initial_size) - module String = unpack(m) - /* let hash = String.hash in - let eq = String.eq in */ - /* let table = M.getData empty in */ - for i in 0 to count { - M.set(empty, string_of_int(i), i) - } - for i in 0 to count { - assert(M.has(empty, string_of_int(i))) - } - for i in 0 to count { - M.remove(empty, string_of_int(i)) - } - assert (M.size(empty) == 0) -} - -/* Belt.HashMap.logStats empty */ -module Md = Belt.Map -module Md0 = Belt.Map.Dict -let bench3 = (type t, m: Belt.Id.comparable) => { - let empty = Md.make(~id=m) - module String = unpack(m) - let cmp = String.cmp - let table = ref(Md.getData(empty)) - for i in 0 to count { - table := Md0.set(~cmp, table.contents, string_of_int(i), i) - } - for i in 0 to count { - assert(Md0.has(~cmp, table.contents, string_of_int(i))) - } - for i in 0 to count { - table := Md0.remove(~cmp, table.contents, string_of_int(i)) - } - assert (Md0.size(table.contents) == 0) -} - -module Sx = unpack(Belt.Id.comparable(~cmp=(x: string, y) => compare(x, y))) -module H = Belt.HashMap.String -let bench4 = () => { - let table = H.make(~hintSize=initial_size) - - for i in 0 to count { - H.set(table, string_of_int(i), i) - } - for i in 0 to count { - assert(H.has(table, string_of_int(i))) - } - for i in 0 to count { - H.remove(table, string_of_int(i)) - } - assert(H.isEmpty(table)) -} - -module H0 = Belt.HashMap -let bench5 = () => { - let table = H0.make(~id=module(Int), ~hintSize=initial_size) - /* let table_data = M.getData table in */ - /* let hash = Int.hash in - let eq = Int.eq in */ - %time( - for i in 0 to count { - H0.set(table, i, i) - } - ) - %time( - for i in 0 to count { - assert(H0.has(table, i)) - } - ) - %time( - for i in 0 to count { - H0.remove(table, i) - } - ) - assert(H0.isEmpty(table)) -} - -module HI = Belt.HashMap.Int -let bench6 = () => { - let table = HI.make(~hintSize=initial_size) - - for i in 0 to count { - HI.set(table, i, i) - } - for i in 0 to count { - assert(HI.has(table, i)) - } - for i in 0 to count { - HI.remove(table, i) - } - assert (HI.size(table) == 0) -} - -module S = Belt.HashSet.Int -let bench7 = () => { - let table = /* [%time */ - S.make(~hintSize=initial_size * 2) - /* ] */ - - /* [%time */ - for i in 0 to count { - S.add(table, i) - } - /* ] */ - - /* [%time */ - for i in 0 to count { - assert(S.has(table, i)) - } - /* ] */ - - /* [%time */ - for i in 0 to count { - S.remove(table, i) - } - /* ] */ - - assert (S.size(table) == 0) -} - -/* ;; [%time bench4 ()] - ;; [%time bench4 ()] - ;; [%time bench2 (module String1)] - ;; [%time bench2 (module String2)] - - ;; [%time bench3 (module S)] - ;; [%time bench5()] */ -/* ;; [%time bench6 ()] */ -%time(bench7()) -/* ;; [%time bench7 ()] -;; [%time bench7 ()] -;; [%time bench7 ()] -;; [%time bench7 ()] -;; [%time bench7 ()] */ diff --git a/jscomp/test/bs_int_test.js b/jscomp/test/bs_int_test.js deleted file mode 100644 index 3f7a90d22ba..00000000000 --- a/jscomp/test/bs_int_test.js +++ /dev/null @@ -1,97 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Belt_Int = require("../../lib/js/belt_Int.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -function $$throw(loc, x) { - Mt.throw_suites(test_id, suites, loc, x); -} - -function neq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + String(test_id.contents)), - (function (param) { - return { - TAG: "Neq", - _0: x, - _1: y - }; - }) - ], - tl: suites.contents - }; -} - -eq("File \"bs_int_test.res\", line 18, characters 5-12", 1, 1.0); - -eq("File \"bs_int_test.res\", line 19, characters 5-12", -1, -1.0); - -eq("File \"bs_int_test.res\", line 23, characters 5-12", 1, 1); - -eq("File \"bs_int_test.res\", line 24, characters 5-12", 1, 1); - -eq("File \"bs_int_test.res\", line 25, characters 5-12", 1, 1); - -eq("File \"bs_int_test.res\", line 26, characters 5-12", -1, -1); - -eq("File \"bs_int_test.res\", line 27, characters 5-12", -1, -1); - -eq("File \"bs_int_test.res\", line 28, characters 5-12", -1, -1); - -eq("File \"bs_int_test.res\", line 32, characters 5-12", Belt_Int.fromString("1"), 1); - -eq("File \"bs_int_test.res\", line 33, characters 5-12", Belt_Int.fromString("-1"), -1); - -eq("File \"bs_int_test.res\", line 34, characters 5-12", Belt_Int.fromString("1.7"), 1); - -eq("File \"bs_int_test.res\", line 35, characters 5-12", Belt_Int.fromString("-1.0"), -1); - -eq("File \"bs_int_test.res\", line 36, characters 5-12", Belt_Int.fromString("-1.5"), -1); - -eq("File \"bs_int_test.res\", line 37, characters 5-12", Belt_Int.fromString("-1.7"), -1); - -eq("File \"bs_int_test.res\", line 38, characters 5-12", Belt_Int.fromString("not an int"), undefined); - -eq("File \"bs_int_test.res\", line 42, characters 5-12", String(1), "1"); - -eq("File \"bs_int_test.res\", line 43, characters 5-12", String(-1), "-1"); - -eq("File \"bs_int_test.res\", line 48, characters 5-12", 5, 5); - -eq("File \"bs_int_test.res\", line 49, characters 5-12", -1, -1); - -eq("File \"bs_int_test.res\", line 50, characters 5-12", 6, 6); - -eq("File \"bs_int_test.res\", line 51, characters 5-12", 0, 0); - -Mt.from_pair_suites("File \"bs_int_test.res\", line 54, characters 20-27", suites.contents); - -var I; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.$$throw = $$throw; -exports.neq = neq; -exports.I = I; -/* Not a pure module */ diff --git a/jscomp/test/bs_int_test.res b/jscomp/test/bs_int_test.res deleted file mode 100644 index 58a9c4597e3..00000000000 --- a/jscomp/test/bs_int_test.res +++ /dev/null @@ -1,54 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => Mt.eq_suites(loc, x, y, ~test_id, ~suites) -let b = (loc, x) => Mt.bool_suites(loc, x, ~test_id, ~suites) -let throw = (loc, x) => Mt.throw_suites(~test_id, ~suites, loc, x) -let neq = (loc, x, y) => { - incr(test_id) - suites := - list{ - (loc ++ (" id " ++ string_of_int(test_id.contents)), _ => Mt.Neq(x, y)), - ...suites.contents, - } -} - -module I = Belt.Int - -let () = { - eq(__LOC__, I.toFloat(1), 1.0) - eq(__LOC__, I.toFloat(-1), -1.0) -} - -let () = { - eq(__LOC__, I.fromFloat(1.0), 1) - eq(__LOC__, I.fromFloat(1.3), 1) - eq(__LOC__, I.fromFloat(1.7), 1) - eq(__LOC__, I.fromFloat(-1.0), -1) - eq(__LOC__, I.fromFloat(-1.5), -1) - eq(__LOC__, I.fromFloat(-1.7), -1) -} - -let () = { - eq(__LOC__, I.fromString("1"), Some(1)) - eq(__LOC__, I.fromString("-1"), Some(-1)) - eq(__LOC__, I.fromString("1.7"), Some(1)) - eq(__LOC__, I.fromString("-1.0"), Some(-1)) - eq(__LOC__, I.fromString("-1.5"), Some(-1)) - eq(__LOC__, I.fromString("-1.7"), Some(-1)) - eq(__LOC__, I.fromString("not an int"), None) -} - -let () = { - eq(__LOC__, I.toString(1), "1") - eq(__LOC__, I.toString(-1), "-1") -} - -let () = { - open! I - eq(__LOC__, 2 + 3, 5) - eq(__LOC__, 2 - 3, -1) - eq(__LOC__, 2 * 3, 6) - eq(__LOC__, 2 / 3, 0) -} - -Mt.from_pair_suites(__LOC__, suites.contents) diff --git a/jscomp/test/bs_list_test.js b/jscomp/test/bs_list_test.js deleted file mode 100644 index 788934f3c56..00000000000 --- a/jscomp/test/bs_list_test.js +++ /dev/null @@ -1,2539 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Caml = require("../../lib/js/caml.js"); -var Caml_obj = require("../../lib/js/caml_obj.js"); -var Belt_List = require("../../lib/js/belt_List.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -function $$throw(loc, x) { - Mt.throw_suites(test_id, suites, loc, x); -} - -function sum(xs) { - var v = { - contents: 0 - }; - Belt_List.forEach(xs, (function (x) { - v.contents = v.contents + x | 0; - })); - return v.contents; -} - -function sum2(xs, ys) { - var v = { - contents: 0 - }; - Belt_List.forEach2(xs, ys, (function (x, y) { - v.contents = (v.contents + x | 0) + y | 0; - })); - return v.contents; -} - -var u = Belt_List.makeBy(5, (function (i) { - return Math.imul(i, i); - })); - -function f(i) { - eq("File \"bs_list_test.res\", line 27, characters 18-25", Belt_List.getExn(u, i), Math.imul(i, i)); -} - -for(var i = 0; i <= 4; ++i){ - f(i); -} - -eq("File \"bs_list_test.res\", line 31, characters 5-12", Belt_List.map(u, (function (i) { - return i + 1 | 0; - })), { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 5, - tl: { - hd: 10, - tl: { - hd: 17, - tl: /* [] */0 - } - } - } - } - }); - -eq("File \"bs_list_test.res\", line 32, characters 5-12", Belt_List.getBy({ - hd: 1, - tl: { - hd: 4, - tl: { - hd: 3, - tl: { - hd: 2, - tl: /* [] */0 - } - } - } - }, (function (x) { - return x % 2 === 0; - })), 4); - -eq("File \"bs_list_test.res\", line 33, characters 5-12", Belt_List.getBy({ - hd: 1, - tl: { - hd: 4, - tl: { - hd: 3, - tl: { - hd: 2, - tl: /* [] */0 - } - } - } - }, (function (x) { - return x % 5 === 0; - })), undefined); - -eq("FLATTEN", Belt_List.flatten({ - hd: { - hd: 1, - tl: /* [] */0 - }, - tl: { - hd: { - hd: 2, - tl: /* [] */0 - }, - tl: { - hd: { - hd: 3, - tl: /* [] */0 - }, - tl: { - hd: /* [] */0, - tl: { - hd: Belt_List.makeBy(4, (function (i) { - return i; - })), - tl: /* [] */0 - } - } - } - } - }), { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 0, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - } - } - } - } - }); - -eq("FLATTEN", Belt_List.flatten(/* [] */0), /* [] */0); - -eq("FLATTEN", Belt_List.flatten({ - hd: /* [] */0, - tl: { - hd: /* [] */0, - tl: { - hd: { - hd: 2, - tl: /* [] */0 - }, - tl: { - hd: { - hd: 1, - tl: /* [] */0 - }, - tl: { - hd: { - hd: 2, - tl: /* [] */0 - }, - tl: { - hd: /* [] */0, - tl: /* [] */0 - } - } - } - } - } - }), { - hd: 2, - tl: { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - } - }); - -eq("CONCATMANY", Belt_List.concatMany([ - { - hd: 1, - tl: /* [] */0 - }, - { - hd: 2, - tl: /* [] */0 - }, - { - hd: 3, - tl: /* [] */0 - }, - /* [] */0, - Belt_List.makeBy(4, (function (i) { - return i; - })) - ]), { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 0, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - } - } - } - } - }); - -eq("CONCATMANY", Belt_List.concatMany([]), /* [] */0); - -eq("CONCATMANY", Belt_List.concatMany([ - /* [] */0, - /* [] */0, - { - hd: 2, - tl: /* [] */0 - }, - { - hd: 1, - tl: /* [] */0 - }, - { - hd: 2, - tl: /* [] */0 - }, - /* [] */0 - ]), { - hd: 2, - tl: { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - } - }); - -eq("CONCATMANY", Belt_List.concatMany([ - /* [] */0, - /* [] */0, - { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, - { - hd: 1, - tl: /* [] */0 - }, - { - hd: 2, - tl: /* [] */0 - }, - /* [] */0 - ]), { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - } - } - }); - -eq("CONCATMANY", Belt_List.concatMany([{ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }]), { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }); - -eq("File \"bs_list_test.res\", line 66, characters 2-9", Belt_List.toArray(Belt_List.concat(Belt_List.makeBy(100, (function (i) { - return i; - })), Belt_List.makeBy(100, (function (i) { - return i; - })))), Belt_Array.concat(Belt_Array.makeBy(100, (function (i) { - return i; - })), Belt_Array.makeBy(100, (function (i) { - return i; - })))); - -eq("APPEND", Belt_List.concat({ - hd: 1, - tl: /* [] */0 - }, /* [] */0), { - hd: 1, - tl: /* [] */0 - }); - -eq("APPEND", Belt_List.concat(/* [] */0, { - hd: 1, - tl: /* [] */0 - }), { - hd: 1, - tl: /* [] */0 - }); - -eq("ZIP", Belt_List.zip({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - }), { - hd: [ - 1, - 3 - ], - tl: { - hd: [ - 2, - 4 - ], - tl: /* [] */0 - } - }); - -eq("ZIP", Belt_List.zip(/* [] */0, { - hd: 1, - tl: /* [] */0 - }), /* [] */0); - -eq("ZIP", Belt_List.zip(/* [] */0, /* [] */0), /* [] */0); - -eq("ZIP", Belt_List.zip({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, /* [] */0), /* [] */0); - -eq("ZIP", Belt_List.zip({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - }), { - hd: [ - 1, - 2 - ], - tl: { - hd: [ - 2, - 3 - ], - tl: { - hd: [ - 3, - 4 - ], - tl: /* [] */0 - } - } - }); - -function mod2(x) { - return x % 2 === 0; -} - -function evenIndex(_x, i) { - return i % 2 === 0; -} - -eq("PARTITION", Belt_List.partition({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - } - } - }, mod2), [ - { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - } - }, - { - hd: 1, - tl: { - hd: 3, - tl: { - hd: 3, - tl: /* [] */0 - } - } - } - ]); - -eq("PARTITION", Belt_List.partition({ - hd: 2, - tl: { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, mod2), [ - { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, - /* [] */0 - ]); - -eq("PARTITION", Belt_List.partition({ - hd: 2, - tl: { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, (function (x) { - return !mod2(x); - })), [ - /* [] */0, - { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - } - ]); - -eq("PARTITION", Belt_List.partition(/* [] */0, mod2), [ - /* [] */0, - /* [] */0 - ]); - -eq("UNZIP", Belt_List.unzip(/* [] */0), [ - /* [] */0, - /* [] */0 - ]); - -eq("UNZIP", Belt_List.unzip({ - hd: [ - 1, - 2 - ], - tl: /* [] */0 - }), [ - { - hd: 1, - tl: /* [] */0 - }, - { - hd: 2, - tl: /* [] */0 - } - ]); - -eq("UNZIP", Belt_List.unzip({ - hd: [ - 1, - 2 - ], - tl: { - hd: [ - 3, - 4 - ], - tl: /* [] */0 - } - }), [ - { - hd: 1, - tl: { - hd: 3, - tl: /* [] */0 - } - }, - { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - } - ]); - -eq("FILTER", Belt_List.keep({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, mod2), { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - }); - -eq("FILTER", Belt_List.keep({ - hd: 1, - tl: { - hd: 3, - tl: { - hd: 41, - tl: /* [] */0 - } - } - }, mod2), /* [] */0); - -eq("FILTER", Belt_List.keep(/* [] */0, mod2), /* [] */0); - -eq("FILTER", Belt_List.keep({ - hd: 2, - tl: { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 4, - tl: { - hd: 6, - tl: /* [] */0 - } - } - } - } - }, mod2), { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 2, - tl: { - hd: 4, - tl: { - hd: 6, - tl: /* [] */0 - } - } - } - } - }); - -eq("FILTER2", Belt_List.keepWithIndex(/* [] */0, evenIndex), /* [] */0); - -eq("FILTER2", Belt_List.keepWithIndex({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, evenIndex), { - hd: 1, - tl: { - hd: 3, - tl: /* [] */0 - } - }); - -eq("FILTER2", Belt_List.keepWithIndex({ - hd: 0, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: { - hd: 5, - tl: { - hd: 6, - tl: { - hd: 7, - tl: /* [] */0 - } - } - } - } - } - } - } - }, evenIndex), { - hd: 0, - tl: { - hd: 2, - tl: { - hd: 4, - tl: { - hd: 6, - tl: /* [] */0 - } - } - } - }); - -function id(x) { - return x; -} - -eq("MAP", Belt_List.map(Belt_List.makeBy(5, id), (function (x) { - return (x << 1); - })), { - hd: 0, - tl: { - hd: 2, - tl: { - hd: 4, - tl: { - hd: 6, - tl: { - hd: 8, - tl: /* [] */0 - } - } - } - } - }); - -eq("MAP", Belt_List.map(/* [] */0, id), /* [] */0); - -eq("MAP", Belt_List.map({ - hd: 1, - tl: /* [] */0 - }, (function (x) { - return -x | 0; - })), { - hd: -1, - tl: /* [] */0 - }); - -function add(a, b) { - return a + b | 0; -} - -var length_10_id = Belt_List.makeBy(10, id); - -var length_8_id = Belt_List.makeBy(8, id); - -var d = Belt_List.makeBy(10, (function (x) { - return (x << 1); - })); - -eq("MAP2", Belt_List.zipBy(length_10_id, length_10_id, add), d); - -eq("MAP2", Belt_List.zipBy(/* [] */0, { - hd: 1, - tl: /* [] */0 - }, add), /* [] */0); - -eq("MAP2", Belt_List.zipBy({ - hd: 1, - tl: /* [] */0 - }, /* [] */0, add), /* [] */0); - -eq("MAP2", Belt_List.zipBy(/* [] */0, /* [] */0, add), /* [] */0); - -eq("MAP2", Belt_List.zipBy(length_10_id, length_10_id, add), Belt_List.concat(Belt_List.map(length_8_id, (function (x) { - return (x << 1); - })), { - hd: 16, - tl: { - hd: 18, - tl: /* [] */0 - } - })); - -eq("MAP2", Belt_List.zipBy(length_10_id, length_8_id, add), Belt_List.mapWithIndex(length_8_id, (function (i, x) { - return i + x | 0; - }))); - -eq("MAP2", Belt_List.reverse(Belt_List.mapReverse2(length_10_id, length_10_id, add)), Belt_List.map(length_10_id, (function (x) { - return (x << 1); - }))); - -var xs = Belt_List.reverse(Belt_List.mapReverse2(length_8_id, length_10_id, add)); - -eq("File \"bs_list_test.res\", line 163, characters 5-12", Belt_List.length(xs), 8); - -eq("MAP2", xs, Belt_List.zipBy(length_10_id, length_8_id, add)); - -eq("MAP2", Belt_List.mapReverse2({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, (function (x, y) { - return x + y | 0; - })), { - hd: 4, - tl: { - hd: 2, - tl: /* [] */0 - } - }); - -eq("TAKE", Belt_List.take({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, 2), { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }); - -eq("TAKE", Belt_List.take(/* [] */0, 1), undefined); - -eq("TAKE", Belt_List.take({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, 3), undefined); - -eq("TAKE", Belt_List.take({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, 2), { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }); - -eq("TAKE", Belt_List.take(length_10_id, 8), length_8_id); - -eq("TAKE", Belt_List.take(length_10_id, 0), /* [] */0); - -eq("TAKE", Belt_List.take(length_8_id, -2), undefined); - -eq("DROP", Belt_List.drop(length_10_id, 10), /* [] */0); - -eq("DROP", Belt_List.drop(length_10_id, 8), { - hd: 8, - tl: { - hd: 9, - tl: /* [] */0 - } - }); - -eq("DROP", Belt_List.drop(length_10_id, 0), length_10_id); - -eq("DROP", Belt_List.drop(length_8_id, -1), undefined); - -var a = Belt_List.makeBy(5, id); - -eq("SPLIT", Belt_List.splitAt(/* [] */0, 1), undefined); - -eq("SPLIT", Belt_List.splitAt(a, 6), undefined); - -eq("SPLIT", Belt_List.splitAt(a, 5), [ - a, - /* [] */0 - ]); - -eq("SPLIT", Belt_List.splitAt(a, 4), [ - { - hd: 0, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - } - }, - { - hd: 4, - tl: /* [] */0 - } - ]); - -eq("SPLIT", Belt_List.splitAt(a, 3), [ - { - hd: 0, - tl: { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - } - }, - { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - ]); - -eq("SPLIT", Belt_List.splitAt(a, 2), [ - { - hd: 0, - tl: { - hd: 1, - tl: /* [] */0 - } - }, - { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - ]); - -eq("SPLIT", Belt_List.splitAt(a, 1), [ - { - hd: 0, - tl: /* [] */0 - }, - { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - } - ]); - -eq("SPLIT", Belt_List.splitAt(a, 0), [ - /* [] */0, - a - ]); - -eq("SPLIT", Belt_List.splitAt(a, -1), undefined); - -function succx(x) { - return x + 1 | 0; -} - -function eqx(x, y) { - return x === y; -} - -b("File \"bs_list_test.res\", line 205, characters 4-11", Belt_List.hasAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 2, (function (prim0, prim1) { - return prim0 === prim1; - }))); - -b("File \"bs_list_test.res\", line 206, characters 4-11", !Belt_List.hasAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 4, (function (prim0, prim1) { - return prim0 === prim1; - }))); - -b("File \"bs_list_test.res\", line 207, characters 4-11", Belt_List.hasAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 4, (function (x, y) { - return (x + 1 | 0) === y; - }))); - -eq("REMOVEASSOQ", Belt_List.removeAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 3, (function (prim0, prim1) { - return prim0 === prim1; - })), { - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: /* [] */0 - } - }); - -eq("REMOVEASSOQ", Belt_List.removeAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 1, (function (prim0, prim1) { - return prim0 === prim1; - })), { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - }); - -eq("REMOVEASSOQ", Belt_List.removeAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 2, (function (prim0, prim1) { - return prim0 === prim1; - })), { - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - }); - -eq("REMOVEASSOQ", Belt_List.removeAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 0, (function (prim0, prim1) { - return prim0 === prim1; - })), { - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }); - -eq("REMOVEASSOQ", Belt_List.removeAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 3, eqx), { - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: /* [] */0 - } - }); - -eq("REMOVEASSOQ", Belt_List.removeAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 1, eqx), { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - }); - -eq("REMOVEASSOQ", Belt_List.removeAssoc({ - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }, 2, eqx), { - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - }); - -eq("REMOVEASSOQ", Belt_List.removeAssoc(/* [] */0, 2, eqx), /* [] */0); - -var ll = { - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } -}; - -var ll0 = Belt_List.removeAssoc(ll, 0, eqx); - -b("File \"bs_list_test.res\", line 222, characters 4-11", ll === ll0); - -var ll1 = Belt_List.setAssoc(ll, 2, "22", (function (prim0, prim1) { - return prim0 === prim1; - })); - -eq("File \"bs_list_test.res\", line 224, characters 5-12", ll1, { - hd: [ - 1, - "1" - ], - tl: { - hd: [ - 2, - "22" - ], - tl: { - hd: [ - 3, - "3" - ], - tl: /* [] */0 - } - } - }); - -var ll2 = Belt_List.setAssoc(ll1, 22, "2", (function (prim0, prim1) { - return prim0 === prim1; - })); - -b("File \"bs_list_test.res\", line 226, characters 4-11", Caml_obj.equal(ll2, { - hd: [ - 22, - "2" - ], - tl: ll1 - })); - -b("File \"bs_list_test.res\", line 227, characters 4-11", Belt_List.tailExn(ll2) === ll1); - -b("File \"bs_list_test.res\", line 229, characters 4-11", Caml_obj.equal(Belt_List.setAssoc({ - hd: [ - 1, - "a" - ], - tl: { - hd: [ - 2, - "b" - ], - tl: { - hd: [ - 3, - "c" - ], - tl: /* [] */0 - } - } - }, 2, "x", (function (prim0, prim1) { - return prim0 === prim1; - })), { - hd: [ - 1, - "a" - ], - tl: { - hd: [ - 2, - "x" - ], - tl: { - hd: [ - 3, - "c" - ], - tl: /* [] */0 - } - } - })); - -b("File \"bs_list_test.res\", line 234, characters 4-11", Caml_obj.equal(Belt_List.setAssoc({ - hd: [ - 1, - "a" - ], - tl: { - hd: [ - 3, - "c" - ], - tl: /* [] */0 - } - }, 2, "2", (function (prim0, prim1) { - return prim0 === prim1; - })), { - hd: [ - 2, - "2" - ], - tl: { - hd: [ - 1, - "a" - ], - tl: { - hd: [ - 3, - "c" - ], - tl: /* [] */0 - } - } - })); - -eq("File \"bs_list_test.res\", line 237, characters 5-12", Belt_List.setAssoc(/* [] */0, 1, "1", (function (prim0, prim1) { - return prim0 === prim1; - })), { - hd: [ - 1, - "1" - ], - tl: /* [] */0 - }); - -debugger; - -eq("File \"bs_list_test.res\", line 239, characters 5-12", Belt_List.setAssoc({ - hd: [ - 1, - "2" - ], - tl: /* [] */0 - }, 1, "1", (function (prim0, prim1) { - return prim0 === prim1; - })), { - hd: [ - 1, - "1" - ], - tl: /* [] */0 - }); - -eq("File \"bs_list_test.res\", line 241, characters 5-12", Belt_List.setAssoc({ - hd: [ - 0, - "0" - ], - tl: { - hd: [ - 1, - "2" - ], - tl: /* [] */0 - } - }, 1, "1", (function (prim0, prim1) { - return prim0 === prim1; - })), { - hd: [ - 0, - "0" - ], - tl: { - hd: [ - 1, - "1" - ], - tl: /* [] */0 - } - }); - -b("File \"bs_list_test.res\", line 242, characters 4-11", Caml_obj.equal(Belt_List.getAssoc({ - hd: [ - 1, - "a" - ], - tl: { - hd: [ - 2, - "b" - ], - tl: { - hd: [ - 3, - "c" - ], - tl: /* [] */0 - } - } - }, 2, (function (prim0, prim1) { - return prim0 === prim1; - })), "b")); - -b("File \"bs_list_test.res\", line 243, characters 4-11", Belt_List.getAssoc({ - hd: [ - 1, - "a" - ], - tl: { - hd: [ - 2, - "b" - ], - tl: { - hd: [ - 3, - "c" - ], - tl: /* [] */0 - } - } - }, 4, (function (prim0, prim1) { - return prim0 === prim1; - })) === undefined); - -eq("File \"bs_list_test.res\", line 248, characters 4-11", [ - Belt_List.head(length_10_id), - Belt_List.tail(length_10_id) - ], [ - 0, - Belt_List.drop(length_10_id, 1) - ]); - -eq("File \"bs_list_test.res\", line 255, characters 5-12", Belt_List.head(/* [] */0), undefined); - -$$throw("File \"bs_list_test.res\", line 256, characters 8-15", (function (param) { - Belt_List.headExn(/* [] */0); - })); - -$$throw("File \"bs_list_test.res\", line 257, characters 8-15", (function (param) { - Belt_List.tailExn(/* [] */0); - })); - -$$throw("File \"bs_list_test.res\", line 258, characters 8-15", (function (param) { - Belt_List.getExn({ - hd: 0, - tl: { - hd: 1, - tl: /* [] */0 - } - }, -1); - })); - -$$throw("File \"bs_list_test.res\", line 259, characters 8-15", (function (param) { - Belt_List.getExn({ - hd: 0, - tl: { - hd: 1, - tl: /* [] */0 - } - }, 2); - })); - -eq("File \"bs_list_test.res\", line 260, characters 5-12", Belt_List.map({ - hd: 0, - tl: { - hd: 1, - tl: /* [] */0 - } - }, (function (i) { - return Belt_List.getExn({ - hd: 0, - tl: { - hd: 1, - tl: /* [] */0 - } - }, i); - })), { - hd: 0, - tl: { - hd: 1, - tl: /* [] */0 - } - }); - -eq("File \"bs_list_test.res\", line 261, characters 5-12", Belt_List.headExn({ - hd: 1, - tl: /* [] */0 - }), 1); - -eq("File \"bs_list_test.res\", line 262, characters 5-12", Belt_List.tailExn({ - hd: 1, - tl: /* [] */0 - }), /* [] */0); - -Belt_List.forEachWithIndex(length_10_id, (function (i, x) { - eq("File \"bs_list_test.res\", line 263, characters 48-55", Belt_List.get(length_10_id, i), x); - })); - -eq("File \"bs_list_test.res\", line 264, characters 5-12", Belt_List.tail(/* [] */0), undefined); - -eq("File \"bs_list_test.res\", line 265, characters 5-12", Belt_List.drop(/* [] */0, 3), undefined); - -eq("File \"bs_list_test.res\", line 266, characters 5-12", Belt_List.mapWithIndex(/* [] */0, (function (i, x) { - return i + x | 0; - })), /* [] */0); - -eq("File \"bs_list_test.res\", line 267, characters 5-12", Belt_List.get(length_10_id, -1), undefined); - -eq("File \"bs_list_test.res\", line 268, characters 5-12", Belt_List.get(length_10_id, 12), undefined); - -eq("File \"bs_list_test.res\", line 269, characters 5-12", sum(/* [] */0), 0); - -eq("File \"bs_list_test.res\", line 270, characters 5-12", sum(length_10_id), 45); - -eq("File \"bs_list_test.res\", line 271, characters 5-12", Belt_List.makeBy(0, id), /* [] */0); - -eq("File \"bs_list_test.res\", line 273, characters 4-11", Belt_List.reverse(Belt_List.reverse(length_10_id)), length_10_id); - -eq("File \"bs_list_test.res\", line 281, characters 4-11", Belt_List.reverse(Belt_List.reverse(length_8_id)), length_8_id); - -eq("File \"bs_list_test.res\", line 288, characters 5-12", Belt_List.reverse(/* [] */0), /* [] */0); - -eq("File \"bs_list_test.res\", line 289, characters 5-12", Belt_List.reverse(Belt_List.mapReverse(length_10_id, succx)), Belt_List.map(length_10_id, succx)); - -eq("File \"bs_list_test.res\", line 290, characters 5-12", Belt_List.reduce(length_10_id, 0, add), 45); - -eq("File \"bs_list_test.res\", line 291, characters 5-12", Belt_List.reduceReverse(length_10_id, 0, add), 45); - -eq("File \"bs_list_test.res\", line 292, characters 5-12", Belt_List.reduceReverse(Belt_List.makeBy(10000, (function (i) { - return i; - })), 0, (function (prim0, prim1) { - return prim0 + prim1 | 0; - })), 49995000); - -eq("File \"bs_list_test.res\", line 295, characters 5-12", sum2(length_10_id, length_10_id), 90); - -eq("File \"bs_list_test.res\", line 296, characters 5-12", sum2(length_8_id, length_10_id), 56); - -eq("File \"bs_list_test.res\", line 297, characters 5-12", sum2(length_10_id, length_8_id), 56); - -eq("File \"bs_list_test.res\", line 298, characters 5-12", Belt_List.reduce2(length_10_id, length_8_id, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; - })), 56); - -eq("File \"bs_list_test.res\", line 299, characters 5-12", Belt_List.reduce2({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 2, - tl: { - hd: 4, - tl: { - hd: 6, - tl: /* [] */0 - } - } - }, 0, (function (a, b, c) { - return (a + b | 0) + c | 0; - })), 18); - -eq("File \"bs_list_test.res\", line 300, characters 5-12", Belt_List.reduceReverse2(length_10_id, length_8_id, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; - })), 56); - -eq("File \"bs_list_test.res\", line 301, characters 5-12", Belt_List.reduceReverse2(length_10_id, length_10_id, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; - })), 90); - -eq("File \"bs_list_test.res\", line 302, characters 5-12", Belt_List.reduceReverse2({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; - })), 6); - -eq("File \"bs_list_test.res\", line 303, characters 5-12", Belt_List.every({ - hd: 2, - tl: { - hd: 4, - tl: { - hd: 6, - tl: /* [] */0 - } - } - }, mod2), true); - -eq("File \"bs_list_test.res\", line 304, characters 5-12", Belt_List.every({ - hd: 1, - tl: /* [] */0 - }, mod2), false); - -eq("File \"bs_list_test.res\", line 305, characters 5-12", Belt_List.every(/* [] */0, mod2), true); - -eq("File \"bs_list_test.res\", line 306, characters 5-12", Belt_List.some({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 5, - tl: /* [] */0 - } - } - }, mod2), true); - -eq("File \"bs_list_test.res\", line 307, characters 5-12", Belt_List.some({ - hd: 1, - tl: { - hd: 3, - tl: { - hd: 5, - tl: /* [] */0 - } - } - }, mod2), false); - -eq("File \"bs_list_test.res\", line 308, characters 5-12", Belt_List.some(/* [] */0, mod2), false); - -eq("File \"bs_list_test.res\", line 309, characters 5-12", Belt_List.has({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, "2", (function (x, s) { - return String(x) === s; - })), true); - -eq("File \"bs_list_test.res\", line 310, characters 5-12", Belt_List.has({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, "0", (function (x, s) { - return String(x) === s; - })), false); - -b("File \"bs_list_test.res\", line 312, characters 4-11", Belt_List.reduceReverse({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, 0, (function (prim0, prim1) { - return prim0 + prim1 | 0; - })) === 10); - -b("File \"bs_list_test.res\", line 313, characters 4-11", Belt_List.reduceReverse({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, 10, (function (prim0, prim1) { - return prim0 - prim1 | 0; - })) === 0); - -b("File \"bs_list_test.res\", line 314, characters 4-11", Caml_obj.equal(Belt_List.reduceReverse({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, /* [] */0, Belt_List.add), { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - })); - -b("File \"bs_list_test.res\", line 315, characters 4-11", Belt_List.reduce({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, 0, (function (prim0, prim1) { - return prim0 + prim1 | 0; - })) === 10); - -b("File \"bs_list_test.res\", line 316, characters 4-11", Belt_List.reduce({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, 10, (function (prim0, prim1) { - return prim0 - prim1 | 0; - })) === 0); - -b("File \"bs_list_test.res\", line 317, characters 4-11", Caml_obj.equal(Belt_List.reduce({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, /* [] */0, Belt_List.add), { - hd: 4, - tl: { - hd: 3, - tl: { - hd: 2, - tl: { - hd: 1, - tl: /* [] */0 - } - } - } - })); - -b("File \"bs_list_test.res\", line 318, characters 4-11", Belt_List.reduceWithIndex({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, 0, (function (acc, x, i) { - return (acc + x | 0) + i | 0; - })) === 16); - -b("File \"bs_list_test.res\", line 319, characters 4-11", Belt_List.reduceReverse2({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; - })) === 6); - -var a$1 = Belt_List.makeBy(10000, (function (i) { - return i; - })); - -b("File \"bs_list_test.res\", line 322, characters 4-11", Belt_List.reduceReverse2(a$1, { - hd: 0, - tl: a$1 - }, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; - })) === 99980001); - -eq("File \"bs_list_test.res\", line 328, characters 5-12", Belt_List.every2(/* [] */0, { - hd: 1, - tl: /* [] */0 - }, (function (x, y) { - return x > y; - })), true); - -eq("File \"bs_list_test.res\", line 329, characters 5-12", Belt_List.every2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: /* [] */0 - }, (function (x, y) { - return x > y; - })), true); - -eq("File \"bs_list_test.res\", line 330, characters 5-12", Belt_List.every2({ - hd: 2, - tl: /* [] */0 - }, { - hd: 1, - tl: /* [] */0 - }, (function (x, y) { - return x > y; - })), true); - -eq("File \"bs_list_test.res\", line 331, characters 5-12", Belt_List.every2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: { - hd: 4, - tl: /* [] */0 - } - }, (function (x, y) { - return x > y; - })), false); - -eq("File \"bs_list_test.res\", line 332, characters 5-12", Belt_List.every2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: { - hd: 0, - tl: /* [] */0 - } - }, (function (x, y) { - return x > y; - })), true); - -eq("File \"bs_list_test.res\", line 333, characters 5-12", Belt_List.some2(/* [] */0, { - hd: 1, - tl: /* [] */0 - }, (function (x, y) { - return x > y; - })), false); - -eq("File \"bs_list_test.res\", line 334, characters 5-12", Belt_List.some2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: /* [] */0 - }, (function (x, y) { - return x > y; - })), true); - -eq("File \"bs_list_test.res\", line 335, characters 5-12", Belt_List.some2({ - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: { - hd: 4, - tl: /* [] */0 - } - }, (function (x, y) { - return x > y; - })), true); - -eq("File \"bs_list_test.res\", line 336, characters 5-12", Belt_List.some2({ - hd: 0, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: { - hd: 4, - tl: /* [] */0 - } - }, (function (x, y) { - return x > y; - })), false); - -eq("File \"bs_list_test.res\", line 337, characters 5-12", Belt_List.some2({ - hd: 0, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 3, - tl: { - hd: 2, - tl: /* [] */0 - } - }, (function (x, y) { - return x > y; - })), true); - -eq("File \"bs_list_test.res\", line 338, characters 5-12", Belt_List.some2({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: -1, - tl: { - hd: -2, - tl: /* [] */0 - } - }, (function (x, y) { - return x === y; - })), false); - -function makeTest(n) { - eq("File \"bs_list_test.res\", line 341, characters 23-30", Belt_List.make(n, 3), Belt_List.makeBy(n, (function (param) { - return 3; - }))); -} - -eq("File \"bs_list_test.res\", line 343, characters 12-19", { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - }); - -b("File \"bs_list_test.res\", line 345, characters 4-11", Belt_List.cmp({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 0, - tl: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - } - }, Caml.int_compare) > 0); - -b("File \"bs_list_test.res\", line 346, characters 4-11", Belt_List.cmp({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, Caml.int_compare) > 0); - -b("File \"bs_list_test.res\", line 347, characters 4-11", Belt_List.cmp({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, Caml.int_compare) < 0); - -b("File \"bs_list_test.res\", line 348, characters 4-11", Belt_List.cmp({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 0, - tl: { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - } - }, Caml.int_compare) > 0); - -b("File \"bs_list_test.res\", line 349, characters 4-11", Belt_List.cmp({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, Caml.int_compare) === 0); - -b("File \"bs_list_test.res\", line 350, characters 4-11", Belt_List.cmp({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, Caml.int_compare) > 0); - -b("File \"bs_list_test.res\", line 351, characters 4-11", Belt_List.cmpByLength(/* [] */0, /* [] */0) === 0); - -b("File \"bs_list_test.res\", line 352, characters 4-11", Belt_List.cmpByLength({ - hd: 1, - tl: /* [] */0 - }, /* [] */0) > 0); - -b("File \"bs_list_test.res\", line 353, characters 4-11", Belt_List.cmpByLength(/* [] */0, { - hd: 1, - tl: /* [] */0 - }) < 0); - -b("File \"bs_list_test.res\", line 354, characters 4-11", Belt_List.cmpByLength({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, { - hd: 1, - tl: /* [] */0 - }) > 0); - -b("File \"bs_list_test.res\", line 355, characters 4-11", Belt_List.cmpByLength({ - hd: 1, - tl: /* [] */0 - }, { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }) < 0); - -b("File \"bs_list_test.res\", line 356, characters 4-11", Belt_List.cmpByLength({ - hd: 1, - tl: { - hd: 3, - tl: /* [] */0 - } - }, { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }) === 0); - -makeTest(0); - -makeTest(1); - -makeTest(2); - -makeTest(3); - -function cmp(a, b) { - return a - b | 0; -} - -eq("SORT", Belt_List.sort({ - hd: 5, - tl: { - hd: 4, - tl: { - hd: 3, - tl: { - hd: 2, - tl: /* [] */0 - } - } - } - }, cmp), { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: { - hd: 5, - tl: /* [] */0 - } - } - } - }); - -eq("SORT", Belt_List.sort({ - hd: 3, - tl: { - hd: 9, - tl: { - hd: 37, - tl: { - hd: 3, - tl: { - hd: 1, - tl: /* [] */0 - } - } - } - } - }, cmp), { - hd: 1, - tl: { - hd: 3, - tl: { - hd: 3, - tl: { - hd: 9, - tl: { - hd: 37, - tl: /* [] */0 - } - } - } - } - }); - -b("File \"bs_list_test.res\", line 374, characters 4-11", !Belt_List.eq({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, (function (x, y) { - return x === y; - }))); - -b("File \"bs_list_test.res\", line 375, characters 4-11", Belt_List.eq({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, (function (x, y) { - return x === y; - }))); - -b("File \"bs_list_test.res\", line 376, characters 4-11", !Belt_List.eq({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 4, - tl: /* [] */0 - } - } - }, (function (x, y) { - return x === y; - }))); - -b("File \"bs_list_test.res\", line 377, characters 4-11", !Belt_List.eq({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, (function (prim0, prim1) { - return prim0 === prim1; - }))); - -var u0 = Belt_List.makeBy(20, (function (x) { - return x; - })); - -var u1 = Belt_List.keepMap(u0, (function (x) { - if (x % 7 === 0) { - return x + 1 | 0; - } - - })); - -eq("File \"bs_list_test.res\", line 388, characters 5-12", u1, { - hd: 1, - tl: { - hd: 8, - tl: { - hd: 15, - tl: /* [] */0 - } - } - }); - -b("File \"bs_list_test.res\", line 390, characters 4-11", Caml_obj.equal(Belt_List.keepMap({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, (function (x) { - if (x % 2 === 0) { - return -x | 0; - } - - })), { - hd: -2, - tl: { - hd: -4, - tl: /* [] */0 - } - })); - -b("File \"bs_list_test.res\", line 404, characters 4-11", Belt_List.keepMap({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: { - hd: 4, - tl: /* [] */0 - } - } - } - }, (function (x) { - if (x % 5 === 0) { - return x; - } - - })) === /* [] */0); - -Mt.from_pair_suites("Bs_list_test", suites.contents); - -var N; - -var A; - -var J; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.$$throw = $$throw; -exports.N = N; -exports.A = A; -exports.J = J; -exports.sum = sum; -exports.sum2 = sum2; -exports.mod2 = mod2; -exports.evenIndex = evenIndex; -exports.id = id; -exports.add = add; -exports.length_10_id = length_10_id; -exports.length_8_id = length_8_id; -exports.succx = succx; -exports.makeTest = makeTest; -/* u Not a pure module */ diff --git a/jscomp/test/bs_list_test.res b/jscomp/test/bs_list_test.res deleted file mode 100644 index 09725095558..00000000000 --- a/jscomp/test/bs_list_test.res +++ /dev/null @@ -1,414 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) - -let eq = (loc, x, y) => Mt.eq_suites(loc, x, y, ~test_id, ~suites) -let b = (loc, x) => Mt.bool_suites(~test_id, ~suites, loc, x) -let throw = (loc, x) => Mt.throw_suites(~test_id, ~suites, loc, x) - -/* module N = Belt.LinkList */ -module N = Belt.List -module A = Belt.Array -module J = Js.Json -let sum = xs => { - let v = ref(0) - N.forEach(xs, x => v := v.contents + x) - v.contents -} - -let sum2 = (xs, ys) => { - let v = ref(0) - N.forEach2(xs, ys, (x, y) => v := v.contents + x + y) - v.contents -} -let () = { - let u = N.makeBy(5, i => i * i) - - /* N.checkInvariantInternal u ; */ - let f = i => eq(__LOC__, N.getExn(u, i), i * i) - for i in 0 to 4 { - f(i) - } - eq(__LOC__, N.map(u, i => i + 1), list{1, 2, 5, 10, 17}) - eq(__LOC__, N.getBy(list{1, 4, 3, 2}, x => mod(x, 2) == 0), Some(4)) - eq(__LOC__, N.getBy(list{1, 4, 3, 2}, x => mod(x, 5) == 0), None) -} - -let () = { - let \"=~" = eq("FLATTEN") - - \"=~"( - { - open N - flatten(list{list{1}, list{2}, list{3}, list{}, makeBy(4, i => i)}) - }, - list{1, 2, 3, 0, 1, 2, 3}, - ) - \"=~"(N.flatten(list{}), list{}) - \"=~"(N.flatten(list{list{}, list{}, list{2}, list{1}, list{2}, list{}}), list{2, 1, 2}) -} - -let () = { - let \"=~" = eq("CONCATMANY") - \"=~"( - { - open N - concatMany([list{1}, list{2}, list{3}, list{}, makeBy(4, i => i)]) - }, - list{1, 2, 3, 0, 1, 2, 3}, - ) - \"=~"(N.concatMany([]), list{}) - \"=~"(N.concatMany([list{}, list{}, list{2}, list{1}, list{2}, list{}]), list{2, 1, 2}) - \"=~"(N.concatMany([list{}, list{}, list{2, 3}, list{1}, list{2}, list{}]), list{2, 3, 1, 2}) - \"=~"(N.concatMany([list{1, 2, 3}]), list{1, 2, 3}) -} - -let () = eq( - __LOC__, - { - open N - concat(makeBy(100, i => i), makeBy(100, i => i)) - } |> N.toArray, - { - open A - concat(makeBy(100, i => i), makeBy(100, i => i)) - }, -) -let () = { - let \"=~" = eq("APPEND") - \"=~"(N.concat(list{1}, list{}), list{1}) - \"=~"(N.concat(list{}, list{1}), list{1}) -} - -let () = { - let \"=~" = eq("ZIP") - - \"=~"(N.zip(list{1, 2, 3}, list{3, 4}), list{(1, 3), (2, 4)}) - \"=~"(N.zip(list{}, list{1}), list{}) - \"=~"(N.zip(list{}, list{}), list{}) - \"=~"(N.zip(list{1, 2, 3}, list{}), list{}) - \"=~"(N.zip(list{1, 2, 3}, list{2, 3, 4}), list{(1, 2), (2, 3), (3, 4)}) -} - -let mod2 = x => mod(x, 2) == 0 -let evenIndex = (_x, i) => mod(i, 2) == 0 - -let () = { - let \"=~" = eq("PARTITION") - - \"=~"(N.partition(list{1, 2, 3, 2, 3, 4}, mod2), (list{2, 2, 4}, list{1, 3, 3})) - \"=~"(N.partition(list{2, 2, 2, 4}, mod2), (list{2, 2, 2, 4}, list{})) - \"=~"(N.partition(list{2, 2, 2, 4}, x => !mod2(x)), (list{}, list{2, 2, 2, 4})) - \"=~"(N.partition(list{}, mod2), (list{}, list{})) -} - -let () = { - let \"=~" = eq("UNZIP") - \"=~"(N.unzip(list{}), (list{}, list{})) - \"=~"(N.unzip(list{(1, 2)}), (list{1}, list{2})) - \"=~"(N.unzip(list{(1, 2), (3, 4)}), (list{1, 3}, list{2, 4})) -} - -let () = { - let \"=~" = eq("FILTER") - \"=~"(N.keep(list{1, 2, 3, 4}, mod2), list{2, 4}) - \"=~"(N.keep(list{1, 3, 41}, mod2), list{}) - \"=~"(N.keep(list{}, mod2), list{}) - \"=~"(N.keep(list{2, 2, 2, 4, 6}, mod2), list{2, 2, 2, 4, 6}) -} - -let () = { - let \"=~" = eq("FILTER2") - \"=~"(N.keepWithIndex(list{}, evenIndex), list{}) - \"=~"(N.keepWithIndex(list{1, 2, 3, 4}, evenIndex), list{1, 3}) - \"=~"(N.keepWithIndex(list{0, 1, 2, 3, 4, 5, 6, 7}, evenIndex), list{0, 2, 4, 6}) -} - -let id: int => int = x => x - -let () = { - let \"=~" = eq("MAP") - \"=~"(N.map(N.makeBy(5, id), x => x * 2), list{0, 2, 4, 6, 8}) - \"=~"(N.map(list{}, id), list{}) - \"=~"(N.map(list{1}, x => -x), list{-1}) -} -let add = (a, b) => a + b -let length_10_id = N.makeBy(10, id) -let length_8_id = N.makeBy(8, id) -let () = { - let \"=~" = eq("MAP2") - let b = length_10_id - let c = length_8_id - let d = N.makeBy(10, x => 2 * x) - let map2_add = (x, y) => N.zipBy(x, y, add) - \"=~"(map2_add(length_10_id, b), d) - \"=~"(map2_add(list{}, list{1}), list{}) - \"=~"(map2_add(list{1}, list{}), list{}) - \"=~"(map2_add(list{}, list{}), list{}) - \"=~"( - map2_add(length_10_id, b), - { - open N - concat(map(c, x => x * 2), list{16, 18}) - }, - ) - \"=~"( - map2_add(length_10_id, length_8_id), - { - open N - mapWithIndex(length_8_id, (i, x) => i + x) - }, - ) - \"=~"(N.reverse(N.mapReverse2(length_10_id, length_10_id, add)), N.map(length_10_id, x => x * 2)) - let xs = N.reverse(N.mapReverse2(length_8_id, length_10_id, add)) - eq(__LOC__, N.length(xs), 8) - \"=~"(xs, N.zipBy(length_10_id, length_8_id, add)) - \"=~"(N.mapReverse2(list{1, 2, 3}, list{1, 2}, (x, y) => x + y), list{4, 2}) -} - -let () = { - let \"=~" = eq("TAKE") - \"=~"(N.take(list{1, 2, 3}, 2), Some(list{1, 2})) - \"=~"(N.take(list{}, 1), None) - \"=~"(N.take(list{1, 2}, 3), None) - \"=~"(N.take(list{1, 2}, 2), Some(list{1, 2})) - \"=~"(N.take(length_10_id, 8), Some(length_8_id)) - \"=~"(N.take(length_10_id, 0), Some(list{})) - \"=~"(N.take(length_8_id, -2), None) -} - -let () = { - let \"=~" = eq("DROP") - \"=~"(N.drop(length_10_id, 10), Some(list{})) - \"=~"(N.drop(length_10_id, 8), Some(list{8, 9})) - \"=~"(N.drop(length_10_id, 0), Some(length_10_id)) - \"=~"(N.drop(length_8_id, -1), None) -} - -let () = { - let \"=~" = eq("SPLIT") - let a = N.makeBy(5, id) - \"=~"(N.splitAt(list{}, 1), None) - \"=~"(N.splitAt(a, 6), None) - \"=~"(N.splitAt(a, 5), Some(a, list{})) - \"=~"(N.splitAt(a, 4), Some(list{0, 1, 2, 3}, list{4})) - \"=~"(N.splitAt(a, 3), Some(list{0, 1, 2}, list{3, 4})) - \"=~"(N.splitAt(a, 2), Some(list{0, 1}, list{2, 3, 4})) - \"=~"(N.splitAt(a, 1), Some(list{0}, list{1, 2, 3, 4})) - \"=~"(N.splitAt(a, 0), Some(list{}, a)) - \"=~"(N.splitAt(a, -1), None) -} -let succx = x => x + 1 - -let () = { - let \"=~" = eq("REMOVEASSOQ") - let eqx = (x, y) => (x: int) == y - b(__LOC__, N.hasAssoc(list{(1, "1"), (2, "2"), (3, "3")}, 2, \"=")) - b(__LOC__, !N.hasAssoc(list{(1, "1"), (2, "2"), (3, "3")}, 4, \"=")) - b(__LOC__, N.hasAssoc(list{(1, "1"), (2, "2"), (3, "3")}, 4, (x, y) => x + 1 == y)) - \"=~"(N.removeAssoc(list{(1, "1"), (2, "2"), (3, "3")}, 3, \"="), list{(1, "1"), (2, "2")}) - \"=~"(N.removeAssoc(list{(1, "1"), (2, "2"), (3, "3")}, 1, \"="), list{(2, "2"), (3, "3")}) - \"=~"(N.removeAssoc(list{(1, "1"), (2, "2"), (3, "3")}, 2, \"="), list{(1, "1"), (3, "3")}) - \"=~"( - N.removeAssoc(list{(1, "1"), (2, "2"), (3, "3")}, 0, \"="), - list{(1, "1"), (2, "2"), (3, "3")}, - ) - - \"=~"(N.removeAssoc(list{(1, "1"), (2, "2"), (3, "3")}, 3, eqx), list{(1, "1"), (2, "2")}) - \"=~"(N.removeAssoc(list{(1, "1"), (2, "2"), (3, "3")}, 1, eqx), list{(2, "2"), (3, "3")}) - \"=~"(N.removeAssoc(list{(1, "1"), (2, "2"), (3, "3")}, 2, eqx), list{(1, "1"), (3, "3")}) - \"=~"(N.removeAssoc(list{}, 2, eqx), list{}) - let ll = list{(1, "1"), (2, "2"), (3, "3")} - let ll0 = N.removeAssoc(ll, 0, eqx) - b(__LOC__, ll === ll0) - let ll1 = N.setAssoc(ll, 2, "22", \"=") - eq(__LOC__, ll1, list{(1, "1"), (2, "22"), (3, "3")}) - let ll2 = N.setAssoc(ll1, 22, "2", \"=") - b(__LOC__, ll2 == list{(22, "2"), ...ll1}) - b(__LOC__, N.tailExn(ll2) === ll1) - b( - __LOC__, - N.setAssoc(list{(1, "a"), (2, "b"), (3, "c")}, 2, "x", \"=") == - list{(1, "a"), (2, "x"), (3, "c")}, - ) - b( - __LOC__, - N.setAssoc(list{(1, "a"), (3, "c")}, 2, "2", \"=") == list{(2, "2"), (1, "a"), (3, "c")}, - ) - eq(__LOC__, N.setAssoc(list{}, 1, "1", \"="), list{(1, "1")}) - %debugger - eq(__LOC__, N.setAssoc(list{(1, "2")}, 1, "1", \"="), list{(1, "1")}) - - eq(__LOC__, N.setAssoc(list{(0, "0"), (1, "2")}, 1, "1", \"="), list{(0, "0"), (1, "1")}) - b(__LOC__, N.getAssoc(list{(1, "a"), (2, "b"), (3, "c")}, 2, \"=") == Some("b")) - b(__LOC__, N.getAssoc(list{(1, "a"), (2, "b"), (3, "c")}, 4, \"=") == None) -} - -let () = { - eq( - __LOC__, - { - open N - (head(length_10_id), tail(length_10_id)) - }, - (Some(0), N.drop(length_10_id, 1)), - ) - eq(__LOC__, N.head(list{}), None) - throw(__LOC__, _ => N.headExn(list{})) - throw(__LOC__, _ => N.tailExn(list{}) |> ignore) - throw(__LOC__, _ => N.getExn(list{0, 1}, -1) |> ignore) - throw(__LOC__, _ => N.getExn(list{0, 1}, 2) |> ignore) - eq(__LOC__, N.map(list{0, 1}, i => N.getExn(list{0, 1}, i)), list{0, 1}) - eq(__LOC__, N.headExn(list{1}), 1) - eq(__LOC__, N.tailExn(list{1}), list{}) - N.forEachWithIndex(length_10_id, (i, x) => eq(__LOC__, N.get(length_10_id, i), Some(x))) - eq(__LOC__, N.tail(list{}), None) - eq(__LOC__, N.drop(list{}, 3), None) - eq(__LOC__, N.mapWithIndex(list{}, (i, x) => i + x), list{}) - eq(__LOC__, N.get(length_10_id, -1), None) - eq(__LOC__, N.get(length_10_id, 12), None) - eq(__LOC__, sum(list{}), 0) - eq(__LOC__, sum(length_10_id), 45) - eq(__LOC__, N.makeBy(0, id), list{}) - eq( - __LOC__, - { - open N - reverse(reverse(length_10_id)) - }, - length_10_id, - ) - eq( - __LOC__, - { - open N - reverse(reverse(length_8_id)) - }, - length_8_id, - ) - eq(__LOC__, N.reverse(list{}), list{}) - eq(__LOC__, N.reverse(N.mapReverse(length_10_id, succx)), N.map(length_10_id, succx)) - eq(__LOC__, N.reduce(length_10_id, 0, add), 45) - eq(__LOC__, N.reduceReverse(length_10_id, 0, add), 45) - eq(__LOC__, N.reduceReverse(N.makeBy(10_000, i => i), 0, \"+"), 0 + 9_999 * 5_000) - /* eq __LOC__ - (N.mapRev2 length_10_id length_8_id add ) */ - eq(__LOC__, sum2(length_10_id, length_10_id), 90) - eq(__LOC__, sum2(length_8_id, length_10_id), 56) - eq(__LOC__, sum2(length_10_id, length_8_id), 56) - eq(__LOC__, N.reduce2(length_10_id, length_8_id, 0, (acc, x, y) => acc + x + y), 56) - eq(__LOC__, N.reduce2(list{1, 2, 3}, list{2, 4, 6}, 0, (a, b, c) => a + b + c), 18) - eq(__LOC__, N.reduceReverse2(length_10_id, length_8_id, 0, (acc, x, y) => acc + x + y), 56) - eq(__LOC__, N.reduceReverse2(length_10_id, length_10_id, 0, (acc, x, y) => acc + x + y), 90) - eq(__LOC__, N.reduceReverse2(list{1, 2, 3}, list{1, 2}, 0, (acc, x, y) => acc + x + y), 6) - eq(__LOC__, N.every(list{2, 4, 6}, mod2), true) - eq(__LOC__, N.every(list{1}, mod2), false) - eq(__LOC__, N.every(list{}, mod2), true) - eq(__LOC__, N.some(list{1, 2, 5}, mod2), true) - eq(__LOC__, N.some(list{1, 3, 5}, mod2), false) - eq(__LOC__, N.some(list{}, mod2), false) - eq(__LOC__, N.has(list{1, 2, 3}, "2", (x, s) => string_of_int(x) == s), true) - eq(__LOC__, N.has(list{1, 2, 3}, "0", (x, s) => string_of_int(x) == s), false) - - b(__LOC__, N.reduceReverse(list{1, 2, 3, 4}, 0, \"+") == 10) - b(__LOC__, N.reduceReverse(list{1, 2, 3, 4}, 10, \"-") == 0) - b(__LOC__, N.reduceReverse(list{1, 2, 3, 4}, list{}, N.add) == list{1, 2, 3, 4}) - b(__LOC__, N.reduce(list{1, 2, 3, 4}, 0, \"+") == 10) - b(__LOC__, N.reduce(list{1, 2, 3, 4}, 10, \"-") == 0) - b(__LOC__, N.reduce(list{1, 2, 3, 4}, list{}, N.add) == list{4, 3, 2, 1}) - b(__LOC__, N.reduceWithIndex(list{1, 2, 3, 4}, 0, (acc, x, i) => acc + x + i) == 16) - b(__LOC__, N.reduceReverse2(list{1, 2, 3}, list{1, 2}, 0, (acc, x, y) => acc + x + y) == 6) - let a = N.makeBy(10_000, i => i) - b( - __LOC__, - N.reduceReverse2(a, list{0, ...a}, 0, (acc, x, y) => acc + x + y) == 9_999 * 10_000 - 9999, - ) -} - -let () = { - eq(__LOC__, N.every2(list{}, list{1}, (x, y) => x > y), true) - eq(__LOC__, N.every2(list{2, 3}, list{1}, (x, y) => x > y), true) - eq(__LOC__, N.every2(list{2}, list{1}, (x, y) => x > y), true) - eq(__LOC__, N.every2(list{2, 3}, list{1, 4}, (x, y) => x > y), false) - eq(__LOC__, N.every2(list{2, 3}, list{1, 0}, (x, y) => x > y), true) - eq(__LOC__, N.some2(list{}, list{1}, (x, y) => x > y), false) - eq(__LOC__, N.some2(list{2, 3}, list{1}, (x, y) => x > y), true) - eq(__LOC__, N.some2(list{2, 3}, list{1, 4}, (x, y) => x > y), true) - eq(__LOC__, N.some2(list{0, 3}, list{1, 4}, (x, y) => x > y), false) - eq(__LOC__, N.some2(list{0, 3}, list{3, 2}, (x, y) => x > y), true) - eq(__LOC__, N.some2(list{1, 2, 3}, list{-1, -2}, (x, y) => x == y), false) -} - -let makeTest = n => eq(__LOC__, N.make(n, 3), N.makeBy(n, _ => 3)) - -let () = eq(__LOC__, list{}->N.add(3)->N.add(2), list{2, 3}) -let () = { - b(__LOC__, N.cmp(list{1, 2, 3}, list{0, 1, 2, 3}, compare) > 0) - b(__LOC__, N.cmp(list{1, 2, 3, 4}, list{1, 2, 3}, compare) > 0) - b(__LOC__, N.cmp(list{1, 2, 3}, list{1, 2, 3, 4}, compare) < 0) - b(__LOC__, N.cmp(list{1, 2, 3}, list{0, 1, 2}, (x, y) => compare(x, y)) > 0) - b(__LOC__, N.cmp(list{1, 2, 3}, list{1, 2, 3}, (x, y) => compare(x, y)) == 0) - b(__LOC__, N.cmp(list{1, 2, 4}, list{1, 2, 3}, (x, y) => compare(x, y)) > 0) - b(__LOC__, N.cmpByLength(list{}, list{}) == 0) - b(__LOC__, N.cmpByLength(list{1}, list{}) > 0) - b(__LOC__, N.cmpByLength(list{}, list{1}) < 0) - b(__LOC__, N.cmpByLength(list{1, 2}, list{1}) > 0) - b(__LOC__, N.cmpByLength(list{1}, list{1, 2}) < 0) - b(__LOC__, N.cmpByLength(list{1, 3}, list{1, 2}) == 0) -} - -let () = { - makeTest(0) - makeTest(1) - makeTest(2) - makeTest(3) -} - -let () = { - let \"=~" = eq("SORT") - let cmp = (a, b) => a - b - \"=~"(N.sort(list{5, 4, 3, 2}, cmp), list{2, 3, 4, 5}) - \"=~"(N.sort(list{3, 9, 37, 3, 1}, cmp), list{1, 3, 3, 9, 37}) -} - -let () = { - b(__LOC__, \"@@"(not, N.eq(list{1, 2, 3}, list{1, 2}, (x, y) => x == y))) - b(__LOC__, N.eq(list{1, 2, 3}, list{1, 2, 3}, (x, y) => x == y)) - b(__LOC__, \"@@"(not, N.eq(list{1, 2, 3}, list{1, 2, 4}, (x, y) => x == y))) - b(__LOC__, \"@@"(not, N.eq(list{1, 2, 3}, list{1, 2, 3, 4}, \"="))) -} -let () = { - let u0 = N.makeBy(20, x => x) - let u1 = u0->N.keepMap(x => - if mod(x, 7) == 0 { - Some(x + 1) - } else { - None - } - ) - eq(__LOC__, u1, list{1, 8, 15}) - b( - __LOC__, - { - open N - - list{1, 2, 3, 4}->keepMap(x => - if mod(x, 2) == 0 { - Some(-x) - } else { - None - } - ) == list{-2, -4} - }, - ) - b( - __LOC__, - N.keepMap(list{1, 2, 3, 4}, x => - if mod(x, 5) == 0 { - Some(x) - } else { - None - } - ) == list{}, - ) -} -Mt.from_pair_suites(__MODULE__, suites.contents) diff --git a/jscomp/test/bs_map_set_dict_test.js b/jscomp/test/bs_map_set_dict_test.js deleted file mode 100644 index 25c8beb3ffa..00000000000 --- a/jscomp/test/bs_map_set_dict_test.js +++ /dev/null @@ -1,214 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Caml = require("../../lib/js/caml.js"); -var Belt_Id = require("../../lib/js/belt_Id.js"); -var Belt_Map = require("../../lib/js/belt_Map.js"); -var Belt_List = require("../../lib/js/belt_List.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); -var Belt_MapDict = require("../../lib/js/belt_MapDict.js"); -var Belt_SetDict = require("../../lib/js/belt_SetDict.js"); -var Array_data_util = require("./array_data_util.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, v) { - Mt.bool_suites(test_id, suites, loc, v); -} - -var Icmp = Belt_Id.comparable(Caml.int_compare); - -var Icmp2 = Belt_Id.comparable(Caml.int_compare); - -var Ic3 = Belt_Id.comparable(Caml.int_compare); - -var m0_cmp = Icmp.cmp; - -var m0 = { - cmp: m0_cmp, - data: undefined -}; - -var m00_cmp = Ic3.cmp; - -var m00 = { - cmp: m00_cmp, - data: undefined -}; - -var I2 = Belt_Id.comparable(function (x, y) { - return Caml.int_compare(y, x); - }); - -var m_cmp = Icmp2.cmp; - -var m = { - cmp: m_cmp, - data: undefined -}; - -var m2_cmp = I2.cmp; - -var m2 = { - cmp: m2_cmp, - data: undefined -}; - -var data; - -Belt_Map.getId(m2); - -var m_dict = Belt_Map.getId(m); - -for(var i = 0; i <= 100000; ++i){ - data = Belt_MapDict.set(data, i, i, m_dict.cmp); -} - -var data$1 = data; - -var newm_cmp = m_dict.cmp; - -var newm = { - cmp: newm_cmp, - data: data$1 -}; - -console.log(newm); - -var m11 = Belt_MapDict.set(undefined, 1, 1, Icmp.cmp); - -console.log(m11); - -var m_dict$1 = Belt_Map.getId(m); - -var cmp = m_dict$1.cmp; - -var data$2; - -for(var i$1 = 0; i$1 <= 100000; ++i$1){ - data$2 = Belt_SetDict.add(data$2, i$1, cmp); -} - -console.log(data$2); - -function f(param) { - return Belt_Map.fromArray(param, Icmp); -} - -function $eq$tilde(a, b) { - return function (param) { - return Belt_Map.eq(a, b, param); - }; -} - -var u0 = f(Belt_Array.map(Array_data_util.randomRange(0, 39), (function (x) { - return [ - x, - x - ]; - }))); - -var u1 = Belt_Map.set(u0, 39, 120); - -b("File \"bs_map_set_dict_test.res\", line 72, characters 4-11", Belt_Array.every2(Belt_MapDict.toArray(u0.data), Belt_Array.map(Array_data_util.range(0, 39), (function (x) { - return [ - x, - x - ]; - })), (function (param, param$1) { - if (param[0] === param$1[0]) { - return param[1] === param$1[1]; - } else { - return false; - } - }))); - -b("File \"bs_map_set_dict_test.res\", line 79, characters 4-11", Belt_List.every2(Belt_MapDict.toList(u0.data), Belt_List.fromArray(Belt_Array.map(Array_data_util.range(0, 39), (function (x) { - return [ - x, - x - ]; - }))), (function (param, param$1) { - if (param[0] === param$1[0]) { - return param[1] === param$1[1]; - } else { - return false; - } - }))); - -eq("File \"bs_map_set_dict_test.res\", line 84, characters 5-12", Belt_Map.get(u0, 39), 39); - -eq("File \"bs_map_set_dict_test.res\", line 85, characters 5-12", Belt_Map.get(u1, 39), 120); - -var u = f(Belt_Array.makeByAndShuffle(10000, (function (x) { - return [ - x, - x - ]; - }))); - -eq("File \"bs_map_set_dict_test.res\", line 90, characters 5-12", Belt_Array.makeBy(10000, (function (x) { - return [ - x, - x - ]; - })), Belt_MapDict.toArray(u.data)); - -Mt.from_pair_suites("Bs_map_set_dict_test", suites.contents); - -var M; - -var MI; - -var I; - -var A; - -var L; - -var vv; - -var vv2; - -var Md0; - -var ISet; - -var S0; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.Icmp = Icmp; -exports.Icmp2 = Icmp2; -exports.Ic3 = Ic3; -exports.M = M; -exports.MI = MI; -exports.I = I; -exports.A = A; -exports.L = L; -exports.m0 = m0; -exports.m00 = m00; -exports.I2 = I2; -exports.m = m; -exports.m2 = m2; -exports.vv = vv; -exports.vv2 = vv2; -exports.Md0 = Md0; -exports.ISet = ISet; -exports.S0 = S0; -exports.f = f; -exports.$eq$tilde = $eq$tilde; -/* Icmp Not a pure module */ diff --git a/jscomp/test/bs_map_set_dict_test.res b/jscomp/test/bs_map_set_dict_test.res deleted file mode 100644 index 24075c1e600..00000000000 --- a/jscomp/test/bs_map_set_dict_test.res +++ /dev/null @@ -1,93 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => Mt.eq_suites(~suites, ~test_id, loc, x, y) -let b = (loc, v) => Mt.bool_suites(~suites, ~test_id, loc, v) - -module Icmp = unpack(Belt.Id.comparable(~cmp=(x: int, y) => compare(x, y))) -module Icmp2 = unpack(Belt.Id.comparable(~cmp=(x: int, y) => compare(x, y))) - -module Ic3 = unpack(Belt.Id.comparable(~cmp=(compare: (int, int) => int))) - -module M = Belt.Map -module MI = Belt.Map.Int -/* module B = Belt.Bag */ -module I = Array_data_util -module A = Belt.Array -module L = Belt.List -let m0: M.t<_, string, _> = M.make(~id=module(Icmp)) - -let m00 = Belt.Set.make(~id=module(Ic3)) -module I2 = unpack(Belt.Id.comparable(~cmp=(x: int, y) => compare(y, x))) - -let m = M.make(~id=module(Icmp2)) -let m2: M.t = M.make(~id=module(I2)) -let vv = MI.empty -let vv2 = MI.empty -module Md0 = Belt.Map.Dict -let () = { - let count = 1_000_00 - let data = ref(M.getData(m)) - let (m2_dict, m_dict) = { - open M - (getId(m2), getId(m)) - } - module N = unpack(m2_dict) - module Mm = unpack(m_dict) - for i in 0 to count { - data := Md0.set(data.contents, ~cmp=Mm.cmp, i, i) - } - let newm = M.packIdData(~data=data.contents, ~id=m_dict) - Js.log(newm) -} -module ISet = Belt.Set -let () = { - let m = Md0.empty - let m11 = Md0.set(~cmp=Icmp.cmp, m, 1, 1) - - let _m20 = M.make(~id=module(Icmp)) - Js.log(m11) -} - -module S0 = Belt.Set.Dict -let () = { - let count = 100_000 - let v = ISet.make(~id=module(Icmp2)) - let m_dict = M.getId(m) - module M = unpack(m_dict) - let cmp = M.cmp - let data = ref(ISet.getData(v)) - for i in 0 to count { - data := S0.add(~cmp, data.contents, i) - } - Js.log(data.contents) -} - -let f = M.fromArray(~id=module(Icmp)) -let \"=~" = (a, b) => M.eq(a, b) - -let () = { - let u0 = f(A.map(I.randomRange(0, 39), x => (x, x))) - let u1 = M.set(u0, 39, 120) - b( - __LOC__, - A.every2(M.toArray(u0), A.map(I.range(0, 39), x => (x, x)), ((x0, x1), (y0, y1)) => - x0 == y0 && x1 == y1 - ), - ) - - b( - __LOC__, - L.every2(M.toList(u0), L.fromArray(A.map(I.range(0, 39), x => (x, x))), ((x0, x1), (y0, y1)) => - x0 == y0 && x1 == y1 - ), - ) - eq(__LOC__, M.get(u0, 39), Some(39)) - eq(__LOC__, M.get(u1, 39), Some(120)) -} - -let () = { - let u = f(A.makeByAndShuffle(10_000, x => (x, x))) - eq(__LOC__, A.makeBy(10_000, x => (x, x)), M.toArray(u)) -} - -Mt.from_pair_suites(__MODULE__, suites.contents) diff --git a/jscomp/test/bs_map_test.js b/jscomp/test/bs_map_test.js deleted file mode 100644 index ac204f9f7fc..00000000000 --- a/jscomp/test/bs_map_test.js +++ /dev/null @@ -1,97 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); -var Belt_MapInt = require("../../lib/js/belt_MapInt.js"); -var Belt_SetInt = require("../../lib/js/belt_SetInt.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + String(test_id.contents)), - (function (param) { - return { - TAG: "Eq", - _0: x, - _1: y - }; - }) - ], - tl: suites.contents - }; -} - -function b(loc, v) { - test_id.contents = test_id.contents + 1 | 0; - suites.contents = { - hd: [ - loc + (" id " + String(test_id.contents)), - (function (param) { - return { - TAG: "Ok", - _0: v - }; - }) - ], - tl: suites.contents - }; -} - -var mapOfArray = Belt_MapInt.fromArray; - -var setOfArray = Belt_SetInt.fromArray; - -function emptyMap(param) { - -} - -var v = Belt_Array.makeByAndShuffle(1000000, (function (i) { - return [ - i, - i - ]; - })); - -var u = Belt_MapInt.fromArray(v); - -Belt_MapInt.checkInvariantInternal(u); - -var firstHalf = Belt_Array.slice(v, 0, 2000); - -var xx = Belt_Array.reduce(firstHalf, u, (function (acc, param) { - return Belt_MapInt.remove(acc, param[0]); - })); - -Belt_MapInt.checkInvariantInternal(u); - -Belt_MapInt.checkInvariantInternal(xx); - -Mt.from_pair_suites("Bs_map_test", suites.contents); - -var M; - -var N; - -var A; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.M = M; -exports.N = N; -exports.A = A; -exports.mapOfArray = mapOfArray; -exports.setOfArray = setOfArray; -exports.emptyMap = emptyMap; -/* v Not a pure module */ diff --git a/jscomp/test/bs_map_test.res b/jscomp/test/bs_map_test.res deleted file mode 100644 index 6c546fcf171..00000000000 --- a/jscomp/test/bs_map_test.res +++ /dev/null @@ -1,33 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => { - incr(test_id) - suites := - list{(loc ++ (" id " ++ string_of_int(test_id.contents)), _ => Mt.Eq(x, y)), ...suites.contents} -} - -let b = (loc, v) => { - incr(test_id) - suites := - list{(loc ++ (" id " ++ string_of_int(test_id.contents)), _ => Mt.Ok(v)), ...suites.contents} -} - -module M = Belt.Map.Int -module N = Belt.Set.Int -module A = Belt.Array - -let mapOfArray = x => M.fromArray(x) -let setOfArray = x => N.fromArray(x) -let emptyMap = () => M.empty - -let () = { - let v = A.makeByAndShuffle(1_000_000, i => (i, i)) - let u = M.fromArray(v) - M.checkInvariantInternal(u) - let firstHalf = A.slice(v, ~offset=0, ~len=2_000) - let xx = A.reduce(firstHalf, u, (acc, (x, _)) => M.remove(acc, x)) - M.checkInvariantInternal(u) - M.checkInvariantInternal(xx) -} - -Mt.from_pair_suites(__MODULE__, suites.contents) diff --git a/jscomp/test/bs_mutable_set_test.js b/jscomp/test/bs_mutable_set_test.js deleted file mode 100644 index bc6b575833f..00000000000 --- a/jscomp/test/bs_mutable_set_test.js +++ /dev/null @@ -1,860 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Belt_List = require("../../lib/js/belt_List.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); -var Belt_Range = require("../../lib/js/belt_Range.js"); -var Caml_array = require("../../lib/js/caml_array.js"); -var Array_data_util = require("./array_data_util.js"); -var Belt_MutableSetInt = require("../../lib/js/belt_MutableSetInt.js"); -var Belt_internalAVLset = require("../../lib/js/belt_internalAVLset.js"); -var Belt_internalSetInt = require("../../lib/js/belt_internalSetInt.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -var xs = Array_data_util.range(0, 30); - -var u = { - data: Belt_internalSetInt.fromArray(xs) -}; - -b("File \"bs_mutable_set_test.res\", line 21, characters 8-15", Belt_MutableSetInt.removeCheck(u, 0)); - -b("File \"bs_mutable_set_test.res\", line 22, characters 8-15", !Belt_MutableSetInt.removeCheck(u, 0)); - -b("File \"bs_mutable_set_test.res\", line 23, characters 8-15", Belt_MutableSetInt.removeCheck(u, 30)); - -b("File \"bs_mutable_set_test.res\", line 24, characters 8-15", Belt_MutableSetInt.removeCheck(u, 20)); - -eq("File \"bs_mutable_set_test.res\", line 25, characters 9-16", Belt_internalAVLset.size(u.data), 28); - -var r = Array_data_util.randomRange(0, 30); - -b("File \"bs_mutable_set_test.res\", line 27, characters 8-15", 29 === Belt_internalAVLset.maxUndefined(u.data)); - -b("File \"bs_mutable_set_test.res\", line 28, characters 8-15", 1 === Belt_internalAVLset.minUndefined(u.data)); - -Belt_MutableSetInt.add(u, 3); - -for(var i = 0 ,i_finish = r.length; i < i_finish; ++i){ - Belt_MutableSetInt.remove(u, r[i]); -} - -b("File \"bs_mutable_set_test.res\", line 33, characters 8-15", Belt_MutableSetInt.isEmpty(u)); - -Belt_MutableSetInt.add(u, 0); - -Belt_MutableSetInt.add(u, 1); - -Belt_MutableSetInt.add(u, 2); - -Belt_MutableSetInt.add(u, 0); - -eq("File \"bs_mutable_set_test.res\", line 38, characters 9-16", Belt_internalAVLset.size(u.data), 3); - -b("File \"bs_mutable_set_test.res\", line 39, characters 8-15", !Belt_MutableSetInt.isEmpty(u)); - -for(var i$1 = 0; i$1 <= 3; ++i$1){ - Belt_MutableSetInt.remove(u, i$1); -} - -b("File \"bs_mutable_set_test.res\", line 43, characters 8-15", Belt_MutableSetInt.isEmpty(u)); - -Belt_MutableSetInt.mergeMany(u, Array_data_util.randomRange(0, 20000)); - -Belt_MutableSetInt.mergeMany(u, Array_data_util.randomRange(0, 200)); - -eq("File \"bs_mutable_set_test.res\", line 46, characters 9-16", Belt_internalAVLset.size(u.data), 20001); - -Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(0, 200)); - -eq("File \"bs_mutable_set_test.res\", line 48, characters 9-16", Belt_internalAVLset.size(u.data), 19800); - -Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(0, 1000)); - -eq("File \"bs_mutable_set_test.res\", line 50, characters 9-16", Belt_internalAVLset.size(u.data), 19000); - -Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(0, 1000)); - -eq("File \"bs_mutable_set_test.res\", line 52, characters 9-16", Belt_internalAVLset.size(u.data), 19000); - -Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(1000, 10000)); - -eq("File \"bs_mutable_set_test.res\", line 54, characters 9-16", Belt_internalAVLset.size(u.data), 10000); - -Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(10000, 19999)); - -eq("File \"bs_mutable_set_test.res\", line 56, characters 9-16", Belt_internalAVLset.size(u.data), 1); - -b("File \"bs_mutable_set_test.res\", line 57, characters 8-15", Belt_internalSetInt.has(u.data, 20000)); - -Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(10000, 30000)); - -b("File \"bs_mutable_set_test.res\", line 59, characters 8-15", Belt_MutableSetInt.isEmpty(u)); - -var xs$1 = Array_data_util.randomRange(1000, 2000); - -var v = { - data: Belt_internalSetInt.fromArray(xs$1) -}; - -var bs = Belt_Array.map(Array_data_util.randomRange(500, 1499), (function (x) { - return Belt_MutableSetInt.removeCheck(v, x); - })); - -var indeedRemoved = Belt_Array.reduce(bs, 0, (function (acc, x) { - if (x) { - return acc + 1 | 0; - } else { - return acc; - } - })); - -eq("File \"bs_mutable_set_test.res\", line 72, characters 9-16", indeedRemoved, 500); - -eq("File \"bs_mutable_set_test.res\", line 73, characters 9-16", Belt_internalAVLset.size(v.data), 501); - -var cs = Belt_Array.map(Array_data_util.randomRange(500, 2000), (function (x) { - return Belt_MutableSetInt.addCheck(v, x); - })); - -var indeedAded = Belt_Array.reduce(cs, 0, (function (acc, x) { - if (x) { - return acc + 1 | 0; - } else { - return acc; - } - })); - -eq("File \"bs_mutable_set_test.res\", line 82, characters 9-16", indeedAded, 1000); - -eq("File \"bs_mutable_set_test.res\", line 83, characters 9-16", Belt_internalAVLset.size(v.data), 1501); - -b("File \"bs_mutable_set_test.res\", line 84, characters 8-15", Belt_MutableSetInt.isEmpty({ - data: undefined - })); - -eq("File \"bs_mutable_set_test.res\", line 85, characters 9-16", Belt_internalAVLset.minimum(v.data), 500); - -eq("File \"bs_mutable_set_test.res\", line 86, characters 9-16", Belt_internalAVLset.maximum(v.data), 2000); - -eq("File \"bs_mutable_set_test.res\", line 87, characters 9-16", Belt_internalAVLset.minUndefined(v.data), 500); - -eq("File \"bs_mutable_set_test.res\", line 88, characters 9-16", Belt_internalAVLset.maxUndefined(v.data), 2000); - -eq("File \"bs_mutable_set_test.res\", line 89, characters 9-16", Belt_MutableSetInt.reduce(v, 0, (function (x, y) { - return x + y | 0; - })), 1876250); - -b("File \"bs_mutable_set_test.res\", line 90, characters 8-15", Belt_List.eq(Belt_internalAVLset.toList(v.data), Belt_List.makeBy(1501, (function (i) { - return i + 500 | 0; - })), (function (x, y) { - return x === y; - }))); - -eq("File \"bs_mutable_set_test.res\", line 91, characters 9-16", Belt_internalAVLset.toArray(v.data), Array_data_util.range(500, 2000)); - -Belt_internalAVLset.checkInvariantInternal(v.data); - -eq("File \"bs_mutable_set_test.res\", line 93, characters 9-16", Belt_internalSetInt.get(v.data, 3), undefined); - -eq("File \"bs_mutable_set_test.res\", line 94, characters 9-16", Belt_internalSetInt.get(v.data, 1200), 1200); - -var match = Belt_MutableSetInt.split(v, 1000); - -var match$1 = match[0]; - -var bb = match$1[1]; - -var aa = match$1[0]; - -b("File \"bs_mutable_set_test.res\", line 96, characters 8-15", match[1]); - -b("File \"bs_mutable_set_test.res\", line 97, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(aa.data), Array_data_util.range(500, 999), (function (x, y) { - return x === y; - }))); - -b("File \"bs_mutable_set_test.res\", line 98, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(bb.data), Array_data_util.range(1001, 2000), (function (prim0, prim1) { - return prim0 === prim1; - }))); - -b("File \"bs_mutable_set_test.res\", line 99, characters 8-15", Belt_MutableSetInt.subset(aa, v)); - -b("File \"bs_mutable_set_test.res\", line 100, characters 8-15", Belt_MutableSetInt.subset(bb, v)); - -b("File \"bs_mutable_set_test.res\", line 101, characters 8-15", Belt_MutableSetInt.isEmpty(Belt_MutableSetInt.intersect(aa, bb))); - -var c = Belt_MutableSetInt.removeCheck(v, 1000); - -b("File \"bs_mutable_set_test.res\", line 103, characters 8-15", c); - -var match$2 = Belt_MutableSetInt.split(v, 1000); - -var match$3 = match$2[0]; - -var bb$1 = match$3[1]; - -var aa$1 = match$3[0]; - -b("File \"bs_mutable_set_test.res\", line 105, characters 8-15", !match$2[1]); - -b("File \"bs_mutable_set_test.res\", line 106, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(aa$1.data), Array_data_util.range(500, 999), (function (prim0, prim1) { - return prim0 === prim1; - }))); - -b("File \"bs_mutable_set_test.res\", line 107, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(bb$1.data), Array_data_util.range(1001, 2000), (function (prim0, prim1) { - return prim0 === prim1; - }))); - -b("File \"bs_mutable_set_test.res\", line 108, characters 8-15", Belt_MutableSetInt.subset(aa$1, v)); - -b("File \"bs_mutable_set_test.res\", line 109, characters 8-15", Belt_MutableSetInt.subset(bb$1, v)); - -b("File \"bs_mutable_set_test.res\", line 110, characters 8-15", Belt_MutableSetInt.isEmpty(Belt_MutableSetInt.intersect(aa$1, bb$1))); - -var xs$2 = Array_data_util.randomRange(0, 100); - -var aa$2 = { - data: Belt_internalSetInt.fromArray(xs$2) -}; - -var xs$3 = Array_data_util.randomRange(40, 120); - -var bb$2 = { - data: Belt_internalSetInt.fromArray(xs$3) -}; - -var cc = Belt_MutableSetInt.union(aa$2, bb$2); - -var xs$4 = Array_data_util.randomRange(0, 120); - -b("File \"bs_mutable_set_test.res\", line 120, characters 8-15", Belt_MutableSetInt.eq(cc, { - data: Belt_internalSetInt.fromArray(xs$4) - })); - -var xs$5 = Array_data_util.randomRange(0, 20); - -var xs$6 = Array_data_util.randomRange(21, 40); - -var xs$7 = Array_data_util.randomRange(0, 40); - -b("File \"bs_mutable_set_test.res\", line 123, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.union({ - data: Belt_internalSetInt.fromArray(xs$5) - }, { - data: Belt_internalSetInt.fromArray(xs$6) - }), { - data: Belt_internalSetInt.fromArray(xs$7) - })); - -var dd = Belt_MutableSetInt.intersect(aa$2, bb$2); - -var xs$8 = Array_data_util.randomRange(40, 100); - -b("File \"bs_mutable_set_test.res\", line 127, characters 8-15", Belt_MutableSetInt.eq(dd, { - data: Belt_internalSetInt.fromArray(xs$8) - })); - -var xs$9 = Array_data_util.randomRange(0, 20); - -var xs$10 = Array_data_util.randomRange(21, 40); - -b("File \"bs_mutable_set_test.res\", line 129, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.fromArray(xs$9) - }, { - data: Belt_internalSetInt.fromArray(xs$10) - }), { - data: undefined - })); - -var xs$11 = Array_data_util.randomRange(21, 40); - -var xs$12 = Array_data_util.randomRange(0, 20); - -b("File \"bs_mutable_set_test.res\", line 136, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.fromArray(xs$11) - }, { - data: Belt_internalSetInt.fromArray(xs$12) - }), { - data: undefined - })); - -b("File \"bs_mutable_set_test.res\", line 142, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.fromArray([ - 1, - 3, - 4, - 5, - 7, - 9 - ]) - }, { - data: Belt_internalSetInt.fromArray([ - 2, - 4, - 5, - 6, - 8, - 10 - ]) - }), { - data: Belt_internalSetInt.fromArray([ - 4, - 5 - ]) - })); - -var xs$13 = Array_data_util.randomRange(0, 39); - -b("File \"bs_mutable_set_test.res\", line 143, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(aa$2, bb$2), { - data: Belt_internalSetInt.fromArray(xs$13) - })); - -var xs$14 = Array_data_util.randomRange(101, 120); - -b("File \"bs_mutable_set_test.res\", line 144, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(bb$2, aa$2), { - data: Belt_internalSetInt.fromArray(xs$14) - })); - -var xs$15 = Array_data_util.randomRange(21, 40); - -var xs$16 = Array_data_util.randomRange(0, 20); - -var xs$17 = Array_data_util.randomRange(21, 40); - -b("File \"bs_mutable_set_test.res\", line 146, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.fromArray(xs$15) - }, { - data: Belt_internalSetInt.fromArray(xs$16) - }), { - data: Belt_internalSetInt.fromArray(xs$17) - })); - -var xs$18 = Array_data_util.randomRange(0, 20); - -var xs$19 = Array_data_util.randomRange(21, 40); - -var xs$20 = Array_data_util.randomRange(0, 20); - -b("File \"bs_mutable_set_test.res\", line 153, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.fromArray(xs$18) - }, { - data: Belt_internalSetInt.fromArray(xs$19) - }), { - data: Belt_internalSetInt.fromArray(xs$20) - })); - -var xs$21 = Array_data_util.randomRange(0, 20); - -var xs$22 = Array_data_util.randomRange(0, 40); - -var xs$23 = Array_data_util.randomRange(0, -1); - -b("File \"bs_mutable_set_test.res\", line 161, characters 8-15", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.fromArray(xs$21) - }, { - data: Belt_internalSetInt.fromArray(xs$22) - }), { - data: Belt_internalSetInt.fromArray(xs$23) - })); - -var xs$24 = Array_data_util.randomRange(0, 1000); - -var a0 = { - data: Belt_internalSetInt.fromArray(xs$24) -}; - -var a1 = Belt_MutableSetInt.keep(a0, (function (x) { - return x % 2 === 0; - })); - -var a2 = Belt_MutableSetInt.keep(a0, (function (x) { - return x % 2 !== 0; - })); - -var match$4 = Belt_MutableSetInt.partition(a0, (function (x) { - return x % 2 === 0; - })); - -var a4 = match$4[1]; - -var a3 = match$4[0]; - -b("File \"bs_mutable_set_test.res\", line 173, characters 8-15", Belt_MutableSetInt.eq(a1, a3)); - -b("File \"bs_mutable_set_test.res\", line 174, characters 8-15", Belt_MutableSetInt.eq(a2, a4)); - -Belt_List.forEach({ - hd: a0, - tl: { - hd: a1, - tl: { - hd: a2, - tl: { - hd: a3, - tl: { - hd: a4, - tl: /* [] */0 - } - } - } - } - }, (function (x) { - Belt_internalAVLset.checkInvariantInternal(x.data); - })); - -var v$1 = { - data: undefined -}; - -for(var i$2 = 0; i$2 <= 100000; ++i$2){ - Belt_MutableSetInt.add(v$1, i$2); -} - -Belt_internalAVLset.checkInvariantInternal(v$1.data); - -b("File \"bs_mutable_set_test.res\", line 188, characters 10-17", Belt_Range.every(0, 100000, (function (i) { - return Belt_internalSetInt.has(v$1.data, i); - }))); - -eq("File \"bs_mutable_set_test.res\", line 189, characters 5-12", Belt_internalAVLset.size(v$1.data), 100001); - -var u$1 = Belt_Array.concat(Array_data_util.randomRange(30, 100), Array_data_util.randomRange(40, 120)); - -var v$2 = { - data: undefined -}; - -Belt_MutableSetInt.mergeMany(v$2, u$1); - -eq("File \"bs_mutable_set_test.res\", line 196, characters 5-12", Belt_internalAVLset.size(v$2.data), 91); - -eq("File \"bs_mutable_set_test.res\", line 197, characters 5-12", Belt_internalAVLset.toArray(v$2.data), Array_data_util.range(30, 120)); - -var u$2 = Belt_Array.concat(Array_data_util.randomRange(0, 100000), Array_data_util.randomRange(0, 100)); - -var v$3 = { - data: Belt_internalSetInt.fromArray(u$2) -}; - -eq("File \"bs_mutable_set_test.res\", line 203, characters 5-12", Belt_internalAVLset.size(v$3.data), 100001); - -var u$3 = Array_data_util.randomRange(50000, 80000); - -for(var i$3 = 0 ,i_finish$1 = u$3.length; i$3 < i_finish$1; ++i$3){ - Belt_MutableSetInt.remove(v$3, i$3); -} - -eq("File \"bs_mutable_set_test.res\", line 210, characters 5-12", Belt_internalAVLset.size(v$3.data), 70000); - -var vv = Array_data_util.randomRange(0, 100000); - -for(var i$4 = 0 ,i_finish$2 = vv.length; i$4 < i_finish$2; ++i$4){ - Belt_MutableSetInt.remove(v$3, Caml_array.get(vv, i$4)); -} - -eq("File \"bs_mutable_set_test.res\", line 216, characters 5-12", Belt_internalAVLset.size(v$3.data), 0); - -b("File \"bs_mutable_set_test.res\", line 217, characters 4-11", Belt_MutableSetInt.isEmpty(v$3)); - -var xs$25 = Belt_Array.makeBy(30, (function (i) { - return i; - })); - -var v$4 = { - data: Belt_internalSetInt.fromArray(xs$25) -}; - -Belt_MutableSetInt.remove(v$4, 30); - -Belt_MutableSetInt.remove(v$4, 29); - -b("File \"bs_mutable_set_test.res\", line 224, characters 4-11", 28 === Belt_internalAVLset.maxUndefined(v$4.data)); - -Belt_MutableSetInt.remove(v$4, 0); - -b("File \"bs_mutable_set_test.res\", line 226, characters 4-11", 1 === Belt_internalAVLset.minUndefined(v$4.data)); - -eq("File \"bs_mutable_set_test.res\", line 227, characters 5-12", Belt_internalAVLset.size(v$4.data), 28); - -var vv$1 = Array_data_util.randomRange(1, 28); - -for(var i$5 = 0 ,i_finish$3 = vv$1.length; i$5 < i_finish$3; ++i$5){ - Belt_MutableSetInt.remove(v$4, Caml_array.get(vv$1, i$5)); -} - -eq("File \"bs_mutable_set_test.res\", line 232, characters 5-12", Belt_internalAVLset.size(v$4.data), 0); - -function id(loc, x) { - var u = { - data: Belt_internalAVLset.fromSortedArrayUnsafe(x) - }; - Belt_internalAVLset.checkInvariantInternal(u.data); - b(loc, Belt_Array.every2(Belt_internalAVLset.toArray(u.data), x, (function (prim0, prim1) { - return prim0 === prim1; - }))); -} - -id("File \"bs_mutable_set_test.res\", line 242, characters 5-12", []); - -id("File \"bs_mutable_set_test.res\", line 243, characters 5-12", [0]); - -id("File \"bs_mutable_set_test.res\", line 244, characters 5-12", [ - 0, - 1 - ]); - -id("File \"bs_mutable_set_test.res\", line 245, characters 5-12", [ - 0, - 1, - 2 - ]); - -id("File \"bs_mutable_set_test.res\", line 246, characters 5-12", [ - 0, - 1, - 2, - 3 - ]); - -id("File \"bs_mutable_set_test.res\", line 247, characters 5-12", [ - 0, - 1, - 2, - 3, - 4 - ]); - -id("File \"bs_mutable_set_test.res\", line 248, characters 5-12", [ - 0, - 1, - 2, - 3, - 4, - 5 - ]); - -id("File \"bs_mutable_set_test.res\", line 249, characters 5-12", [ - 0, - 1, - 2, - 3, - 4, - 6 - ]); - -id("File \"bs_mutable_set_test.res\", line 250, characters 5-12", [ - 0, - 1, - 2, - 3, - 4, - 6, - 7 - ]); - -id("File \"bs_mutable_set_test.res\", line 251, characters 5-12", [ - 0, - 1, - 2, - 3, - 4, - 6, - 7, - 8 - ]); - -id("File \"bs_mutable_set_test.res\", line 252, characters 5-12", [ - 0, - 1, - 2, - 3, - 4, - 6, - 7, - 8, - 9 - ]); - -id("File \"bs_mutable_set_test.res\", line 253, characters 5-12", Array_data_util.range(0, 1000)); - -var xs$26 = Array_data_util.randomRange(0, 1000); - -var v$5 = { - data: Belt_internalSetInt.fromArray(xs$26) -}; - -var copyV = Belt_MutableSetInt.keep(v$5, (function (x) { - return x % 8 === 0; - })); - -var match$5 = Belt_MutableSetInt.partition(v$5, (function (x) { - return x % 8 === 0; - })); - -var cc$1 = Belt_MutableSetInt.keep(v$5, (function (x) { - return x % 8 !== 0; - })); - -for(var i$6 = 0; i$6 <= 200; ++i$6){ - Belt_MutableSetInt.remove(v$5, i$6); -} - -eq("File \"bs_mutable_set_test.res\", line 264, characters 5-12", Belt_internalAVLset.size(copyV.data), 126); - -eq("File \"bs_mutable_set_test.res\", line 265, characters 5-12", Belt_internalAVLset.toArray(copyV.data), Belt_Array.makeBy(126, (function (i) { - return (i << 3); - }))); - -eq("File \"bs_mutable_set_test.res\", line 266, characters 5-12", Belt_internalAVLset.size(v$5.data), 800); - -b("File \"bs_mutable_set_test.res\", line 267, characters 4-11", Belt_MutableSetInt.eq(copyV, match$5[0])); - -b("File \"bs_mutable_set_test.res\", line 268, characters 4-11", Belt_MutableSetInt.eq(cc$1, match$5[1])); - -var xs$27 = Array_data_util.randomRange(0, 1000); - -var v$6 = { - data: Belt_internalSetInt.fromArray(xs$27) -}; - -var match$6 = Belt_MutableSetInt.split(v$6, 400); - -var match$7 = match$6[0]; - -var xs$28 = Array_data_util.randomRange(0, 399); - -b("File \"bs_mutable_set_test.res\", line 274, characters 4-11", Belt_MutableSetInt.eq(match$7[0], { - data: Belt_internalSetInt.fromArray(xs$28) - })); - -var xs$29 = Array_data_util.randomRange(401, 1000); - -b("File \"bs_mutable_set_test.res\", line 275, characters 4-11", Belt_MutableSetInt.eq(match$7[1], { - data: Belt_internalSetInt.fromArray(xs$29) - })); - -var xs$30 = Belt_Array.map(Array_data_util.randomRange(0, 1000), (function (x) { - return (x << 1); - })); - -var d = { - data: Belt_internalSetInt.fromArray(xs$30) -}; - -var match$8 = Belt_MutableSetInt.split(d, 1001); - -var match$9 = match$8[0]; - -var xs$31 = Belt_Array.makeBy(501, (function (x) { - return (x << 1); - })); - -b("File \"bs_mutable_set_test.res\", line 278, characters 4-11", Belt_MutableSetInt.eq(match$9[0], { - data: Belt_internalSetInt.fromArray(xs$31) - })); - -var xs$32 = Belt_Array.makeBy(500, (function (x) { - return 1002 + (x << 1) | 0; - })); - -b("File \"bs_mutable_set_test.res\", line 279, characters 4-11", Belt_MutableSetInt.eq(match$9[1], { - data: Belt_internalSetInt.fromArray(xs$32) - })); - -var xs$33 = Array_data_util.randomRange(0, 100); - -var aa$3 = { - data: Belt_internalSetInt.fromArray(xs$33) -}; - -var xs$34 = Array_data_util.randomRange(40, 120); - -var bb$3 = { - data: Belt_internalSetInt.fromArray(xs$34) -}; - -var cc$2 = Belt_MutableSetInt.union(aa$3, bb$3); - -var xs$35 = Array_data_util.randomRange(0, 120); - -b("File \"bs_mutable_set_test.res\", line 289, characters 4-11", Belt_MutableSetInt.eq(cc$2, { - data: Belt_internalSetInt.fromArray(xs$35) - })); - -var xs$36 = Array_data_util.randomRange(0, 20); - -var xs$37 = Array_data_util.randomRange(21, 40); - -var xs$38 = Array_data_util.randomRange(0, 40); - -b("File \"bs_mutable_set_test.res\", line 292, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.union({ - data: Belt_internalSetInt.fromArray(xs$36) - }, { - data: Belt_internalSetInt.fromArray(xs$37) - }), { - data: Belt_internalSetInt.fromArray(xs$38) - })); - -var dd$1 = Belt_MutableSetInt.intersect(aa$3, bb$3); - -var xs$39 = Array_data_util.randomRange(40, 100); - -b("File \"bs_mutable_set_test.res\", line 296, characters 4-11", Belt_MutableSetInt.eq(dd$1, { - data: Belt_internalSetInt.fromArray(xs$39) - })); - -var xs$40 = Array_data_util.randomRange(0, 20); - -var xs$41 = Array_data_util.randomRange(21, 40); - -b("File \"bs_mutable_set_test.res\", line 298, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.fromArray(xs$40) - }, { - data: Belt_internalSetInt.fromArray(xs$41) - }), { - data: undefined - })); - -var xs$42 = Array_data_util.randomRange(21, 40); - -var xs$43 = Array_data_util.randomRange(0, 20); - -b("File \"bs_mutable_set_test.res\", line 302, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.fromArray(xs$42) - }, { - data: Belt_internalSetInt.fromArray(xs$43) - }), { - data: undefined - })); - -b("File \"bs_mutable_set_test.res\", line 305, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.fromArray([ - 1, - 3, - 4, - 5, - 7, - 9 - ]) - }, { - data: Belt_internalSetInt.fromArray([ - 2, - 4, - 5, - 6, - 8, - 10 - ]) - }), { - data: Belt_internalSetInt.fromArray([ - 4, - 5 - ]) - })); - -var xs$44 = Array_data_util.randomRange(0, 39); - -b("File \"bs_mutable_set_test.res\", line 306, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(aa$3, bb$3), { - data: Belt_internalSetInt.fromArray(xs$44) - })); - -var xs$45 = Array_data_util.randomRange(101, 120); - -b("File \"bs_mutable_set_test.res\", line 307, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(bb$3, aa$3), { - data: Belt_internalSetInt.fromArray(xs$45) - })); - -var xs$46 = Array_data_util.randomRange(21, 40); - -var xs$47 = Array_data_util.randomRange(0, 20); - -var xs$48 = Array_data_util.randomRange(21, 40); - -b("File \"bs_mutable_set_test.res\", line 309, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.fromArray(xs$46) - }, { - data: Belt_internalSetInt.fromArray(xs$47) - }), { - data: Belt_internalSetInt.fromArray(xs$48) - })); - -var xs$49 = Array_data_util.randomRange(0, 20); - -var xs$50 = Array_data_util.randomRange(21, 40); - -var xs$51 = Array_data_util.randomRange(0, 20); - -b("File \"bs_mutable_set_test.res\", line 316, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.fromArray(xs$49) - }, { - data: Belt_internalSetInt.fromArray(xs$50) - }), { - data: Belt_internalSetInt.fromArray(xs$51) - })); - -var xs$52 = Array_data_util.randomRange(0, 20); - -var xs$53 = Array_data_util.randomRange(0, 40); - -var xs$54 = Array_data_util.randomRange(0, -1); - -b("File \"bs_mutable_set_test.res\", line 324, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.fromArray(xs$52) - }, { - data: Belt_internalSetInt.fromArray(xs$53) - }), { - data: Belt_internalSetInt.fromArray(xs$54) - })); - -Mt.from_pair_suites("Bs_mutable_set_test", suites.contents); - -var N; - -var I; - -var R; - -var A; - -var L; - -var empty = Belt_MutableSetInt.make; - -var fromArray = Belt_MutableSetInt.fromArray; - -var $plus$plus = Belt_MutableSetInt.union; - -var f = Belt_MutableSetInt.fromArray; - -var $eq$tilde = Belt_MutableSetInt.eq; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.N = N; -exports.I = I; -exports.R = R; -exports.A = A; -exports.L = L; -exports.empty = empty; -exports.fromArray = fromArray; -exports.$plus$plus = $plus$plus; -exports.f = f; -exports.$eq$tilde = $eq$tilde; -/* u Not a pure module */ diff --git a/jscomp/test/bs_mutable_set_test.res b/jscomp/test/bs_mutable_set_test.res deleted file mode 100644 index 478bdd3c777..00000000000 --- a/jscomp/test/bs_mutable_set_test.res +++ /dev/null @@ -1,332 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => Mt.eq_suites(~test_id, ~suites, loc, x, y) -let b = (loc, x) => Mt.bool_suites(~test_id, ~suites, loc, x) - -module N = Belt.MutableSet.Int - -module I = Array_data_util -module R = Belt.Range -module A = Belt.Array -module L = Belt.List -let \"++" = A.concat -let empty = N.make -let fromArray = N.fromArray - -/* ********************************************** */ -include ( - { - let () = { - let u = fromArray(I.range(0, 30)) - b(__LOC__, N.removeCheck(u, 0)) - b(__LOC__, !N.removeCheck(u, 0)) - b(__LOC__, N.removeCheck(u, 30)) - b(__LOC__, N.removeCheck(u, 20)) - eq(__LOC__, N.size(u), 28) - let r = I.randomRange(0, 30) - b(__LOC__, Js.eqUndefined(29, N.maxUndefined(u))) - b(__LOC__, Js.eqUndefined(1, N.minUndefined(u))) - N.add(u, 3) - for i in 0 to A.length(r) - 1 { - N.remove(u, A.getUnsafe(r, i)) - } - b(__LOC__, N.isEmpty(u)) - N.add(u, 0) - N.add(u, 1) - N.add(u, 2) - N.add(u, 0) - eq(__LOC__, N.size(u), 3) - b(__LOC__, !N.isEmpty(u)) - for i in 0 to 3 { - N.remove(u, i) - } - b(__LOC__, N.isEmpty(u)) - N.mergeMany(u, I.randomRange(0, 20000)) - N.mergeMany(u, I.randomRange(0, 200)) - eq(__LOC__, N.size(u), 20001) - N.removeMany(u, I.randomRange(0, 200)) - eq(__LOC__, N.size(u), 19800) - N.removeMany(u, I.randomRange(0, 1000)) - eq(__LOC__, N.size(u), 19000) - N.removeMany(u, I.randomRange(0, 1000)) - eq(__LOC__, N.size(u), 19000) - N.removeMany(u, I.randomRange(1000, 10000)) - eq(__LOC__, N.size(u), 10000) - N.removeMany(u, I.randomRange(10000, 20000 - 1)) - eq(__LOC__, N.size(u), 1) - b(__LOC__, N.has(u, 20000)) - N.removeMany(u, I.randomRange(10_000, 30_000)) - b(__LOC__, N.isEmpty(u)) - } - - let () = { - let v = fromArray(I.randomRange(1_000, 2_000)) - let bs = A.map(I.randomRange(500, 1499), x => N.removeCheck(v, x)) - let indeedRemoved = A.reduce(bs, 0, (acc, x) => - if x { - acc + 1 - } else { - acc - } - ) - eq(__LOC__, indeedRemoved, 500) - eq(__LOC__, N.size(v), 501) - let cs = A.map(I.randomRange(500, 2_000), x => N.addCheck(v, x)) - let indeedAded = A.reduce(cs, 0, (acc, x) => - if x { - acc + 1 - } else { - acc - } - ) - eq(__LOC__, indeedAded, 1000) - eq(__LOC__, N.size(v), 1_501) - b(__LOC__, N.isEmpty(empty())) - eq(__LOC__, N.minimum(v), Some(500)) - eq(__LOC__, N.maximum(v), Some(2000)) - eq(__LOC__, N.minUndefined(v), Js.Undefined.return(500)) - eq(__LOC__, N.maxUndefined(v), Js.Undefined.return(2000)) - eq(__LOC__, N.reduce(v, 0, (x, y) => x + y), (500 + 2000) / 2 * 1501) - b(__LOC__, L.eq(N.toList(v), L.makeBy(1_501, i => i + 500), (x, y) => x == y)) - eq(__LOC__, N.toArray(v), I.range(500, 2000)) - N.checkInvariantInternal(v) - eq(__LOC__, N.get(v, 3), None) - eq(__LOC__, N.get(v, 1_200), Some(1_200)) - let ((aa, bb), pres) = N.split(v, 1000) - b(__LOC__, pres) - b(__LOC__, A.eq(N.toArray(aa), I.range(500, 999), (x, y) => x == y)) - b(__LOC__, A.eq(N.toArray(bb), I.range(1_001, 2_000), \"=")) - b(__LOC__, N.subset(aa, v)) - b(__LOC__, N.subset(bb, v)) - b(__LOC__, N.isEmpty(N.intersect(aa, bb))) - let c = N.removeCheck(v, 1_000) - b(__LOC__, c) - let ((aa, bb), pres) = N.split(v, 1_000) - b(__LOC__, !pres) - b(__LOC__, A.eq(N.toArray(aa), I.range(500, 999), \"=")) - b(__LOC__, A.eq(N.toArray(bb), I.range(1_001, 2_000), \"=")) - b(__LOC__, N.subset(aa, v)) - b(__LOC__, N.subset(bb, v)) - b(__LOC__, N.isEmpty(N.intersect(aa, bb))) - } - - let \"++" = N.union - let f = fromArray - let \"=~" = N.eq - let () = { - let aa = f(I.randomRange(0, 100)) - let bb = f(I.randomRange(40, 120)) - let cc = \"++"(aa, bb) - b(__LOC__, \"=~"(cc, f(I.randomRange(0, 120)))) - - b( - __LOC__, - N.eq(N.union(f(I.randomRange(0, 20)), f(I.randomRange(21, 40))), f(I.randomRange(0, 40))), - ) - let dd = N.intersect(aa, bb) - b(__LOC__, \"=~"(dd, f(I.randomRange(40, 100)))) - b( - __LOC__, - \"=~"( - N.intersect(\"@@"(f, I.randomRange(0, 20)), \"@@"(f, I.randomRange(21, 40))), - empty(), - ), - ) - b( - __LOC__, - \"=~"( - N.intersect(\"@@"(f, I.randomRange(21, 40)), \"@@"(f, I.randomRange(0, 20))), - empty(), - ), - ) - b(__LOC__, \"=~"(N.intersect(f([1, 3, 4, 5, 7, 9]), f([2, 4, 5, 6, 8, 10])), f([4, 5]))) - b(__LOC__, \"=~"(N.diff(aa, bb), f(I.randomRange(0, 39)))) - b(__LOC__, \"=~"(N.diff(bb, aa), f(I.randomRange(101, 120)))) - b( - __LOC__, - \"=~"( - N.diff(\"@@"(f, I.randomRange(21, 40)), \"@@"(f, I.randomRange(0, 20))), - f(I.randomRange(21, 40)), - ), - ) - b( - __LOC__, - \"=~"( - N.diff(\"@@"(f, I.randomRange(0, 20)), \"@@"(f, I.randomRange(21, 40))), - f(I.randomRange(0, 20)), - ), - ) - - b( - __LOC__, - \"=~"( - N.diff(\"@@"(f, I.randomRange(0, 20)), \"@@"(f, I.randomRange(0, 40))), - f(I.randomRange(0, -1)), - ), - ) - } - - let () = { - let a0 = fromArray(I.randomRange(0, 1000)) - let (a1, a2) = (N.keep(a0, x => mod(x, 2) == 0), N.keep(a0, x => mod(x, 2) != 0)) - let (a3, a4) = N.partition(a0, x => mod(x, 2) == 0) - b(__LOC__, N.eq(a1, a3)) - b(__LOC__, N.eq(a2, a4)) - L.forEach(list{a0, a1, a2, a3, a4}, x => N.checkInvariantInternal(x)) - } - }: {} -) - -/* ********************************************** */ -let () = { - let v = N.make() - for i in 0 to 1_00_000 { - /* [%assert (N.checkInvariantInternal !v)]; */ - N.add(v, i) - } - N.checkInvariantInternal(v) - \"@@"(b(__LOC__), R.every(0, 1_00_000, i => N.has(v, i))) - eq(__LOC__, N.size(v), 1_00_001) -} - -let () = { - let u = \"++"(I.randomRange(30, 100), I.randomRange(40, 120)) - let v = N.make() - N.mergeMany(v, u) - eq(__LOC__, N.size(v), 91) - eq(__LOC__, N.toArray(v), I.range(30, 120)) -} - -let () = { - let u = \"++"(I.randomRange(0, 100_000), I.randomRange(0, 100)) - let v = N.fromArray(u) - eq(__LOC__, N.size(v), 100_001) - let u = I.randomRange(50_000, 80_000) - - for i in 0 to A.length(u) - 1 { - N.remove(v, i) - } - - eq(__LOC__, N.size(v), 70_000) - let count = 100_000 - let vv = I.randomRange(0, count) - for i in 0 to A.length(vv) - 1 { - N.remove(v, vv[i]) - } - eq(__LOC__, N.size(v), 0) - b(__LOC__, N.isEmpty(v)) -} - -let () = { - let v = N.fromArray(A.makeBy(30, i => i)) - N.remove(v, 30) - N.remove(v, 29) - b(__LOC__, Js.eqUndefined(28, N.maxUndefined(v))) - N.remove(v, 0) - b(__LOC__, Js.eqUndefined(1, N.minUndefined(v))) - eq(__LOC__, N.size(v), 28) - let vv = I.randomRange(1, 28) - for i in 0 to A.length(vv) - 1 { - N.remove(v, vv[i]) - } - eq(__LOC__, N.size(v), 0) -} - -let () = { - let id = (loc, x) => { - let u = N.fromSortedArrayUnsafe(x) - N.checkInvariantInternal(u) - b(loc, A.every2(N.toArray(u), x, \"=")) - } - - id(__LOC__, []) - id(__LOC__, [0]) - id(__LOC__, [0, 1]) - id(__LOC__, [0, 1, 2]) - id(__LOC__, [0, 1, 2, 3]) - id(__LOC__, [0, 1, 2, 3, 4]) - id(__LOC__, [0, 1, 2, 3, 4, 5]) - id(__LOC__, [0, 1, 2, 3, 4, 6]) - id(__LOC__, [0, 1, 2, 3, 4, 6, 7]) - id(__LOC__, [0, 1, 2, 3, 4, 6, 7, 8]) - id(__LOC__, [0, 1, 2, 3, 4, 6, 7, 8, 9]) - id(__LOC__, I.range(0, 1000)) -} - -let () = { - let v = N.fromArray(I.randomRange(0, 1000)) - let copyV = N.keep(v, x => mod(x, 8) == 0) - let (aa, bb) = N.partition(v, x => mod(x, 8) == 0) - let cc = N.keep(v, x => mod(x, 8) != 0) - for i in 0 to 200 { - N.remove(v, i) - } - eq(__LOC__, N.size(copyV), 126) - eq(__LOC__, N.toArray(copyV), A.makeBy(126, i => i * 8)) - eq(__LOC__, N.size(v), 800) - b(__LOC__, N.eq(copyV, aa)) - b(__LOC__, N.eq(cc, bb)) -} - -let () = { - let v = N.fromArray(I.randomRange(0, 1000)) - let ((aa, bb), _) = N.split(v, 400) - b(__LOC__, N.eq(aa, N.fromArray(I.randomRange(0, 399)))) - b(__LOC__, N.eq(bb, N.fromArray(I.randomRange(401, 1000)))) - let d = N.fromArray(A.map(I.randomRange(0, 1000), x => x * 2)) - let ((cc, dd), _) = N.split(d, 1001) - b(__LOC__, N.eq(cc, N.fromArray(A.makeBy(501, x => x * 2)))) - b(__LOC__, N.eq(dd, N.fromArray(A.makeBy(500, x => 1002 + x * 2)))) -} - -let \"++" = N.union -let f = N.fromArray -let \"=~" = N.eq -let () = { - let aa = f(I.randomRange(0, 100)) - let bb = f(I.randomRange(40, 120)) - let cc = \"++"(aa, bb) - b(__LOC__, \"=~"(cc, f(I.randomRange(0, 120)))) - - b( - __LOC__, - N.eq(N.union(f(I.randomRange(0, 20)), f(I.randomRange(21, 40))), f(I.randomRange(0, 40))), - ) - let dd = N.intersect(aa, bb) - b(__LOC__, \"=~"(dd, f(I.randomRange(40, 100)))) - b( - __LOC__, - \"=~"(N.intersect(\"@@"(f, I.randomRange(0, 20)), \"@@"(f, I.randomRange(21, 40))), N.make()), - ) - b( - __LOC__, - \"=~"(N.intersect(\"@@"(f, I.randomRange(21, 40)), \"@@"(f, I.randomRange(0, 20))), N.make()), - ) - b(__LOC__, \"=~"(N.intersect(f([1, 3, 4, 5, 7, 9]), f([2, 4, 5, 6, 8, 10])), f([4, 5]))) - b(__LOC__, \"=~"(N.diff(aa, bb), f(I.randomRange(0, 39)))) - b(__LOC__, \"=~"(N.diff(bb, aa), f(I.randomRange(101, 120)))) - b( - __LOC__, - \"=~"( - N.diff(\"@@"(f, I.randomRange(21, 40)), \"@@"(f, I.randomRange(0, 20))), - f(I.randomRange(21, 40)), - ), - ) - b( - __LOC__, - \"=~"( - N.diff(\"@@"(f, I.randomRange(0, 20)), \"@@"(f, I.randomRange(21, 40))), - f(I.randomRange(0, 20)), - ), - ) - - b( - __LOC__, - \"=~"( - N.diff(\"@@"(f, I.randomRange(0, 20)), \"@@"(f, I.randomRange(0, 40))), - f(I.randomRange(0, -1)), - ), - ) -} - -Mt.from_pair_suites(__MODULE__, suites.contents) diff --git a/jscomp/test/bs_poly_map_test.js b/jscomp/test/bs_poly_map_test.js deleted file mode 100644 index 07accf3b4f6..00000000000 --- a/jscomp/test/bs_poly_map_test.js +++ /dev/null @@ -1,330 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Caml = require("../../lib/js/caml.js"); -var Belt_Id = require("../../lib/js/belt_Id.js"); -var Belt_Map = require("../../lib/js/belt_Map.js"); -var Belt_Set = require("../../lib/js/belt_Set.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); -var Caml_option = require("../../lib/js/caml_option.js"); -var Belt_MapDict = require("../../lib/js/belt_MapDict.js"); -var Array_data_util = require("./array_data_util.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, v) { - Mt.bool_suites(test_id, suites, loc, v); -} - -var Icmp = Belt_Id.comparable(Caml.int_compare); - -function mapOfArray(x) { - return Belt_Map.fromArray(x, Icmp); -} - -function setOfArray(x) { - return Belt_Set.fromArray(x, Icmp); -} - -function emptyMap(param) { - return { - cmp: Icmp.cmp, - data: undefined - }; -} - -function mergeInter(s1, s2) { - var m = Belt_Map.merge(s1, s2, (function (k, v1, v2) { - if (v1 !== undefined && v2 !== undefined) { - return Caml_option.some(undefined); - } - - })); - return Belt_Set.fromArray(Belt_MapDict.keysToArray(m.data), Icmp); -} - -function mergeUnion(s1, s2) { - var m = Belt_Map.merge(s1, s2, (function (k, v1, v2) { - if (v1 !== undefined || v2 !== undefined) { - return Caml_option.some(undefined); - } - - })); - return Belt_Set.fromArray(Belt_MapDict.keysToArray(m.data), Icmp); -} - -function mergeDiff(s1, s2) { - var m = Belt_Map.merge(s1, s2, (function (k, v1, v2) { - if (v1 !== undefined && v2 === undefined) { - return Caml_option.some(undefined); - } - - })); - return Belt_Set.fromArray(Belt_MapDict.keysToArray(m.data), Icmp); -} - -function randomRange(i, j) { - return Belt_Array.map(Array_data_util.randomRange(i, j), (function (x) { - return [ - x, - x - ]; - })); -} - -var u0 = Belt_Map.fromArray(randomRange(0, 100), Icmp); - -var u1 = Belt_Map.fromArray(randomRange(30, 120), Icmp); - -b("File \"bs_poly_map_test.res\", line 64, characters 4-11", Belt_Set.eq(mergeInter(u0, u1), Belt_Set.fromArray(Array_data_util.range(30, 100), Icmp))); - -b("File \"bs_poly_map_test.res\", line 65, characters 4-11", Belt_Set.eq(mergeUnion(u0, u1), Belt_Set.fromArray(Array_data_util.range(0, 120), Icmp))); - -b("File \"bs_poly_map_test.res\", line 66, characters 4-11", Belt_Set.eq(mergeDiff(u0, u1), Belt_Set.fromArray(Array_data_util.range(0, 29), Icmp))); - -b("File \"bs_poly_map_test.res\", line 67, characters 4-11", Belt_Set.eq(mergeDiff(u1, u0), Belt_Set.fromArray(Array_data_util.range(101, 120), Icmp))); - -var a0 = Belt_Map.fromArray(randomRange(0, 10), Icmp); - -var a1 = Belt_Map.set(a0, 3, 33); - -var a2 = Belt_Map.remove(a1, 3); - -var a3 = Belt_Map.update(a2, 3, (function (k) { - if (k !== undefined) { - return k + 1 | 0; - } else { - return 11; - } - })); - -var a4 = Belt_Map.update(a2, 3, (function (k) { - if (k !== undefined) { - return k + 1 | 0; - } - - })); - -var a5 = Belt_Map.remove(a0, 3); - -var a6 = Belt_Map.remove(a5, 3); - -b("File \"bs_poly_map_test.res\", line 88, characters 4-11", a5 === a6); - -b("File \"bs_poly_map_test.res\", line 89, characters 4-11", Belt_Map.has(a0, 3)); - -b("File \"bs_poly_map_test.res\", line 90, characters 4-11", !Belt_Map.has(a5, 3)); - -b("File \"bs_poly_map_test.res\", line 91, characters 4-11", 3 === Belt_Map.getUndefined(a0, 3)); - -b("File \"bs_poly_map_test.res\", line 92, characters 4-11", 33 === Belt_Map.getUndefined(a1, 3)); - -b("File \"bs_poly_map_test.res\", line 93, characters 4-11", Belt_Map.getUndefined(a2, 3) === undefined); - -b("File \"bs_poly_map_test.res\", line 95, characters 4-11", 11 === Belt_Map.getUndefined(a3, 3)); - -b("File \"bs_poly_map_test.res\", line 96, characters 4-11", Belt_Map.getUndefined(a4, 3) === undefined); - -var a7 = Belt_Map.removeMany(a0, [ - 7, - 8, - 0, - 1, - 3, - 2, - 4, - 922, - 4, - 5, - 6 - ]); - -eq("File \"bs_poly_map_test.res\", line 99, characters 5-12", Belt_MapDict.keysToArray(a7.data), [ - 9, - 10 - ]); - -var a8 = Belt_Map.removeMany(a7, Array_data_util.randomRange(0, 100)); - -b("File \"bs_poly_map_test.res\", line 101, characters 4-11", Belt_MapDict.isEmpty(a8.data)); - -var u0$1 = Belt_Map.fromArray(randomRange(0, 100), Icmp); - -var u1$1 = Belt_Map.set(u0$1, 3, 32); - -eq("File \"bs_poly_map_test.res\", line 108, characters 5-12", Belt_Map.get(u1$1, 3), 32); - -eq("File \"bs_poly_map_test.res\", line 109, characters 5-12", Belt_Map.get(u0$1, 3), 3); - -function acc(m, is) { - return Belt_Array.reduce(is, m, (function (a, i) { - return Belt_Map.update(a, i, (function (n) { - if (n !== undefined) { - return n + 1 | 0; - } else { - return 1; - } - })); - })); -} - -var m_cmp = Icmp.cmp; - -var m = { - cmp: m_cmp, - data: undefined -}; - -var m1 = acc(m, Belt_Array.concat(Array_data_util.randomRange(0, 20), Array_data_util.randomRange(10, 30))); - -b("File \"bs_poly_map_test.res\", line 126, characters 4-11", Belt_Map.eq(m1, Belt_Map.fromArray(Belt_Array.makeBy(31, (function (i) { - return [ - i, - i >= 10 && i <= 20 ? 2 : 1 - ]; - })), Icmp), (function (x, y) { - return x === y; - }))); - -var v0_cmp = Icmp.cmp; - -var v0 = { - cmp: v0_cmp, - data: undefined -}; - -var v1 = Belt_Map.mergeMany(v0, Belt_Array.map(Array_data_util.randomRange(0, 10000), (function (x) { - return [ - x, - x - ]; - }))); - -var v2 = Belt_Map.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 10000), (function (x) { - return [ - x, - x - ]; - })), Icmp); - -b("File \"bs_poly_map_test.res\", line 150, characters 4-11", Belt_Map.eq(v1, v2, (function (x, y) { - return x === y; - }))); - -function inc(x) { - if (x !== undefined) { - return x + 1 | 0; - } else { - return 0; - } -} - -var v3 = Belt_Map.update(v1, 10, inc); - -var v4 = Belt_Map.update(v3, -10, inc); - -var match = Belt_Map.split(v3, 5000); - -var pres = match[1]; - -var match$1 = match[0]; - -var match$2 = Belt_Map.get(v3, 10); - -b("File \"bs_poly_map_test.res\", line 161, characters 4-11", match$2 !== undefined ? match$2 === 11 : false); - -var match$3 = Belt_Map.get(v3, -10); - -b("File \"bs_poly_map_test.res\", line 168, characters 4-11", match$3 === undefined); - -var match$4 = Belt_Map.get(v4, -10); - -b("File \"bs_poly_map_test.res\", line 175, characters 4-11", match$4 !== undefined ? match$4 === 0 : false); - -var map = Belt_Map.remove({ - cmp: Icmp.cmp, - data: undefined - }, 0); - -b("File \"bs_poly_map_test.res\", line 181, characters 4-11", Belt_MapDict.isEmpty(map.data)); - -var map$1 = Belt_Map.removeMany({ - cmp: Icmp.cmp, - data: undefined - }, [0]); - -b("File \"bs_poly_map_test.res\", line 182, characters 4-11", Belt_MapDict.isEmpty(map$1.data)); - -b("File \"bs_poly_map_test.res\", line 184, characters 4-11", pres !== undefined ? pres === 5000 : false); - -b("File \"bs_poly_map_test.res\", line 190, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$1[0].data), Belt_Array.makeBy(5000, (function (i) { - return i; - })), (function (prim0, prim1) { - return prim0 === prim1; - }))); - -b("File \"bs_poly_map_test.res\", line 191, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$1[1].data), Belt_Array.makeBy(5000, (function (i) { - return 5001 + i | 0; - })), (function (prim0, prim1) { - return prim0 === prim1; - }))); - -var v7 = Belt_Map.remove(v3, 5000); - -var match$5 = Belt_Map.split(v7, 5000); - -var match$6 = match$5[0]; - -b("File \"bs_poly_map_test.res\", line 196, characters 4-11", match$5[1] === undefined); - -b("File \"bs_poly_map_test.res\", line 202, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$6[0].data), Belt_Array.makeBy(5000, (function (i) { - return i; - })), (function (prim0, prim1) { - return prim0 === prim1; - }))); - -b("File \"bs_poly_map_test.res\", line 203, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$6[1].data), Belt_Array.makeBy(5000, (function (i) { - return 5001 + i | 0; - })), (function (prim0, prim1) { - return prim0 === prim1; - }))); - -Mt.from_pair_suites("Bs_poly_map_test", suites.contents); - -var M; - -var N; - -var A; - -var I; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.Icmp = Icmp; -exports.M = M; -exports.N = N; -exports.A = A; -exports.I = I; -exports.mapOfArray = mapOfArray; -exports.setOfArray = setOfArray; -exports.emptyMap = emptyMap; -exports.mergeInter = mergeInter; -exports.mergeUnion = mergeUnion; -exports.mergeDiff = mergeDiff; -exports.randomRange = randomRange; -exports.acc = acc; -/* Icmp Not a pure module */ diff --git a/jscomp/test/bs_poly_map_test.res b/jscomp/test/bs_poly_map_test.res deleted file mode 100644 index d3084fa4878..00000000000 --- a/jscomp/test/bs_poly_map_test.res +++ /dev/null @@ -1,206 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => Mt.eq_suites(~suites, ~test_id, loc, x, y) -let b = (loc, v) => Mt.bool_suites(~suites, ~test_id, loc, v) - -module Icmp = unpack(Belt.Id.comparable(~cmp=(x: int, y) => compare(x, y))) -module M = Belt.Map -module N = Belt.Set - -module A = Belt.Array -module I = Array_data_util - -let mapOfArray = x => M.fromArray(~id=module(Icmp), x) -let setOfArray = x => N.fromArray(~id=module(Icmp), x) -let emptyMap = () => M.make(~id=module(Icmp)) - -let mergeInter = (s1, s2) => - \"@@"( - setOfArray, - M.keysToArray( - M.merge(s1, s2, (k, v1, v2) => - switch (v1, v2) { - | (Some(_), Some(_)) => Some() - | (_, _) => None - } - ), - ), - ) - -let mergeUnion = (s1, s2) => - \"@@"( - setOfArray, - \"@@"( - M.keysToArray, - M.merge(s1, s2, (k, v1, v2) => - switch (v1, v2) { - | (None, None) => None - | (_, _) => Some() - } - ), - ), - ) -let mergeDiff = (s1, s2) => - \"@@"( - setOfArray, - \"@@"( - M.keysToArray, - M.merge(s1, s2, (k, v1, v2) => - switch (v1, v2) { - | (Some(_), None) => Some() - | (Some(_), Some(_)) - | (None, _) => - None - } - ), - ), - ) - -let randomRange = (i, j) => A.map(I.randomRange(i, j), x => (x, x)) - -let () = { - let u0 = mapOfArray(randomRange(0, 100)) - let u1 = mapOfArray(randomRange(30, 120)) - b(__LOC__, N.eq(mergeInter(u0, u1), setOfArray(I.range(30, 100)))) - b(__LOC__, N.eq(mergeUnion(u0, u1), setOfArray(I.range(0, 120)))) - b(__LOC__, N.eq(mergeDiff(u0, u1), setOfArray(I.range(0, 29)))) - b(__LOC__, N.eq(mergeDiff(u1, u0), setOfArray(I.range(101, 120)))) -} - -let () = { - let a0 = mapOfArray(randomRange(0, 10)) - let a1 = M.set(a0, 3, 33) /* (3,3) */ - let a2 = M.remove(a1, 3) /* no 3 */ - let a3 = M.update(a2, 3, (k: option) => - switch k { - | Some(k: int) => Some(k + 1) - | None => Some(11) - } - ) /* 3, 11 */ - let a4 = M.update(a2, 3, k => - switch k { - | Some(k) => Some(k + 1) - | None => None - } - ) /* no 3 */ - let a5 = M.remove(a0, 3) - let a6 = M.remove(a5, 3) - b(__LOC__, a5 === a6) - b(__LOC__, M.has(a0, 3)) - b(__LOC__, !M.has(a5, 3)) - b(__LOC__, Js.eqUndefined(3, M.getUndefined(a0, 3))) - b(__LOC__, Js.eqUndefined(33, M.getUndefined(a1, 3))) - b(__LOC__, M.getUndefined(a2, 3) == Js.undefined) - - b(__LOC__, Js.eqUndefined(11, M.getUndefined(a3, 3))) - b(__LOC__, M.getUndefined(a4, 3) == Js.undefined) - - let a7 = M.removeMany(a0, [7, 8, 0, 1, 3, 2, 4, 922, 4, 5, 6]) - eq(__LOC__, M.keysToArray(a7), [9, 10]) - let a8 = M.removeMany(a7, I.randomRange(0, 100)) - b(__LOC__, M.isEmpty(a8)) -} - -let () = { - module Array = M - let u0 = mapOfArray(randomRange(0, 100)) - let u1 = u0[3] = 32 - eq(__LOC__, u1[3], Some(32)) - eq(__LOC__, u0[3], Some(3)) -} - -let acc = (m, i) => - M.update(m, i, n => - switch n { - | None => Some(1) - | Some(acc) => Some(acc + 1) - } - ) - -let acc = (m, is): M.t<_> => A.reduce(is, m, (a, i) => acc(a, i)) - -let () = { - let m = emptyMap() - let m1 = acc(m, A.concat(I.randomRange(0, 20), I.randomRange(10, 30))) - b( - __LOC__, - M.eq( - m1, - mapOfArray( - A.makeBy(31, i => ( - i, - if i >= 10 && i <= 20 { - 2 - } else { - 1 - }, - )), - ), - (x, y) => x == y, - ), - ) -} - -let () = { - let v0 = emptyMap() - let v1 = M.mergeMany(v0, A.map(I.randomRange(0, 10_000), x => (x, x))) - - let v2 = mapOfArray(A.map(I.randomRange(0, 10_000), x => (x, x))) - - b(__LOC__, M.eq(v1, v2, (x, y) => x == y)) - - let inc = x => - switch x { - | None => Some(0) - | Some(v) => Some(v + 1) - } - let v3 = M.update(v1, 10, inc) - let v4 = M.update(v3, -10, inc) - let ((v5, v6), pres) = M.split(v3, 5_000) - b( - __LOC__, - switch M.get(v3, 10) { - | Some(11) => true - | _ => false - }, - ) - b( - __LOC__, - switch M.get(v3, -10) { - | None => true - | _ => false - }, - ) - b( - __LOC__, - switch M.get(v4, -10) { - | Some(0) => true - | _ => false - }, - ) - b(__LOC__, M.isEmpty(M.remove(emptyMap(), 0))) - b(__LOC__, M.isEmpty(M.removeMany(emptyMap(), [0]))) - b( - __LOC__, - switch pres { - | Some(5_000) => true - | _ => false - }, - ) - b(__LOC__, A.eq(M.keysToArray(v5), A.makeBy(5_000, i => i), \"=")) - b(__LOC__, A.eq(M.keysToArray(v6), A.makeBy(5_000, i => 5_001 + i), \"=")) - - let v7 = M.remove(v3, 5_000) - let ((v8, v9), pres2) = M.split(v7, 5_000) - b( - __LOC__, - switch pres2 { - | None => true - | _ => false - }, - ) - b(__LOC__, A.eq(M.keysToArray(v8), A.makeBy(5_000, i => i), \"=")) - b(__LOC__, A.eq(M.keysToArray(v9), A.makeBy(5_000, i => 5_001 + i), \"=")) -} - -Mt.from_pair_suites(__MODULE__, suites.contents) diff --git a/jscomp/test/bs_poly_mutable_map_test.js b/jscomp/test/bs_poly_mutable_map_test.js deleted file mode 100644 index 1237d06ae11..00000000000 --- a/jscomp/test/bs_poly_mutable_map_test.js +++ /dev/null @@ -1,126 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Caml = require("../../lib/js/caml.js"); -var Belt_Id = require("../../lib/js/belt_Id.js"); -var Belt_Set = require("../../lib/js/belt_Set.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); -var Array_data_util = require("./array_data_util.js"); -var Belt_MutableMap = require("../../lib/js/belt_MutableMap.js"); -var Belt_internalAVLtree = require("../../lib/js/belt_internalAVLtree.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, v) { - Mt.bool_suites(test_id, suites, loc, v); -} - -var Icmp = Belt_Id.comparable(Caml.int_compare); - -function f(x) { - return Belt_MutableMap.fromArray(x, Icmp); -} - -function ff(x) { - return Belt_Set.fromArray(x, Icmp); -} - -function randomRange(i, j) { - return Belt_Array.map(Array_data_util.randomRange(i, j), (function (x) { - return [ - x, - x - ]; - })); -} - -var a0 = Belt_MutableMap.fromArray(randomRange(0, 10), Icmp); - -Belt_MutableMap.set(a0, 3, 33); - -eq("File \"bs_poly_mutable_map_test.res\", line 27, characters 5-12", Belt_MutableMap.getExn(a0, 3), 33); - -Belt_MutableMap.removeMany(a0, [ - 7, - 8, - 0, - 1, - 3, - 2, - 4, - 922, - 4, - 5, - 6 - ]); - -eq("File \"bs_poly_mutable_map_test.res\", line 29, characters 5-12", Belt_internalAVLtree.keysToArray(a0.data), [ - 9, - 10 - ]); - -Belt_MutableMap.removeMany(a0, Array_data_util.randomRange(0, 100)); - -b("File \"bs_poly_mutable_map_test.res\", line 31, characters 4-11", Belt_MutableMap.isEmpty(a0)); - -var a0$1 = Belt_MutableMap.fromArray(randomRange(0, 10000), Icmp); - -Belt_MutableMap.set(a0$1, 2000, 33); - -Belt_MutableMap.removeMany(a0$1, Belt_Array.map(randomRange(0, 1998), (function (prim) { - return prim[0]; - }))); - -Belt_MutableMap.removeMany(a0$1, Belt_Array.map(randomRange(2002, 11000), (function (prim) { - return prim[0]; - }))); - -eq("File \"bs_poly_mutable_map_test.res\", line 39, characters 5-12", Belt_internalAVLtree.toArray(a0$1.data), [ - [ - 1999, - 1999 - ], - [ - 2000, - 33 - ], - [ - 2001, - 2001 - ] - ]); - -Mt.from_pair_suites("Bs_poly_mutable_map_test", suites.contents); - -var M; - -var N; - -var A; - -var I; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.Icmp = Icmp; -exports.M = M; -exports.N = N; -exports.A = A; -exports.I = I; -exports.f = f; -exports.ff = ff; -exports.randomRange = randomRange; -/* Icmp Not a pure module */ diff --git a/jscomp/test/bs_poly_mutable_map_test.res b/jscomp/test/bs_poly_mutable_map_test.res deleted file mode 100644 index f79d8c7e7ab..00000000000 --- a/jscomp/test/bs_poly_mutable_map_test.res +++ /dev/null @@ -1,42 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => Mt.eq_suites(~suites, ~test_id, loc, x, y) -let b = (loc, v) => Mt.bool_suites(~suites, ~test_id, loc, v) - -module Icmp = unpack(Belt.Id.comparable(~cmp=(x: int, y) => compare(x, y))) -module M = Belt.MutableMap -module N = Belt.Set - -module A = Belt.Array -module I = Array_data_util -let f = x => M.fromArray(~id=module(Icmp), x) -let ff = x => N.fromArray(~id=module(Icmp), x) - -let randomRange = (i, j): array<(int, int)> => A.map(I.randomRange(i, j), x => (x, x)) - -%%private( - let (\".!()<-", \".!()") = { - open M - (set, getExn) - } -) - -let () = { - let a0 = f(randomRange(0, 10)) - \".!()<-"(a0, 3, 33) - eq(__LOC__, M.getExn(a0, 3), 33) - M.removeMany(a0, [7, 8, 0, 1, 3, 2, 4, 922, 4, 5, 6]) - eq(__LOC__, M.keysToArray(a0), [9, 10]) - M.removeMany(a0, I.randomRange(0, 100)) - b(__LOC__, M.isEmpty(a0)) -} - -let () = { - let a0 = f(randomRange(0, 10000)) - \".!()<-"(a0, 2000, 33) - a0->M.removeMany(randomRange(0, 1998)->A.map(fst)) - a0->M.removeMany(randomRange(2002, 11000)->A.map(fst)) - eq(__LOC__, a0->M.toArray, [(1999, 1999), (2000, 33), (2001, 2001)]) -} - -Mt.from_pair_suites(__MODULE__, suites.contents) diff --git a/jscomp/test/bs_poly_mutable_set_test.js b/jscomp/test/bs_poly_mutable_set_test.js deleted file mode 100644 index a2a1a92556a..00000000000 --- a/jscomp/test/bs_poly_mutable_set_test.js +++ /dev/null @@ -1,359 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Caml = require("../../lib/js/caml.js"); -var Belt_Id = require("../../lib/js/belt_Id.js"); -var Belt_List = require("../../lib/js/belt_List.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); -var Array_data_util = require("./array_data_util.js"); -var Belt_MutableSet = require("../../lib/js/belt_MutableSet.js"); -var Belt_internalAVLset = require("../../lib/js/belt_internalAVLset.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -var IntCmp = Belt_Id.comparable(Caml.int_compare); - -function fromArray(param) { - return Belt_MutableSet.fromArray(param, IntCmp); -} - -function empty(param) { - return { - cmp: IntCmp.cmp, - data: undefined - }; -} - -var u = fromArray(Array_data_util.range(0, 30)); - -b("File \"bs_poly_mutable_set_test.res\", line 16, characters 4-11", Belt_MutableSet.removeCheck(u, 0)); - -b("File \"bs_poly_mutable_set_test.res\", line 17, characters 4-11", !Belt_MutableSet.removeCheck(u, 0)); - -b("File \"bs_poly_mutable_set_test.res\", line 18, characters 4-11", Belt_MutableSet.removeCheck(u, 30)); - -b("File \"bs_poly_mutable_set_test.res\", line 19, characters 4-11", Belt_MutableSet.removeCheck(u, 20)); - -eq("File \"bs_poly_mutable_set_test.res\", line 20, characters 5-12", Belt_internalAVLset.size(u.data), 28); - -var r = Array_data_util.randomRange(0, 30); - -b("File \"bs_poly_mutable_set_test.res\", line 22, characters 4-11", 29 === Belt_internalAVLset.maxUndefined(u.data)); - -b("File \"bs_poly_mutable_set_test.res\", line 23, characters 4-11", 1 === Belt_internalAVLset.minUndefined(u.data)); - -Belt_MutableSet.add(u, 3); - -for(var i = 0 ,i_finish = r.length; i < i_finish; ++i){ - Belt_MutableSet.remove(u, r[i]); -} - -b("File \"bs_poly_mutable_set_test.res\", line 28, characters 4-11", Belt_MutableSet.isEmpty(u)); - -Belt_MutableSet.add(u, 0); - -Belt_MutableSet.add(u, 1); - -Belt_MutableSet.add(u, 2); - -Belt_MutableSet.add(u, 0); - -eq("File \"bs_poly_mutable_set_test.res\", line 33, characters 5-12", Belt_internalAVLset.size(u.data), 3); - -b("File \"bs_poly_mutable_set_test.res\", line 34, characters 4-11", !Belt_MutableSet.isEmpty(u)); - -for(var i$1 = 0; i$1 <= 3; ++i$1){ - Belt_MutableSet.remove(u, i$1); -} - -b("File \"bs_poly_mutable_set_test.res\", line 38, characters 4-11", Belt_MutableSet.isEmpty(u)); - -Belt_MutableSet.mergeMany(u, Array_data_util.randomRange(0, 20000)); - -Belt_MutableSet.mergeMany(u, Array_data_util.randomRange(0, 200)); - -eq("File \"bs_poly_mutable_set_test.res\", line 41, characters 5-12", Belt_internalAVLset.size(u.data), 20001); - -Belt_MutableSet.removeMany(u, Array_data_util.randomRange(0, 200)); - -eq("File \"bs_poly_mutable_set_test.res\", line 43, characters 5-12", Belt_internalAVLset.size(u.data), 19800); - -Belt_MutableSet.removeMany(u, Array_data_util.randomRange(0, 1000)); - -eq("File \"bs_poly_mutable_set_test.res\", line 45, characters 5-12", Belt_internalAVLset.size(u.data), 19000); - -Belt_MutableSet.removeMany(u, Array_data_util.randomRange(0, 1000)); - -eq("File \"bs_poly_mutable_set_test.res\", line 47, characters 5-12", Belt_internalAVLset.size(u.data), 19000); - -Belt_MutableSet.removeMany(u, Array_data_util.randomRange(1000, 10000)); - -eq("File \"bs_poly_mutable_set_test.res\", line 49, characters 5-12", Belt_internalAVLset.size(u.data), 10000); - -Belt_MutableSet.removeMany(u, Array_data_util.randomRange(10000, 19999)); - -eq("File \"bs_poly_mutable_set_test.res\", line 51, characters 5-12", Belt_internalAVLset.size(u.data), 1); - -b("File \"bs_poly_mutable_set_test.res\", line 52, characters 4-11", Belt_MutableSet.has(u, 20000)); - -Belt_MutableSet.removeMany(u, Array_data_util.randomRange(10000, 30000)); - -b("File \"bs_poly_mutable_set_test.res\", line 54, characters 4-11", Belt_MutableSet.isEmpty(u)); - -var v = fromArray(Array_data_util.randomRange(1000, 2000)); - -var bs = Belt_Array.map(Array_data_util.randomRange(500, 1499), (function (x) { - return Belt_MutableSet.removeCheck(v, x); - })); - -var indeedRemoved = Belt_Array.reduce(bs, 0, (function (acc, x) { - if (x) { - return acc + 1 | 0; - } else { - return acc; - } - })); - -eq("File \"bs_poly_mutable_set_test.res\", line 67, characters 5-12", indeedRemoved, 500); - -eq("File \"bs_poly_mutable_set_test.res\", line 68, characters 5-12", Belt_internalAVLset.size(v.data), 501); - -var cs = Belt_Array.map(Array_data_util.randomRange(500, 2000), (function (x) { - return Belt_MutableSet.addCheck(v, x); - })); - -var indeedAded = Belt_Array.reduce(cs, 0, (function (acc, x) { - if (x) { - return acc + 1 | 0; - } else { - return acc; - } - })); - -eq("File \"bs_poly_mutable_set_test.res\", line 77, characters 5-12", indeedAded, 1000); - -eq("File \"bs_poly_mutable_set_test.res\", line 78, characters 5-12", Belt_internalAVLset.size(v.data), 1501); - -b("File \"bs_poly_mutable_set_test.res\", line 79, characters 4-11", Belt_MutableSet.isEmpty({ - cmp: IntCmp.cmp, - data: undefined - })); - -eq("File \"bs_poly_mutable_set_test.res\", line 80, characters 5-12", Belt_internalAVLset.minimum(v.data), 500); - -eq("File \"bs_poly_mutable_set_test.res\", line 81, characters 5-12", Belt_internalAVLset.maximum(v.data), 2000); - -eq("File \"bs_poly_mutable_set_test.res\", line 82, characters 5-12", Belt_internalAVLset.minUndefined(v.data), 500); - -eq("File \"bs_poly_mutable_set_test.res\", line 83, characters 5-12", Belt_internalAVLset.maxUndefined(v.data), 2000); - -eq("File \"bs_poly_mutable_set_test.res\", line 84, characters 5-12", Belt_MutableSet.reduce(v, 0, (function (x, y) { - return x + y | 0; - })), 1876250); - -b("File \"bs_poly_mutable_set_test.res\", line 85, characters 4-11", Belt_List.eq(Belt_internalAVLset.toList(v.data), Belt_List.makeBy(1501, (function (i) { - return i + 500 | 0; - })), (function (x, y) { - return x === y; - }))); - -eq("File \"bs_poly_mutable_set_test.res\", line 86, characters 5-12", Belt_internalAVLset.toArray(v.data), Array_data_util.range(500, 2000)); - -Belt_internalAVLset.checkInvariantInternal(v.data); - -eq("File \"bs_poly_mutable_set_test.res\", line 88, characters 5-12", Belt_MutableSet.get(v, 3), undefined); - -eq("File \"bs_poly_mutable_set_test.res\", line 89, characters 5-12", Belt_MutableSet.get(v, 1200), 1200); - -var match = Belt_MutableSet.split(v, 1000); - -var match$1 = match[0]; - -var bb = match$1[1]; - -var aa = match$1[0]; - -b("File \"bs_poly_mutable_set_test.res\", line 91, characters 4-11", match[1]); - -b("File \"bs_poly_mutable_set_test.res\", line 92, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(aa.data), Array_data_util.range(500, 999), (function (prim0, prim1) { - return prim0 === prim1; - }))); - -b("File \"bs_poly_mutable_set_test.res\", line 93, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(bb.data), Array_data_util.range(1001, 2000), (function (prim0, prim1) { - return prim0 === prim1; - }))); - -b("File \"bs_poly_mutable_set_test.res\", line 94, characters 4-11", Belt_MutableSet.subset(aa, v)); - -b("File \"bs_poly_mutable_set_test.res\", line 95, characters 4-11", Belt_MutableSet.subset(bb, v)); - -b("File \"bs_poly_mutable_set_test.res\", line 96, characters 4-11", Belt_MutableSet.isEmpty(Belt_MutableSet.intersect(aa, bb))); - -var c = Belt_MutableSet.removeCheck(v, 1000); - -b("File \"bs_poly_mutable_set_test.res\", line 98, characters 4-11", c); - -var match$2 = Belt_MutableSet.split(v, 1000); - -var match$3 = match$2[0]; - -var bb$1 = match$3[1]; - -var aa$1 = match$3[0]; - -b("File \"bs_poly_mutable_set_test.res\", line 100, characters 4-11", !match$2[1]); - -b("File \"bs_poly_mutable_set_test.res\", line 101, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(aa$1.data), Array_data_util.range(500, 999), (function (prim0, prim1) { - return prim0 === prim1; - }))); - -b("File \"bs_poly_mutable_set_test.res\", line 102, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(bb$1.data), Array_data_util.range(1001, 2000), (function (prim0, prim1) { - return prim0 === prim1; - }))); - -b("File \"bs_poly_mutable_set_test.res\", line 103, characters 4-11", Belt_MutableSet.subset(aa$1, v)); - -b("File \"bs_poly_mutable_set_test.res\", line 104, characters 4-11", Belt_MutableSet.subset(bb$1, v)); - -b("File \"bs_poly_mutable_set_test.res\", line 105, characters 4-11", Belt_MutableSet.isEmpty(Belt_MutableSet.intersect(aa$1, bb$1))); - -var aa$2 = fromArray(Array_data_util.randomRange(0, 100)); - -var bb$2 = fromArray(Array_data_util.randomRange(40, 120)); - -var cc = Belt_MutableSet.union(aa$2, bb$2); - -b("File \"bs_poly_mutable_set_test.res\", line 115, characters 4-11", Belt_MutableSet.eq(cc, fromArray(Array_data_util.randomRange(0, 120)))); - -b("File \"bs_poly_mutable_set_test.res\", line 118, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.union(fromArray(Array_data_util.randomRange(0, 20)), fromArray(Array_data_util.randomRange(21, 40))), fromArray(Array_data_util.randomRange(0, 40)))); - -var dd = Belt_MutableSet.intersect(aa$2, bb$2); - -b("File \"bs_poly_mutable_set_test.res\", line 122, characters 4-11", Belt_MutableSet.eq(dd, fromArray(Array_data_util.randomRange(40, 100)))); - -b("File \"bs_poly_mutable_set_test.res\", line 124, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.intersect(fromArray(Array_data_util.randomRange(0, 20)), fromArray(Array_data_util.randomRange(21, 40))), { - cmp: IntCmp.cmp, - data: undefined - })); - -b("File \"bs_poly_mutable_set_test.res\", line 128, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.intersect(fromArray(Array_data_util.randomRange(21, 40)), fromArray(Array_data_util.randomRange(0, 20))), { - cmp: IntCmp.cmp, - data: undefined - })); - -b("File \"bs_poly_mutable_set_test.res\", line 131, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.intersect(fromArray([ - 1, - 3, - 4, - 5, - 7, - 9 - ]), fromArray([ - 2, - 4, - 5, - 6, - 8, - 10 - ])), fromArray([ - 4, - 5 - ]))); - -b("File \"bs_poly_mutable_set_test.res\", line 132, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.diff(aa$2, bb$2), fromArray(Array_data_util.randomRange(0, 39)))); - -b("File \"bs_poly_mutable_set_test.res\", line 133, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.diff(bb$2, aa$2), fromArray(Array_data_util.randomRange(101, 120)))); - -b("File \"bs_poly_mutable_set_test.res\", line 135, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.diff(fromArray(Array_data_util.randomRange(21, 40)), fromArray(Array_data_util.randomRange(0, 20))), fromArray(Array_data_util.randomRange(21, 40)))); - -b("File \"bs_poly_mutable_set_test.res\", line 142, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.diff(fromArray(Array_data_util.randomRange(0, 20)), fromArray(Array_data_util.randomRange(21, 40))), fromArray(Array_data_util.randomRange(0, 20)))); - -b("File \"bs_poly_mutable_set_test.res\", line 150, characters 4-11", Belt_MutableSet.eq(Belt_MutableSet.diff(fromArray(Array_data_util.randomRange(0, 20)), fromArray(Array_data_util.randomRange(0, 40))), fromArray(Array_data_util.randomRange(0, -1)))); - -var a0 = fromArray(Array_data_util.randomRange(0, 1000)); - -var a1 = Belt_MutableSet.keep(a0, (function (x) { - return x % 2 === 0; - })); - -var a2 = Belt_MutableSet.keep(a0, (function (x) { - return x % 2 !== 0; - })); - -var match$4 = Belt_MutableSet.partition(a0, (function (x) { - return x % 2 === 0; - })); - -var a4 = match$4[1]; - -var a3 = match$4[0]; - -b("File \"bs_poly_mutable_set_test.res\", line 162, characters 4-11", Belt_MutableSet.eq(a1, a3)); - -b("File \"bs_poly_mutable_set_test.res\", line 163, characters 4-11", Belt_MutableSet.eq(a2, a4)); - -Belt_List.forEach({ - hd: a0, - tl: { - hd: a1, - tl: { - hd: a2, - tl: { - hd: a3, - tl: { - hd: a4, - tl: /* [] */0 - } - } - } - } - }, (function (x) { - Belt_internalAVLset.checkInvariantInternal(x.data); - })); - -Mt.from_pair_suites("Bs_poly_mutable_set_test", suites.contents); - -var N; - -var I; - -var A; - -var L; - -var $plus$plus = Belt_MutableSet.union; - -var f = fromArray; - -var $eq$tilde = Belt_MutableSet.eq; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.N = N; -exports.I = I; -exports.A = A; -exports.IntCmp = IntCmp; -exports.L = L; -exports.fromArray = fromArray; -exports.empty = empty; -exports.$plus$plus = $plus$plus; -exports.f = f; -exports.$eq$tilde = $eq$tilde; -/* IntCmp Not a pure module */ diff --git a/jscomp/test/bs_poly_mutable_set_test.res b/jscomp/test/bs_poly_mutable_set_test.res deleted file mode 100644 index d808233fe97..00000000000 --- a/jscomp/test/bs_poly_mutable_set_test.res +++ /dev/null @@ -1,167 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => Mt.eq_suites(~test_id, ~suites, loc, x, y) -let b = (loc, x) => Mt.bool_suites(~test_id, ~suites, loc, x) - -module N = Belt.MutableSet -module I = Array_data_util -module A = Belt.Array -module IntCmp = unpack(Belt.Id.comparable(~cmp=(x: int, y) => compare(x, y))) -module L = Belt.List -let fromArray = N.fromArray(~id=module(IntCmp)) -let empty = () => N.make(~id=module(IntCmp)) - -let () = { - let u = fromArray(I.range(0, 30)) - b(__LOC__, N.removeCheck(u, 0)) - b(__LOC__, !N.removeCheck(u, 0)) - b(__LOC__, N.removeCheck(u, 30)) - b(__LOC__, N.removeCheck(u, 20)) - eq(__LOC__, N.size(u), 28) - let r = I.randomRange(0, 30) - b(__LOC__, Js.eqUndefined(29, N.maxUndefined(u))) - b(__LOC__, Js.eqUndefined(1, N.minUndefined(u))) - N.add(u, 3) - for i in 0 to A.length(r) - 1 { - N.remove(u, A.getUnsafe(r, i)) - } - b(__LOC__, N.isEmpty(u)) - N.add(u, 0) - N.add(u, 1) - N.add(u, 2) - N.add(u, 0) - eq(__LOC__, N.size(u), 3) - b(__LOC__, !N.isEmpty(u)) - for i in 0 to 3 { - N.remove(u, i) - } - b(__LOC__, N.isEmpty(u)) - N.mergeMany(u, I.randomRange(0, 20000)) - N.mergeMany(u, I.randomRange(0, 200)) - eq(__LOC__, N.size(u), 20001) - N.removeMany(u, I.randomRange(0, 200)) - eq(__LOC__, N.size(u), 19800) - N.removeMany(u, I.randomRange(0, 1000)) - eq(__LOC__, N.size(u), 19000) - N.removeMany(u, I.randomRange(0, 1000)) - eq(__LOC__, N.size(u), 19000) - N.removeMany(u, I.randomRange(1000, 10000)) - eq(__LOC__, N.size(u), 10000) - N.removeMany(u, I.randomRange(10000, 20000 - 1)) - eq(__LOC__, N.size(u), 1) - b(__LOC__, N.has(u, 20000)) - N.removeMany(u, I.randomRange(10_000, 30_000)) - b(__LOC__, N.isEmpty(u)) -} - -let () = { - let v = fromArray(I.randomRange(1_000, 2_000)) - let bs = A.map(I.randomRange(500, 1499), x => N.removeCheck(v, x)) - let indeedRemoved = A.reduce(bs, 0, (acc, x) => - if x { - acc + 1 - } else { - acc - } - ) - eq(__LOC__, indeedRemoved, 500) - eq(__LOC__, N.size(v), 501) - let cs = A.map(I.randomRange(500, 2_000), x => N.addCheck(v, x)) - let indeedAded = A.reduce(cs, 0, (acc, x) => - if x { - acc + 1 - } else { - acc - } - ) - eq(__LOC__, indeedAded, 1000) - eq(__LOC__, N.size(v), 1_501) - b(__LOC__, N.isEmpty(empty())) - eq(__LOC__, N.minimum(v), Some(500)) - eq(__LOC__, N.maximum(v), Some(2000)) - eq(__LOC__, N.minUndefined(v), Js.Undefined.return(500)) - eq(__LOC__, N.maxUndefined(v), Js.Undefined.return(2000)) - eq(__LOC__, N.reduce(v, 0, (x, y) => x + y), (500 + 2000) / 2 * 1501) - b(__LOC__, L.eq(N.toList(v), L.makeBy(1_501, i => i + 500), (x, y) => x == y)) - eq(__LOC__, N.toArray(v), I.range(500, 2000)) - N.checkInvariantInternal(v) - eq(__LOC__, N.get(v, 3), None) - eq(__LOC__, N.get(v, 1_200), Some(1_200)) - let ((aa, bb), pres) = N.split(v, 1000) - b(__LOC__, pres) - b(__LOC__, A.eq(N.toArray(aa), I.range(500, 999), \"=")) - b(__LOC__, A.eq(N.toArray(bb), I.range(1_001, 2_000), \"=")) - b(__LOC__, N.subset(aa, v)) - b(__LOC__, N.subset(bb, v)) - b(__LOC__, N.isEmpty(N.intersect(aa, bb))) - let c = N.removeCheck(v, 1_000) - b(__LOC__, c) - let ((aa, bb), pres) = N.split(v, 1_000) - b(__LOC__, !pres) - b(__LOC__, A.eq(N.toArray(aa), I.range(500, 999), \"=")) - b(__LOC__, A.eq(N.toArray(bb), I.range(1_001, 2_000), \"=")) - b(__LOC__, N.subset(aa, v)) - b(__LOC__, N.subset(bb, v)) - b(__LOC__, N.isEmpty(N.intersect(aa, bb))) -} - -let \"++" = N.union -let f = fromArray -let \"=~" = N.eq -let () = { - let aa = f(I.randomRange(0, 100)) - let bb = f(I.randomRange(40, 120)) - let cc = \"++"(aa, bb) - b(__LOC__, \"=~"(cc, f(I.randomRange(0, 120)))) - - b( - __LOC__, - N.eq(N.union(f(I.randomRange(0, 20)), f(I.randomRange(21, 40))), f(I.randomRange(0, 40))), - ) - let dd = N.intersect(aa, bb) - b(__LOC__, \"=~"(dd, f(I.randomRange(40, 100)))) - b( - __LOC__, - \"=~"(N.intersect(\"@@"(f, I.randomRange(0, 20)), \"@@"(f, I.randomRange(21, 40))), empty()), - ) - b( - __LOC__, - \"=~"(N.intersect(\"@@"(f, I.randomRange(21, 40)), \"@@"(f, I.randomRange(0, 20))), empty()), - ) - b(__LOC__, \"=~"(N.intersect(f([1, 3, 4, 5, 7, 9]), f([2, 4, 5, 6, 8, 10])), f([4, 5]))) - b(__LOC__, \"=~"(N.diff(aa, bb), f(I.randomRange(0, 39)))) - b(__LOC__, \"=~"(N.diff(bb, aa), f(I.randomRange(101, 120)))) - b( - __LOC__, - \"=~"( - N.diff(\"@@"(f, I.randomRange(21, 40)), \"@@"(f, I.randomRange(0, 20))), - f(I.randomRange(21, 40)), - ), - ) - b( - __LOC__, - \"=~"( - N.diff(\"@@"(f, I.randomRange(0, 20)), \"@@"(f, I.randomRange(21, 40))), - f(I.randomRange(0, 20)), - ), - ) - - b( - __LOC__, - \"=~"( - N.diff(\"@@"(f, I.randomRange(0, 20)), \"@@"(f, I.randomRange(0, 40))), - f(I.randomRange(0, -1)), - ), - ) -} - -let () = { - let a0 = fromArray(I.randomRange(0, 1000)) - let (a1, a2) = (N.keep(a0, x => mod(x, 2) == 0), N.keep(a0, x => mod(x, 2) != 0)) - let (a3, a4) = N.partition(a0, x => mod(x, 2) == 0) - b(__LOC__, N.eq(a1, a3)) - b(__LOC__, N.eq(a2, a4)) - L.forEach(list{a0, a1, a2, a3, a4}, x => N.checkInvariantInternal(x)) -} - -Mt.from_pair_suites(__MODULE__, suites.contents) diff --git a/jscomp/test/bs_poly_set_test.js b/jscomp/test/bs_poly_set_test.js deleted file mode 100644 index d2a95f712bc..00000000000 --- a/jscomp/test/bs_poly_set_test.js +++ /dev/null @@ -1,422 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Caml = require("../../lib/js/caml.js"); -var Belt_Id = require("../../lib/js/belt_Id.js"); -var Belt_Set = require("../../lib/js/belt_Set.js"); -var Caml_obj = require("../../lib/js/caml_obj.js"); -var Belt_List = require("../../lib/js/belt_List.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); -var Belt_SetDict = require("../../lib/js/belt_SetDict.js"); -var Belt_SortArray = require("../../lib/js/belt_SortArray.js"); -var Array_data_util = require("./array_data_util.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -function t(loc, x) { - Mt.throw_suites(test_id, suites, loc, x); -} - -var IntCmp = Belt_Id.comparable(Caml.int_compare); - -var u0 = Belt_Set.fromArray(Array_data_util.range(0, 30), IntCmp); - -var u1 = Belt_Set.remove(u0, 0); - -var u2 = Belt_Set.remove(u1, 0); - -var u3 = Belt_Set.remove(u2, 30); - -var u4 = Belt_Set.remove(u3, 20); - -var r = Array_data_util.randomRange(0, 30); - -var u5 = Belt_Set.add(u4, 3); - -var u6 = Belt_Set.removeMany(u5, r); - -var u7 = Belt_Set.mergeMany(u6, [ - 0, - 1, - 2, - 0 - ]); - -var u8 = Belt_Set.removeMany(u7, [ - 0, - 1, - 2, - 3 - ]); - -var u9 = Belt_Set.mergeMany(u8, Array_data_util.randomRange(0, 20000)); - -var u10 = Belt_Set.mergeMany(u9, Array_data_util.randomRange(0, 200)); - -var u11 = Belt_Set.removeMany(u10, Array_data_util.randomRange(0, 200)); - -var u12 = Belt_Set.removeMany(u11, Array_data_util.randomRange(0, 1000)); - -var u13 = Belt_Set.removeMany(u12, Array_data_util.randomRange(0, 1000)); - -var u14 = Belt_Set.removeMany(u13, Array_data_util.randomRange(1000, 10000)); - -var u15 = Belt_Set.removeMany(u14, Array_data_util.randomRange(10000, 19999)); - -var u16 = Belt_Set.removeMany(u15, Array_data_util.randomRange(20000, 21000)); - -b("File \"bs_poly_set_test.res\", line 34, characters 4-11", u0 !== u1); - -b("File \"bs_poly_set_test.res\", line 35, characters 4-11", u2 === u1); - -eq("File \"bs_poly_set_test.res\", line 36, characters 5-12", Belt_SetDict.size(u4.data), 28); - -b("File \"bs_poly_set_test.res\", line 37, characters 4-11", 29 === Belt_SetDict.maxUndefined(u4.data)); - -b("File \"bs_poly_set_test.res\", line 38, characters 4-11", 1 === Belt_SetDict.minUndefined(u4.data)); - -b("File \"bs_poly_set_test.res\", line 39, characters 4-11", u4 === u5); - -b("File \"bs_poly_set_test.res\", line 40, characters 4-11", Belt_SetDict.isEmpty(u6.data)); - -eq("File \"bs_poly_set_test.res\", line 41, characters 5-12", Belt_SetDict.size(u7.data), 3); - -b("File \"bs_poly_set_test.res\", line 42, characters 4-11", !Belt_SetDict.isEmpty(u7.data)); - -b("File \"bs_poly_set_test.res\", line 43, characters 4-11", Belt_SetDict.isEmpty(u8.data)); - -b("File \"bs_poly_set_test.res\", line 46, characters 4-11", Belt_Set.has(u10, 20)); - -b("File \"bs_poly_set_test.res\", line 47, characters 4-11", Belt_Set.has(u10, 21)); - -eq("File \"bs_poly_set_test.res\", line 48, characters 5-12", Belt_SetDict.size(u10.data), 20001); - -eq("File \"bs_poly_set_test.res\", line 49, characters 5-12", Belt_SetDict.size(u11.data), 19800); - -eq("File \"bs_poly_set_test.res\", line 50, characters 5-12", Belt_SetDict.size(u12.data), 19000); - -eq("File \"bs_poly_set_test.res\", line 52, characters 5-12", Belt_SetDict.size(u13.data), Belt_SetDict.size(u12.data)); - -eq("File \"bs_poly_set_test.res\", line 53, characters 5-12", Belt_SetDict.size(u14.data), 10000); - -eq("File \"bs_poly_set_test.res\", line 54, characters 5-12", Belt_SetDict.size(u15.data), 1); - -b("File \"bs_poly_set_test.res\", line 55, characters 4-11", Belt_Set.has(u15, 20000)); - -b("File \"bs_poly_set_test.res\", line 56, characters 4-11", !Belt_Set.has(u15, 2000)); - -b("File \"bs_poly_set_test.res\", line 57, characters 4-11", Belt_SetDict.isEmpty(u16.data)); - -var u17 = Belt_Set.fromArray(Array_data_util.randomRange(0, 100), IntCmp); - -var u18 = Belt_Set.fromArray(Array_data_util.randomRange(59, 200), IntCmp); - -var u19 = Belt_Set.union(u17, u18); - -var u20 = Belt_Set.fromArray(Array_data_util.randomRange(0, 200), IntCmp); - -var u21 = Belt_Set.intersect(u17, u18); - -var u22 = Belt_Set.diff(u17, u18); - -var u23 = Belt_Set.diff(u18, u17); - -var u24 = Belt_Set.union(u18, u17); - -var u25 = Belt_Set.add(u22, 59); - -var u26 = Belt_Set.add({ - cmp: IntCmp.cmp, - data: undefined - }, 3); - -var ss = Belt_Array.makeByAndShuffle(100, (function (i) { - return (i << 1); - })); - -var u27 = Belt_Set.fromArray(ss, IntCmp); - -var u28 = Belt_Set.union(u27, u26); - -var u29 = Belt_Set.union(u26, u27); - -b("File \"bs_poly_set_test.res\", line 71, characters 4-11", Belt_Set.eq(u28, u29)); - -b("File \"bs_poly_set_test.res\", line 72, characters 4-11", Caml_obj.equal(Belt_SetDict.toArray(u29.data), Belt_SortArray.stableSortBy(Belt_Array.concat(ss, [3]), Caml.int_compare))); - -b("File \"bs_poly_set_test.res\", line 73, characters 4-11", Belt_Set.eq(u19, u20)); - -eq("File \"bs_poly_set_test.res\", line 74, characters 5-12", Belt_SetDict.toArray(u21.data), Array_data_util.range(59, 100)); - -eq("File \"bs_poly_set_test.res\", line 75, characters 5-12", Belt_SetDict.toArray(u22.data), Array_data_util.range(0, 58)); - -b("File \"bs_poly_set_test.res\", line 76, characters 4-11", Belt_Set.eq(u24, u19)); - -eq("File \"bs_poly_set_test.res\", line 77, characters 5-12", Belt_SetDict.toArray(u23.data), Array_data_util.range(101, 200)); - -b("File \"bs_poly_set_test.res\", line 78, characters 4-11", Belt_Set.subset(u23, u18)); - -b("File \"bs_poly_set_test.res\", line 79, characters 4-11", !Belt_Set.subset(u18, u23)); - -b("File \"bs_poly_set_test.res\", line 80, characters 4-11", Belt_Set.subset(u22, u17)); - -b("File \"bs_poly_set_test.res\", line 81, characters 4-11", Belt_Set.subset(u21, u17) && Belt_Set.subset(u21, u18)); - -b("File \"bs_poly_set_test.res\", line 82, characters 4-11", 47 === Belt_Set.getUndefined(u22, 47)); - -b("File \"bs_poly_set_test.res\", line 83, characters 4-11", Caml_obj.equal(47, Belt_Set.get(u22, 47))); - -b("File \"bs_poly_set_test.res\", line 84, characters 4-11", Belt_Set.getUndefined(u22, 59) === undefined); - -b("File \"bs_poly_set_test.res\", line 85, characters 4-11", undefined === Belt_Set.get(u22, 59)); - -eq("File \"bs_poly_set_test.res\", line 87, characters 5-12", Belt_SetDict.size(u25.data), 60); - -b("File \"bs_poly_set_test.res\", line 88, characters 4-11", Belt_SetDict.minimum(undefined) === undefined); - -b("File \"bs_poly_set_test.res\", line 89, characters 4-11", Belt_SetDict.maximum(undefined) === undefined); - -b("File \"bs_poly_set_test.res\", line 90, characters 4-11", Belt_SetDict.minUndefined(undefined) === undefined); - -b("File \"bs_poly_set_test.res\", line 91, characters 4-11", Belt_SetDict.maxUndefined(undefined) === undefined); - -function testIterToList(xs) { - var v = { - contents: /* [] */0 - }; - Belt_Set.forEach(xs, (function (x) { - v.contents = { - hd: x, - tl: v.contents - }; - })); - return Belt_List.reverse(v.contents); -} - -function testIterToList2(xs) { - var v = { - contents: /* [] */0 - }; - Belt_SetDict.forEach(xs.data, (function (x) { - v.contents = { - hd: x, - tl: v.contents - }; - })); - return Belt_List.reverse(v.contents); -} - -var u0$1 = Belt_Set.fromArray(Array_data_util.randomRange(0, 20), IntCmp); - -var u1$1 = Belt_Set.remove(u0$1, 17); - -var u2$1 = Belt_Set.add(u1$1, 33); - -b("File \"bs_poly_set_test.res\", line 110, characters 4-11", Belt_List.every2(testIterToList(u0$1), Belt_List.makeBy(21, (function (i) { - return i; - })), (function (x, y) { - return x === y; - }))); - -b("File \"bs_poly_set_test.res\", line 111, characters 4-11", Belt_List.every2(testIterToList2(u0$1), Belt_List.makeBy(21, (function (i) { - return i; - })), (function (x, y) { - return x === y; - }))); - -b("File \"bs_poly_set_test.res\", line 112, characters 4-11", Belt_List.every2(testIterToList(u0$1), Belt_SetDict.toList(u0$1.data), (function (x, y) { - return x === y; - }))); - -b("File \"bs_poly_set_test.res\", line 113, characters 4-11", Belt_Set.some(u0$1, (function (x) { - return x === 17; - }))); - -b("File \"bs_poly_set_test.res\", line 114, characters 4-11", !Belt_Set.some(u1$1, (function (x) { - return x === 17; - }))); - -b("File \"bs_poly_set_test.res\", line 115, characters 4-11", Belt_Set.every(u0$1, (function (x) { - return x < 24; - }))); - -b("File \"bs_poly_set_test.res\", line 116, characters 4-11", Belt_SetDict.every(u0$1.data, (function (x) { - return x < 24; - }))); - -b("File \"bs_poly_set_test.res\", line 117, characters 4-11", !Belt_Set.every(u2$1, (function (x) { - return x < 24; - }))); - -b("File \"bs_poly_set_test.res\", line 118, characters 4-11", !Belt_Set.every(Belt_Set.fromArray([ - 1, - 2, - 3 - ], IntCmp), (function (x) { - return x === 2; - }))); - -b("File \"bs_poly_set_test.res\", line 119, characters 4-11", Belt_Set.cmp(u1$1, u0$1) < 0); - -b("File \"bs_poly_set_test.res\", line 120, characters 4-11", Belt_Set.cmp(u0$1, u1$1) > 0); - -var a0 = Belt_Set.fromArray(Array_data_util.randomRange(0, 1000), IntCmp); - -var a1 = Belt_Set.keep(a0, (function (x) { - return x % 2 === 0; - })); - -var a2 = Belt_Set.keep(a0, (function (x) { - return x % 2 !== 0; - })); - -var match = Belt_Set.partition(a0, (function (x) { - return x % 2 === 0; - })); - -var a4 = match[1]; - -var a3 = match[0]; - -b("File \"bs_poly_set_test.res\", line 127, characters 4-11", Belt_Set.eq(a1, a3)); - -b("File \"bs_poly_set_test.res\", line 128, characters 4-11", Belt_Set.eq(a2, a4)); - -eq("File \"bs_poly_set_test.res\", line 129, characters 5-12", Belt_Set.getExn(a0, 3), 3); - -eq("File \"bs_poly_set_test.res\", line 130, characters 5-12", Belt_Set.getExn(a0, 4), 4); - -t("File \"bs_poly_set_test.res\", line 131, characters 4-11", (function (param) { - Belt_Set.getExn(a0, 1002); - })); - -t("File \"bs_poly_set_test.res\", line 132, characters 4-11", (function (param) { - Belt_Set.getExn(a0, -1); - })); - -eq("File \"bs_poly_set_test.res\", line 133, characters 5-12", Belt_SetDict.size(a0.data), 1001); - -b("File \"bs_poly_set_test.res\", line 134, characters 4-11", !Belt_SetDict.isEmpty(a0.data)); - -var match$1 = Belt_Set.split(a0, 200); - -var match$2 = match$1[0]; - -b("File \"bs_poly_set_test.res\", line 136, characters 4-11", match$1[1]); - -eq("File \"bs_poly_set_test.res\", line 137, characters 5-12", Belt_SetDict.toArray(match$2[0].data), Belt_Array.makeBy(200, (function (i) { - return i; - }))); - -eq("File \"bs_poly_set_test.res\", line 138, characters 5-12", Belt_SetDict.toList(match$2[1].data), Belt_List.makeBy(800, (function (i) { - return i + 201 | 0; - }))); - -var a7 = Belt_Set.remove(a0, 200); - -var match$3 = Belt_Set.split(a7, 200); - -var match$4 = match$3[0]; - -var a9 = match$4[1]; - -var a8 = match$4[0]; - -b("File \"bs_poly_set_test.res\", line 141, characters 4-11", !match$3[1]); - -eq("File \"bs_poly_set_test.res\", line 142, characters 5-12", Belt_SetDict.toArray(a8.data), Belt_Array.makeBy(200, (function (i) { - return i; - }))); - -eq("File \"bs_poly_set_test.res\", line 143, characters 5-12", Belt_SetDict.toList(a9.data), Belt_List.makeBy(800, (function (i) { - return i + 201 | 0; - }))); - -eq("File \"bs_poly_set_test.res\", line 144, characters 5-12", Belt_SetDict.minimum(a8.data), 0); - -eq("File \"bs_poly_set_test.res\", line 145, characters 5-12", Belt_SetDict.minimum(a9.data), 201); - -Belt_List.forEach({ - hd: a0, - tl: { - hd: a1, - tl: { - hd: a2, - tl: { - hd: a3, - tl: { - hd: a4, - tl: /* [] */0 - } - } - } - } - }, (function (x) { - Belt_SetDict.checkInvariantInternal(x.data); - })); - -var a = Belt_Set.fromArray([], IntCmp); - -var m = Belt_Set.keep(a, (function (x) { - return x % 2 === 0; - })); - -b("File \"bs_poly_set_test.res\", line 151, characters 4-11", Belt_SetDict.isEmpty(m.data)); - -var match$5 = Belt_Set.split({ - cmp: IntCmp.cmp, - data: undefined - }, 0); - -var match$6 = match$5[0]; - -b("File \"bs_poly_set_test.res\", line 156, characters 4-11", Belt_SetDict.isEmpty(match$6[0].data)); - -b("File \"bs_poly_set_test.res\", line 157, characters 4-11", Belt_SetDict.isEmpty(match$6[1].data)); - -b("File \"bs_poly_set_test.res\", line 158, characters 4-11", !match$5[1]); - -Mt.from_pair_suites("Bs_poly_set_test", suites.contents); - -var N; - -var D; - -var I; - -var A; - -var S; - -var L; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.t = t; -exports.N = N; -exports.D = D; -exports.I = I; -exports.A = A; -exports.S = S; -exports.IntCmp = IntCmp; -exports.L = L; -exports.testIterToList = testIterToList; -exports.testIterToList2 = testIterToList2; -/* IntCmp Not a pure module */ diff --git a/jscomp/test/bs_poly_set_test.res b/jscomp/test/bs_poly_set_test.res deleted file mode 100644 index f5d2aded12d..00000000000 --- a/jscomp/test/bs_poly_set_test.res +++ /dev/null @@ -1,160 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => Mt.eq_suites(~test_id, ~suites, loc, x, y) -let b = (loc, x) => Mt.bool_suites(~test_id, ~suites, loc, x) -let t = (loc, x) => Mt.throw_suites(~test_id, ~suites, loc, x) -module N = Belt.Set -module D = Belt.Set.Dict -module I = Array_data_util -module A = Belt.Array -module S = Belt.SortArray -module IntCmp = unpack(Belt.Id.comparable(~cmp=(x: int, y) => compare(x, y))) -module L = Belt.List - -let () = { - let u0 = N.fromArray(~id=module(IntCmp), I.range(0, 30)) - let u1 = N.remove(u0, 0) - let u2 = N.remove(u1, 0) - let u3 = N.remove(u2, 30) - let u4 = N.remove(u3, 20) - let r = I.randomRange(0, 30) - - let u5 = N.add(u4, 3) - let u6 = N.removeMany(u5, r) - let u7 = N.mergeMany(u6, [0, 1, 2, 0]) - let u8 = N.removeMany(u7, [0, 1, 2, 3]) - let u9 = N.mergeMany(u8, I.randomRange(0, 20000)) - let u10 = N.mergeMany(u9, I.randomRange(0, 200)) - let u11 = N.removeMany(u10, I.randomRange(0, 200)) - let u12 = N.removeMany(u11, I.randomRange(0, 1000)) - let u13 = N.removeMany(u12, I.randomRange(0, 1000)) - let u14 = N.removeMany(u13, I.randomRange(1000, 10000)) - let u15 = N.removeMany(u14, I.randomRange(10000, 20000 - 1)) - let u16 = N.removeMany(u15, I.randomRange(20000, 21000)) - b(__LOC__, u0 !== u1) - b(__LOC__, u2 === u1) - eq(__LOC__, N.size(u4), 28) - b(__LOC__, Js.eqUndefined(29, N.maxUndefined(u4))) - b(__LOC__, Js.eqUndefined(1, N.minUndefined(u4))) - b(__LOC__, u4 === u5) - b(__LOC__, N.isEmpty(u6)) - eq(__LOC__, N.size(u7), 3) - b(__LOC__, !N.isEmpty(u7)) - b(__LOC__, N.isEmpty(u8)) - /* b __LOC__ (u9 == u10); */ - /* addArray does not get reference equality guarantee */ - b(__LOC__, N.has(u10, 20)) - b(__LOC__, N.has(u10, 21)) - eq(__LOC__, N.size(u10), 20001) - eq(__LOC__, N.size(u11), 19800) - eq(__LOC__, N.size(u12), 19000) - /* b __LOC__ (u12 == u13); */ - eq(__LOC__, N.size(u13), N.size(u12)) - eq(__LOC__, N.size(u14), 10000) - eq(__LOC__, N.size(u15), 1) - b(__LOC__, N.has(u15, 20000)) - b(__LOC__, \"@@"(not, N.has(u15, 2000))) - b(__LOC__, N.isEmpty(u16)) - let u17 = N.fromArray(~id=module(IntCmp), I.randomRange(0, 100)) - let u18 = N.fromArray(~id=module(IntCmp), I.randomRange(59, 200)) - let u19 = N.union(u17, u18) - let u20 = N.fromArray(~id=module(IntCmp), I.randomRange(0, 200)) - let u21 = N.intersect(u17, u18) - let u22 = N.diff(u17, u18) - let u23 = N.diff(u18, u17) - let u24 = N.union(u18, u17) - let u25 = N.add(u22, 59) - let u26 = N.add(N.make(~id=module(IntCmp)), 3) - let ss = A.makeByAndShuffle(100, i => i * 2) - let u27 = N.fromArray(~id=module(IntCmp), ss) - let (u28, u29) = (N.union(u27, u26), N.union(u26, u27)) - b(__LOC__, N.eq(u28, u29)) - b(__LOC__, N.toArray(u29) == S.stableSortBy(A.concat(ss, [3]), compare)) - b(__LOC__, N.eq(u19, u20)) - eq(__LOC__, N.toArray(u21), I.range(59, 100)) - eq(__LOC__, N.toArray(u22), I.range(0, 58)) - b(__LOC__, N.eq(u24, u19)) - eq(__LOC__, N.toArray(u23), I.range(101, 200)) - b(__LOC__, N.subset(u23, u18)) - b(__LOC__, !N.subset(u18, u23)) - b(__LOC__, N.subset(u22, u17)) - b(__LOC__, N.subset(u21, u17) && N.subset(u21, u18)) - b(__LOC__, Js.eqUndefined(47, N.getUndefined(u22, 47))) - b(__LOC__, Some(47) == N.get(u22, 47)) - b(__LOC__, N.getUndefined(u22, 59) == Js.undefined) - b(__LOC__, None == N.get(u22, 59)) - - eq(__LOC__, N.size(u25), 60) - b(__LOC__, N.minimum(N.make(~id=module(IntCmp))) == None) - b(__LOC__, N.maximum(N.make(~id=module(IntCmp))) == None) - b(__LOC__, N.minUndefined(N.make(~id=module(IntCmp))) == Js.undefined) - b(__LOC__, N.maxUndefined(N.make(~id=module(IntCmp))) == Js.undefined) -} - -let testIterToList = xs => { - let v = ref(list{}) - N.forEach(xs, x => v := list{x, ...v.contents}) - L.reverse(v.contents) -} - -let testIterToList2 = xs => { - let v = ref(list{}) - D.forEach(N.getData(xs), x => v := list{x, ...v.contents}) - L.reverse(v.contents) -} - -let () = { - let u0 = N.fromArray(~id=module(IntCmp), I.randomRange(0, 20)) - let u1 = N.remove(u0, 17) - let u2 = N.add(u1, 33) - b(__LOC__, L.every2(testIterToList(u0), L.makeBy(21, i => i), (x, y) => x == y)) - b(__LOC__, L.every2(testIterToList2(u0), L.makeBy(21, i => i), (x, y) => x == y)) - b(__LOC__, L.every2(testIterToList(u0), N.toList(u0), (x, y) => x == y)) - b(__LOC__, N.some(u0, x => x == 17)) - b(__LOC__, !N.some(u1, x => x == 17)) - b(__LOC__, N.every(u0, x => x < 24)) - b(__LOC__, D.every(N.getData(u0), x => x < 24)) - b(__LOC__, !N.every(u2, x => x < 24)) - b(__LOC__, \"@@"(not, N.every(N.fromArray(~id=module(IntCmp), [1, 2, 3]), x => x == 2))) - b(__LOC__, N.cmp(u1, u0) < 0) - b(__LOC__, N.cmp(u0, u1) > 0) -} - -let () = { - let a0 = N.fromArray(~id=module(IntCmp), I.randomRange(0, 1000)) - let (a1, a2) = (N.keep(a0, x => mod(x, 2) == 0), N.keep(a0, x => mod(x, 2) != 0)) - let (a3, a4) = N.partition(a0, x => mod(x, 2) == 0) - b(__LOC__, N.eq(a1, a3)) - b(__LOC__, N.eq(a2, a4)) - eq(__LOC__, N.getExn(a0, 3), 3) - eq(__LOC__, N.getExn(a0, 4), 4) - t(__LOC__, _ => \"@@"(ignore, N.getExn(a0, 1002))) - t(__LOC__, _ => \"@@"(ignore, N.getExn(a0, -1))) - eq(__LOC__, N.size(a0), 1001) - b(__LOC__, \"@@"(not, N.isEmpty(a0))) - let ((a5, a6), pres) = N.split(a0, 200) - b(__LOC__, pres) - eq(__LOC__, N.toArray(a5), A.makeBy(200, i => i)) - eq(__LOC__, N.toList(a6), L.makeBy(800, i => i + 201)) - let a7 = N.remove(a0, 200) - let ((a8, a9), pres) = N.split(a7, 200) - b(__LOC__, !pres) - eq(__LOC__, N.toArray(a8), A.makeBy(200, i => i)) - eq(__LOC__, N.toList(a9), L.makeBy(800, i => i + 201)) - eq(__LOC__, N.minimum(a8), Some(0)) - eq(__LOC__, N.minimum(a9), Some(201)) - L.forEach(list{a0, a1, a2, a3, a4}, x => N.checkInvariantInternal(x)) -} - -let () = { - let a = N.fromArray(~id=module(IntCmp), []) - b(__LOC__, N.isEmpty(N.keep(a, x => mod(x, 2) == 0))) -} - -let () = { - let ((aa, bb), pres) = N.split(N.make(~id=module(IntCmp)), 0) - b(__LOC__, N.isEmpty(aa)) - b(__LOC__, N.isEmpty(bb)) - b(__LOC__, !pres) -} -Mt.from_pair_suites(__MODULE__, suites.contents) diff --git a/jscomp/test/bs_queue_test.js b/jscomp/test/bs_queue_test.js deleted file mode 100644 index 7c55cc79c1c..00000000000 --- a/jscomp/test/bs_queue_test.js +++ /dev/null @@ -1,1294 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Curry = require("../../lib/js/curry.js"); -var Caml_obj = require("../../lib/js/caml_obj.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); -var Belt_MutableQueue = require("../../lib/js/belt_MutableQueue.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -function does_raise(f, q) { - try { - Curry._1(f, q); - return false; - } - catch (exn){ - return true; - } -} - -function $plus$plus(q, x) { - Belt_MutableQueue.add(q, x); - return q; -} - -var q = { - length: 0, - first: undefined, - last: undefined -}; - -if (!(Caml_obj.equal(Belt_MutableQueue.toArray(q), []) && q.length === 0)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 25, - 2 - ], - Error: new Error() - }; -} - -if (!(Caml_obj.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 1), q)), [1]) && q.length === 1)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 26, - 2 - ], - Error: new Error() - }; -} - -if (!(Caml_obj.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 2), q)), [ - 1, - 2 - ]) && q.length === 2)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 27, - 2 - ], - Error: new Error() - }; -} - -if (!(Caml_obj.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 3), q)), [ - 1, - 2, - 3 - ]) && q.length === 3)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 28, - 2 - ], - Error: new Error() - }; -} - -if (!(Caml_obj.equal(Belt_MutableQueue.toArray((Belt_MutableQueue.add(q, 4), q)), [ - 1, - 2, - 3, - 4 - ]) && q.length === 4)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 29, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.popExn(q) !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 30, - 2 - ], - Error: new Error() - }; -} - -if (!(Caml_obj.equal(Belt_MutableQueue.toArray(q), [ - 2, - 3, - 4 - ]) && q.length === 3)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 31, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.popExn(q) !== 2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 32, - 2 - ], - Error: new Error() - }; -} - -if (!(Caml_obj.equal(Belt_MutableQueue.toArray(q), [ - 3, - 4 - ]) && q.length === 2)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 33, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.popExn(q) !== 3) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 34, - 2 - ], - Error: new Error() - }; -} - -if (!(Caml_obj.equal(Belt_MutableQueue.toArray(q), [4]) && q.length === 1)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 35, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.popExn(q) !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 36, - 2 - ], - Error: new Error() - }; -} - -if (!(Caml_obj.equal(Belt_MutableQueue.toArray(q), []) && q.length === 0)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 37, - 2 - ], - Error: new Error() - }; -} - -if (!does_raise(Belt_MutableQueue.popExn, q)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 38, - 2 - ], - Error: new Error() - }; -} - -var q$1 = { - length: 0, - first: undefined, - last: undefined -}; - -if (Belt_MutableQueue.popExn((Belt_MutableQueue.add(q$1, 1), q$1)) !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 43, - 2 - ], - Error: new Error() - }; -} - -if (!does_raise(Belt_MutableQueue.popExn, q$1)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 44, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.popExn((Belt_MutableQueue.add(q$1, 2), q$1)) !== 2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 45, - 2 - ], - Error: new Error() - }; -} - -if (!does_raise(Belt_MutableQueue.popExn, q$1)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 46, - 2 - ], - Error: new Error() - }; -} - -if (q$1.length !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 47, - 2 - ], - Error: new Error() - }; -} - -var q$2 = { - length: 0, - first: undefined, - last: undefined -}; - -if (Belt_MutableQueue.peekExn((Belt_MutableQueue.add(q$2, 1), q$2)) !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 52, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.peekExn((Belt_MutableQueue.add(q$2, 2), q$2)) !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 53, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.peekExn((Belt_MutableQueue.add(q$2, 3), q$2)) !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 54, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.peekExn(q$2) !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 55, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.popExn(q$2) !== 1) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 56, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.peekExn(q$2) !== 2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 57, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.popExn(q$2) !== 2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 58, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.peekExn(q$2) !== 3) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 59, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.popExn(q$2) !== 3) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 60, - 2 - ], - Error: new Error() - }; -} - -if (!does_raise(Belt_MutableQueue.peekExn, q$2)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 61, - 2 - ], - Error: new Error() - }; -} - -if (!does_raise(Belt_MutableQueue.peekExn, q$2)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 62, - 2 - ], - Error: new Error() - }; -} - -var q$3 = { - length: 0, - first: undefined, - last: undefined -}; - -for(var i = 1; i <= 10; ++i){ - Belt_MutableQueue.add(q$3, i); -} - -Belt_MutableQueue.clear(q$3); - -if (q$3.length !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 71, - 2 - ], - Error: new Error() - }; -} - -if (!does_raise(Belt_MutableQueue.popExn, q$3)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 72, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(q$3, { - length: 0, - first: undefined, - last: undefined - })) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 73, - 2 - ], - Error: new Error() - }; -} - -Belt_MutableQueue.add(q$3, 42); - -if (Belt_MutableQueue.popExn(q$3) !== 42) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 75, - 2 - ], - Error: new Error() - }; -} - -var q1 = { - length: 0, - first: undefined, - last: undefined -}; - -for(var i$1 = 1; i$1 <= 10; ++i$1){ - Belt_MutableQueue.add(q1, i$1); -} - -var q2 = Belt_MutableQueue.copy(q1); - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q1), [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 84, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q2), [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 85, - 2 - ], - Error: new Error() - }; -} - -if (q1.length !== 10) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 86, - 2 - ], - Error: new Error() - }; -} - -if (q2.length !== 10) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 87, - 2 - ], - Error: new Error() - }; -} - -for(var i$2 = 1; i$2 <= 10; ++i$2){ - if (Belt_MutableQueue.popExn(q1) !== i$2) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 89, - 4 - ], - Error: new Error() - }; - } - -} - -for(var i$3 = 1; i$3 <= 10; ++i$3){ - if (Belt_MutableQueue.popExn(q2) !== i$3) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 92, - 4 - ], - Error: new Error() - }; - } - -} - -var q$4 = { - length: 0, - first: undefined, - last: undefined -}; - -if (q$4.length !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 98, - 2 - ], - Error: new Error() - }; -} - -for(var i$4 = 1; i$4 <= 10; ++i$4){ - Belt_MutableQueue.add(q$4, i$4); - if (q$4.length !== i$4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 101, - 4 - ], - Error: new Error() - }; - } - if (q$4.length === 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 102, - 4 - ], - Error: new Error() - }; - } - -} - -for(var i$5 = 10; i$5 >= 1; --i$5){ - if (q$4.length !== i$5) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 105, - 4 - ], - Error: new Error() - }; - } - if (q$4.length === 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 106, - 4 - ], - Error: new Error() - }; - } - Belt_MutableQueue.popExn(q$4); -} - -if (q$4.length !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 109, - 2 - ], - Error: new Error() - }; -} - -if (q$4.length !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 110, - 2 - ], - Error: new Error() - }; -} - -var q$5 = { - length: 0, - first: undefined, - last: undefined -}; - -for(var i$6 = 1; i$6 <= 10; ++i$6){ - Belt_MutableQueue.add(q$5, i$6); -} - -var i$7 = { - contents: 1 -}; - -Belt_MutableQueue.forEach(q$5, (function (j) { - if (i$7.contents !== j) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 120, - 4 - ], - Error: new Error() - }; - } - i$7.contents = i$7.contents + 1 | 0; - })); - -var q1$1 = { - length: 0, - first: undefined, - last: undefined -}; - -var q2$1 = { - length: 0, - first: undefined, - last: undefined -}; - -if (q1$1.length !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 127, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q1$1), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 128, - 2 - ], - Error: new Error() - }; -} - -if (q2$1.length !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 129, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q2$1), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 130, - 2 - ], - Error: new Error() - }; -} - -Belt_MutableQueue.transfer(q1$1, q2$1); - -if (q1$1.length !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 132, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q1$1), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 133, - 2 - ], - Error: new Error() - }; -} - -if (q2$1.length !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 134, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q2$1), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 135, - 2 - ], - Error: new Error() - }; -} - -var q1$2 = { - length: 0, - first: undefined, - last: undefined -}; - -var q2$2 = { - length: 0, - first: undefined, - last: undefined -}; - -for(var i$8 = 1; i$8 <= 4; ++i$8){ - Belt_MutableQueue.add(q1$2, i$8); -} - -if (q1$2.length !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 143, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q1$2), [ - 1, - 2, - 3, - 4 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 144, - 2 - ], - Error: new Error() - }; -} - -if (q2$2.length !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 145, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q2$2), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 146, - 2 - ], - Error: new Error() - }; -} - -Belt_MutableQueue.transfer(q1$2, q2$2); - -if (q1$2.length !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 148, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q1$2), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 149, - 2 - ], - Error: new Error() - }; -} - -if (q2$2.length !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 150, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q2$2), [ - 1, - 2, - 3, - 4 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 151, - 2 - ], - Error: new Error() - }; -} - -var q1$3 = { - length: 0, - first: undefined, - last: undefined -}; - -var q2$3 = { - length: 0, - first: undefined, - last: undefined -}; - -for(var i$9 = 5; i$9 <= 8; ++i$9){ - Belt_MutableQueue.add(q2$3, i$9); -} - -if (q1$3.length !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 159, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q1$3), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 160, - 2 - ], - Error: new Error() - }; -} - -if (q2$3.length !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 161, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q2$3), [ - 5, - 6, - 7, - 8 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 162, - 2 - ], - Error: new Error() - }; -} - -Belt_MutableQueue.transfer(q1$3, q2$3); - -if (q1$3.length !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 164, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q1$3), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 165, - 2 - ], - Error: new Error() - }; -} - -if (q2$3.length !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 166, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q2$3), [ - 5, - 6, - 7, - 8 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 167, - 2 - ], - Error: new Error() - }; -} - -var q1$4 = { - length: 0, - first: undefined, - last: undefined -}; - -var q2$4 = { - length: 0, - first: undefined, - last: undefined -}; - -for(var i$10 = 1; i$10 <= 4; ++i$10){ - Belt_MutableQueue.add(q1$4, i$10); -} - -for(var i$11 = 5; i$11 <= 8; ++i$11){ - Belt_MutableQueue.add(q2$4, i$11); -} - -if (q1$4.length !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 178, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q1$4), [ - 1, - 2, - 3, - 4 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 179, - 2 - ], - Error: new Error() - }; -} - -if (q2$4.length !== 4) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 180, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q2$4), [ - 5, - 6, - 7, - 8 - ])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 181, - 2 - ], - Error: new Error() - }; -} - -Belt_MutableQueue.transfer(q1$4, q2$4); - -if (q1$4.length !== 0) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 183, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q1$4), [])) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 184, - 2 - ], - Error: new Error() - }; -} - -var v = [ - 5, - 6, - 7, - 8, - 1, - 2, - 3, - 4 -]; - -if (q2$4.length !== 8) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 186, - 2 - ], - Error: new Error() - }; -} - -if (!Caml_obj.equal(Belt_MutableQueue.toArray(q2$4), v)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 187, - 2 - ], - Error: new Error() - }; -} - -if (Belt_MutableQueue.reduce(q2$4, 0, (function (x, y) { - return x - y | 0; - })) !== Belt_Array.reduce(v, 0, (function (x, y) { - return x - y | 0; - }))) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_queue_test.res", - 189, - 2 - ], - Error: new Error() - }; -} - -console.log("OK"); - -var q$6 = Belt_MutableQueue.fromArray([ - 1, - 2, - 3, - 4 - ]); - -var q1$5 = Belt_MutableQueue.map(q$6, (function (x) { - return x - 1 | 0; - })); - -eq("File \"bs_queue_test.res\", line 197, characters 5-12", Belt_MutableQueue.toArray(q1$5), [ - 0, - 1, - 2, - 3 - ]); - -var q$7 = Belt_MutableQueue.fromArray([]); - -b("File \"bs_queue_test.res\", line 198, characters 4-11", q$7.length === 0); - -var q$8 = Belt_MutableQueue.map(Belt_MutableQueue.fromArray([]), (function (x) { - return x + 1 | 0; - })); - -b("File \"bs_queue_test.res\", line 199, characters 4-11", q$8.length === 0); - -Mt.from_pair_suites("Bs_queue_test", suites.contents); - -var Q; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.Q = Q; -exports.does_raise = does_raise; -exports.$plus$plus = $plus$plus; -/* Not a pure module */ diff --git a/jscomp/test/bs_queue_test.res b/jscomp/test/bs_queue_test.res deleted file mode 100644 index df132d49b08..00000000000 --- a/jscomp/test/bs_queue_test.res +++ /dev/null @@ -1,202 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => Mt.eq_suites(~test_id, ~suites, loc, x, y) - -let b = (loc, x) => Mt.bool_suites(~test_id, ~suites, loc, x) -/* TEST - */ - -module Q = Belt.MutableQueue - -let does_raise = (f, q) => - try { - ignore((f(q): int)) - false - } catch { - | _ => true - } -let \"++" = (q, x) => { - Q.add(q, x) - q -} - -let () = { - let q = Q.make() - assert(Q.toArray(q) == [] && Q.size(q) == 0) - assert(Q.toArray(\"++"(q, 1)) == [1] && Q.size(q) == 1) - assert(Q.toArray(\"++"(q, 2)) == [1, 2] && Q.size(q) == 2) - assert(Q.toArray(\"++"(q, 3)) == [1, 2, 3] && Q.size(q) == 3) - assert(Q.toArray(\"++"(q, 4)) == [1, 2, 3, 4] && Q.size(q) == 4) - assert(Q.popExn(q) == 1) - assert(Q.toArray(q) == [2, 3, 4] && Q.size(q) == 3) - assert(Q.popExn(q) == 2) - assert(Q.toArray(q) == [3, 4] && Q.size(q) == 2) - assert(Q.popExn(q) == 3) - assert(Q.toArray(q) == [4] && Q.size(q) == 1) - assert(Q.popExn(q) == 4) - assert(Q.toArray(q) == [] && Q.size(q) == 0) - assert(does_raise(Q.popExn, q)) -} - -let () = { - let q = Q.make() - assert(Q.popExn(\"++"(q, 1)) == 1) - assert(does_raise(Q.popExn, q)) - assert(Q.popExn(\"++"(q, 2)) == 2) - assert(does_raise(Q.popExn, q)) - assert(Q.size(q) == 0) -} - -let () = { - let q = Q.make() - assert(Q.peekExn(\"++"(q, 1)) == 1) - assert(Q.peekExn(\"++"(q, 2)) == 1) - assert(Q.peekExn(\"++"(q, 3)) == 1) - assert(Q.peekExn(q) == 1) - assert(Q.popExn(q) == 1) - assert(Q.peekExn(q) == 2) - assert(Q.popExn(q) == 2) - assert(Q.peekExn(q) == 3) - assert(Q.popExn(q) == 3) - assert(does_raise(Q.peekExn, q)) - assert(does_raise(Q.peekExn, q)) -} - -let () = { - let q = Q.make() - for i in 1 to 10 { - Q.add(q, i) - } - Q.clear(q) - assert(Q.size(q) == 0) - assert(does_raise(Q.popExn, q)) - assert(q == Q.make()) - Q.add(q, 42) - assert(Q.popExn(q) == 42) -} - -let () = { - let q1 = Q.make() - for i in 1 to 10 { - Q.add(q1, i) - } - let q2 = Q.copy(q1) - assert(Q.toArray(q1) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) - assert(Q.toArray(q2) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) - assert(Q.size(q1) == 10) - assert(Q.size(q2) == 10) - for i in 1 to 10 { - assert(Q.popExn(q1) == i) - } - for i in 1 to 10 { - assert(Q.popExn(q2) == i) - } -} - -let () = { - let q = Q.make() - assert(Q.isEmpty(q)) - for i in 1 to 10 { - Q.add(q, i) - assert(Q.size(q) == i) - assert(!Q.isEmpty(q)) - } - for i in 10 downto 1 { - assert(Q.size(q) == i) - assert(!Q.isEmpty(q)) - ignore((Q.popExn(q): int)) - } - assert(Q.size(q) == 0) - assert(Q.isEmpty(q)) -} - -let () = { - let q = Q.make() - for i in 1 to 10 { - Q.add(q, i) - } - let i = ref(1) - Q.forEach(q, j => { - assert(i.contents == j) - incr(i) - }) -} - -let () = { - let q1 = Q.make() and q2 = Q.make() - assert(Q.size(q1) == 0) - assert(Q.toArray(q1) == []) - assert(Q.size(q2) == 0) - assert(Q.toArray(q2) == []) - Q.transfer(q1, q2) - assert(Q.size(q1) == 0) - assert(Q.toArray(q1) == []) - assert(Q.size(q2) == 0) - assert(Q.toArray(q2) == []) -} - -let () = { - let q1 = Q.make() and q2 = Q.make() - for i in 1 to 4 { - Q.add(q1, i) - } - assert(Q.size(q1) == 4) - assert(Q.toArray(q1) == [1, 2, 3, 4]) - assert(Q.size(q2) == 0) - assert(Q.toArray(q2) == []) - Q.transfer(q1, q2) - assert(Q.size(q1) == 0) - assert(Q.toArray(q1) == []) - assert(Q.size(q2) == 4) - assert(Q.toArray(q2) == [1, 2, 3, 4]) -} - -let () = { - let q1 = Q.make() and q2 = Q.make() - for i in 5 to 8 { - Q.add(q2, i) - } - assert(Q.size(q1) == 0) - assert(Q.toArray(q1) == []) - assert(Q.size(q2) == 4) - assert(Q.toArray(q2) == [5, 6, 7, 8]) - Q.transfer(q1, q2) - assert(Q.size(q1) == 0) - assert(Q.toArray(q1) == []) - assert(Q.size(q2) == 4) - assert(Q.toArray(q2) == [5, 6, 7, 8]) -} - -let () = { - let q1 = Q.make() and q2 = Q.make() - for i in 1 to 4 { - Q.add(q1, i) - } - for i in 5 to 8 { - Q.add(q2, i) - } - assert(Q.size(q1) == 4) - assert(Q.toArray(q1) == [1, 2, 3, 4]) - assert(Q.size(q2) == 4) - assert(Q.toArray(q2) == [5, 6, 7, 8]) - Q.transfer(q1, q2) - assert(Q.size(q1) == 0) - assert(Q.toArray(q1) == []) - let v = [5, 6, 7, 8, 1, 2, 3, 4] - assert(Q.size(q2) == 8) - assert(Q.toArray(q2) == v) - - assert(Q.reduce(q2, 0, (x, y) => x - y) == Belt.Array.reduce(v, 0, (x, y) => x - y)) -} - -let () = Js.log("OK") - -let () = { - let q = Q.fromArray([1, 2, 3, 4]) - let q1 = Q.map(q, x => x - 1) - eq(__LOC__, Q.toArray(q1), [0, 1, 2, 3]) - b(__LOC__, Q.isEmpty(Q.fromArray([]))) - b(__LOC__, Q.isEmpty(Q.map(Q.fromArray([]), x => x + 1))) -} - -Mt.from_pair_suites(__MODULE__, suites.contents) diff --git a/jscomp/test/bs_set_bench.js b/jscomp/test/bs_set_bench.js deleted file mode 100644 index c522372a1ab..00000000000 --- a/jscomp/test/bs_set_bench.js +++ /dev/null @@ -1,61 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Belt_SetInt = require("../../lib/js/belt_SetInt.js"); - -function bench(param) { - var data; - console.time("bs_set_bench.res 6"); - for(var i = 0; i <= 1000000; ++i){ - data = Belt_SetInt.add(data, i); - } - console.timeEnd("bs_set_bench.res 6"); - console.time("bs_set_bench.res 11"); - for(var i$1 = 0; i$1 <= 1000000; ++i$1){ - if (!Belt_SetInt.has(data, i$1)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_set_bench.res", - 13, - 6 - ], - Error: new Error() - }; - } - - } - console.timeEnd("bs_set_bench.res 11"); - console.time("bs_set_bench.res 16"); - for(var i$2 = 0; i$2 <= 1000000; ++i$2){ - data = Belt_SetInt.remove(data, i$2); - } - console.timeEnd("bs_set_bench.res 16"); - if (Belt_SetInt.size(data) === 0) { - return ; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "bs_set_bench.res", - 21, - 2 - ], - Error: new Error() - }; -} - -console.time("bs_set_bench.res 24"); - -bench(); - -console.timeEnd("bs_set_bench.res 24"); - -var count = 1000000; - -var N; - -exports.count = count; -exports.N = N; -exports.bench = bench; -/* Not a pure module */ diff --git a/jscomp/test/bs_set_bench.res b/jscomp/test/bs_set_bench.res deleted file mode 100644 index 118dd79f10b..00000000000 --- a/jscomp/test/bs_set_bench.res +++ /dev/null @@ -1,24 +0,0 @@ -let count = 1_000_000 - -module N = Belt.Set.Int -let bench = () => { - let data = ref(N.empty) - %time( - for i in 0 to count { - data := N.add(data.contents, i) - } - ) - %time( - for i in 0 to count { - assert(N.has(data.contents, i)) - } - ) - %time( - for i in 0 to count { - data := N.remove(data.contents, i) - } - ) - assert (N.size(data.contents) == 0) -} - -%time(bench()) diff --git a/jscomp/test/bs_set_int_test.js b/jscomp/test/bs_set_int_test.js deleted file mode 100644 index 77c7589ca00..00000000000 --- a/jscomp/test/bs_set_int_test.js +++ /dev/null @@ -1,397 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var List = require("../../lib/js/list.js"); -var $$Array = require("../../lib/js/array.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); -var Belt_SetInt = require("../../lib/js/belt_SetInt.js"); -var Array_data_util = require("./array_data_util.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, v) { - Mt.bool_suites(test_id, suites, loc, v); -} - -function $eq$tilde(s, i) { - return Belt_SetInt.eq(Belt_SetInt.fromArray(i), s); -} - -function $eq$star(a, b) { - return Belt_SetInt.eq(Belt_SetInt.fromArray(a), Belt_SetInt.fromArray(b)); -} - -b("File \"bs_set_int_test.res\", line 21, characters 11-18", $eq$star([ - 1, - 2, - 3 - ], [ - 3, - 2, - 1 - ])); - -var u = Belt_SetInt.intersect(Belt_SetInt.fromArray([ - 1, - 2, - 3 - ]), Belt_SetInt.fromArray([ - 3, - 4, - 5 - ])); - -b("File \"bs_set_int_test.res\", line 27, characters 11-18", Belt_SetInt.eq(Belt_SetInt.fromArray([3]), u)); - -function range(i, j) { - return $$Array.init((j - i | 0) + 1 | 0, (function (k) { - return k + i | 0; - })); -} - -function revRange(i, j) { - return $$Array.of_list(List.rev($$Array.to_list($$Array.init((j - i | 0) + 1 | 0, (function (k) { - return k + i | 0; - }))))); -} - -var v = Belt_SetInt.fromArray($$Array.append(range(100, 1000), revRange(400, 1500))); - -var i = range(100, 1500); - -b("File \"bs_set_int_test.res\", line 37, characters 4-11", Belt_SetInt.eq(Belt_SetInt.fromArray(i), v)); - -var match = Belt_SetInt.partition(v, (function (x) { - return x % 3 === 0; - })); - -var l; - -var r; - -for(var i$1 = 100; i$1 <= 1500; ++i$1){ - if (i$1 % 3 === 0) { - l = Belt_SetInt.add(l, i$1); - } else { - r = Belt_SetInt.add(r, i$1); - } -} - -var nl = l; - -var nr = r; - -b("File \"bs_set_int_test.res\", line 50, characters 4-11", Belt_SetInt.eq(match[0], nl)); - -b("File \"bs_set_int_test.res\", line 51, characters 4-11", Belt_SetInt.eq(match[1], nr)); - -var i$2 = range(50, 100); - -var s = Belt_SetInt.intersect(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))); - -b("File \"bs_set_int_test.res\", line 55, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$2), s)); - -var i$3 = range(1, 200); - -var s$1 = Belt_SetInt.union(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))); - -b("File \"bs_set_int_test.res\", line 66, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$3), s$1)); - -var i$4 = range(1, 49); - -var s$2 = Belt_SetInt.diff(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))); - -b("File \"bs_set_int_test.res\", line 77, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$4), s$2)); - -var i$5 = revRange(50, 100); - -var s$3 = Belt_SetInt.intersect(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))); - -b("File \"bs_set_int_test.res\", line 88, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$5), s$3)); - -var i$6 = revRange(1, 200); - -var s$4 = Belt_SetInt.union(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))); - -b("File \"bs_set_int_test.res\", line 99, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$6), s$4)); - -var i$7 = revRange(1, 49); - -var s$5 = Belt_SetInt.diff(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))); - -b("File \"bs_set_int_test.res\", line 110, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$7), s$5)); - -var ss = [ - 1, - 222, - 3, - 4, - 2, - 0, - 33, - -1 -]; - -var v$1 = Belt_SetInt.fromArray([ - 1, - 222, - 3, - 4, - 2, - 0, - 33, - -1 - ]); - -var minv = Belt_SetInt.minUndefined(v$1); - -var maxv = Belt_SetInt.maxUndefined(v$1); - -function approx(loc, x, y) { - b(loc, x === y); -} - -eq("File \"bs_set_int_test.res\", line 125, characters 5-12", Belt_SetInt.reduce(v$1, 0, (function (x, y) { - return x + y | 0; - })), Belt_Array.reduce(ss, 0, (function (prim0, prim1) { - return prim0 + prim1 | 0; - }))); - -approx("File \"bs_set_int_test.res\", line 126, characters 9-16", -1, minv); - -approx("File \"bs_set_int_test.res\", line 127, characters 9-16", 222, maxv); - -var v$2 = Belt_SetInt.remove(v$1, 3); - -var minv$1 = Belt_SetInt.minimum(v$2); - -var maxv$1 = Belt_SetInt.maximum(v$2); - -eq("File \"bs_set_int_test.res\", line 130, characters 5-12", minv$1, -1); - -eq("File \"bs_set_int_test.res\", line 131, characters 5-12", maxv$1, 222); - -var v$3 = Belt_SetInt.remove(v$2, 222); - -var minv$2 = Belt_SetInt.minimum(v$3); - -var maxv$2 = Belt_SetInt.maximum(v$3); - -eq("File \"bs_set_int_test.res\", line 134, characters 5-12", minv$2, -1); - -eq("File \"bs_set_int_test.res\", line 135, characters 5-12", maxv$2, 33); - -var v$4 = Belt_SetInt.remove(v$3, -1); - -var minv$3 = Belt_SetInt.minimum(v$4); - -var maxv$3 = Belt_SetInt.maximum(v$4); - -eq("File \"bs_set_int_test.res\", line 138, characters 5-12", minv$3, 0); - -eq("File \"bs_set_int_test.res\", line 139, characters 5-12", maxv$3, 33); - -var v$5 = Belt_SetInt.remove(v$4, 0); - -var v$6 = Belt_SetInt.remove(v$5, 33); - -var v$7 = Belt_SetInt.remove(v$6, 2); - -var v$8 = Belt_SetInt.remove(v$7, 3); - -var v$9 = Belt_SetInt.remove(v$8, 4); - -var v$10 = Belt_SetInt.remove(v$9, 1); - -b("File \"bs_set_int_test.res\", line 146, characters 4-11", Belt_SetInt.isEmpty(v$10)); - -var v$11 = Belt_Array.makeByAndShuffle(1000000, (function (i) { - return i; - })); - -var u$1 = Belt_SetInt.fromArray(v$11); - -Belt_SetInt.checkInvariantInternal(u$1); - -var firstHalf = Belt_Array.slice(v$11, 0, 2000); - -var xx = Belt_Array.reduce(firstHalf, u$1, Belt_SetInt.remove); - -Belt_SetInt.checkInvariantInternal(u$1); - -b("File \"bs_set_int_test.res\", line 158, characters 4-11", Belt_SetInt.eq(Belt_SetInt.union(Belt_SetInt.fromArray(firstHalf), xx), u$1)); - -var aa = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)); - -var bb = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 200)); - -var cc = Belt_SetInt.fromArray(Array_data_util.randomRange(120, 200)); - -var dd = Belt_SetInt.union(aa, cc); - -b("File \"bs_set_int_test.res\", line 171, characters 4-11", Belt_SetInt.subset(aa, bb)); - -b("File \"bs_set_int_test.res\", line 172, characters 4-11", Belt_SetInt.subset(dd, bb)); - -b("File \"bs_set_int_test.res\", line 173, characters 4-11", Belt_SetInt.subset(Belt_SetInt.add(dd, 200), bb)); - -b("File \"bs_set_int_test.res\", line 174, characters 4-11", Belt_SetInt.add(dd, 200) === dd); - -b("File \"bs_set_int_test.res\", line 175, characters 4-11", Belt_SetInt.add(dd, 0) === dd); - -b("File \"bs_set_int_test.res\", line 176, characters 4-11", !Belt_SetInt.subset(Belt_SetInt.add(dd, 201), bb)); - -var aa$1 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)); - -var bb$1 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)); - -var cc$1 = Belt_SetInt.add(bb$1, 101); - -var dd$1 = Belt_SetInt.remove(bb$1, 99); - -var ee = Belt_SetInt.add(dd$1, 101); - -b("File \"bs_set_int_test.res\", line 185, characters 4-11", Belt_SetInt.eq(aa$1, bb$1)); - -b("File \"bs_set_int_test.res\", line 186, characters 4-11", !Belt_SetInt.eq(aa$1, cc$1)); - -b("File \"bs_set_int_test.res\", line 187, characters 4-11", !Belt_SetInt.eq(dd$1, cc$1)); - -b("File \"bs_set_int_test.res\", line 188, characters 4-11", !Belt_SetInt.eq(bb$1, ee)); - -var a1 = Belt_SetInt.mergeMany(undefined, Array_data_util.randomRange(0, 100)); - -var a2 = Belt_SetInt.removeMany(a1, Array_data_util.randomRange(40, 100)); - -var a3 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 39)); - -var match$1 = Belt_SetInt.split(a1, 40); - -var match$2 = match$1[0]; - -var a5 = match$2[1]; - -var a4 = match$2[0]; - -b("File \"bs_set_int_test.res\", line 197, characters 4-11", Belt_SetInt.eq(a1, Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)))); - -b("File \"bs_set_int_test.res\", line 198, characters 4-11", Belt_SetInt.eq(a2, a3)); - -b("File \"bs_set_int_test.res\", line 199, characters 4-11", match$1[1]); - -b("File \"bs_set_int_test.res\", line 200, characters 4-11", Belt_SetInt.eq(a3, a4)); - -var a6 = Belt_SetInt.remove(Belt_SetInt.removeMany(a1, Array_data_util.randomRange(0, 39)), 40); - -b("File \"bs_set_int_test.res\", line 202, characters 4-11", Belt_SetInt.eq(a5, a6)); - -var a7 = Belt_SetInt.remove(a1, 40); - -var match$3 = Belt_SetInt.split(a7, 40); - -var match$4 = match$3[0]; - -var a9 = match$4[1]; - -b("File \"bs_set_int_test.res\", line 205, characters 4-11", !match$3[1]); - -b("File \"bs_set_int_test.res\", line 206, characters 4-11", Belt_SetInt.eq(a4, match$4[0])); - -b("File \"bs_set_int_test.res\", line 207, characters 4-11", Belt_SetInt.eq(a5, a9)); - -var a10 = Belt_SetInt.removeMany(a9, Array_data_util.randomRange(42, 2000)); - -eq("File \"bs_set_int_test.res\", line 209, characters 5-12", Belt_SetInt.size(a10), 1); - -var a11 = Belt_SetInt.removeMany(a9, Array_data_util.randomRange(0, 2000)); - -b("File \"bs_set_int_test.res\", line 211, characters 4-11", Belt_SetInt.isEmpty(a11)); - -var match$5 = Belt_SetInt.split(undefined, 0); - -var match$6 = match$5[0]; - -b("File \"bs_set_int_test.res\", line 216, characters 4-11", Belt_SetInt.isEmpty(match$6[0])); - -b("File \"bs_set_int_test.res\", line 217, characters 4-11", Belt_SetInt.isEmpty(match$6[1])); - -b("File \"bs_set_int_test.res\", line 218, characters 4-11", !match$5[1]); - -var v$12 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 2000)); - -var v0 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 2000)); - -var v1 = Belt_SetInt.fromArray(Array_data_util.randomRange(1, 2001)); - -var v2 = Belt_SetInt.fromArray(Array_data_util.randomRange(3, 2002)); - -var v3 = Belt_SetInt.removeMany(v2, [ - 2002, - 2001 - ]); - -var us = Belt_Array.map(Array_data_util.randomRange(1000, 3000), (function (x) { - return Belt_SetInt.has(v$12, x); - })); - -var counted = Belt_Array.reduce(us, 0, (function (acc, x) { - if (x) { - return acc + 1 | 0; - } else { - return acc; - } - })); - -eq("File \"bs_set_int_test.res\", line 235, characters 5-12", counted, 1001); - -b("File \"bs_set_int_test.res\", line 236, characters 4-11", Belt_SetInt.eq(v$12, v0)); - -b("File \"bs_set_int_test.res\", line 237, characters 4-11", Belt_SetInt.cmp(v$12, v0) === 0); - -b("File \"bs_set_int_test.res\", line 238, characters 4-11", Belt_SetInt.cmp(v$12, v1) < 0); - -b("File \"bs_set_int_test.res\", line 239, characters 4-11", Belt_SetInt.cmp(v$12, v2) > 0); - -b("File \"bs_set_int_test.res\", line 240, characters 4-11", Belt_SetInt.subset(v3, v0)); - -b("File \"bs_set_int_test.res\", line 241, characters 4-11", !Belt_SetInt.subset(v1, v0)); - -eq("File \"bs_set_int_test.res\", line 242, characters 5-12", Belt_SetInt.get(v$12, 30), 30); - -eq("File \"bs_set_int_test.res\", line 243, characters 5-12", Belt_SetInt.get(v$12, 3000), undefined); - -Mt.from_pair_suites("Bs_set_int_test", suites.contents); - -var N; - -var I; - -var A; - -var ofA = Belt_SetInt.fromArray; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.N = N; -exports.I = I; -exports.A = A; -exports.$eq$tilde = $eq$tilde; -exports.$eq$star = $eq$star; -exports.ofA = ofA; -exports.u = u; -exports.range = range; -exports.revRange = revRange; -/* Not a pure module */ diff --git a/jscomp/test/bs_set_int_test.res b/jscomp/test/bs_set_int_test.res deleted file mode 100644 index 31f009650b2..00000000000 --- a/jscomp/test/bs_set_int_test.res +++ /dev/null @@ -1,245 +0,0 @@ -@@warning("-44") -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => Mt.eq_suites(~suites, ~test_id, loc, x, y) - -let b = (loc, v) => Mt.bool_suites(~suites, ~test_id, loc, v) - -module N = Belt.Set.Int -module I = Array_data_util -module A = Belt.Array -let \"=~" = (s, i) => { - open N - eq(fromArray(i), s) -} -let \"=*" = (a, b) => { - open N - eq(fromArray(a), fromArray(b)) -} -let ofA = N.fromArray - -let () = b(__LOC__, \"=*"([1, 2, 3], [3, 2, 1])) -let u = { - open N - intersect(ofA([1, 2, 3]), ofA([3, 4, 5])) -} - -let () = b(__LOC__, \"=~"(u, [3])) - -/* inclusive */ -let range = (i, j) => Array.init(j - i + 1, k => k + i) - -let revRange = (i, j) => - Array.init(j - i + 1, k => k + i) |> Array.to_list |> List.rev |> Array.of_list - -let () = { - let v = ofA(Array.append(range(100, 1000), revRange(400, 1500))) - b(__LOC__, \"=~"(v, range(100, 1500))) - let (l, r) = N.partition(v, x => mod(x, 3) == 0) - let (nl, nr) = { - let (l, r) = (ref(N.empty), ref(N.empty)) - for i in 100 to 1500 { - if mod(i, 3) == 0 { - l := N.add(l.contents, i) - } else { - r := N.add(r.contents, i) - } - } - (l.contents, r.contents) - } - b(__LOC__, N.eq(l, nl)) - b(__LOC__, N.eq(r, nr)) -} - -let () = b( - __LOC__, - \"=~"( - { - open N - intersect(ofA(range(1, 100)), ofA(range(50, 200))) - }, - range(50, 100), - ), -) - -let () = b( - __LOC__, - \"=~"( - { - open N - union(ofA(range(1, 100)), ofA(range(50, 200))) - }, - range(1, 200), - ), -) - -let () = b( - __LOC__, - \"=~"( - { - open N - diff(ofA(range(1, 100)), ofA(range(50, 200))) - }, - range(1, 49), - ), -) - -let () = b( - __LOC__, - \"=~"( - { - open N - intersect(ofA(revRange(1, 100)), ofA(revRange(50, 200))) - }, - revRange(50, 100), - ), -) - -let () = b( - __LOC__, - \"=~"( - { - open N - union(ofA(revRange(1, 100)), ofA(revRange(50, 200))) - }, - revRange(1, 200), - ), -) - -let () = b( - __LOC__, - \"=~"( - { - open N - diff(ofA(revRange(1, 100)), ofA(revRange(50, 200))) - }, - revRange(1, 49), - ), -) - -let () = { - let ss = [1, 222, 3, 4, 2, 0, 33, -1] - let v = ofA([1, 222, 3, 4, 2, 0, 33, -1]) - let (minv, maxv) = (N.minUndefined(v), N.maxUndefined(v)) - let approx = (loc, x: int, y) => b(loc, Js.eqUndefined(x, y)) - eq(__LOC__, N.reduce(v, 0, (x, y) => x + y), A.reduce(ss, 0, \"+")) - approx(__LOC__, -1, minv) - approx(__LOC__, 222, maxv) - let v = N.remove(v, 3) - let (minv, maxv) = (N.minimum(v), N.maximum(v)) - eq(__LOC__, minv, Some(-1)) - eq(__LOC__, maxv, Some(222)) - let v = N.remove(v, 222) - let (minv, maxv) = (N.minimum(v), N.maximum(v)) - eq(__LOC__, minv, Some(-1)) - eq(__LOC__, maxv, Some(33)) - let v = N.remove(v, -1) - let (minv, maxv) = (N.minimum(v), N.maximum(v)) - eq(__LOC__, minv, Some(0)) - eq(__LOC__, maxv, Some(33)) - let v = N.remove(v, 0) - let v = N.remove(v, 33) - let v = N.remove(v, 2) - let v = N.remove(v, 3) - let v = N.remove(v, 4) - let v = N.remove(v, 1) - b(__LOC__, N.isEmpty(v)) -} - -let () = { - let count = 1_000_000 - let v = A.makeByAndShuffle(count, i => i) - let u = N.fromArray(v) - N.checkInvariantInternal(u) - let firstHalf = A.slice(v, ~offset=0, ~len=2_000) - let xx = Belt.Array.reduce(firstHalf, u, N.remove) - N.checkInvariantInternal(u) - b( - __LOC__, - { - open N - eq(union(fromArray(firstHalf), xx), u) - }, - ) -} - -let () = { - let aa = N.fromArray(I.randomRange(0, 100)) - let bb = N.fromArray(I.randomRange(0, 200)) - let cc = N.fromArray(I.randomRange(120, 200)) - let dd = N.union(aa, cc) - b(__LOC__, N.subset(aa, bb)) - b(__LOC__, N.subset(dd, bb)) - b(__LOC__, N.subset(N.add(dd, 200), bb)) - b(__LOC__, N.add(dd, 200) === dd) - b(__LOC__, N.add(dd, 0) === dd) - b(__LOC__, !N.subset(N.add(dd, 201), bb)) -} - -let () = { - let aa = N.fromArray(I.randomRange(0, 100)) - let bb = N.fromArray(I.randomRange(0, 100)) - let cc = N.add(bb, 101) - let dd = N.remove(bb, 99) - let ee = N.add(dd, 101) - b(__LOC__, N.eq(aa, bb)) - b(__LOC__, !N.eq(aa, cc)) - b(__LOC__, !N.eq(dd, cc)) - b(__LOC__, !N.eq(bb, ee)) -} - -let () = { - let a0 = N.empty - let a1 = N.mergeMany(a0, I.randomRange(0, 100)) - let a2 = N.removeMany(a1, I.randomRange(40, 100)) - let a3 = N.fromArray(I.randomRange(0, 39)) - let ((a4, a5), pres) = N.split(a1, 40) - b(__LOC__, N.eq(a1, N.fromArray(I.randomRange(0, 100)))) - b(__LOC__, N.eq(a2, a3)) - b(__LOC__, pres) - b(__LOC__, N.eq(a3, a4)) - let a6 = N.remove(N.removeMany(a1, I.randomRange(0, 39)), 40) - b(__LOC__, N.eq(a5, a6)) - let a7 = N.remove(a1, 40) - let ((a8, a9), pres2) = N.split(a7, 40) - b(__LOC__, !pres2) - b(__LOC__, N.eq(a4, a8)) - b(__LOC__, N.eq(a5, a9)) - let a10 = N.removeMany(a9, I.randomRange(42, 2000)) - eq(__LOC__, N.size(a10), 1) - let a11 = N.removeMany(a9, I.randomRange(0, 2000)) - b(__LOC__, N.isEmpty(a11)) -} - -let () = { - let ((aa, bb), pres) = N.split(N.empty, 0) - b(__LOC__, N.isEmpty(aa)) - b(__LOC__, N.isEmpty(bb)) - b(__LOC__, !pres) -} - -let () = { - let v = N.fromArray(I.randomRange(0, 2_000)) - let v0 = N.fromArray(I.randomRange(0, 2_000)) - let v1 = N.fromArray(I.randomRange(1, 2_001)) - let v2 = N.fromArray(I.randomRange(3, 2_002)) - let v3 = N.removeMany(v2, [2_002, 2_001]) - let us = A.map(I.randomRange(1_000, 3_000), x => N.has(v, x)) - let counted = A.reduce(us, 0, (acc, x) => - if x { - acc + 1 - } else { - acc - } - ) - eq(__LOC__, counted, 1_001) - b(__LOC__, N.eq(v, v0)) - b(__LOC__, N.cmp(v, v0) == 0) - b(__LOC__, N.cmp(v, v1) < 0) - b(__LOC__, N.cmp(v, v2) > 0) - b(__LOC__, N.subset(v3, v0)) - b(__LOC__, !N.subset(v1, v0)) - eq(__LOC__, N.get(v, 30), Some(30)) - eq(__LOC__, N.get(v, 3_000), None) -} -Mt.from_pair_suites(__MODULE__, suites.contents) diff --git a/jscomp/test/bs_sort_test.js b/jscomp/test/bs_sort_test.js deleted file mode 100644 index 1ee8bbce68d..00000000000 --- a/jscomp/test/bs_sort_test.js +++ /dev/null @@ -1,439 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Caml = require("../../lib/js/caml.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); -var Belt_Range = require("../../lib/js/belt_Range.js"); -var Belt_SortArray = require("../../lib/js/belt_SortArray.js"); -var Array_data_util = require("./array_data_util.js"); -var Belt_SortArrayInt = require("../../lib/js/belt_SortArrayInt.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, x) { - Mt.bool_suites(test_id, suites, loc, x); -} - -function cmp(x, y) { - return x - y | 0; -} - -function unions(xs, ys) { - var lenX = xs.length; - var lenY = ys.length; - var o = new Array(lenX + lenY | 0); - var v = Belt_SortArray.union(xs, 0, lenX, ys, 0, lenY, o, 0, cmp); - o.length = v; - return o; -} - -function inters(xs, ys) { - var lenX = xs.length; - var lenY = ys.length; - var o = new Array(lenX); - var v = Belt_SortArray.intersect(xs, 0, lenX, ys, 0, lenY, o, 0, cmp); - o.length = v; - return o; -} - -function diffs(xs, ys) { - var lenX = xs.length; - var lenY = ys.length; - var o = new Array(lenX); - var v = Belt_SortArray.diff(xs, 0, lenX, ys, 0, lenY, o, 0, cmp); - o.length = v; - return o; -} - -eq("File \"bs_sort_test.res\", line 35, characters 5-12", unions(Array_data_util.range(1, 10), Array_data_util.range(3, 13)), Array_data_util.range(1, 13)); - -eq("File \"bs_sort_test.res\", line 36, characters 5-12", unions(Array_data_util.range(1, 10), Array_data_util.range(9, 13)), Array_data_util.range(1, 13)); - -eq("File \"bs_sort_test.res\", line 37, characters 5-12", unions(Array_data_util.range(8, 10), Array_data_util.range(9, 13)), Array_data_util.range(8, 13)); - -eq("File \"bs_sort_test.res\", line 38, characters 5-12", unions(Array_data_util.range(0, 2), Array_data_util.range(4, 7)), [ - 0, - 1, - 2, - 4, - 5, - 6, - 7 - ]); - -eq("File \"bs_sort_test.res\", line 42, characters 5-12", inters(Array_data_util.range(1, 10), Array_data_util.range(3, 13)), Array_data_util.range(3, 10)); - -eq("File \"bs_sort_test.res\", line 43, characters 5-12", inters(Array_data_util.range(1, 10), Array_data_util.range(9, 13)), Array_data_util.range(9, 10)); - -eq("File \"bs_sort_test.res\", line 44, characters 5-12", inters(Array_data_util.range(8, 10), Array_data_util.range(9, 13)), Array_data_util.range(9, 10)); - -eq("File \"bs_sort_test.res\", line 45, characters 5-12", inters(Array_data_util.range(0, 2), Array_data_util.range(4, 7)), []); - -eq("File \"bs_sort_test.res\", line 49, characters 5-12", diffs(Array_data_util.range(1, 10), Array_data_util.range(3, 13)), Array_data_util.range(1, 2)); - -eq("File \"bs_sort_test.res\", line 50, characters 5-12", diffs(Array_data_util.range(1, 10), Array_data_util.range(9, 13)), Array_data_util.range(1, 8)); - -eq("File \"bs_sort_test.res\", line 51, characters 5-12", diffs(Array_data_util.range(8, 10), Array_data_util.range(9, 13)), Array_data_util.range(8, 8)); - -eq("File \"bs_sort_test.res\", line 52, characters 5-12", diffs(Array_data_util.range(0, 2), Array_data_util.range(4, 7)), [ - 0, - 1, - 2 - ]); - -b("File \"bs_sort_test.res\", line 56, characters 4-11", Belt_Range.every(0, 200, (function (i) { - var v = Array_data_util.randomRange(0, i); - Belt_SortArray.stableSortInPlaceBy(v, cmp); - return Belt_SortArray.isSorted(v, cmp); - }))); - -b("File \"bs_sort_test.res\", line 64, characters 4-11", Belt_Range.every(0, 200, (function (i) { - var v = Array_data_util.randomRange(0, i); - Belt_SortArray.stableSortInPlaceBy(v, cmp); - return Belt_SortArray.isSorted(v, cmp); - }))); - -b("File \"bs_sort_test.res\", line 71, characters 4-11", Belt_SortArray.isSorted([], cmp)); - -b("File \"bs_sort_test.res\", line 73, characters 4-11", Belt_SortArray.isSorted([0], cmp)); - -b("File \"bs_sort_test.res\", line 75, characters 4-11", Belt_SortArray.isSorted([ - 0, - 1 - ], cmp)); - -b("File \"bs_sort_test.res\", line 76, characters 4-11", !Belt_SortArray.isSorted([ - 1, - 0 - ], cmp)); - -var u = Array_data_util.randomRange(0, 1000000); - -var u1 = u.slice(0); - -var u2 = u.slice(0); - -console.time("bs_sort_test.res 85"); - -Belt_SortArray.stableSortInPlaceBy(u, cmp); - -console.timeEnd("bs_sort_test.res 85"); - -b("File \"bs_sort_test.res\", line 86, characters 4-11", Belt_SortArray.isSorted(u, cmp)); - -console.time("bs_sort_test.res 87"); - -Belt_SortArrayInt.stableSortInPlace(u2); - -console.timeEnd("bs_sort_test.res 87"); - -b("File \"bs_sort_test.res\", line 88, characters 4-11", Belt_SortArray.isSorted(u2, cmp)); - -console.time("bs_sort_test.res 89"); - -Belt_SortArray.stableSortInPlaceBy(u1, cmp); - -console.timeEnd("bs_sort_test.res 89"); - -b("File \"bs_sort_test.res\", line 90, characters 4-11", Belt_SortArray.isSorted(u1, cmp)); - -var u$1 = [ - [ - 1, - "a" - ], - [ - 1, - "b" - ], - [ - 2, - "a" - ] -]; - -eq("File \"bs_sort_test.res\", line 95, characters 5-12", Belt_SortArray.stableSortBy(u$1, (function (param, param$1) { - return param[0] - param$1[0] | 0; - })), [ - [ - 1, - "a" - ], - [ - 1, - "b" - ], - [ - 2, - "a" - ] - ]); - -var u$2 = [ - [ - 1, - "b" - ], - [ - 1, - "a" - ], - [ - 1, - "b" - ], - [ - 2, - "a" - ] -]; - -eq("File \"bs_sort_test.res\", line 98, characters 4-11", Belt_SortArray.stableSortBy(u$2, (function (param, param$1) { - return param[0] - param$1[0] | 0; - })), [ - [ - 1, - "b" - ], - [ - 1, - "a" - ], - [ - 1, - "b" - ], - [ - 2, - "a" - ] - ]); - -var u$3 = [ - [ - 1, - "c" - ], - [ - 1, - "b" - ], - [ - 1, - "a" - ], - [ - 1, - "b" - ], - [ - 1, - "c" - ], - [ - 2, - "a" - ] -]; - -eq("File \"bs_sort_test.res\", line 104, characters 4-11", Belt_SortArray.stableSortBy(u$3, (function (param, param$1) { - return param[0] - param$1[0] | 0; - })), [ - [ - 1, - "c" - ], - [ - 1, - "b" - ], - [ - 1, - "a" - ], - [ - 1, - "b" - ], - [ - 1, - "c" - ], - [ - 2, - "a" - ] - ]); - -eq("File \"bs_sort_test.res\", line 111, characters 5-12", Belt_SortArray.binarySearchBy([ - 1, - 3, - 5, - 7 - ], 4, Caml.int_compare) ^ -1, 2); - -eq("File \"bs_sort_test.res\", line 112, characters 5-12", Belt_SortArray.binarySearchBy([ - 1, - 2, - 3, - 4, - 33, - 35, - 36 - ], 33, cmp), 4); - -eq("File \"bs_sort_test.res\", line 113, characters 5-12", Belt_SortArray.binarySearchBy([ - 1, - 2, - 3, - 4, - 33, - 35, - 36 - ], 1, cmp), 0); - -eq("File \"bs_sort_test.res\", line 114, characters 5-12", Belt_SortArray.binarySearchBy([ - 1, - 2, - 3, - 4, - 33, - 35, - 36 - ], 2, cmp), 1); - -eq("File \"bs_sort_test.res\", line 115, characters 5-12", Belt_SortArray.binarySearchBy([ - 1, - 2, - 3, - 4, - 33, - 35, - 36 - ], 3, cmp), 2); - -eq("File \"bs_sort_test.res\", line 116, characters 5-12", Belt_SortArray.binarySearchBy([ - 1, - 2, - 3, - 4, - 33, - 35, - 36 - ], 4, cmp), 3); - -var aa = Array_data_util.range(0, 1000); - -b("File \"bs_sort_test.res\", line 118, characters 10-17", Belt_Range.every(0, 1000, (function (i) { - return Belt_SortArray.binarySearchBy(aa, i, cmp) === i; - }))); - -var cc = Belt_Array.map(Array_data_util.range(0, 2000), (function (x) { - return (x << 1); - })); - -eq("File \"bs_sort_test.res\", line 121, characters 5-12", Belt_SortArray.binarySearchBy(cc, 5000, cmp) ^ -1, 2001); - -eq("File \"bs_sort_test.res\", line 122, characters 5-12", Belt_SortArray.binarySearchBy(cc, -1, cmp) ^ -1, 0); - -eq("File \"bs_sort_test.res\", line 123, characters 5-12", Belt_SortArray.binarySearchBy(cc, 0, cmp), 0); - -eq("File \"bs_sort_test.res\", line 125, characters 5-12", Belt_SortArray.binarySearchBy(cc, 1, cmp) ^ -1, 1); - -b("File \"bs_sort_test.res\", line 127, characters 6-13", Belt_Range.every(0, 1999, (function (i) { - return (Belt_SortArray.binarySearchBy(cc, (i << 1) + 1 | 0, cmp) ^ -1) === (i + 1 | 0); - }))); - -function lt(x, y) { - return x < y; -} - -eq("File \"bs_sort_test.res\", line 137, characters 5-12", Belt_SortArray.strictlySortedLength([], lt), 0); - -eq("File \"bs_sort_test.res\", line 138, characters 5-12", Belt_SortArray.strictlySortedLength([1], lt), 1); - -eq("File \"bs_sort_test.res\", line 139, characters 5-12", Belt_SortArray.strictlySortedLength([ - 1, - 1 - ], lt), 1); - -eq("File \"bs_sort_test.res\", line 140, characters 5-12", Belt_SortArray.strictlySortedLength([ - 1, - 1, - 2 - ], lt), 1); - -eq("File \"bs_sort_test.res\", line 141, characters 5-12", Belt_SortArray.strictlySortedLength([ - 1, - 2 - ], lt), 2); - -eq("File \"bs_sort_test.res\", line 142, characters 5-12", Belt_SortArray.strictlySortedLength([ - 1, - 2, - 3, - 4, - 3 - ], lt), 4); - -eq("File \"bs_sort_test.res\", line 143, characters 5-12", Belt_SortArray.strictlySortedLength([ - 4, - 4, - 3, - 2, - 1 - ], lt), 1); - -eq("File \"bs_sort_test.res\", line 144, characters 5-12", Belt_SortArray.strictlySortedLength([ - 4, - 3, - 2, - 1 - ], lt), -4); - -eq("File \"bs_sort_test.res\", line 145, characters 5-12", Belt_SortArray.strictlySortedLength([ - 4, - 3, - 2, - 1, - 0 - ], lt), -5); - -Mt.from_pair_suites("Bs_sort_test", suites.contents); - -var I; - -var S; - -var R; - -var A; - -var SI; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.I = I; -exports.S = S; -exports.R = R; -exports.cmp = cmp; -exports.A = A; -exports.unions = unions; -exports.inters = inters; -exports.diffs = diffs; -exports.SI = SI; -exports.lt = lt; -/* Not a pure module */ diff --git a/jscomp/test/bs_sort_test.res b/jscomp/test/bs_sort_test.res deleted file mode 100644 index 42b90594725..00000000000 --- a/jscomp/test/bs_sort_test.res +++ /dev/null @@ -1,148 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => Mt.eq_suites(~test_id, ~suites, loc, x, y) -let b = (loc, x) => Mt.bool_suites(~test_id, ~suites, loc, x) - -module I = Array_data_util -module S = Belt.SortArray -module R = Belt.Range -let cmp = (x, y) => x - y -module A = Belt.Array - -let unions = (xs, ys) => { - let (lenX, lenY) = (A.length(xs), A.length(ys)) - let o = A.makeUninitializedUnsafe(lenX + lenY) - let v = S.union(xs, 0, lenX, ys, 0, lenY, o, 0, cmp) - A.truncateToLengthUnsafe(o, v) - o -} -let inters = (xs, ys) => { - let (lenX, lenY) = (A.length(xs), A.length(ys)) - let o = A.makeUninitializedUnsafe(lenX) - let v = S.intersect(xs, 0, lenX, ys, 0, lenY, o, 0, cmp) - A.truncateToLengthUnsafe(o, v) - o -} -let diffs = (xs, ys) => { - let (lenX, lenY) = (A.length(xs), A.length(ys)) - let o = A.makeUninitializedUnsafe(lenX) - let v = S.diff(xs, 0, lenX, ys, 0, lenY, o, 0, cmp) - A.truncateToLengthUnsafe(o, v) - o -} - -let () = { - eq(__LOC__, unions(I.range(1, 10), I.range(3, 13)), I.range(1, 13)) - eq(__LOC__, unions(I.range(1, 10), I.range(9, 13)), I.range(1, 13)) - eq(__LOC__, unions(I.range(8, 10), I.range(9, 13)), I.range(8, 13)) - eq(__LOC__, unions(I.range(0, 2), I.range(4, 7)), [0, 1, 2, 4, 5, 6, 7]) -} - -let () = { - eq(__LOC__, inters(I.range(1, 10), I.range(3, 13)), I.range(3, 10)) - eq(__LOC__, inters(I.range(1, 10), I.range(9, 13)), I.range(9, 10)) - eq(__LOC__, inters(I.range(8, 10), I.range(9, 13)), I.range(9, 10)) - eq(__LOC__, inters(I.range(0, 2), I.range(4, 7)), []) -} - -let () = { - eq(__LOC__, diffs(I.range(1, 10), I.range(3, 13)), I.range(1, 2)) - eq(__LOC__, diffs(I.range(1, 10), I.range(9, 13)), I.range(1, 8)) - eq(__LOC__, diffs(I.range(8, 10), I.range(9, 13)), I.range(8, 8)) - eq(__LOC__, diffs(I.range(0, 2), I.range(4, 7)), [0, 1, 2]) -} -let () = { - b( - __LOC__, - R.every(0, 200, i => { - let v = I.randomRange(0, i) - S.stableSortInPlaceBy(v, cmp) - S.isSorted(v, cmp) - }), - ) - b( - __LOC__, - R.every(0, 200, i => { - let v = I.randomRange(0, i) - S.stableSortInPlaceBy(v, cmp) - S.isSorted(v, cmp) - }), - ) - b(__LOC__, S.isSorted([], cmp)) - - b(__LOC__, S.isSorted([0], cmp)) - - b(__LOC__, S.isSorted([0, 1], cmp)) - b(__LOC__, \"@@"(not, S.isSorted([1, 0], cmp))) -} - -module SI = Belt.SortArray.Int -let () = { - let u = I.randomRange(0, 1_000_000) - let u1 = A.copy(u) - let u2 = A.copy(u) - /* let u3 = A.map u (fun[@bs] x -> float x) in */ - %time(S.stableSortInPlaceBy(u, cmp)) - b(__LOC__, S.isSorted(u, cmp)) - %time(SI.stableSortInPlace(u2)) - b(__LOC__, S.isSorted(u2, cmp)) - %time(S.stableSortInPlaceBy(u1, cmp)) - b(__LOC__, S.isSorted(u1, cmp)) -} - -let () = { - let u = [(1, "a"), (1, "b"), (2, "a")] - eq(__LOC__, S.stableSortBy(u, ((a, _), (b, _)) => a - b), [(1, "a"), (1, "b"), (2, "a")]) - let u = [(1, "b"), (1, "a"), (1, "b"), (2, "a")] - eq( - __LOC__, - S.stableSortBy(u, ((a, _), (b, _)) => a - b), - [(1, "b"), (1, "a"), (1, "b"), (2, "a")], - ) - let u = [(1, "c"), (1, "b"), (1, "a"), (1, "b"), (1, "c"), (2, "a")] - eq( - __LOC__, - S.stableSortBy(u, ((a, _), (b, _)) => a - b), - [(1, "c"), (1, "b"), (1, "a"), (1, "b"), (1, "c"), (2, "a")], - ) -} - -let () = { - eq(__LOC__, lnot(S.binarySearchBy([1, 3, 5, 7], 4, compare)), 2) - eq(__LOC__, S.binarySearchBy([1, 2, 3, 4, 33, 35, 36], 33, cmp), 4) - eq(__LOC__, S.binarySearchBy([1, 2, 3, 4, 33, 35, 36], 1, cmp), 0) - eq(__LOC__, S.binarySearchBy([1, 2, 3, 4, 33, 35, 36], 2, cmp), 1) - eq(__LOC__, S.binarySearchBy([1, 2, 3, 4, 33, 35, 36], 3, cmp), 2) - eq(__LOC__, S.binarySearchBy([1, 2, 3, 4, 33, 35, 36], 4, cmp), 3) - let aa = I.range(0, 1000) - \"@@"(b(__LOC__), R.every(0, 1000, i => S.binarySearchBy(aa, i, cmp) == i)) - /* 0, 2, 4, ... 4000 */ - let cc = A.map(I.range(0, 2000), x => x * 2) - eq(__LOC__, lnot(S.binarySearchBy(cc, 5000, cmp)), 2001) - eq(__LOC__, lnot(S.binarySearchBy(cc, -1, cmp)), 0) - eq(__LOC__, S.binarySearchBy(cc, 0, cmp), 0) - - eq(__LOC__, lnot(S.binarySearchBy(cc, 1, cmp)), 1) - \"@@"( - b(__LOC__), - R.every(0, 1999, i => - lnot(S.binarySearchBy(cc, 2 * i + 1, cmp)) == i + 1 - /* 1, 3, 5, ... , 3999 */ - ), - ) -} - -let lt = (x: int, y) => x < y -let () = { - eq(__LOC__, S.strictlySortedLength([], lt), 0) - eq(__LOC__, S.strictlySortedLength([1], lt), 1) - eq(__LOC__, S.strictlySortedLength([1, 1], lt), 1) - eq(__LOC__, S.strictlySortedLength([1, 1, 2], lt), 1) - eq(__LOC__, S.strictlySortedLength([1, 2], lt), 2) - eq(__LOC__, S.strictlySortedLength([1, 2, 3, 4, 3], lt), 4) - eq(__LOC__, S.strictlySortedLength([4, 4, 3, 2, 1], lt), 1) - eq(__LOC__, S.strictlySortedLength([4, 3, 2, 1], lt), -4) - eq(__LOC__, S.strictlySortedLength([4, 3, 2, 1, 0], lt), -5) -} - -Mt.from_pair_suites(__MODULE__, suites.contents) diff --git a/jscomp/test/bs_stack_test.js b/jscomp/test/bs_stack_test.js deleted file mode 100644 index 1cde971cdfc..00000000000 --- a/jscomp/test/bs_stack_test.js +++ /dev/null @@ -1,163 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Caml_option = require("../../lib/js/caml_option.js"); -var Js_undefined = require("../../lib/js/js_undefined.js"); -var Belt_MutableQueue = require("../../lib/js/belt_MutableQueue.js"); -var Belt_MutableStack = require("../../lib/js/belt_MutableStack.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function inOrder(v) { - var current = v; - var s = { - root: undefined - }; - var q = { - length: 0, - first: undefined, - last: undefined - }; - while(current !== undefined) { - var v$1 = current; - Belt_MutableStack.push(s, v$1); - current = v$1.left; - }; - while(s.root !== undefined) { - current = Belt_MutableStack.popUndefined(s); - var v$2 = current; - Belt_MutableQueue.add(q, v$2.value); - current = v$2.right; - while(current !== undefined) { - var v$3 = current; - Belt_MutableStack.push(s, v$3); - current = v$3.left; - }; - }; - return Belt_MutableQueue.toArray(q); -} - -function inOrder3(v) { - var current = v; - var s = { - root: undefined - }; - var q = { - length: 0, - first: undefined, - last: undefined - }; - while(current !== undefined) { - var v$1 = current; - Belt_MutableStack.push(s, v$1); - current = v$1.left; - }; - Belt_MutableStack.dynamicPopIter(s, (function (popped) { - Belt_MutableQueue.add(q, popped.value); - var current = popped.right; - while(current !== undefined) { - var v = current; - Belt_MutableStack.push(s, v); - current = v.left; - }; - })); - return Belt_MutableQueue.toArray(q); -} - -function inOrder2(v) { - var todo = true; - var cursor = v; - var s = { - root: undefined - }; - var q = { - length: 0, - first: undefined, - last: undefined - }; - while(todo) { - if (cursor !== undefined) { - var v$1 = cursor; - Belt_MutableStack.push(s, v$1); - cursor = v$1.left; - } else if (s.root !== undefined) { - cursor = Belt_MutableStack.popUndefined(s); - var current = cursor; - Belt_MutableQueue.add(q, current.value); - cursor = current.right; - } else { - todo = false; - } - }; -} - -function n(l, r, a) { - return { - value: a, - left: Js_undefined.fromOption(l), - right: Js_undefined.fromOption(r) - }; -} - -var test1 = n(Caml_option.some(n(Caml_option.some(n(undefined, undefined, 4)), Caml_option.some(n(undefined, undefined, 5)), 2)), Caml_option.some(n(undefined, undefined, 3)), 1); - -function pushAllLeft(st1, s1) { - var current = st1; - while(current !== undefined) { - var v = current; - Belt_MutableStack.push(s1, v); - current = v.left; - }; -} - -var test2 = n(Caml_option.some(n(Caml_option.some(n(Caml_option.some(n(Caml_option.some(n(undefined, undefined, 4)), undefined, 2)), undefined, 5)), undefined, 1)), undefined, 3); - -var test3 = n(Caml_option.some(n(Caml_option.some(n(Caml_option.some(n(undefined, undefined, 4)), undefined, 2)), undefined, 5)), Caml_option.some(n(undefined, undefined, 3)), 1); - -eq("File \"bs_stack_test.res\", line 98, characters 3-10", inOrder(test1), [ - 4, - 2, - 5, - 1, - 3 - ]); - -eq("File \"bs_stack_test.res\", line 99, characters 3-10", inOrder3(test1), [ - 4, - 2, - 5, - 1, - 3 - ]); - -Mt.from_pair_suites("bs_stack_test.res", suites.contents); - -var S; - -var Q; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.S = S; -exports.Q = Q; -exports.inOrder = inOrder; -exports.inOrder3 = inOrder3; -exports.inOrder2 = inOrder2; -exports.n = n; -exports.test1 = test1; -exports.pushAllLeft = pushAllLeft; -exports.test2 = test2; -exports.test3 = test3; -/* test1 Not a pure module */ diff --git a/jscomp/test/bs_stack_test.res b/jscomp/test/bs_stack_test.res deleted file mode 100644 index 6f0b02cc9d9..00000000000 --- a/jscomp/test/bs_stack_test.res +++ /dev/null @@ -1,101 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => Mt.eq_suites(~test_id, ~suites, loc, x, y) - -type rec node = { - value: int, - left: t, - right: t, -} -@deriving(abstract) and t = Js.undefined - -module S = Belt.MutableStack -module Q = Belt.MutableQueue - -let inOrder = (v: t): array => { - let current = ref(v) - let s: S.t = S.make() - let q: Q.t = Q.make() - while current.contents !== Js.undefined { - let v = Js.Undefined.getUnsafe(current.contents) - S.push(s, v) - current := leftGet(v) - } - while !S.isEmpty(s) { - current := S.popUndefined(s) - let v = Js.Undefined.getUnsafe(current.contents) - Q.add(q, valueGet(v)) - current := rightGet(v) - while current.contents !== Js.undefined { - let v = Js.Undefined.getUnsafe(current.contents) - S.push(s, v) - current := leftGet(v) - } - } - Q.toArray(q) -} - -let inOrder3 = (v: t): array => { - let current = ref(v) - let s: S.t = S.make() - let q: Q.t = Q.make() - while current.contents !== Js.undefined { - let v = Js.Undefined.getUnsafe(current.contents) - S.push(s, v) - current := leftGet(v) - } - S.dynamicPopIter(s, popped => { - Q.add(q, valueGet(popped)) - let current = ref(rightGet(popped)) - while current.contents !== Js.undefined { - let v = Js.Undefined.getUnsafe(current.contents) - S.push(s, v) - current := leftGet(v) - } - }) - Q.toArray(q) -} - -let inOrder2 = (v: t) => { - let todo = ref(true) - let cursor = ref(v) - let s: S.t = S.make() - let q: Q.t = Q.make() - while todo.contents { - if cursor.contents !== Js.undefined { - let v = Js.Undefined.getUnsafe(cursor.contents) - S.push(s, v) - cursor := leftGet(v) - } else if !S.isEmpty(s) { - cursor := S.popUndefined(s) - let current = Js.Undefined.getUnsafe(cursor.contents) - Q.add(q, valueGet(current)) - cursor := rightGet(current) - } else { - todo := false - } - } -} - -let n = (~l=?, ~r=?, a) => - node(~value=a, ~left=Js.Undefined.fromOption(l), ~right=Js.Undefined.fromOption(r)) - -let test1 = n(1, ~l=n(2, ~l=n(4), ~r=n(5)), ~r=n(3)) - -let pushAllLeft = (st1, s1) => { - let current = ref(st1) - while current.contents !== Js.undefined { - let v = Js.Undefined.getUnsafe(current.contents) - S.push(s1, v) - current := leftGet(v) - } -} - -let test2 = n(3, ~l=n(1, ~l=n(5, ~l=n(2, ~l=n(4))))) - -let test3 = n(1, ~l=n(5, ~l=n(2, ~l=n(4))), ~r=n(3)) - -eq(__LOC__, inOrder(Js.Undefined.return(test1)), [4, 2, 5, 1, 3]) -eq(__LOC__, inOrder3(Js.Undefined.return(test1)), [4, 2, 5, 1, 3]) - -Mt.from_pair_suites(__FILE__, suites.contents) diff --git a/jscomp/test/build.ninja b/jscomp/test/build.ninja index b752adee5b3..6b30f2986dc 100644 --- a/jscomp/test/build.ninja +++ b/jscomp/test/build.ninja @@ -24,7 +24,6 @@ o test/Coercion.cmi test/Coercion.cmj : cc test/Coercion.res | $bsc $stdlib runt o test/DotDotDot.cmi test/DotDotDot.cmj : cc test/DotDotDot.res | $bsc $stdlib runtime o test/EmptyRecord.cmi test/EmptyRecord.cmj : cc test/EmptyRecord.res | $bsc $stdlib runtime o test/FFI.cmi test/FFI.cmj : cc test/FFI.res | $bsc $stdlib runtime -o test/Import.cmi test/Import.cmj : cc test/Import.res | $bsc $stdlib runtime o test/RecordCoercion.cmi test/RecordCoercion.cmj : cc test/RecordCoercion.res | $bsc $stdlib runtime o test/RecordOrObject.cmi test/RecordOrObject.cmj : cc test/RecordOrObject.res | $bsc $stdlib runtime o test/SafePromises.cmi test/SafePromises.cmj : cc test/SafePromises.res | $bsc $stdlib runtime @@ -57,7 +56,6 @@ o test/arith_syntax.cmi test/arith_syntax.cmj : cc test/arith_syntax.res | $bsc o test/arity.cmi test/arity.cmj : cc test/arity.res | $bsc $stdlib runtime o test/arity_deopt.cmi test/arity_deopt.cmj : cc test/arity_deopt.res | test/mt.cmj $bsc $stdlib runtime o test/arity_infer.cmi test/arity_infer.cmj : cc test/arity_infer.res | $bsc $stdlib runtime -o test/array_data_util.cmi test/array_data_util.cmj : cc test/array_data_util.res | $bsc $stdlib runtime o test/array_safe_get.cmi test/array_safe_get.cmj : cc test/array_safe_get.res | $bsc $stdlib runtime o test/array_subtle_test.cmi test/array_subtle_test.cmj : cc test/array_subtle_test.res | test/mt.cmj $bsc $stdlib runtime o test/array_test.cmj : cc_cmi test/array_test.res | test/array_test.cmi test/mt.cmj $bsc $stdlib runtime @@ -78,43 +76,22 @@ o test/basic_module_test.cmi : cc test/basic_module_test.resi | $bsc $stdlib run o test/bb.cmi test/bb.cmj : cc test/bb.res | $bsc $stdlib runtime o test/bdd.cmi test/bdd.cmj : cc test/bdd.res | $bsc $stdlib runtime o test/belt_internal_test.cmi test/belt_internal_test.cmj : cc test/belt_internal_test.res | $bsc $stdlib runtime -o test/belt_result_alias_test.cmi test/belt_result_alias_test.cmj : cc test/belt_result_alias_test.res | $bsc $stdlib runtime o test/bench.cmi test/bench.cmj : cc test/bench.res | $bsc $stdlib runtime o test/big_enum.cmi test/big_enum.cmj : cc test/big_enum.res | $bsc $stdlib runtime o test/big_polyvar_test.cmi test/big_polyvar_test.cmj : cc test/big_polyvar_test.res | $bsc $stdlib runtime o test/block_alias_test.cmi test/block_alias_test.cmj : cc test/block_alias_test.res | test/mt.cmj $bsc $stdlib runtime o test/boolean_test.cmi test/boolean_test.cmj : cc test/boolean_test.res | test/mt.cmj test/test_bool_equal.cmj $bsc $stdlib runtime -o test/bs_MapInt_test.cmi test/bs_MapInt_test.cmj : cc test/bs_MapInt_test.res | $bsc $stdlib runtime o test/bs_abstract_test.cmj : cc_cmi test/bs_abstract_test.res | test/bs_abstract_test.cmi $bsc $stdlib runtime o test/bs_abstract_test.cmi : cc test/bs_abstract_test.resi | $bsc $stdlib runtime -o test/bs_array_test.cmi test/bs_array_test.cmj : cc test/bs_array_test.res | test/mt.cmj $bsc $stdlib runtime o test/bs_auto_uncurry.cmi test/bs_auto_uncurry.cmj : cc test/bs_auto_uncurry.res | $bsc $stdlib runtime o test/bs_auto_uncurry_test.cmi test/bs_auto_uncurry_test.cmj : cc test/bs_auto_uncurry_test.res | test/mt.cmj $bsc $stdlib runtime -o test/bs_float_test.cmi test/bs_float_test.cmj : cc test/bs_float_test.res | test/mt.cmj $bsc $stdlib runtime -o test/bs_hashmap_test.cmi test/bs_hashmap_test.cmj : cc test/bs_hashmap_test.res | test/array_data_util.cmj test/mt.cmj $bsc $stdlib runtime -o test/bs_hashset_int_test.cmi test/bs_hashset_int_test.cmj : cc test/bs_hashset_int_test.res | test/array_data_util.cmj test/mt.cmj $bsc $stdlib runtime -o test/bs_hashtbl_string_test.cmi test/bs_hashtbl_string_test.cmj : cc test/bs_hashtbl_string_test.res | $bsc $stdlib runtime o test/bs_ignore_effect.cmi test/bs_ignore_effect.cmj : cc test/bs_ignore_effect.res | test/mt.cmj $bsc $stdlib runtime o test/bs_ignore_test.cmi test/bs_ignore_test.cmj : cc test/bs_ignore_test.res | $bsc $stdlib runtime -o test/bs_int_test.cmi test/bs_int_test.cmj : cc test/bs_int_test.res | test/mt.cmj $bsc $stdlib runtime -o test/bs_list_test.cmi test/bs_list_test.cmj : cc test/bs_list_test.res | test/mt.cmj $bsc $stdlib runtime -o test/bs_map_set_dict_test.cmi test/bs_map_set_dict_test.cmj : cc test/bs_map_set_dict_test.res | test/array_data_util.cmj test/mt.cmj $bsc $stdlib runtime -o test/bs_map_test.cmi test/bs_map_test.cmj : cc test/bs_map_test.res | test/mt.cmj $bsc $stdlib runtime o test/bs_min_max_test.cmi test/bs_min_max_test.cmj : cc test/bs_min_max_test.res | test/mt.cmj $bsc $stdlib runtime -o test/bs_mutable_set_test.cmi test/bs_mutable_set_test.cmj : cc test/bs_mutable_set_test.res | test/array_data_util.cmj test/mt.cmj $bsc $stdlib runtime -o test/bs_poly_map_test.cmi test/bs_poly_map_test.cmj : cc test/bs_poly_map_test.res | test/array_data_util.cmj test/mt.cmj $bsc $stdlib runtime -o test/bs_poly_mutable_map_test.cmi test/bs_poly_mutable_map_test.cmj : cc test/bs_poly_mutable_map_test.res | test/array_data_util.cmj test/mt.cmj $bsc $stdlib runtime -o test/bs_poly_mutable_set_test.cmi test/bs_poly_mutable_set_test.cmj : cc test/bs_poly_mutable_set_test.res | test/array_data_util.cmj test/mt.cmj $bsc $stdlib runtime -o test/bs_poly_set_test.cmi test/bs_poly_set_test.cmj : cc test/bs_poly_set_test.res | test/array_data_util.cmj test/mt.cmj $bsc $stdlib runtime o test/bs_qualified.cmi test/bs_qualified.cmj : cc test/bs_qualified.res | $bsc $stdlib runtime -o test/bs_queue_test.cmi test/bs_queue_test.cmj : cc test/bs_queue_test.res | test/mt.cmj $bsc $stdlib runtime o test/bs_rbset_int_bench.cmi test/bs_rbset_int_bench.cmj : cc test/bs_rbset_int_bench.res | test/rbset.cmj $bsc $stdlib runtime o test/bs_rest_test.cmi test/bs_rest_test.cmj : cc test/bs_rest_test.res | $bsc $stdlib runtime -o test/bs_set_bench.cmi test/bs_set_bench.cmj : cc test/bs_set_bench.res | $bsc $stdlib runtime -o test/bs_set_int_test.cmi test/bs_set_int_test.cmj : cc test/bs_set_int_test.res | test/array_data_util.cmj test/mt.cmj $bsc $stdlib runtime -o test/bs_sort_test.cmi test/bs_sort_test.cmj : cc test/bs_sort_test.res | test/array_data_util.cmj test/mt.cmj $bsc $stdlib runtime o test/bs_splice_partial.cmi test/bs_splice_partial.cmj : cc test/bs_splice_partial.res | $bsc $stdlib runtime -o test/bs_stack_test.cmi test/bs_stack_test.cmj : cc test/bs_stack_test.res | test/mt.cmj $bsc $stdlib runtime o test/bs_string_test.cmi test/bs_string_test.cmj : cc test/bs_string_test.res | test/mt.cmj $bsc $stdlib runtime o test/bs_unwrap_test.cmi test/bs_unwrap_test.cmj : cc test/bs_unwrap_test.res | $bsc $stdlib runtime o test/buffer_test.cmi test/buffer_test.cmj : cc test/buffer_test.res | test/mt.cmj $bsc $stdlib runtime @@ -262,7 +239,6 @@ o test/gpr_2316_test.cmi test/gpr_2316_test.cmj : cc test/gpr_2316_test.res | te o test/gpr_2352_test.cmi test/gpr_2352_test.cmj : cc test/gpr_2352_test.res | $bsc $stdlib runtime o test/gpr_2413_test.cmi test/gpr_2413_test.cmj : cc test/gpr_2413_test.res | $bsc $stdlib runtime o test/gpr_2474.cmi test/gpr_2474.cmj : cc test/gpr_2474.res | $bsc $stdlib runtime -o test/gpr_2487.cmi test/gpr_2487.cmj : cc test/gpr_2487.res | $bsc $stdlib runtime o test/gpr_2503_test.cmi test/gpr_2503_test.cmj : cc test/gpr_2503_test.res | test/mt.cmj $bsc $stdlib runtime o test/gpr_2608_test.cmi test/gpr_2608_test.cmj : cc test/gpr_2608_test.res | test/mt.cmj $bsc $stdlib runtime o test/gpr_2614_test.cmi test/gpr_2614_test.cmj : cc test/gpr_2614_test.res | $bsc $stdlib runtime @@ -307,8 +283,6 @@ o test/gpr_4025_test.cmi test/gpr_4025_test.cmj : cc test/gpr_4025_test.res | $b o test/gpr_405_test.cmj : cc_cmi test/gpr_405_test.res | test/gpr_405_test.cmi $bsc $stdlib runtime o test/gpr_405_test.cmi : cc test/gpr_405_test.resi | $bsc $stdlib runtime o test/gpr_4069_test.cmi test/gpr_4069_test.cmj : cc test/gpr_4069_test.res | $bsc $stdlib runtime -o test/gpr_4265_test.cmi test/gpr_4265_test.cmj : cc test/gpr_4265_test.res | test/mt.cmj $bsc $stdlib runtime -o test/gpr_4274_test.cmi test/gpr_4274_test.cmj : cc test/gpr_4274_test.res | $bsc $stdlib runtime o test/gpr_4280_test.cmi test/gpr_4280_test.cmj : cc test/gpr_4280_test.res | test/mt.cmj $bsc $stdlib runtime o test/gpr_4407_test.cmi test/gpr_4407_test.cmj : cc test/gpr_4407_test.res | test/debug_mode_value.cmj test/mt.cmj $bsc $stdlib runtime o test/gpr_441.cmi test/gpr_441.cmj : cc test/gpr_441.res | $bsc $stdlib runtime @@ -349,7 +323,6 @@ o test/hello.foo.cmi test/hello.foo.cmj : cc test/hello.foo.res | $bsc $stdlib r o test/hello_res.cmj : cc_cmi test/hello_res.res | test/hello_res.cmi $bsc $stdlib runtime o test/hello_res.cmi : cc test/hello_res.resi | $bsc $stdlib runtime o test/ignore_test.cmi test/ignore_test.cmj : cc test/ignore_test.res | test/mt.cmj $bsc $stdlib runtime -o test/imm_map_bench.cmi test/imm_map_bench.cmj : cc test/imm_map_bench.res | $bsc $stdlib runtime o test/import_side_effect.cmi test/import_side_effect.cmj : cc test/import_side_effect.res | test/side_effect.cmj test/side_effect2.cmj $bsc $stdlib runtime o test/import_side_effect_free.cmi test/import_side_effect_free.cmj : cc test/import_side_effect_free.res | test/side_effect_free.cmj $bsc $stdlib runtime o test/include_side_effect.cmi test/include_side_effect.cmj : cc test/include_side_effect.res | test/side_effect.cmj $bsc $stdlib runtime @@ -476,7 +449,6 @@ o test/of_string_test.cmi test/of_string_test.cmj : cc test/of_string_test.res | o test/offset.cmi test/offset.cmj : cc test/offset.res | $bsc $stdlib runtime o test/option_encoding_test.cmi test/option_encoding_test.cmj : cc test/option_encoding_test.res | $bsc $stdlib runtime o test/option_record_none_test.cmi test/option_record_none_test.cmj : cc test/option_record_none_test.res | $bsc $stdlib runtime -o test/option_repr_test.cmi test/option_repr_test.cmj : cc test/option_repr_test.res | test/mt.cmj $bsc $stdlib runtime o test/optional_ffi_test.cmi test/optional_ffi_test.cmj : cc test/optional_ffi_test.res | test/mt.cmj $bsc $stdlib runtime o test/optional_regression_test.cmi test/optional_regression_test.cmj : cc test/optional_regression_test.res | test/mt.cmj $bsc $stdlib runtime o test/pipe_send_readline.cmi test/pipe_send_readline.cmj : cc test/pipe_send_readline.res | $bsc $stdlib runtime @@ -698,7 +670,6 @@ o test/unboxed_attribute_test.cmi test/unboxed_attribute_test.cmj : cc test/unbo o test/unboxed_crash.cmi test/unboxed_crash.cmj : cc test/unboxed_crash.res | $bsc $stdlib runtime o test/unboxed_use_case.cmj : cc_cmi test/unboxed_use_case.res | test/unboxed_use_case.cmi $bsc $stdlib runtime o test/unboxed_use_case.cmi : cc test/unboxed_use_case.resi | $bsc $stdlib runtime -o test/uncurried_cast.cmi test/uncurried_cast.cmj : cc test/uncurried_cast.res | $bsc $stdlib runtime o test/uncurried_default.args.cmi test/uncurried_default.args.cmj : cc test/uncurried_default.args.res | $bsc $stdlib runtime o test/uncurried_pipe.cmi test/uncurried_pipe.cmj : cc test/uncurried_pipe.res | $bsc $stdlib runtime o test/uncurry_external_test.cmi test/uncurry_external_test.cmj : cc test/uncurry_external_test.res | test/mt.cmj $bsc $stdlib runtime @@ -717,4 +688,4 @@ o test/update_record_test.cmi test/update_record_test.cmj : cc test/update_recor o test/variant.cmi test/variant.cmj : cc test/variant.res | $bsc $stdlib runtime o test/variantsMatching.cmi test/variantsMatching.cmj : cc test/variantsMatching.res | $bsc $stdlib runtime o test/webpack_config.cmi test/webpack_config.cmj : cc test/webpack_config.res | $bsc $stdlib runtime -o test : phony test/406_primitive_test.cmi test/406_primitive_test.cmj test/AsInUncurriedExternals.cmi test/AsInUncurriedExternals.cmj test/Coercion.cmi test/Coercion.cmj test/DotDotDot.cmi test/DotDotDot.cmj test/EmptyRecord.cmi test/EmptyRecord.cmj test/FFI.cmi test/FFI.cmj test/Import.cmi test/Import.cmj test/RecordCoercion.cmi test/RecordCoercion.cmj test/RecordOrObject.cmi test/RecordOrObject.cmj test/SafePromises.cmi test/SafePromises.cmj test/UncurriedAlways.cmi test/UncurriedAlways.cmj test/UncurriedExternals.cmi test/UncurriedExternals.cmj test/UncurriedPervasives.cmi test/UncurriedPervasives.cmj test/UntaggedVariants.cmi test/UntaggedVariants.cmj test/VariantCoercion.cmi test/VariantCoercion.cmj test/VariantSpreads.cmi test/VariantSpreads.cmj test/a.cmi test/a.cmj test/a_filename_test.cmi test/a_filename_test.cmj test/a_list_test.cmi test/a_list_test.cmj test/a_recursive_type.cmi test/a_recursive_type.cmj test/a_scope_bug.cmi test/a_scope_bug.cmj test/a_string_test.cmi test/a_string_test.cmj test/abstract_type.cmi test/abstract_type.cmj test/adt_optimize_test.cmi test/adt_optimize_test.cmj test/alias_default_value_test.cmi test/alias_default_value_test.cmj test/alias_test.cmi test/alias_test.cmj test/and_or_tailcall_test.cmi test/and_or_tailcall_test.cmj test/argv_test.cmi test/argv_test.cmj test/ari_regress_test.cmi test/ari_regress_test.cmj test/arith_lexer.cmi test/arith_lexer.cmj test/arith_parser.cmi test/arith_parser.cmj test/arith_syntax.cmi test/arith_syntax.cmj test/arity.cmi test/arity.cmj test/arity_deopt.cmi test/arity_deopt.cmj test/arity_infer.cmi test/arity_infer.cmj test/array_data_util.cmi test/array_data_util.cmj test/array_safe_get.cmi test/array_safe_get.cmj test/array_subtle_test.cmi test/array_subtle_test.cmj test/array_test.cmi test/array_test.cmj test/as_inline_record_test.cmi test/as_inline_record_test.cmj test/ast_abstract_test.cmi test/ast_abstract_test.cmj test/ast_mapper_unused_warning_test.cmi test/ast_mapper_unused_warning_test.cmj test/async_await.cmi test/async_await.cmj test/async_ideas.cmi test/async_ideas.cmj test/async_inline.cmi test/async_inline.cmj test/async_inside_loop.cmi test/async_inside_loop.cmj test/attr_test.cmi test/attr_test.cmj test/b.cmi test/b.cmj test/bal_set_mini.cmi test/bal_set_mini.cmj test/bang_primitive.cmi test/bang_primitive.cmj test/basic_module_test.cmi test/basic_module_test.cmj test/bb.cmi test/bb.cmj test/bdd.cmi test/bdd.cmj test/belt_internal_test.cmi test/belt_internal_test.cmj test/belt_result_alias_test.cmi test/belt_result_alias_test.cmj test/bench.cmi test/bench.cmj test/big_enum.cmi test/big_enum.cmj test/big_polyvar_test.cmi test/big_polyvar_test.cmj test/block_alias_test.cmi test/block_alias_test.cmj test/boolean_test.cmi test/boolean_test.cmj test/bs_MapInt_test.cmi test/bs_MapInt_test.cmj test/bs_abstract_test.cmi test/bs_abstract_test.cmj test/bs_array_test.cmi test/bs_array_test.cmj test/bs_auto_uncurry.cmi test/bs_auto_uncurry.cmj test/bs_auto_uncurry_test.cmi test/bs_auto_uncurry_test.cmj test/bs_float_test.cmi test/bs_float_test.cmj test/bs_hashmap_test.cmi test/bs_hashmap_test.cmj test/bs_hashset_int_test.cmi test/bs_hashset_int_test.cmj test/bs_hashtbl_string_test.cmi test/bs_hashtbl_string_test.cmj test/bs_ignore_effect.cmi test/bs_ignore_effect.cmj test/bs_ignore_test.cmi test/bs_ignore_test.cmj test/bs_int_test.cmi test/bs_int_test.cmj test/bs_list_test.cmi test/bs_list_test.cmj test/bs_map_set_dict_test.cmi test/bs_map_set_dict_test.cmj test/bs_map_test.cmi test/bs_map_test.cmj test/bs_min_max_test.cmi test/bs_min_max_test.cmj test/bs_mutable_set_test.cmi test/bs_mutable_set_test.cmj test/bs_poly_map_test.cmi test/bs_poly_map_test.cmj test/bs_poly_mutable_map_test.cmi test/bs_poly_mutable_map_test.cmj test/bs_poly_mutable_set_test.cmi test/bs_poly_mutable_set_test.cmj test/bs_poly_set_test.cmi test/bs_poly_set_test.cmj test/bs_qualified.cmi test/bs_qualified.cmj test/bs_queue_test.cmi test/bs_queue_test.cmj test/bs_rbset_int_bench.cmi test/bs_rbset_int_bench.cmj test/bs_rest_test.cmi test/bs_rest_test.cmj test/bs_set_bench.cmi test/bs_set_bench.cmj test/bs_set_int_test.cmi test/bs_set_int_test.cmj test/bs_sort_test.cmi test/bs_sort_test.cmj test/bs_splice_partial.cmi test/bs_splice_partial.cmj test/bs_stack_test.cmi test/bs_stack_test.cmj test/bs_string_test.cmi test/bs_string_test.cmj test/bs_unwrap_test.cmi test/bs_unwrap_test.cmj test/buffer_test.cmi test/buffer_test.cmj test/bytes_split_gpr_743_test.cmi test/bytes_split_gpr_743_test.cmj test/caml_compare_bigint_test.cmi test/caml_compare_bigint_test.cmj test/caml_compare_test.cmi test/caml_compare_test.cmj test/caml_format_test.cmi test/caml_format_test.cmj test/chain_code_test.cmi test/chain_code_test.cmj test/chn_test.cmi test/chn_test.cmj test/class_type_ffi_test.cmi test/class_type_ffi_test.cmj test/coercion_module_alias_test.cmi test/coercion_module_alias_test.cmj test/compare_test.cmi test/compare_test.cmj test/complete_parmatch_test.cmi test/complete_parmatch_test.cmj test/complex_if_test.cmi test/complex_if_test.cmj test/complex_test.cmi test/complex_test.cmj test/complex_while_loop.cmi test/complex_while_loop.cmj test/condition_compilation_test.cmi test/condition_compilation_test.cmj test/config1_test.cmi test/config1_test.cmj test/console_log_test.cmi test/console_log_test.cmj test/const_block_test.cmi test/const_block_test.cmj test/const_defs.cmi test/const_defs.cmj test/const_defs_test.cmi test/const_defs_test.cmj test/const_test.cmi test/const_test.cmj test/cont_int_fold_test.cmi test/cont_int_fold_test.cmj test/cps_test.cmi test/cps_test.cmj test/cross_module_inline_test.cmi test/cross_module_inline_test.cmj test/custom_error_test.cmi test/custom_error_test.cmj test/debug_keep_test.cmi test/debug_keep_test.cmj test/debug_mode_value.cmi test/debug_mode_value.cmj test/debug_tmp.cmi test/debug_tmp.cmj test/debugger_test.cmi test/debugger_test.cmj test/default_export_test.cmi test/default_export_test.cmj test/defunctor_make_test.cmi test/defunctor_make_test.cmj test/demo_int_map.cmi test/demo_int_map.cmj test/demo_page.cmi test/demo_page.cmj test/demo_pipe.cmi test/demo_pipe.cmj test/derive_dyntype.cmi test/derive_dyntype.cmj test/derive_projector_test.cmi test/derive_projector_test.cmj test/derive_type_test.cmi test/derive_type_test.cmj test/digest_test.cmi test/digest_test.cmj test/directives.cmi test/directives.cmj test/div_by_zero_test.cmi test/div_by_zero_test.cmj test/dollar_escape_test.cmi test/dollar_escape_test.cmj test/earger_curry_test.cmi test/earger_curry_test.cmj test/effect.cmi test/effect.cmj test/epsilon_test.cmi test/epsilon_test.cmj test/equal_box_test.cmi test/equal_box_test.cmj test/equal_exception_test.cmi test/equal_exception_test.cmj test/equal_test.cmi test/equal_test.cmj test/es6_export.cmi test/es6_export.cmj test/es6_import.cmi test/es6_import.cmj test/es6_module_test.cmi test/es6_module_test.cmj test/escape_esmodule.cmi test/escape_esmodule.cmj test/esmodule_ref.cmi test/esmodule_ref.cmj test/event_ffi.cmi test/event_ffi.cmj test/exception_alias.cmi test/exception_alias.cmj test/exception_raise_test.cmi test/exception_raise_test.cmj test/exception_rebound_err_test.cmi test/exception_rebound_err_test.cmj test/exception_value_test.cmi test/exception_value_test.cmj test/exponentiation_precedence_test.cmi test/exponentiation_precedence_test.cmj test/export_keyword.cmi test/export_keyword.cmj test/ext_array_test.cmi test/ext_array_test.cmj test/ext_bytes_test.cmi test/ext_bytes_test.cmj test/ext_filename_test.cmi test/ext_filename_test.cmj test/ext_list_test.cmi test/ext_list_test.cmj test/ext_pervasives_test.cmi test/ext_pervasives_test.cmj test/ext_string_test.cmi test/ext_string_test.cmj test/ext_sys_test.cmi test/ext_sys_test.cmj test/extensible_variant_test.cmi test/extensible_variant_test.cmj test/external_polyfill_test.cmi test/external_polyfill_test.cmj test/external_ppx.cmi test/external_ppx.cmj test/external_ppx2.cmi test/external_ppx2.cmj test/fail_comp.cmi test/fail_comp.cmj test/ffi_arity_test.cmi test/ffi_arity_test.cmj test/ffi_array_test.cmi test/ffi_array_test.cmj test/ffi_js_test.cmi test/ffi_js_test.cmj test/ffi_splice_test.cmi test/ffi_splice_test.cmj test/ffi_test.cmi test/ffi_test.cmj test/fib.cmi test/fib.cmj test/flattern_order_test.cmi test/flattern_order_test.cmj test/flexible_array_test.cmi test/flexible_array_test.cmj test/float_array.cmi test/float_array.cmj test/float_of_bits_test.cmi test/float_of_bits_test.cmj test/float_record.cmi test/float_record.cmj test/float_test.cmi test/float_test.cmj test/floatarray_test.cmi test/floatarray_test.cmj test/for_loop_test.cmi test/for_loop_test.cmj test/for_side_effect_test.cmi test/for_side_effect_test.cmj test/format_regression.cmi test/format_regression.cmj test/format_test.cmi test/format_test.cmj test/fun_pattern_match.cmi test/fun_pattern_match.cmj test/functor_app_test.cmi test/functor_app_test.cmj test/functor_def.cmi test/functor_def.cmj test/functor_ffi.cmi test/functor_ffi.cmj test/functor_inst.cmi test/functor_inst.cmj test/functors.cmi test/functors.cmj test/gbk.cmi test/gbk.cmj test/genlex_test.cmi test/genlex_test.cmj test/gentTypeReTest.cmi test/gentTypeReTest.cmj test/global_exception_regression_test.cmi test/global_exception_regression_test.cmj test/global_mangles.cmi test/global_mangles.cmj test/global_module_alias_test.cmi test/global_module_alias_test.cmj test/google_closure_test.cmi test/google_closure_test.cmj test/gpr496_test.cmi test/gpr496_test.cmj test/gpr_1072.cmi test/gpr_1072.cmj test/gpr_1072_reg.cmi test/gpr_1072_reg.cmj test/gpr_1150.cmi test/gpr_1150.cmj test/gpr_1154_test.cmi test/gpr_1154_test.cmj test/gpr_1170.cmi test/gpr_1170.cmj test/gpr_1240_missing_unbox.cmi test/gpr_1240_missing_unbox.cmj test/gpr_1245_test.cmi test/gpr_1245_test.cmj test/gpr_1268.cmi test/gpr_1268.cmj test/gpr_1409_test.cmi test/gpr_1409_test.cmj test/gpr_1423_app_test.cmi test/gpr_1423_app_test.cmj test/gpr_1423_nav.cmi test/gpr_1423_nav.cmj test/gpr_1438.cmi test/gpr_1438.cmj test/gpr_1481.cmi test/gpr_1481.cmj test/gpr_1484.cmi test/gpr_1484.cmj test/gpr_1503_test.cmi test/gpr_1503_test.cmj test/gpr_1539_test.cmi test/gpr_1539_test.cmj test/gpr_1658_test.cmi test/gpr_1658_test.cmj test/gpr_1667_test.cmi test/gpr_1667_test.cmj test/gpr_1692_test.cmi test/gpr_1692_test.cmj test/gpr_1698_test.cmi test/gpr_1698_test.cmj test/gpr_1701_test.cmi test/gpr_1701_test.cmj test/gpr_1716_test.cmi test/gpr_1716_test.cmj test/gpr_1717_test.cmi test/gpr_1717_test.cmj test/gpr_1728_test.cmi test/gpr_1728_test.cmj test/gpr_1749_test.cmi test/gpr_1749_test.cmj test/gpr_1759_test.cmi test/gpr_1759_test.cmj test/gpr_1760_test.cmi test/gpr_1760_test.cmj test/gpr_1762_test.cmi test/gpr_1762_test.cmj test/gpr_1817_test.cmi test/gpr_1817_test.cmj test/gpr_1822_test.cmi test/gpr_1822_test.cmj test/gpr_1891_test.cmi test/gpr_1891_test.cmj test/gpr_1943_test.cmi test/gpr_1943_test.cmj test/gpr_1946_test.cmi test/gpr_1946_test.cmj test/gpr_2316_test.cmi test/gpr_2316_test.cmj test/gpr_2352_test.cmi test/gpr_2352_test.cmj test/gpr_2413_test.cmi test/gpr_2413_test.cmj test/gpr_2474.cmi test/gpr_2474.cmj test/gpr_2487.cmi test/gpr_2487.cmj test/gpr_2503_test.cmi test/gpr_2503_test.cmj test/gpr_2608_test.cmi test/gpr_2608_test.cmj test/gpr_2614_test.cmi test/gpr_2614_test.cmj test/gpr_2633_test.cmi test/gpr_2633_test.cmj test/gpr_2642_test.cmi test/gpr_2642_test.cmj test/gpr_2682_test.cmi test/gpr_2682_test.cmj test/gpr_2700_test.cmi test/gpr_2700_test.cmj test/gpr_2731_test.cmi test/gpr_2731_test.cmj test/gpr_2789_test.cmi test/gpr_2789_test.cmj test/gpr_2931_test.cmi test/gpr_2931_test.cmj test/gpr_3142_test.cmi test/gpr_3142_test.cmj test/gpr_3154_test.cmi test/gpr_3154_test.cmj test/gpr_3209_test.cmi test/gpr_3209_test.cmj test/gpr_3492_test.cmi test/gpr_3492_test.cmj test/gpr_3519_jsx_test.cmi test/gpr_3519_jsx_test.cmj test/gpr_3519_test.cmi test/gpr_3519_test.cmj test/gpr_3536_test.cmi test/gpr_3536_test.cmj test/gpr_3546_test.cmi test/gpr_3546_test.cmj test/gpr_3548_test.cmi test/gpr_3548_test.cmj test/gpr_3549_test.cmi test/gpr_3549_test.cmj test/gpr_3566_drive_test.cmi test/gpr_3566_drive_test.cmj test/gpr_3566_test.cmi test/gpr_3566_test.cmj test/gpr_3595_test.cmi test/gpr_3595_test.cmj test/gpr_3609_test.cmi test/gpr_3609_test.cmj test/gpr_3697_test.cmi test/gpr_3697_test.cmj test/gpr_373_test.cmi test/gpr_373_test.cmj test/gpr_3770_test.cmi test/gpr_3770_test.cmj test/gpr_3852_alias.cmi test/gpr_3852_alias.cmj test/gpr_3852_alias_reify.cmi test/gpr_3852_alias_reify.cmj test/gpr_3852_effect.cmi test/gpr_3852_effect.cmj test/gpr_3865.cmi test/gpr_3865.cmj test/gpr_3865_bar.cmi test/gpr_3865_bar.cmj test/gpr_3865_foo.cmi test/gpr_3865_foo.cmj test/gpr_3875_test.cmi test/gpr_3875_test.cmj test/gpr_3877_test.cmi test/gpr_3877_test.cmj test/gpr_3895_test.cmi test/gpr_3895_test.cmj test/gpr_3897_test.cmi test/gpr_3897_test.cmj test/gpr_3931_test.cmi test/gpr_3931_test.cmj test/gpr_3980_test.cmi test/gpr_3980_test.cmj test/gpr_4025_test.cmi test/gpr_4025_test.cmj test/gpr_405_test.cmi test/gpr_405_test.cmj test/gpr_4069_test.cmi test/gpr_4069_test.cmj test/gpr_4265_test.cmi test/gpr_4265_test.cmj test/gpr_4274_test.cmi test/gpr_4274_test.cmj test/gpr_4280_test.cmi test/gpr_4280_test.cmj test/gpr_4407_test.cmi test/gpr_4407_test.cmj test/gpr_441.cmi test/gpr_441.cmj test/gpr_4442_test.cmi test/gpr_4442_test.cmj test/gpr_4491_test.cmi test/gpr_4491_test.cmj test/gpr_4494_test.cmi test/gpr_4494_test.cmj test/gpr_4519_test.cmi test/gpr_4519_test.cmj test/gpr_459_test.cmi test/gpr_459_test.cmj test/gpr_4632.cmi test/gpr_4632.cmj test/gpr_4639_test.cmi test/gpr_4639_test.cmj test/gpr_4900_test.cmi test/gpr_4900_test.cmj test/gpr_4924_test.cmi test/gpr_4924_test.cmj test/gpr_4931.cmi test/gpr_4931.cmj test/gpr_4931_allow.cmi test/gpr_4931_allow.cmj test/gpr_5071_test.cmi test/gpr_5071_test.cmj test/gpr_5169_test.cmi test/gpr_5169_test.cmj test/gpr_5218_test.cmi test/gpr_5218_test.cmj test/gpr_5280_optimize_test.cmi test/gpr_5280_optimize_test.cmj test/gpr_5312.cmi test/gpr_5312.cmj test/gpr_5557.cmi test/gpr_5557.cmj test/gpr_5753.cmi test/gpr_5753.cmj test/gpr_658.cmi test/gpr_658.cmj test/gpr_858_test.cmi test/gpr_858_test.cmj test/gpr_858_unit2_test.cmi test/gpr_858_unit2_test.cmj test/gpr_904_test.cmi test/gpr_904_test.cmj test/gpr_974_test.cmi test/gpr_974_test.cmj test/gpr_977_test.cmi test/gpr_977_test.cmj test/gpr_return_type_unused_attribute.cmi test/gpr_return_type_unused_attribute.cmj test/gray_code_test.cmi test/gray_code_test.cmj test/guide_for_ext.cmi test/guide_for_ext.cmj test/hamming_test.cmi test/hamming_test.cmj test/hash_collision_test.cmi test/hash_collision_test.cmj test/hash_sugar_desugar.cmi test/hash_sugar_desugar.cmj test/hash_test.cmi test/hash_test.cmj test/hashtbl_test.cmi test/hashtbl_test.cmj test/hello.foo.cmi test/hello.foo.cmj test/hello_res.cmi test/hello_res.cmj test/ignore_test.cmi test/ignore_test.cmj test/imm_map_bench.cmi test/imm_map_bench.cmj test/import_side_effect.cmi test/import_side_effect.cmj test/import_side_effect_free.cmi test/import_side_effect_free.cmj test/include_side_effect.cmi test/include_side_effect.cmj test/include_side_effect_free.cmi test/include_side_effect_free.cmj test/incomplete_toplevel_test.cmi test/incomplete_toplevel_test.cmj test/infer_type_test.cmi test/infer_type_test.cmj test/inline_condition_with_pattern_matching.cmi test/inline_condition_with_pattern_matching.cmj test/inline_const.cmi test/inline_const.cmj test/inline_const_test.cmi test/inline_const_test.cmj test/inline_edge_cases.cmi test/inline_edge_cases.cmj test/inline_map2_test.cmi test/inline_map2_test.cmj test/inline_map_demo.cmi test/inline_map_demo.cmj test/inline_map_test.cmi test/inline_map_test.cmj test/inline_record_test.cmi test/inline_record_test.cmj test/inline_regression_test.cmi test/inline_regression_test.cmj test/inline_string_test.cmi test/inline_string_test.cmj test/inner_call.cmi test/inner_call.cmj test/inner_define.cmi test/inner_define.cmj test/inner_unused.cmi test/inner_unused.cmj test/installation_test.cmi test/installation_test.cmj test/int32_test.cmi test/int32_test.cmj test/int64_mul_div_test.cmi test/int64_mul_div_test.cmj test/int64_string_bench.cmi test/int64_string_bench.cmj test/int64_string_test.cmi test/int64_string_test.cmj test/int64_test.cmi test/int64_test.cmj test/int_hashtbl_test.cmi test/int_hashtbl_test.cmj test/int_map.cmi test/int_map.cmj test/int_overflow_test.cmi test/int_overflow_test.cmj test/int_poly_var.cmi test/int_poly_var.cmj test/int_switch_test.cmi test/int_switch_test.cmj test/internal_unused_test.cmi test/internal_unused_test.cmj test/io_test.cmi test/io_test.cmj test/js_array_test.cmi test/js_array_test.cmj test/js_bool_test.cmi test/js_bool_test.cmj test/js_cast_test.cmi test/js_cast_test.cmj test/js_date_test.cmi test/js_date_test.cmj test/js_dict_test.cmi test/js_dict_test.cmj test/js_exception_catch_test.cmi test/js_exception_catch_test.cmj test/js_float_test.cmi test/js_float_test.cmj test/js_global_test.cmi test/js_global_test.cmj test/js_int_test.cmi test/js_int_test.cmj test/js_json_test.cmi test/js_json_test.cmj test/js_list_test.cmi test/js_list_test.cmj test/js_math_test.cmi test/js_math_test.cmj test/js_null_test.cmi test/js_null_test.cmj test/js_null_undefined_test.cmi test/js_null_undefined_test.cmj test/js_nullable_test.cmi test/js_nullable_test.cmj test/js_obj_test.cmi test/js_obj_test.cmj test/js_option_test.cmi test/js_option_test.cmj test/js_re_test.cmi test/js_re_test.cmj test/js_string_test.cmi test/js_string_test.cmj test/js_typed_array_test.cmi test/js_typed_array_test.cmj test/js_undefined_test.cmi test/js_undefined_test.cmj test/js_val.cmi test/js_val.cmj test/jsoo_400_test.cmi test/jsoo_400_test.cmj test/jsoo_485_test.cmi test/jsoo_485_test.cmj test/jsxv4_newtype.cmi test/jsxv4_newtype.cmj test/key_word_property.cmi test/key_word_property.cmj test/key_word_property2.cmi test/key_word_property2.cmj test/key_word_property_plus_test.cmi test/key_word_property_plus_test.cmj test/label_uncurry.cmi test/label_uncurry.cmj test/large_integer_pat.cmi test/large_integer_pat.cmj test/large_record_duplication_test.cmi test/large_record_duplication_test.cmj test/largest_int_flow.cmi test/largest_int_flow.cmj test/lazy_demo.cmi test/lazy_demo.cmj test/lazy_test.cmi test/lazy_test.cmj test/lib_js_test.cmi test/lib_js_test.cmj test/libarg_test.cmi test/libarg_test.cmj test/libqueue_test.cmi test/libqueue_test.cmj test/limits_test.cmi test/limits_test.cmj test/list_stack.cmi test/list_stack.cmj test/list_test.cmi test/list_test.cmj test/local_exception_test.cmi test/local_exception_test.cmj test/loop_regression_test.cmi test/loop_regression_test.cmj test/loop_suites_test.cmi test/loop_suites_test.cmj test/map_find_test.cmi test/map_find_test.cmj test/map_test.cmi test/map_test.cmj test/mario_game.cmi test/mario_game.cmj test/marshal.cmi test/marshal.cmj test/meth_annotation.cmi test/meth_annotation.cmj test/method_name_test.cmi test/method_name_test.cmj test/method_string_name.cmi test/method_string_name.cmj test/minimal_test.cmi test/minimal_test.cmj test/miss_colon_test.cmi test/miss_colon_test.cmj test/mock_mt.cmi test/mock_mt.cmj test/module_alias_test.cmi test/module_alias_test.cmj test/module_as_class_ffi.cmi test/module_as_class_ffi.cmj test/module_as_function.cmi test/module_as_function.cmj test/module_missing_conversion.cmi test/module_missing_conversion.cmj test/module_parameter_test.cmi test/module_parameter_test.cmj test/module_splice_test.cmi test/module_splice_test.cmj test/more_poly_variant_test.cmi test/more_poly_variant_test.cmj test/more_uncurry.cmi test/more_uncurry.cmj test/mpr_6033_test.cmi test/mpr_6033_test.cmj test/mt.cmi test/mt.cmj test/mt_global.cmi test/mt_global.cmj test/mutable_obj_test.cmi test/mutable_obj_test.cmj test/mutable_uncurry_test.cmi test/mutable_uncurry_test.cmj test/mutual_non_recursive_type.cmi test/mutual_non_recursive_type.cmj test/name_mangle_test.cmi test/name_mangle_test.cmj test/nested_include.cmi test/nested_include.cmj test/nested_module_alias.cmi test/nested_module_alias.cmj test/nested_obj_literal.cmi test/nested_obj_literal.cmj test/nested_obj_test.cmi test/nested_obj_test.cmj test/nested_pattern_match_test.cmi test/nested_pattern_match_test.cmj test/noassert.cmi test/noassert.cmj test/node_path_test.cmi test/node_path_test.cmj test/null_list_test.cmi test/null_list_test.cmj test/number_lexer.cmi test/number_lexer.cmj test/obj_literal_ppx.cmi test/obj_literal_ppx.cmj test/obj_literal_ppx_test.cmi test/obj_literal_ppx_test.cmj test/obj_magic_test.cmi test/obj_magic_test.cmj test/obj_type_test.cmi test/obj_type_test.cmj test/ocaml_re_test.cmi test/ocaml_re_test.cmj test/of_string_test.cmi test/of_string_test.cmj test/offset.cmi test/offset.cmj test/option_encoding_test.cmi test/option_encoding_test.cmj test/option_record_none_test.cmi test/option_record_none_test.cmj test/option_repr_test.cmi test/option_repr_test.cmj test/optional_ffi_test.cmi test/optional_ffi_test.cmj test/optional_regression_test.cmi test/optional_regression_test.cmj test/pipe_send_readline.cmi test/pipe_send_readline.cmj test/pipe_syntax.cmi test/pipe_syntax.cmj test/poly_empty_array.cmi test/poly_empty_array.cmj test/poly_variant_test.cmi test/poly_variant_test.cmj test/polymorphic_raw_test.cmi test/polymorphic_raw_test.cmj test/polymorphism_test.cmi test/polymorphism_test.cmj test/polyvar_convert.cmi test/polyvar_convert.cmj test/polyvar_test.cmi test/polyvar_test.cmj test/ppx_apply_test.cmi test/ppx_apply_test.cmj test/pq_test.cmi test/pq_test.cmj test/pr6726.cmi test/pr6726.cmj test/pr_regression_test.cmi test/pr_regression_test.cmj test/prepend_data_ffi.cmi test/prepend_data_ffi.cmj test/primitive_reg_test.cmi test/primitive_reg_test.cmj test/print_alpha_test.cmi test/print_alpha_test.cmj test/queue_402.cmi test/queue_402.cmj test/queue_test.cmi test/queue_test.cmj test/random_test.cmi test/random_test.cmj test/raw_hash_tbl_bench.cmi test/raw_hash_tbl_bench.cmj test/raw_output_test.cmi test/raw_output_test.cmj test/raw_pure_test.cmi test/raw_pure_test.cmj test/rbset.cmi test/rbset.cmj test/react.cmi test/react.cmj test/reactDOMRe.cmi test/reactDOMRe.cmj test/reactDOMServerRe.cmi test/reactDOMServerRe.cmj test/reactEvent.cmi test/reactEvent.cmj test/reactTestUtils.cmi test/reactTestUtils.cmj test/reasonReact.cmi test/reasonReact.cmj test/reasonReactCompat.cmi test/reasonReactCompat.cmj test/reasonReactOptimizedCreateClass.cmi test/reasonReactOptimizedCreateClass.cmj test/reasonReactRouter.cmi test/reasonReactRouter.cmj test/rebind_module.cmi test/rebind_module.cmj test/rebind_module_test.cmi test/rebind_module_test.cmj test/rec_array_test.cmi test/rec_array_test.cmj test/rec_fun_test.cmi test/rec_fun_test.cmj test/rec_module_opt.cmi test/rec_module_opt.cmj test/rec_module_test.cmi test/rec_module_test.cmj test/recmodule.cmi test/recmodule.cmj test/record_debug_test.cmi test/record_debug_test.cmj test/record_extension_test.cmi test/record_extension_test.cmj test/record_name_test.cmi test/record_name_test.cmj test/record_regression.cmi test/record_regression.cmj test/record_type_spread.cmi test/record_type_spread.cmj test/record_with_test.cmi test/record_with_test.cmj test/recursive_module.cmi test/recursive_module.cmj test/recursive_module_test.cmi test/recursive_module_test.cmj test/recursive_react_component.cmi test/recursive_react_component.cmj test/recursive_records_test.cmi test/recursive_records_test.cmj test/recursive_unbound_module_test.cmi test/recursive_unbound_module_test.cmj test/regression_print.cmi test/regression_print.cmj test/relative_path.cmi test/relative_path.cmj test/res_debug.cmi test/res_debug.cmj test/return_check.cmi test/return_check.cmj test/runtime_encoding_test.cmi test/runtime_encoding_test.cmj test/set_annotation.cmi test/set_annotation.cmj test/set_gen.cmi test/set_gen.cmj test/sexp.cmi test/sexp.cmj test/sexpm.cmi test/sexpm.cmj test/sexpm_test.cmi test/sexpm_test.cmj test/side_effect.cmi test/side_effect.cmj test/side_effect2.cmi test/side_effect2.cmj test/side_effect_free.cmi test/side_effect_free.cmj test/simple_derive_test.cmi test/simple_derive_test.cmj test/simple_derive_use.cmi test/simple_derive_use.cmj test/simplify_lambda_632o.cmi test/simplify_lambda_632o.cmj test/single_module_alias.cmi test/single_module_alias.cmj test/singular_unit_test.cmi test/singular_unit_test.cmj test/small_inline_test.cmi test/small_inline_test.cmj test/splice_test.cmi test/splice_test.cmj test/stack_comp_test.cmi test/stack_comp_test.cmj test/stack_test.cmi test/stack_test.cmj test/stream_parser_test.cmi test/stream_parser_test.cmj test/string_bound_get_test.cmi test/string_bound_get_test.cmj test/string_constant_compare.cmi test/string_constant_compare.cmj test/string_get_set_test.cmi test/string_get_set_test.cmj test/string_runtime_test.cmi test/string_runtime_test.cmj test/string_set.cmi test/string_set.cmj test/string_set_test.cmi test/string_set_test.cmj test/string_test.cmi test/string_test.cmj test/string_unicode_test.cmi test/string_unicode_test.cmj test/stringmatch_test.cmi test/stringmatch_test.cmj test/submodule.cmi test/submodule.cmj test/submodule_call.cmi test/submodule_call.cmj test/switch_case_test.cmi test/switch_case_test.cmj test/switch_string.cmi test/switch_string.cmj test/tailcall_inline_test.cmi test/tailcall_inline_test.cmj test/template.cmi test/template.cmj test/test.cmi test/test.cmj test/test2.cmi test/test2.cmj test/test_alias.cmi test/test_alias.cmj test/test_ari.cmi test/test_ari.cmj test/test_array.cmi test/test_array.cmj test/test_array_append.cmi test/test_array_append.cmj test/test_array_primitive.cmi test/test_array_primitive.cmj test/test_bool_equal.cmi test/test_bool_equal.cmj test/test_bs_this.cmi test/test_bs_this.cmj test/test_bug.cmi test/test_bug.cmj test/test_bytes.cmi test/test_bytes.cmj test/test_case_opt_collision.cmi test/test_case_opt_collision.cmj test/test_case_set.cmi test/test_case_set.cmj test/test_char.cmi test/test_char.cmj test/test_closure.cmi test/test_closure.cmj test/test_common.cmi test/test_common.cmj test/test_const_elim.cmi test/test_const_elim.cmj test/test_const_propogate.cmi test/test_const_propogate.cmj test/test_cpp.cmi test/test_cpp.cmj test/test_cps.cmi test/test_cps.cmj test/test_demo.cmi test/test_demo.cmj test/test_dup_param.cmi test/test_dup_param.cmj test/test_eq.cmi test/test_eq.cmj test/test_exception.cmi test/test_exception.cmj test/test_exception_escape.cmi test/test_exception_escape.cmj test/test_export2.cmi test/test_export2.cmj test/test_external.cmi test/test_external.cmj test/test_external_unit.cmi test/test_external_unit.cmj test/test_ffi.cmi test/test_ffi.cmj test/test_fib.cmi test/test_fib.cmj test/test_filename.cmi test/test_filename.cmj test/test_for_loop.cmi test/test_for_loop.cmj test/test_for_map.cmi test/test_for_map.cmj test/test_for_map2.cmi test/test_for_map2.cmj test/test_format.cmi test/test_format.cmj test/test_formatter.cmi test/test_formatter.cmj test/test_functor_dead_code.cmi test/test_functor_dead_code.cmj test/test_generative_module.cmi test/test_generative_module.cmj test/test_global_print.cmi test/test_global_print.cmj test/test_google_closure.cmi test/test_google_closure.cmj test/test_include.cmi test/test_include.cmj test/test_incomplete.cmi test/test_incomplete.cmj test/test_incr_ref.cmi test/test_incr_ref.cmj test/test_int_map_find.cmi test/test_int_map_find.cmj test/test_internalOO.cmi test/test_internalOO.cmj test/test_is_js.cmi test/test_is_js.cmj test/test_js_ffi.cmi test/test_js_ffi.cmj test/test_let.cmi test/test_let.cmj test/test_list.cmi test/test_list.cmj test/test_literal.cmi test/test_literal.cmj test/test_literals.cmi test/test_literals.cmj test/test_match_exception.cmi test/test_match_exception.cmj test/test_mutliple.cmi test/test_mutliple.cmj test/test_nat64.cmi test/test_nat64.cmj test/test_nested_let.cmi test/test_nested_let.cmj test/test_nested_print.cmi test/test_nested_print.cmj test/test_non_export.cmi test/test_non_export.cmj test/test_nullary.cmi test/test_nullary.cmj test/test_obj.cmi test/test_obj.cmj test/test_order.cmi test/test_order.cmj test/test_order_tailcall.cmi test/test_order_tailcall.cmj test/test_other_exn.cmi test/test_other_exn.cmj test/test_pack.cmi test/test_pack.cmj test/test_per.cmi test/test_per.cmj test/test_pervasive.cmi test/test_pervasive.cmj test/test_pervasives2.cmi test/test_pervasives2.cmj test/test_pervasives3.cmi test/test_pervasives3.cmj test/test_primitive.cmi test/test_primitive.cmj test/test_ramification.cmi test/test_ramification.cmj test/test_react.cmi test/test_react.cmj test/test_react_case.cmi test/test_react_case.cmj test/test_regex.cmi test/test_regex.cmj test/test_runtime_encoding.cmi test/test_runtime_encoding.cmj test/test_scope.cmi test/test_scope.cmj test/test_seq.cmi test/test_seq.cmj test/test_set.cmi test/test_set.cmj test/test_side_effect_functor.cmi test/test_side_effect_functor.cmj test/test_simple_include.cmi test/test_simple_include.cmj test/test_simple_pattern_match.cmi test/test_simple_pattern_match.cmj test/test_simple_ref.cmi test/test_simple_ref.cmj test/test_simple_tailcall.cmi test/test_simple_tailcall.cmj test/test_small.cmi test/test_small.cmj test/test_sprintf.cmi test/test_sprintf.cmj test/test_stack.cmi test/test_stack.cmj test/test_static_catch_ident.cmi test/test_static_catch_ident.cmj test/test_string.cmi test/test_string.cmj test/test_string_case.cmi test/test_string_case.cmj test/test_string_const.cmi test/test_string_const.cmj test/test_string_map.cmi test/test_string_map.cmj test/test_string_switch.cmi test/test_string_switch.cmj test/test_switch.cmi test/test_switch.cmj test/test_trywith.cmi test/test_trywith.cmj test/test_tuple.cmi test/test_tuple.cmj test/test_tuple_destructring.cmi test/test_tuple_destructring.cmj test/test_type_based_arity.cmi test/test_type_based_arity.cmj test/test_u.cmi test/test_u.cmj test/test_unknown.cmi test/test_unknown.cmj test/test_unsafe_cmp.cmi test/test_unsafe_cmp.cmj test/test_unsafe_obj_ffi.cmi test/test_unsafe_obj_ffi.cmj test/test_unsafe_obj_ffi_ppx.cmi test/test_unsafe_obj_ffi_ppx.cmj test/test_unsupported_primitive.cmi test/test_unsupported_primitive.cmj test/test_while_closure.cmi test/test_while_closure.cmj test/test_while_side_effect.cmi test/test_while_side_effect.cmj test/test_zero_nullable.cmi test/test_zero_nullable.cmj test/then_mangle_test.cmi test/then_mangle_test.cmj test/ticker.cmi test/ticker.cmj test/to_string_test.cmi test/to_string_test.cmj test/topsort_test.cmi test/topsort_test.cmj test/tramp_fib.cmi test/tramp_fib.cmj test/tuple_alloc.cmi test/tuple_alloc.cmj test/type_disambiguate.cmi test/type_disambiguate.cmj test/typeof_test.cmi test/typeof_test.cmj test/unboxed_attribute.cmi test/unboxed_attribute.cmj test/unboxed_attribute_test.cmi test/unboxed_attribute_test.cmj test/unboxed_crash.cmi test/unboxed_crash.cmj test/unboxed_use_case.cmi test/unboxed_use_case.cmj test/uncurried_cast.cmi test/uncurried_cast.cmj test/uncurried_default.args.cmi test/uncurried_default.args.cmj test/uncurried_pipe.cmi test/uncurried_pipe.cmj test/uncurry_external_test.cmi test/uncurry_external_test.cmj test/uncurry_glob_test.cmi test/uncurry_glob_test.cmj test/uncurry_test.cmi test/uncurry_test.cmj test/undef_regression2_test.cmi test/undef_regression2_test.cmj test/undef_regression_test.cmi test/undef_regression_test.cmj test/undefine_conditional.cmi test/undefine_conditional.cmj test/unicode_type_error.cmi test/unicode_type_error.cmj test/unit_undefined_test.cmi test/unit_undefined_test.cmj test/unitest_string.cmi test/unitest_string.cmj test/unsafe_full_apply_primitive.cmi test/unsafe_full_apply_primitive.cmj test/unsafe_ppx_test.cmi test/unsafe_ppx_test.cmj test/update_record_test.cmi test/update_record_test.cmj test/variant.cmi test/variant.cmj test/variantsMatching.cmi test/variantsMatching.cmj test/webpack_config.cmi test/webpack_config.cmj +o test : phony test/406_primitive_test.cmi test/406_primitive_test.cmj test/AsInUncurriedExternals.cmi test/AsInUncurriedExternals.cmj test/Coercion.cmi test/Coercion.cmj test/DotDotDot.cmi test/DotDotDot.cmj test/EmptyRecord.cmi test/EmptyRecord.cmj test/FFI.cmi test/FFI.cmj test/RecordCoercion.cmi test/RecordCoercion.cmj test/RecordOrObject.cmi test/RecordOrObject.cmj test/SafePromises.cmi test/SafePromises.cmj test/UncurriedAlways.cmi test/UncurriedAlways.cmj test/UncurriedExternals.cmi test/UncurriedExternals.cmj test/UncurriedPervasives.cmi test/UncurriedPervasives.cmj test/UntaggedVariants.cmi test/UntaggedVariants.cmj test/VariantCoercion.cmi test/VariantCoercion.cmj test/VariantSpreads.cmi test/VariantSpreads.cmj test/a.cmi test/a.cmj test/a_filename_test.cmi test/a_filename_test.cmj test/a_list_test.cmi test/a_list_test.cmj test/a_recursive_type.cmi test/a_recursive_type.cmj test/a_scope_bug.cmi test/a_scope_bug.cmj test/a_string_test.cmi test/a_string_test.cmj test/abstract_type.cmi test/abstract_type.cmj test/adt_optimize_test.cmi test/adt_optimize_test.cmj test/alias_default_value_test.cmi test/alias_default_value_test.cmj test/alias_test.cmi test/alias_test.cmj test/and_or_tailcall_test.cmi test/and_or_tailcall_test.cmj test/argv_test.cmi test/argv_test.cmj test/ari_regress_test.cmi test/ari_regress_test.cmj test/arith_lexer.cmi test/arith_lexer.cmj test/arith_parser.cmi test/arith_parser.cmj test/arith_syntax.cmi test/arith_syntax.cmj test/arity.cmi test/arity.cmj test/arity_deopt.cmi test/arity_deopt.cmj test/arity_infer.cmi test/arity_infer.cmj test/array_safe_get.cmi test/array_safe_get.cmj test/array_subtle_test.cmi test/array_subtle_test.cmj test/array_test.cmi test/array_test.cmj test/as_inline_record_test.cmi test/as_inline_record_test.cmj test/ast_abstract_test.cmi test/ast_abstract_test.cmj test/ast_mapper_unused_warning_test.cmi test/ast_mapper_unused_warning_test.cmj test/async_await.cmi test/async_await.cmj test/async_ideas.cmi test/async_ideas.cmj test/async_inline.cmi test/async_inline.cmj test/async_inside_loop.cmi test/async_inside_loop.cmj test/attr_test.cmi test/attr_test.cmj test/b.cmi test/b.cmj test/bal_set_mini.cmi test/bal_set_mini.cmj test/bang_primitive.cmi test/bang_primitive.cmj test/basic_module_test.cmi test/basic_module_test.cmj test/bb.cmi test/bb.cmj test/bdd.cmi test/bdd.cmj test/belt_internal_test.cmi test/belt_internal_test.cmj test/bench.cmi test/bench.cmj test/big_enum.cmi test/big_enum.cmj test/big_polyvar_test.cmi test/big_polyvar_test.cmj test/block_alias_test.cmi test/block_alias_test.cmj test/boolean_test.cmi test/boolean_test.cmj test/bs_abstract_test.cmi test/bs_abstract_test.cmj test/bs_auto_uncurry.cmi test/bs_auto_uncurry.cmj test/bs_auto_uncurry_test.cmi test/bs_auto_uncurry_test.cmj test/bs_ignore_effect.cmi test/bs_ignore_effect.cmj test/bs_ignore_test.cmi test/bs_ignore_test.cmj test/bs_min_max_test.cmi test/bs_min_max_test.cmj test/bs_qualified.cmi test/bs_qualified.cmj test/bs_rbset_int_bench.cmi test/bs_rbset_int_bench.cmj test/bs_rest_test.cmi test/bs_rest_test.cmj test/bs_splice_partial.cmi test/bs_splice_partial.cmj test/bs_string_test.cmi test/bs_string_test.cmj test/bs_unwrap_test.cmi test/bs_unwrap_test.cmj test/buffer_test.cmi test/buffer_test.cmj test/bytes_split_gpr_743_test.cmi test/bytes_split_gpr_743_test.cmj test/caml_compare_bigint_test.cmi test/caml_compare_bigint_test.cmj test/caml_compare_test.cmi test/caml_compare_test.cmj test/caml_format_test.cmi test/caml_format_test.cmj test/chain_code_test.cmi test/chain_code_test.cmj test/chn_test.cmi test/chn_test.cmj test/class_type_ffi_test.cmi test/class_type_ffi_test.cmj test/coercion_module_alias_test.cmi test/coercion_module_alias_test.cmj test/compare_test.cmi test/compare_test.cmj test/complete_parmatch_test.cmi test/complete_parmatch_test.cmj test/complex_if_test.cmi test/complex_if_test.cmj test/complex_test.cmi test/complex_test.cmj test/complex_while_loop.cmi test/complex_while_loop.cmj test/condition_compilation_test.cmi test/condition_compilation_test.cmj test/config1_test.cmi test/config1_test.cmj test/console_log_test.cmi test/console_log_test.cmj test/const_block_test.cmi test/const_block_test.cmj test/const_defs.cmi test/const_defs.cmj test/const_defs_test.cmi test/const_defs_test.cmj test/const_test.cmi test/const_test.cmj test/cont_int_fold_test.cmi test/cont_int_fold_test.cmj test/cps_test.cmi test/cps_test.cmj test/cross_module_inline_test.cmi test/cross_module_inline_test.cmj test/custom_error_test.cmi test/custom_error_test.cmj test/debug_keep_test.cmi test/debug_keep_test.cmj test/debug_mode_value.cmi test/debug_mode_value.cmj test/debug_tmp.cmi test/debug_tmp.cmj test/debugger_test.cmi test/debugger_test.cmj test/default_export_test.cmi test/default_export_test.cmj test/defunctor_make_test.cmi test/defunctor_make_test.cmj test/demo_int_map.cmi test/demo_int_map.cmj test/demo_page.cmi test/demo_page.cmj test/demo_pipe.cmi test/demo_pipe.cmj test/derive_dyntype.cmi test/derive_dyntype.cmj test/derive_projector_test.cmi test/derive_projector_test.cmj test/derive_type_test.cmi test/derive_type_test.cmj test/digest_test.cmi test/digest_test.cmj test/directives.cmi test/directives.cmj test/div_by_zero_test.cmi test/div_by_zero_test.cmj test/dollar_escape_test.cmi test/dollar_escape_test.cmj test/earger_curry_test.cmi test/earger_curry_test.cmj test/effect.cmi test/effect.cmj test/epsilon_test.cmi test/epsilon_test.cmj test/equal_box_test.cmi test/equal_box_test.cmj test/equal_exception_test.cmi test/equal_exception_test.cmj test/equal_test.cmi test/equal_test.cmj test/es6_export.cmi test/es6_export.cmj test/es6_import.cmi test/es6_import.cmj test/es6_module_test.cmi test/es6_module_test.cmj test/escape_esmodule.cmi test/escape_esmodule.cmj test/esmodule_ref.cmi test/esmodule_ref.cmj test/event_ffi.cmi test/event_ffi.cmj test/exception_alias.cmi test/exception_alias.cmj test/exception_raise_test.cmi test/exception_raise_test.cmj test/exception_rebound_err_test.cmi test/exception_rebound_err_test.cmj test/exception_value_test.cmi test/exception_value_test.cmj test/exponentiation_precedence_test.cmi test/exponentiation_precedence_test.cmj test/export_keyword.cmi test/export_keyword.cmj test/ext_array_test.cmi test/ext_array_test.cmj test/ext_bytes_test.cmi test/ext_bytes_test.cmj test/ext_filename_test.cmi test/ext_filename_test.cmj test/ext_list_test.cmi test/ext_list_test.cmj test/ext_pervasives_test.cmi test/ext_pervasives_test.cmj test/ext_string_test.cmi test/ext_string_test.cmj test/ext_sys_test.cmi test/ext_sys_test.cmj test/extensible_variant_test.cmi test/extensible_variant_test.cmj test/external_polyfill_test.cmi test/external_polyfill_test.cmj test/external_ppx.cmi test/external_ppx.cmj test/external_ppx2.cmi test/external_ppx2.cmj test/fail_comp.cmi test/fail_comp.cmj test/ffi_arity_test.cmi test/ffi_arity_test.cmj test/ffi_array_test.cmi test/ffi_array_test.cmj test/ffi_js_test.cmi test/ffi_js_test.cmj test/ffi_splice_test.cmi test/ffi_splice_test.cmj test/ffi_test.cmi test/ffi_test.cmj test/fib.cmi test/fib.cmj test/flattern_order_test.cmi test/flattern_order_test.cmj test/flexible_array_test.cmi test/flexible_array_test.cmj test/float_array.cmi test/float_array.cmj test/float_of_bits_test.cmi test/float_of_bits_test.cmj test/float_record.cmi test/float_record.cmj test/float_test.cmi test/float_test.cmj test/floatarray_test.cmi test/floatarray_test.cmj test/for_loop_test.cmi test/for_loop_test.cmj test/for_side_effect_test.cmi test/for_side_effect_test.cmj test/format_regression.cmi test/format_regression.cmj test/format_test.cmi test/format_test.cmj test/fun_pattern_match.cmi test/fun_pattern_match.cmj test/functor_app_test.cmi test/functor_app_test.cmj test/functor_def.cmi test/functor_def.cmj test/functor_ffi.cmi test/functor_ffi.cmj test/functor_inst.cmi test/functor_inst.cmj test/functors.cmi test/functors.cmj test/gbk.cmi test/gbk.cmj test/genlex_test.cmi test/genlex_test.cmj test/gentTypeReTest.cmi test/gentTypeReTest.cmj test/global_exception_regression_test.cmi test/global_exception_regression_test.cmj test/global_mangles.cmi test/global_mangles.cmj test/global_module_alias_test.cmi test/global_module_alias_test.cmj test/google_closure_test.cmi test/google_closure_test.cmj test/gpr496_test.cmi test/gpr496_test.cmj test/gpr_1072.cmi test/gpr_1072.cmj test/gpr_1072_reg.cmi test/gpr_1072_reg.cmj test/gpr_1150.cmi test/gpr_1150.cmj test/gpr_1154_test.cmi test/gpr_1154_test.cmj test/gpr_1170.cmi test/gpr_1170.cmj test/gpr_1240_missing_unbox.cmi test/gpr_1240_missing_unbox.cmj test/gpr_1245_test.cmi test/gpr_1245_test.cmj test/gpr_1268.cmi test/gpr_1268.cmj test/gpr_1409_test.cmi test/gpr_1409_test.cmj test/gpr_1423_app_test.cmi test/gpr_1423_app_test.cmj test/gpr_1423_nav.cmi test/gpr_1423_nav.cmj test/gpr_1438.cmi test/gpr_1438.cmj test/gpr_1481.cmi test/gpr_1481.cmj test/gpr_1484.cmi test/gpr_1484.cmj test/gpr_1503_test.cmi test/gpr_1503_test.cmj test/gpr_1539_test.cmi test/gpr_1539_test.cmj test/gpr_1658_test.cmi test/gpr_1658_test.cmj test/gpr_1667_test.cmi test/gpr_1667_test.cmj test/gpr_1692_test.cmi test/gpr_1692_test.cmj test/gpr_1698_test.cmi test/gpr_1698_test.cmj test/gpr_1701_test.cmi test/gpr_1701_test.cmj test/gpr_1716_test.cmi test/gpr_1716_test.cmj test/gpr_1717_test.cmi test/gpr_1717_test.cmj test/gpr_1728_test.cmi test/gpr_1728_test.cmj test/gpr_1749_test.cmi test/gpr_1749_test.cmj test/gpr_1759_test.cmi test/gpr_1759_test.cmj test/gpr_1760_test.cmi test/gpr_1760_test.cmj test/gpr_1762_test.cmi test/gpr_1762_test.cmj test/gpr_1817_test.cmi test/gpr_1817_test.cmj test/gpr_1822_test.cmi test/gpr_1822_test.cmj test/gpr_1891_test.cmi test/gpr_1891_test.cmj test/gpr_1943_test.cmi test/gpr_1943_test.cmj test/gpr_1946_test.cmi test/gpr_1946_test.cmj test/gpr_2316_test.cmi test/gpr_2316_test.cmj test/gpr_2352_test.cmi test/gpr_2352_test.cmj test/gpr_2413_test.cmi test/gpr_2413_test.cmj test/gpr_2474.cmi test/gpr_2474.cmj test/gpr_2503_test.cmi test/gpr_2503_test.cmj test/gpr_2608_test.cmi test/gpr_2608_test.cmj test/gpr_2614_test.cmi test/gpr_2614_test.cmj test/gpr_2633_test.cmi test/gpr_2633_test.cmj test/gpr_2642_test.cmi test/gpr_2642_test.cmj test/gpr_2682_test.cmi test/gpr_2682_test.cmj test/gpr_2700_test.cmi test/gpr_2700_test.cmj test/gpr_2731_test.cmi test/gpr_2731_test.cmj test/gpr_2789_test.cmi test/gpr_2789_test.cmj test/gpr_2931_test.cmi test/gpr_2931_test.cmj test/gpr_3142_test.cmi test/gpr_3142_test.cmj test/gpr_3154_test.cmi test/gpr_3154_test.cmj test/gpr_3209_test.cmi test/gpr_3209_test.cmj test/gpr_3492_test.cmi test/gpr_3492_test.cmj test/gpr_3519_jsx_test.cmi test/gpr_3519_jsx_test.cmj test/gpr_3519_test.cmi test/gpr_3519_test.cmj test/gpr_3536_test.cmi test/gpr_3536_test.cmj test/gpr_3546_test.cmi test/gpr_3546_test.cmj test/gpr_3548_test.cmi test/gpr_3548_test.cmj test/gpr_3549_test.cmi test/gpr_3549_test.cmj test/gpr_3566_drive_test.cmi test/gpr_3566_drive_test.cmj test/gpr_3566_test.cmi test/gpr_3566_test.cmj test/gpr_3595_test.cmi test/gpr_3595_test.cmj test/gpr_3609_test.cmi test/gpr_3609_test.cmj test/gpr_3697_test.cmi test/gpr_3697_test.cmj test/gpr_373_test.cmi test/gpr_373_test.cmj test/gpr_3770_test.cmi test/gpr_3770_test.cmj test/gpr_3852_alias.cmi test/gpr_3852_alias.cmj test/gpr_3852_alias_reify.cmi test/gpr_3852_alias_reify.cmj test/gpr_3852_effect.cmi test/gpr_3852_effect.cmj test/gpr_3865.cmi test/gpr_3865.cmj test/gpr_3865_bar.cmi test/gpr_3865_bar.cmj test/gpr_3865_foo.cmi test/gpr_3865_foo.cmj test/gpr_3875_test.cmi test/gpr_3875_test.cmj test/gpr_3877_test.cmi test/gpr_3877_test.cmj test/gpr_3895_test.cmi test/gpr_3895_test.cmj test/gpr_3897_test.cmi test/gpr_3897_test.cmj test/gpr_3931_test.cmi test/gpr_3931_test.cmj test/gpr_3980_test.cmi test/gpr_3980_test.cmj test/gpr_4025_test.cmi test/gpr_4025_test.cmj test/gpr_405_test.cmi test/gpr_405_test.cmj test/gpr_4069_test.cmi test/gpr_4069_test.cmj test/gpr_4280_test.cmi test/gpr_4280_test.cmj test/gpr_4407_test.cmi test/gpr_4407_test.cmj test/gpr_441.cmi test/gpr_441.cmj test/gpr_4442_test.cmi test/gpr_4442_test.cmj test/gpr_4491_test.cmi test/gpr_4491_test.cmj test/gpr_4494_test.cmi test/gpr_4494_test.cmj test/gpr_4519_test.cmi test/gpr_4519_test.cmj test/gpr_459_test.cmi test/gpr_459_test.cmj test/gpr_4632.cmi test/gpr_4632.cmj test/gpr_4639_test.cmi test/gpr_4639_test.cmj test/gpr_4900_test.cmi test/gpr_4900_test.cmj test/gpr_4924_test.cmi test/gpr_4924_test.cmj test/gpr_4931.cmi test/gpr_4931.cmj test/gpr_4931_allow.cmi test/gpr_4931_allow.cmj test/gpr_5071_test.cmi test/gpr_5071_test.cmj test/gpr_5169_test.cmi test/gpr_5169_test.cmj test/gpr_5218_test.cmi test/gpr_5218_test.cmj test/gpr_5280_optimize_test.cmi test/gpr_5280_optimize_test.cmj test/gpr_5312.cmi test/gpr_5312.cmj test/gpr_5557.cmi test/gpr_5557.cmj test/gpr_5753.cmi test/gpr_5753.cmj test/gpr_658.cmi test/gpr_658.cmj test/gpr_858_test.cmi test/gpr_858_test.cmj test/gpr_858_unit2_test.cmi test/gpr_858_unit2_test.cmj test/gpr_904_test.cmi test/gpr_904_test.cmj test/gpr_974_test.cmi test/gpr_974_test.cmj test/gpr_977_test.cmi test/gpr_977_test.cmj test/gpr_return_type_unused_attribute.cmi test/gpr_return_type_unused_attribute.cmj test/gray_code_test.cmi test/gray_code_test.cmj test/guide_for_ext.cmi test/guide_for_ext.cmj test/hamming_test.cmi test/hamming_test.cmj test/hash_collision_test.cmi test/hash_collision_test.cmj test/hash_sugar_desugar.cmi test/hash_sugar_desugar.cmj test/hash_test.cmi test/hash_test.cmj test/hashtbl_test.cmi test/hashtbl_test.cmj test/hello.foo.cmi test/hello.foo.cmj test/hello_res.cmi test/hello_res.cmj test/ignore_test.cmi test/ignore_test.cmj test/import_side_effect.cmi test/import_side_effect.cmj test/import_side_effect_free.cmi test/import_side_effect_free.cmj test/include_side_effect.cmi test/include_side_effect.cmj test/include_side_effect_free.cmi test/include_side_effect_free.cmj test/incomplete_toplevel_test.cmi test/incomplete_toplevel_test.cmj test/infer_type_test.cmi test/infer_type_test.cmj test/inline_condition_with_pattern_matching.cmi test/inline_condition_with_pattern_matching.cmj test/inline_const.cmi test/inline_const.cmj test/inline_const_test.cmi test/inline_const_test.cmj test/inline_edge_cases.cmi test/inline_edge_cases.cmj test/inline_map2_test.cmi test/inline_map2_test.cmj test/inline_map_demo.cmi test/inline_map_demo.cmj test/inline_map_test.cmi test/inline_map_test.cmj test/inline_record_test.cmi test/inline_record_test.cmj test/inline_regression_test.cmi test/inline_regression_test.cmj test/inline_string_test.cmi test/inline_string_test.cmj test/inner_call.cmi test/inner_call.cmj test/inner_define.cmi test/inner_define.cmj test/inner_unused.cmi test/inner_unused.cmj test/installation_test.cmi test/installation_test.cmj test/int32_test.cmi test/int32_test.cmj test/int64_mul_div_test.cmi test/int64_mul_div_test.cmj test/int64_string_bench.cmi test/int64_string_bench.cmj test/int64_string_test.cmi test/int64_string_test.cmj test/int64_test.cmi test/int64_test.cmj test/int_hashtbl_test.cmi test/int_hashtbl_test.cmj test/int_map.cmi test/int_map.cmj test/int_overflow_test.cmi test/int_overflow_test.cmj test/int_poly_var.cmi test/int_poly_var.cmj test/int_switch_test.cmi test/int_switch_test.cmj test/internal_unused_test.cmi test/internal_unused_test.cmj test/io_test.cmi test/io_test.cmj test/js_array_test.cmi test/js_array_test.cmj test/js_bool_test.cmi test/js_bool_test.cmj test/js_cast_test.cmi test/js_cast_test.cmj test/js_date_test.cmi test/js_date_test.cmj test/js_dict_test.cmi test/js_dict_test.cmj test/js_exception_catch_test.cmi test/js_exception_catch_test.cmj test/js_float_test.cmi test/js_float_test.cmj test/js_global_test.cmi test/js_global_test.cmj test/js_int_test.cmi test/js_int_test.cmj test/js_json_test.cmi test/js_json_test.cmj test/js_list_test.cmi test/js_list_test.cmj test/js_math_test.cmi test/js_math_test.cmj test/js_null_test.cmi test/js_null_test.cmj test/js_null_undefined_test.cmi test/js_null_undefined_test.cmj test/js_nullable_test.cmi test/js_nullable_test.cmj test/js_obj_test.cmi test/js_obj_test.cmj test/js_option_test.cmi test/js_option_test.cmj test/js_re_test.cmi test/js_re_test.cmj test/js_string_test.cmi test/js_string_test.cmj test/js_typed_array_test.cmi test/js_typed_array_test.cmj test/js_undefined_test.cmi test/js_undefined_test.cmj test/js_val.cmi test/js_val.cmj test/jsoo_400_test.cmi test/jsoo_400_test.cmj test/jsoo_485_test.cmi test/jsoo_485_test.cmj test/jsxv4_newtype.cmi test/jsxv4_newtype.cmj test/key_word_property.cmi test/key_word_property.cmj test/key_word_property2.cmi test/key_word_property2.cmj test/key_word_property_plus_test.cmi test/key_word_property_plus_test.cmj test/label_uncurry.cmi test/label_uncurry.cmj test/large_integer_pat.cmi test/large_integer_pat.cmj test/large_record_duplication_test.cmi test/large_record_duplication_test.cmj test/largest_int_flow.cmi test/largest_int_flow.cmj test/lazy_demo.cmi test/lazy_demo.cmj test/lazy_test.cmi test/lazy_test.cmj test/lib_js_test.cmi test/lib_js_test.cmj test/libarg_test.cmi test/libarg_test.cmj test/libqueue_test.cmi test/libqueue_test.cmj test/limits_test.cmi test/limits_test.cmj test/list_stack.cmi test/list_stack.cmj test/list_test.cmi test/list_test.cmj test/local_exception_test.cmi test/local_exception_test.cmj test/loop_regression_test.cmi test/loop_regression_test.cmj test/loop_suites_test.cmi test/loop_suites_test.cmj test/map_find_test.cmi test/map_find_test.cmj test/map_test.cmi test/map_test.cmj test/mario_game.cmi test/mario_game.cmj test/marshal.cmi test/marshal.cmj test/meth_annotation.cmi test/meth_annotation.cmj test/method_name_test.cmi test/method_name_test.cmj test/method_string_name.cmi test/method_string_name.cmj test/minimal_test.cmi test/minimal_test.cmj test/miss_colon_test.cmi test/miss_colon_test.cmj test/mock_mt.cmi test/mock_mt.cmj test/module_alias_test.cmi test/module_alias_test.cmj test/module_as_class_ffi.cmi test/module_as_class_ffi.cmj test/module_as_function.cmi test/module_as_function.cmj test/module_missing_conversion.cmi test/module_missing_conversion.cmj test/module_parameter_test.cmi test/module_parameter_test.cmj test/module_splice_test.cmi test/module_splice_test.cmj test/more_poly_variant_test.cmi test/more_poly_variant_test.cmj test/more_uncurry.cmi test/more_uncurry.cmj test/mpr_6033_test.cmi test/mpr_6033_test.cmj test/mt.cmi test/mt.cmj test/mt_global.cmi test/mt_global.cmj test/mutable_obj_test.cmi test/mutable_obj_test.cmj test/mutable_uncurry_test.cmi test/mutable_uncurry_test.cmj test/mutual_non_recursive_type.cmi test/mutual_non_recursive_type.cmj test/name_mangle_test.cmi test/name_mangle_test.cmj test/nested_include.cmi test/nested_include.cmj test/nested_module_alias.cmi test/nested_module_alias.cmj test/nested_obj_literal.cmi test/nested_obj_literal.cmj test/nested_obj_test.cmi test/nested_obj_test.cmj test/nested_pattern_match_test.cmi test/nested_pattern_match_test.cmj test/noassert.cmi test/noassert.cmj test/node_path_test.cmi test/node_path_test.cmj test/null_list_test.cmi test/null_list_test.cmj test/number_lexer.cmi test/number_lexer.cmj test/obj_literal_ppx.cmi test/obj_literal_ppx.cmj test/obj_literal_ppx_test.cmi test/obj_literal_ppx_test.cmj test/obj_magic_test.cmi test/obj_magic_test.cmj test/obj_type_test.cmi test/obj_type_test.cmj test/ocaml_re_test.cmi test/ocaml_re_test.cmj test/of_string_test.cmi test/of_string_test.cmj test/offset.cmi test/offset.cmj test/option_encoding_test.cmi test/option_encoding_test.cmj test/option_record_none_test.cmi test/option_record_none_test.cmj test/optional_ffi_test.cmi test/optional_ffi_test.cmj test/optional_regression_test.cmi test/optional_regression_test.cmj test/pipe_send_readline.cmi test/pipe_send_readline.cmj test/pipe_syntax.cmi test/pipe_syntax.cmj test/poly_empty_array.cmi test/poly_empty_array.cmj test/poly_variant_test.cmi test/poly_variant_test.cmj test/polymorphic_raw_test.cmi test/polymorphic_raw_test.cmj test/polymorphism_test.cmi test/polymorphism_test.cmj test/polyvar_convert.cmi test/polyvar_convert.cmj test/polyvar_test.cmi test/polyvar_test.cmj test/ppx_apply_test.cmi test/ppx_apply_test.cmj test/pq_test.cmi test/pq_test.cmj test/pr6726.cmi test/pr6726.cmj test/pr_regression_test.cmi test/pr_regression_test.cmj test/prepend_data_ffi.cmi test/prepend_data_ffi.cmj test/primitive_reg_test.cmi test/primitive_reg_test.cmj test/print_alpha_test.cmi test/print_alpha_test.cmj test/queue_402.cmi test/queue_402.cmj test/queue_test.cmi test/queue_test.cmj test/random_test.cmi test/random_test.cmj test/raw_hash_tbl_bench.cmi test/raw_hash_tbl_bench.cmj test/raw_output_test.cmi test/raw_output_test.cmj test/raw_pure_test.cmi test/raw_pure_test.cmj test/rbset.cmi test/rbset.cmj test/react.cmi test/react.cmj test/reactDOMRe.cmi test/reactDOMRe.cmj test/reactDOMServerRe.cmi test/reactDOMServerRe.cmj test/reactEvent.cmi test/reactEvent.cmj test/reactTestUtils.cmi test/reactTestUtils.cmj test/reasonReact.cmi test/reasonReact.cmj test/reasonReactCompat.cmi test/reasonReactCompat.cmj test/reasonReactOptimizedCreateClass.cmi test/reasonReactOptimizedCreateClass.cmj test/reasonReactRouter.cmi test/reasonReactRouter.cmj test/rebind_module.cmi test/rebind_module.cmj test/rebind_module_test.cmi test/rebind_module_test.cmj test/rec_array_test.cmi test/rec_array_test.cmj test/rec_fun_test.cmi test/rec_fun_test.cmj test/rec_module_opt.cmi test/rec_module_opt.cmj test/rec_module_test.cmi test/rec_module_test.cmj test/recmodule.cmi test/recmodule.cmj test/record_debug_test.cmi test/record_debug_test.cmj test/record_extension_test.cmi test/record_extension_test.cmj test/record_name_test.cmi test/record_name_test.cmj test/record_regression.cmi test/record_regression.cmj test/record_type_spread.cmi test/record_type_spread.cmj test/record_with_test.cmi test/record_with_test.cmj test/recursive_module.cmi test/recursive_module.cmj test/recursive_module_test.cmi test/recursive_module_test.cmj test/recursive_react_component.cmi test/recursive_react_component.cmj test/recursive_records_test.cmi test/recursive_records_test.cmj test/recursive_unbound_module_test.cmi test/recursive_unbound_module_test.cmj test/regression_print.cmi test/regression_print.cmj test/relative_path.cmi test/relative_path.cmj test/res_debug.cmi test/res_debug.cmj test/return_check.cmi test/return_check.cmj test/runtime_encoding_test.cmi test/runtime_encoding_test.cmj test/set_annotation.cmi test/set_annotation.cmj test/set_gen.cmi test/set_gen.cmj test/sexp.cmi test/sexp.cmj test/sexpm.cmi test/sexpm.cmj test/sexpm_test.cmi test/sexpm_test.cmj test/side_effect.cmi test/side_effect.cmj test/side_effect2.cmi test/side_effect2.cmj test/side_effect_free.cmi test/side_effect_free.cmj test/simple_derive_test.cmi test/simple_derive_test.cmj test/simple_derive_use.cmi test/simple_derive_use.cmj test/simplify_lambda_632o.cmi test/simplify_lambda_632o.cmj test/single_module_alias.cmi test/single_module_alias.cmj test/singular_unit_test.cmi test/singular_unit_test.cmj test/small_inline_test.cmi test/small_inline_test.cmj test/splice_test.cmi test/splice_test.cmj test/stack_comp_test.cmi test/stack_comp_test.cmj test/stack_test.cmi test/stack_test.cmj test/stream_parser_test.cmi test/stream_parser_test.cmj test/string_bound_get_test.cmi test/string_bound_get_test.cmj test/string_constant_compare.cmi test/string_constant_compare.cmj test/string_get_set_test.cmi test/string_get_set_test.cmj test/string_runtime_test.cmi test/string_runtime_test.cmj test/string_set.cmi test/string_set.cmj test/string_set_test.cmi test/string_set_test.cmj test/string_test.cmi test/string_test.cmj test/string_unicode_test.cmi test/string_unicode_test.cmj test/stringmatch_test.cmi test/stringmatch_test.cmj test/submodule.cmi test/submodule.cmj test/submodule_call.cmi test/submodule_call.cmj test/switch_case_test.cmi test/switch_case_test.cmj test/switch_string.cmi test/switch_string.cmj test/tailcall_inline_test.cmi test/tailcall_inline_test.cmj test/template.cmi test/template.cmj test/test.cmi test/test.cmj test/test2.cmi test/test2.cmj test/test_alias.cmi test/test_alias.cmj test/test_ari.cmi test/test_ari.cmj test/test_array.cmi test/test_array.cmj test/test_array_append.cmi test/test_array_append.cmj test/test_array_primitive.cmi test/test_array_primitive.cmj test/test_bool_equal.cmi test/test_bool_equal.cmj test/test_bs_this.cmi test/test_bs_this.cmj test/test_bug.cmi test/test_bug.cmj test/test_bytes.cmi test/test_bytes.cmj test/test_case_opt_collision.cmi test/test_case_opt_collision.cmj test/test_case_set.cmi test/test_case_set.cmj test/test_char.cmi test/test_char.cmj test/test_closure.cmi test/test_closure.cmj test/test_common.cmi test/test_common.cmj test/test_const_elim.cmi test/test_const_elim.cmj test/test_const_propogate.cmi test/test_const_propogate.cmj test/test_cpp.cmi test/test_cpp.cmj test/test_cps.cmi test/test_cps.cmj test/test_demo.cmi test/test_demo.cmj test/test_dup_param.cmi test/test_dup_param.cmj test/test_eq.cmi test/test_eq.cmj test/test_exception.cmi test/test_exception.cmj test/test_exception_escape.cmi test/test_exception_escape.cmj test/test_export2.cmi test/test_export2.cmj test/test_external.cmi test/test_external.cmj test/test_external_unit.cmi test/test_external_unit.cmj test/test_ffi.cmi test/test_ffi.cmj test/test_fib.cmi test/test_fib.cmj test/test_filename.cmi test/test_filename.cmj test/test_for_loop.cmi test/test_for_loop.cmj test/test_for_map.cmi test/test_for_map.cmj test/test_for_map2.cmi test/test_for_map2.cmj test/test_format.cmi test/test_format.cmj test/test_formatter.cmi test/test_formatter.cmj test/test_functor_dead_code.cmi test/test_functor_dead_code.cmj test/test_generative_module.cmi test/test_generative_module.cmj test/test_global_print.cmi test/test_global_print.cmj test/test_google_closure.cmi test/test_google_closure.cmj test/test_include.cmi test/test_include.cmj test/test_incomplete.cmi test/test_incomplete.cmj test/test_incr_ref.cmi test/test_incr_ref.cmj test/test_int_map_find.cmi test/test_int_map_find.cmj test/test_internalOO.cmi test/test_internalOO.cmj test/test_is_js.cmi test/test_is_js.cmj test/test_js_ffi.cmi test/test_js_ffi.cmj test/test_let.cmi test/test_let.cmj test/test_list.cmi test/test_list.cmj test/test_literal.cmi test/test_literal.cmj test/test_literals.cmi test/test_literals.cmj test/test_match_exception.cmi test/test_match_exception.cmj test/test_mutliple.cmi test/test_mutliple.cmj test/test_nat64.cmi test/test_nat64.cmj test/test_nested_let.cmi test/test_nested_let.cmj test/test_nested_print.cmi test/test_nested_print.cmj test/test_non_export.cmi test/test_non_export.cmj test/test_nullary.cmi test/test_nullary.cmj test/test_obj.cmi test/test_obj.cmj test/test_order.cmi test/test_order.cmj test/test_order_tailcall.cmi test/test_order_tailcall.cmj test/test_other_exn.cmi test/test_other_exn.cmj test/test_pack.cmi test/test_pack.cmj test/test_per.cmi test/test_per.cmj test/test_pervasive.cmi test/test_pervasive.cmj test/test_pervasives2.cmi test/test_pervasives2.cmj test/test_pervasives3.cmi test/test_pervasives3.cmj test/test_primitive.cmi test/test_primitive.cmj test/test_ramification.cmi test/test_ramification.cmj test/test_react.cmi test/test_react.cmj test/test_react_case.cmi test/test_react_case.cmj test/test_regex.cmi test/test_regex.cmj test/test_runtime_encoding.cmi test/test_runtime_encoding.cmj test/test_scope.cmi test/test_scope.cmj test/test_seq.cmi test/test_seq.cmj test/test_set.cmi test/test_set.cmj test/test_side_effect_functor.cmi test/test_side_effect_functor.cmj test/test_simple_include.cmi test/test_simple_include.cmj test/test_simple_pattern_match.cmi test/test_simple_pattern_match.cmj test/test_simple_ref.cmi test/test_simple_ref.cmj test/test_simple_tailcall.cmi test/test_simple_tailcall.cmj test/test_small.cmi test/test_small.cmj test/test_sprintf.cmi test/test_sprintf.cmj test/test_stack.cmi test/test_stack.cmj test/test_static_catch_ident.cmi test/test_static_catch_ident.cmj test/test_string.cmi test/test_string.cmj test/test_string_case.cmi test/test_string_case.cmj test/test_string_const.cmi test/test_string_const.cmj test/test_string_map.cmi test/test_string_map.cmj test/test_string_switch.cmi test/test_string_switch.cmj test/test_switch.cmi test/test_switch.cmj test/test_trywith.cmi test/test_trywith.cmj test/test_tuple.cmi test/test_tuple.cmj test/test_tuple_destructring.cmi test/test_tuple_destructring.cmj test/test_type_based_arity.cmi test/test_type_based_arity.cmj test/test_u.cmi test/test_u.cmj test/test_unknown.cmi test/test_unknown.cmj test/test_unsafe_cmp.cmi test/test_unsafe_cmp.cmj test/test_unsafe_obj_ffi.cmi test/test_unsafe_obj_ffi.cmj test/test_unsafe_obj_ffi_ppx.cmi test/test_unsafe_obj_ffi_ppx.cmj test/test_unsupported_primitive.cmi test/test_unsupported_primitive.cmj test/test_while_closure.cmi test/test_while_closure.cmj test/test_while_side_effect.cmi test/test_while_side_effect.cmj test/test_zero_nullable.cmi test/test_zero_nullable.cmj test/then_mangle_test.cmi test/then_mangle_test.cmj test/ticker.cmi test/ticker.cmj test/to_string_test.cmi test/to_string_test.cmj test/topsort_test.cmi test/topsort_test.cmj test/tramp_fib.cmi test/tramp_fib.cmj test/tuple_alloc.cmi test/tuple_alloc.cmj test/type_disambiguate.cmi test/type_disambiguate.cmj test/typeof_test.cmi test/typeof_test.cmj test/unboxed_attribute.cmi test/unboxed_attribute.cmj test/unboxed_attribute_test.cmi test/unboxed_attribute_test.cmj test/unboxed_crash.cmi test/unboxed_crash.cmj test/unboxed_use_case.cmi test/unboxed_use_case.cmj test/uncurried_default.args.cmi test/uncurried_default.args.cmj test/uncurried_pipe.cmi test/uncurried_pipe.cmj test/uncurry_external_test.cmi test/uncurry_external_test.cmj test/uncurry_glob_test.cmi test/uncurry_glob_test.cmj test/uncurry_test.cmi test/uncurry_test.cmj test/undef_regression2_test.cmi test/undef_regression2_test.cmj test/undef_regression_test.cmi test/undef_regression_test.cmj test/undefine_conditional.cmi test/undefine_conditional.cmj test/unicode_type_error.cmi test/unicode_type_error.cmj test/unit_undefined_test.cmi test/unit_undefined_test.cmj test/unitest_string.cmi test/unitest_string.cmj test/unsafe_full_apply_primitive.cmi test/unsafe_full_apply_primitive.cmj test/unsafe_ppx_test.cmi test/unsafe_ppx_test.cmj test/update_record_test.cmi test/update_record_test.cmj test/variant.cmi test/variant.cmj test/variantsMatching.cmi test/variantsMatching.cmj test/webpack_config.cmi test/webpack_config.cmj diff --git a/jscomp/test/digest_test.js b/jscomp/test/digest_test.js index fe38db27769..105a3c24dec 100644 --- a/jscomp/test/digest_test.js +++ b/jscomp/test/digest_test.js @@ -219,7 +219,7 @@ Mt.from_pair_suites("Digest_test", Pervasives.$at({ } }, $$Array.to_list($$Array.map((function (i) { return [ - String(i), + i.toString(), (function (param) { return { TAG: "Eq", diff --git a/jscomp/test/digest_test.res b/jscomp/test/digest_test.res index 8c9f0edce6d..fb084d160d1 100644 --- a/jscomp/test/digest_test.res +++ b/jscomp/test/digest_test.res @@ -190,7 +190,7 @@ let f = x => \"@@"(Digest.to_hex, Digest.string(x)) Ext_array_test.range(0, 129) |> Array.map(i => ( - Belt.Int.toString(i), + Js.Int.toString(i), _ => Mt.Eq(\"@@"(Digest.to_hex, \"@@"(Digest.string, String.make(i, 'a'))), ref[i]), )) |> Array.to_list diff --git a/jscomp/test/directives.js b/jscomp/test/directives.js index bb2c1a80d85..b0d38ee5f86 100644 --- a/jscomp/test/directives.js +++ b/jscomp/test/directives.js @@ -3,9 +3,9 @@ second directive; // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -var Belt_Array = require("../../lib/js/belt_Array.js"); +var $$Array = require("../../lib/js/array.js"); -var a = Belt_Array.forEach; +var a = $$Array.iter; exports.a = a; /* No side effect */ diff --git a/jscomp/test/directives.res b/jscomp/test/directives.res index 7e7c2e7863c..ce55587d7c1 100644 --- a/jscomp/test/directives.res +++ b/jscomp/test/directives.res @@ -1,5 +1,5 @@ @@directive("first directive;") @@directive("second directive;") -let a = Belt.Array.forEach +let a = Array.iter diff --git a/jscomp/test/gpr_2487.js b/jscomp/test/gpr_2487.js deleted file mode 100644 index 6bf5991877b..00000000000 --- a/jscomp/test/gpr_2487.js +++ /dev/null @@ -1,22 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Belt_Array = require("../../lib/js/belt_Array.js"); - -var b = Belt_Array.eq([ - 1, - 2, - 3 - ], [ - 1, - 2, - 3 - ], (function (prim0, prim1) { - return prim0 === prim1; - })); - -var A; - -exports.A = A; -exports.b = b; -/* b Not a pure module */ diff --git a/jscomp/test/gpr_2487.res b/jscomp/test/gpr_2487.res deleted file mode 100644 index 8a2763c4271..00000000000 --- a/jscomp/test/gpr_2487.res +++ /dev/null @@ -1,3 +0,0 @@ -module A = Belt.Array - -let b = A.eq([1, 2, 3], [1, 2, 3], \"=") diff --git a/jscomp/test/gpr_4265_test.js b/jscomp/test/gpr_4265_test.js deleted file mode 100644 index b5e9236bb5a..00000000000 --- a/jscomp/test/gpr_4265_test.js +++ /dev/null @@ -1,55 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Belt_MutableMapInt = require("../../lib/js/belt_MutableMapInt.js"); -var Belt_internalMapInt = require("../../lib/js/belt_internalMapInt.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -var mockMap = { - data: undefined -}; - -function add(id) { - Belt_MutableMapInt.set(mockMap, id, id); - return id; -} - -function remove(id) { - Belt_MutableMapInt.remove(mockMap, id); -} - -add(1726); - -var n = add(6667); - -add(486); - -Belt_MutableMapInt.remove(mockMap, 1726); - -var n1 = Belt_internalMapInt.getExn(mockMap.data, 6667); - -eq("File \"gpr_4265_test.res\", line 18, characters 3-10", n, n1); - -Mt.from_pair_suites("gpr_4265_test.res", suites.contents); - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.mockMap = mockMap; -exports.add = add; -exports.remove = remove; -exports.n = n; -exports.n1 = n1; -/* Not a pure module */ diff --git a/jscomp/test/gpr_4265_test.res b/jscomp/test/gpr_4265_test.res deleted file mode 100644 index 0db028d430b..00000000000 --- a/jscomp/test/gpr_4265_test.res +++ /dev/null @@ -1,20 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => Mt.eq_suites(~test_id, ~suites, loc, x, y) - -open Belt -let mockMap = MutableMap.Int.make() -let add = id => { - (mockMap->MutableMap.Int.set)(id, id) - id -} -let remove = id => (mockMap->MutableMap.Int.remove)(id) -let _ = add(1726) -let n = add(6667) -let _ = add(486) -let _ = remove(1726) -let n1 = (mockMap->MutableMap.Int.getExn)(6667) - -eq(__LOC__, n, n1) - -Mt.from_pair_suites(__FILE__, suites.contents) diff --git a/jscomp/test/gpr_4274_test.js b/jscomp/test/gpr_4274_test.js deleted file mode 100644 index 55ce7a26408..00000000000 --- a/jscomp/test/gpr_4274_test.js +++ /dev/null @@ -1,40 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Belt_List = require("../../lib/js/belt_List.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); - -var N = {}; - -function f(X, xs) { - X.forEach(xs, { - i: (function (x) { - console.log(x.x); - }) - }); -} - -Belt_List.forEachU({ - hd: { - x: 3 - }, - tl: /* [] */0 - }, (function (x) { - console.log(x.x); - })); - -var Foo = {}; - -var bar = [{ - foo: "bar" - }]; - -Belt_Array.mapU(bar, (function (b) { - return b.foo; - })); - -exports.N = N; -exports.f = f; -exports.Foo = Foo; -exports.bar = bar; -/* Not a pure module */ diff --git a/jscomp/test/gpr_4274_test.res b/jscomp/test/gpr_4274_test.res deleted file mode 100644 index e692133fd7c..00000000000 --- a/jscomp/test/gpr_4274_test.res +++ /dev/null @@ -1,20 +0,0 @@ -module N = { - type t = {x: int} -} - -module type X = { - type f<'a> = {i: 'a} - let forEach: (. array<'a>, f<'a => unit>) => unit -} - -/* type annotation here interferes.. */ -let f = (module(X: X), xs: array) => X.forEach(. xs, {X.i: x => Js.log(x.x)}) - -Belt.List.forEachU(list{{N.x: 3}}, (. x) => Js.log(x.x)) - -module Foo = { - type record = {foo: string} -} -let bar = [{Foo.foo: @reason.raw_literal("bar") "bar"}] - -let _ = Belt.Array.mapU(bar, (. b) => b.foo) diff --git a/jscomp/test/imm_map_bench.js b/jscomp/test/imm_map_bench.js deleted file mode 100644 index 63b569c7c79..00000000000 --- a/jscomp/test/imm_map_bench.js +++ /dev/null @@ -1,74 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Immutable = require("immutable"); -var Belt_Array = require("../../lib/js/belt_Array.js"); -var Belt_MapInt = require("../../lib/js/belt_MapInt.js"); - -var empty = new Immutable.OrderedMap(); - -function fromArray(kvs) { - var v = empty; - for(var i = 0 ,i_finish = kvs.length; i < i_finish; ++i){ - var match = kvs[i]; - v = v.set(match[0], match[1]); - } - return v; -} - -function should(b) { - if (b) { - return ; - } - throw new Error("impossible"); -} - -var shuffledDataAdd = Belt_Array.makeByAndShuffle(1000001, (function (i) { - return [ - i, - i - ]; - })); - -function test(param) { - var v = fromArray(shuffledDataAdd); - for(var j = 0; j <= 1000000; ++j){ - should(v.has(j)); - } -} - -function test2(param) { - var v = Belt_MapInt.fromArray(shuffledDataAdd); - for(var j = 0; j <= 1000000; ++j){ - should(Belt_MapInt.has(v, j)); - } -} - -console.time("imm_map_bench.res 43"); - -test(); - -console.timeEnd("imm_map_bench.res 43"); - -console.time("imm_map_bench.res 44"); - -test2(); - -console.timeEnd("imm_map_bench.res 44"); - -var A; - -var count = 1000000; - -var M; - -exports.A = A; -exports.empty = empty; -exports.fromArray = fromArray; -exports.should = should; -exports.count = count; -exports.shuffledDataAdd = shuffledDataAdd; -exports.test = test; -exports.M = M; -exports.test2 = test2; -/* empty Not a pure module */ diff --git a/jscomp/test/imm_map_bench.res b/jscomp/test/imm_map_bench.res deleted file mode 100644 index b0d4eff625c..00000000000 --- a/jscomp/test/imm_map_bench.res +++ /dev/null @@ -1,44 +0,0 @@ -type map -@new @module("immutable") external empty: unit => map = "OrderedMap" -@send external set: (map, int, int) => map = "set" -@send @return(undefined_to_opt) external get: (map, int) => option = "get" -@send external mem: (map, int) => bool = "has" - -module A = Belt.Array -let empty = empty() -let fromArray = kvs => { - let v = ref(empty) - for i in 0 to A.length(kvs) - 1 { - let (key, value) = A.getUnsafe(kvs, i) - v := set(v.contents, key, value) - } - v.contents -} - -let should = b => - if !b { - Js.Exn.raiseError("impossible") - } - -let count = 1_000_000 - -let shuffledDataAdd = A.makeByAndShuffle(count + 1, i => (i, i)) - -let test = () => { - let v = fromArray(shuffledDataAdd) - for j in 0 to count { - should(mem(v, j)) - } -} - -module M = Belt.Map.Int - -let test2 = () => { - let v = M.fromArray(shuffledDataAdd) - for j in 0 to count { - should(M.has(v, j)) - } -} - -%time(test()) -%time(test2()) diff --git a/jscomp/test/int64_string_test.js b/jscomp/test/int64_string_test.js index af2ed53ebd5..4de08f64a20 100644 --- a/jscomp/test/int64_string_test.js +++ b/jscomp/test/int64_string_test.js @@ -2,8 +2,8 @@ 'use strict'; var Mt = require("./mt.js"); +var List = require("../../lib/js/list.js"); var Int64 = require("../../lib/js/int64.js"); -var Belt_List = require("../../lib/js/belt_List.js"); var Caml_int64 = require("../../lib/js/caml_int64.js"); var suites = { @@ -1304,7 +1304,7 @@ var random_data = { } }; -Belt_List.forEach(random_data, (function (u) { +List.iter((function (u) { if (u) { if (u.tl) { throw { @@ -1329,7 +1329,7 @@ Belt_List.forEach(random_data, (function (u) { ], Error: new Error() }; - })); + }), random_data); eq("File \"int64_string_test.res\", line 195, characters 3-10", Caml_int64.to_string([ -2097152, diff --git a/jscomp/test/int64_string_test.res b/jscomp/test/int64_string_test.res index 804eb3bfcb8..4e01ddaae0c 100644 --- a/jscomp/test/int64_string_test.res +++ b/jscomp/test/int64_string_test.res @@ -185,7 +185,7 @@ let random_data = list{ list{(-8852749148056563032L, "-8852749148056563032")}, } -Belt_List.forEach(random_data, u => +random_data |> List.iter(u => switch u { | list{(v, str)} => eq(__LOC__, Int64.to_string(v), str) | _ => assert(false) diff --git a/jscomp/test/js_json_test.js b/jscomp/test/js_json_test.js index 8068a48e4ca..92a5d799c1e 100644 --- a/jscomp/test/js_json_test.js +++ b/jscomp/test/js_json_test.js @@ -5,8 +5,6 @@ var Mt = require("./mt.js"); var $$Array = require("../../lib/js/array.js"); var Js_dict = require("../../lib/js/js_dict.js"); var Js_json = require("../../lib/js/js_json.js"); -var Belt_List = require("../../lib/js/belt_List.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); var Caml_array = require("../../lib/js/caml_array.js"); var Caml_option = require("../../lib/js/caml_option.js"); @@ -740,37 +738,6 @@ function id(obj) { return Js_json.deserializeUnsafe(Js_json.serializeExn(obj)); } -function idtest(obj) { - eq("File \"js_json_test.res\", line 355, characters 23-30", obj, Js_json.deserializeUnsafe(Js_json.serializeExn(obj))); -} - -idtest(undefined); - -idtest({ - hd: [ - undefined, - undefined, - undefined - ], - tl: /* [] */0 - }); - -idtest(Belt_List.makeBy(500, (function (i) { - if (i % 2 === 0) { - return ; - } else { - return 1; - } - }))); - -idtest(Belt_Array.makeBy(500, (function (i) { - if (i % 2 === 0) { - return ; - } else { - return 1; - } - }))); - Mt.from_pair_suites("Js_json_test", suites.contents); var J; @@ -784,5 +751,4 @@ exports.true_ = true_; exports.option_get = option_get; exports.eq_at_i = eq_at_i; exports.id = id; -exports.idtest = idtest; /* v Not a pure module */ diff --git a/jscomp/test/js_json_test.res b/jscomp/test/js_json_test.res index 04086a7cce2..65961f4dcfa 100644 --- a/jscomp/test/js_json_test.res +++ b/jscomp/test/js_json_test.res @@ -352,28 +352,28 @@ let () = { let id = (type t, obj: t): t => obj->J.serializeExn->J.deserializeUnsafe -let idtest = obj => eq(__LOC__, obj, id(obj)) -let () = { - idtest(None) - idtest(list{(None, None, None)}) - idtest( - Belt.List.makeBy(500, i => - if mod(i, 2) == 0 { - None - } else { - Some(1) - } - ), - ) - idtest( - Belt.Array.makeBy(500, i => - if mod(i, 2) == 0 { - None - } else { - Some(1) - } - ), - ) -} +// let idtest = obj => eq(__LOC__, obj, id(obj)) +// let () = { +// idtest(None) +// idtest(list{(None, None, None)}) +// idtest( +// Belt.List.makeBy(500, i => +// if mod(i, 2) == 0 { +// None +// } else { +// Some(1) +// } +// ), +// ) +// idtest( +// Belt.Array.makeBy(500, i => +// if mod(i, 2) == 0 { +// None +// } else { +// Some(1) +// } +// ), +// ) +// } let () = Mt.from_pair_suites(__MODULE__, suites.contents) diff --git a/jscomp/test/js_string_test.js b/jscomp/test/js_string_test.js index fd1d58dd42e..ea49038caaa 100644 --- a/jscomp/test/js_string_test.js +++ b/jscomp/test/js_string_test.js @@ -2,7 +2,7 @@ 'use strict'; var Mt = require("./mt.js"); -var Belt_Option = require("../../lib/js/belt_Option.js"); +var Js_option = require("../../lib/js/js_option.js"); var Caml_option = require("../../lib/js/caml_option.js"); var suites_0 = [ @@ -282,9 +282,9 @@ var suites_1 = { "hello ", undefined ], - _1: Belt_Option.map(Caml_option.null_to_opt("hello word".match(/hello (world)?/)), (function (prim) { - return prim.slice(); - })) + _1: Js_option.map((function (x) { + return x.slice(); + }), Caml_option.null_to_opt("hello word".match(/hello (world)?/))) }; }) ], diff --git a/jscomp/test/js_string_test.res b/jscomp/test/js_string_test.res index f1ae84d6d8b..506c46aa9f8 100644 --- a/jscomp/test/js_string_test.res +++ b/jscomp/test/js_string_test.res @@ -33,7 +33,7 @@ let suites = { "match - not found capture groups", _ => Eq( Some([Some("hello "), None]), - "hello word"->Js.String2.match_(%re("/hello (world)?/"))->Belt.Option.map(Js.Array.copy), + Js.Option.map(((. x) => Js.Array.copy(x)), "hello word"->Js.String2.match_(%re("/hello (world)?/"))), ), ), /* es2015 */ diff --git a/jscomp/test/option_repr_test.js b/jscomp/test/option_repr_test.js deleted file mode 100644 index a9cf2b9eb81..00000000000 --- a/jscomp/test/option_repr_test.js +++ /dev/null @@ -1,316 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Mt = require("./mt.js"); -var Caml_obj = require("../../lib/js/caml_obj.js"); -var Belt_List = require("../../lib/js/belt_List.js"); -var Caml_option = require("../../lib/js/caml_option.js"); - -var suites = { - contents: /* [] */0 -}; - -var test_id = { - contents: 0 -}; - -function eq(loc, x, y) { - Mt.eq_suites(test_id, suites, loc, x, y); -} - -function b(loc, v) { - Mt.bool_suites(test_id, suites, loc, v); -} - -function f0(x) { - var match = x[1]; - if (match !== undefined && match) { - return 1; - } else { - return 2; - } -} - -function f1(u) { - if (typeof u !== "object") { - return 1; - } else { - return 0; - } -} - -function f2(x, y, zOpt, param) { - var z = zOpt !== undefined ? zOpt : 3; - console.log(x); - if (y !== undefined) { - return y + z | 0; - } else { - return 0; - } -} - -function f3(x) { - if (x !== undefined) { - return 1; - } else { - return 0; - } -} - -function f4(x) { - if (x !== undefined) { - return x + 1 | 0; - } else { - return 0; - } -} - -function f5(a) { - return false; -} - -function f6(a) { - return true; -} - -var f10 = Caml_option.some(Caml_option.some(Caml_option.some(Caml_option.some(undefined)))); - -var f11 = Caml_option.some(f10); - -var randomized = { - contents: false -}; - -function create(randomOpt, param) { - var random = randomOpt !== undefined ? randomOpt : randomized.contents; - if (random) { - return 2; - } else { - return 1; - } -} - -var ff = create(false, undefined); - -function f13(xOpt, yOpt, param) { - var x = xOpt !== undefined ? xOpt : 3; - var y = yOpt !== undefined ? yOpt : 4; - return x + y | 0; -} - -var a = f13(2, undefined, undefined); - -function f12(x) { - return x; -} - -var length_8_id = Belt_List.makeBy(8, (function (x) { - return x; - })); - -var length_10_id = Belt_List.makeBy(10, (function (x) { - return x; - })); - -function f13$1(param) { - return Caml_obj.equal(Belt_List.take(length_10_id, 8), { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }); -} - -b("File \"option_repr_test.res\", line 93, characters 4-11", Caml_obj.lessthan(undefined, null)); - -b("File \"option_repr_test.res\", line 94, characters 4-11", !Caml_obj.greaterthan(undefined, null)); - -b("File \"option_repr_test.res\", line 95, characters 4-11", Caml_obj.greaterthan(null, undefined)); - -b("File \"option_repr_test.res\", line 96, characters 4-11", Caml_obj.lessthan(undefined, Caml_option.some(undefined))); - -b("File \"option_repr_test.res\", line 97, characters 4-11", Caml_obj.greaterthan(Caml_option.some(undefined), undefined)); - -console.log(6, undefined); - -function ltx(a, b) { - if (Caml_obj.lessthan(a, b)) { - return Caml_obj.greaterthan(b, a); - } else { - return false; - } -} - -function gtx(a, b) { - if (Caml_obj.greaterthan(a, b)) { - return Caml_obj.lessthan(b, a); - } else { - return false; - } -} - -function eqx(a, b) { - if (Caml_obj.equal(a, b)) { - return Caml_obj.equal(b, a); - } else { - return false; - } -} - -function neqx(a, b) { - if (Caml_obj.notequal(a, b)) { - return Caml_obj.notequal(b, a); - } else { - return false; - } -} - -function all_true(xs) { - return Belt_List.every(xs, (function (x) { - return x; - })); -} - -var xs_0 = gtx(Caml_option.some(null), Caml_option.some(undefined)); - -var xs = { - hd: xs_0, - tl: /* [] */0 -}; - -b("File \"option_repr_test.res\", line 125, characters 8-15", Belt_List.every(xs, (function (x) { - return x; - }))); - -var xs_0$1 = ltx(Caml_option.some(undefined), 3); - -var xs_1 = { - hd: ltx(Caml_option.some(undefined), Caml_option.some(Caml_option.some(undefined))), - tl: { - hd: ltx(Caml_option.some(undefined), "3"), - tl: { - hd: ltx(Caml_option.some(undefined), true), - tl: { - hd: ltx(Caml_option.some(undefined), false), - tl: { - hd: ltx(false, true), - tl: { - hd: ltx(false, true), - tl: { - hd: ltx(undefined, Caml_option.some(undefined)), - tl: { - hd: ltx(undefined, null), - tl: { - hd: ltx(undefined, (function (x) { - return x; - })), - tl: { - hd: ltx(null, 3), - tl: /* [] */0 - } - } - } - } - } - } - } - } - } -}; - -var xs$1 = { - hd: xs_0$1, - tl: xs_1 -}; - -b("File \"option_repr_test.res\", line 128, characters 4-11", Belt_List.every(xs$1, (function (x) { - return x; - }))); - -var xs_0$2 = eqx(undefined, undefined); - -var xs_1$1 = { - hd: neqx(undefined, null), - tl: { - hd: eqx(Caml_option.some(undefined), Caml_option.some(undefined)), - tl: { - hd: eqx(Caml_option.some(Caml_option.some(undefined)), Caml_option.some(Caml_option.some(undefined))), - tl: { - hd: neqx(Caml_option.some(Caml_option.some(Caml_option.some(undefined))), Caml_option.some(Caml_option.some(undefined))), - tl: /* [] */0 - } - } - } -}; - -var xs$2 = { - hd: xs_0$2, - tl: xs_1$1 -}; - -b("File \"option_repr_test.res\", line 145, characters 4-11", Belt_List.every(xs$2, (function (x) { - return x; - }))); - -function v(x) { - return x; -} - -function v0(x) { - return x; -} - -var N0 = { - v: v, - v0: v0 -}; - -Mt.from_pair_suites("Option_repr_test", suites.contents); - -var f7; - -var f8 = Caml_option.some(undefined); - -var f9 = Caml_option.some(Caml_option.some(undefined)); - -var N; - -var none_arg; - -exports.suites = suites; -exports.test_id = test_id; -exports.eq = eq; -exports.b = b; -exports.f0 = f0; -exports.f1 = f1; -exports.f2 = f2; -exports.f3 = f3; -exports.f4 = f4; -exports.f5 = f5; -exports.f6 = f6; -exports.f7 = f7; -exports.f8 = f8; -exports.f9 = f9; -exports.f10 = f10; -exports.f11 = f11; -exports.randomized = randomized; -exports.create = create; -exports.ff = ff; -exports.a = a; -exports.f12 = f12; -exports.N = N; -exports.length_8_id = length_8_id; -exports.length_10_id = length_10_id; -exports.f13 = f13$1; -exports.none_arg = none_arg; -exports.ltx = ltx; -exports.gtx = gtx; -exports.eqx = eqx; -exports.neqx = neqx; -exports.all_true = all_true; -exports.N0 = N0; -/* ff Not a pure module */ diff --git a/jscomp/test/option_repr_test.res b/jscomp/test/option_repr_test.res deleted file mode 100644 index a57ca374389..00000000000 --- a/jscomp/test/option_repr_test.res +++ /dev/null @@ -1,165 +0,0 @@ -let suites: ref = ref(list{}) -let test_id = ref(0) -let eq = (loc, x, y) => Mt.eq_suites(~suites, ~test_id, loc, x, y) -let b = (loc, v) => Mt.bool_suites(~suites, ~test_id, loc, v) - -type u<'a> = option<'a> = - private - | None - | Some('a) - -let f0 = x => - switch x { - | (_, Some(true)) => 1 - | (_, _) => 2 - } - -type x = A(int, int) | None - -type x0 = Some(int) | None -let f1 = u => - switch u { - | A(_) => 0 - | None => 1 - } - -let f2 = (~x=?, ~y: option=?, ~z=3, ()) => { - Js.log(x) - switch y { - | None => 0 - | Some(y) => y + z - } -} - -let f3 = x => - switch x { - | None => 0 - | Some(_) => 1 - } - -let f4 = x => - switch x { - | None => 0 - | Some(x) => x + 1 - } - -type t<'a> = - | None - | Some('a) -let f5 = a => Some(a) == None - -let f6 = a => Some(a) != None - -let f7 = None - -let f8 = Some(None) - -let f9 = Some(Some(None)) - -let f10 = Some(Some(Some(Some(None)))) - -let f11 = Some(f10) - -let f12 = Some(Some(Some(Some(list{(1, 2)})))) - -let randomized = ref(false) - -let create = (~random=randomized.contents, ()) => - if random { - 2 - } else { - 1 - } - -let ff = create(~random=false, ()) - -let f13 = (~x=3, ~y=4, ()) => x + y - -let a = f13(~x=2, ()) - -let f12 = (x: list<_>) => Some(x) - -module N = Belt.List - -let length_8_id: list = N.makeBy(8, x => x) -let length_10_id: list = N.makeBy(10, x => x) - -type xx<'a> = option<'a> = - | None - | Some('a) -let f13 = () => N.take(length_10_id, 8) == (Some(list{1, 2, 3}): option<_>) - -let () = { - b(__LOC__, None < Some(Js.null)) - b(__LOC__, !(None > Some(Js.null))) - b(__LOC__, Some(Js.null) > None) - b(__LOC__, None < Some(Js.undefined)) - b(__LOC__, Some(Js.undefined) > None) -} - -@val -external log3: ( - ~req: @unwrap - [ - | #String(string) - | #Int(int) - ], - ~opt: @unwrap - [ - | #String(string) - | #Bool(bool) - ]=?, - unit, -) => unit = "console.log" - -let none_arg = None -let _ = log3(~req=#Int(6), ~opt=?none_arg, ()) - -let ltx = (a, b) => a < b && b > a -let gtx = (a, b) => a > b && b < a -let eqx = (a, b) => a == b && b == a -let neqx = (a, b) => a != b && b != a - -let all_true = xs => Belt.List.every(xs, x => x) - -\"@@"(b(__LOC__), all_true(list{gtx(Some(Some(Js.null)), Some(None))})) - -\"@@"( - b(__LOC__), - all_true(list{ - ltx(Some(None), Some(Some(3))), - ltx(Some(None), Some(Some(None))), - ltx(Some(None), Some(Some("3"))), - ltx(Some(None), Some(Some(true))), - ltx(Some(None), Some(Some(false))), - ltx(Some(false), Some(true)), - ltx(Some(Some(false)), Some(Some(true))), - ltx(None, Some(None)), - ltx(None, Some(Js.null)), - ltx(None, Some(x => x)), - ltx(Some(Js.null), Some(Js.Null.return(3))), - }), -) - -\"@@"( - b(__LOC__), - all_true(list{ - eqx(None, None), - neqx(None, Some(Js.null)), - eqx(Some(None), Some(None)), - eqx(Some(Some(None)), Some(Some(None))), - neqx(Some(Some(Some(None))), Some(Some(None))), - }), -) - -module N0 = { - type record = {x: int, mutable y: string} - type t = - | None - | Some(record) - - let v = (x: record): t => Some(x) - let v0 = (x: record): option => Some(x) - /* [v] and [v0] should be just an identity function */ -} -Mt.from_pair_suites(__MODULE__, suites.contents) diff --git a/jscomp/test/reactTestUtils.js b/jscomp/test/reactTestUtils.js index e17fd624afe..26cf660a7df 100644 --- a/jscomp/test/reactTestUtils.js +++ b/jscomp/test/reactTestUtils.js @@ -2,8 +2,7 @@ 'use strict'; var Curry = require("../../lib/js/curry.js"); -var Belt_Array = require("../../lib/js/belt_Array.js"); -var Belt_Option = require("../../lib/js/belt_Option.js"); +var Js_option = require("../../lib/js/js_option.js"); var Caml_option = require("../../lib/js/caml_option.js"); var TestUtils = require("react-dom/test-utils"); @@ -52,15 +51,15 @@ function findByAllSelector(element, selector) { } function findBySelectorAndTextContent(element, selector, content) { - return Belt_Array.getBy(Array.from(element.querySelectorAll(selector)), (function (node) { - return node.textContent === content; - })); + return Caml_option.undefined_to_opt(Array.from(element.querySelectorAll(selector)).find(function (node) { + return node.textContent === content; + })); } function findBySelectorAndPartialTextContent(element, selector, content) { - return Belt_Array.getBy(Array.from(element.querySelectorAll(selector)), (function (node) { - return node.textContent.includes(content); - })); + return Caml_option.undefined_to_opt(Array.from(element.querySelectorAll(selector)).find(function (node) { + return node.textContent.includes(content); + })); } var DOM = { @@ -72,21 +71,23 @@ var DOM = { function prepareContainer(container, param) { var containerElement = document.createElement("div"); - Belt_Option.map(document.body, (function (body) { - return body.appendChild(containerElement); - })); + var body = document.body; + if (body !== undefined) { + Caml_option.valFromOption(body).appendChild(containerElement); + } container.contents = Caml_option.some(containerElement); } function cleanupContainer(container, param) { - Belt_Option.map(container.contents, (function (prim) { - prim.remove(); - })); + var contents = container.contents; + if (contents !== undefined) { + Caml_option.valFromOption(contents).remove(); + } container.contents = undefined; } function getContainer(container) { - return Belt_Option.getExn(container.contents); + return Js_option.getExn(container.contents); } exports.act = act; diff --git a/jscomp/test/reactTestUtils.res b/jscomp/test/reactTestUtils.res index 30b76182ca1..ffa2c1405dc 100644 --- a/jscomp/test/reactTestUtils.res +++ b/jscomp/test/reactTestUtils.res @@ -94,8 +94,6 @@ external appendChild: (Dom.element, Dom.element) => Dom.element = "appendChild" let querySelectorAll = (element, string) => Js.Array.from(querySelectorAll(element, string)) module DOM = { - open Belt - @return(nullable) @get external value: Dom.element => option = "value" @@ -104,30 +102,31 @@ module DOM = { let findByAllSelector = (element, selector) => querySelectorAll(element, selector) let findBySelectorAndTextContent = (element, selector, content) => - querySelectorAll(element, selector)->Array.getBy(node => node->textContent === content) + querySelectorAll(element, selector)->Js.Array2.find(node => node->textContent === content) let findBySelectorAndPartialTextContent = (element, selector, content) => - querySelectorAll(element, selector)->Array.getBy(node => + querySelectorAll(element, selector)->Js.Array2.find(node => node->textContent->Js.String2.includes(content) ) } let prepareContainer = (container: ref>, ()) => { - open Belt - let containerElement = document->createElement("div") - let _ = document->body->Option.map(body => body->appendChild(containerElement)) + switch document->body { + | Some(body) => let _ = body->appendChild(containerElement) + | None => () + } container := Some(containerElement) } let cleanupContainer = (container: ref>, ()) => { - open Belt - - let _ = container.contents->Option.map(remove) + switch container.contents { + | Some(contents) => let _ = contents->remove + | None => () + } container := None } let getContainer = container => { - open Belt - container.contents->Option.getExn + container.contents->Js.Option.getExn } diff --git a/jscomp/test/side_effect2.js b/jscomp/test/side_effect2.js index da6ef1f323b..f450e1354ec 100644 --- a/jscomp/test/side_effect2.js +++ b/jscomp/test/side_effect2.js @@ -1,11 +1,11 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -var Belt_Array = require("../../lib/js/belt_Array.js"); +var $$Array = require("../../lib/js/array.js"); -var a = Belt_Array.map([1], (function (x) { +var a = $$Array.map((function (x) { return x; - })); + }), [1]); exports.a = a; /* a Not a pure module */ diff --git a/jscomp/test/side_effect2.res b/jscomp/test/side_effect2.res index 6d45776b597..036d2742e0b 100644 --- a/jscomp/test/side_effect2.res +++ b/jscomp/test/side_effect2.res @@ -1 +1 @@ -let a = Belt.Array.map([1], x => x) +let a = Array.map(x => x, [1]) diff --git a/jscomp/test/test_bool_equal.res b/jscomp/test/test_bool_equal.res index 304644a39ae..5264d2073f7 100644 --- a/jscomp/test/test_bool_equal.res +++ b/jscomp/test/test_bool_equal.res @@ -70,14 +70,14 @@ let f6 = x => } let f7 = x => - if Belt.Array.length(x) > 0 { + if Array.length(x) > 0 { 1 } else { 2 } let f8 = x => - if Belt.Array.length(x) >= 0 { + if Array.length(x) >= 0 { 1 } else { 2 diff --git a/jscomp/test/uncurried_cast.js b/jscomp/test/uncurried_cast.js deleted file mode 100644 index 0e633f6d807..00000000000 --- a/jscomp/test/uncurried_cast.js +++ /dev/null @@ -1,139 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -var Curry = require("../../lib/js/curry.js"); -var Belt_List = require("../../lib/js/belt_List.js"); -var Caml_exceptions = require("../../lib/js/caml_exceptions.js"); - -function raise(e) { - throw e; -} - -var map = Belt_List.mapU; - -var List = { - map: map -}; - -var Uncurried = { - raise: raise, - List: List -}; - -var E = /* @__PURE__ */Caml_exceptions.create("Uncurried_cast.E"); - -function testRaise(param) { - throw { - RE_EXN_ID: E, - Error: new Error() - }; -} - -var l = Belt_List.mapU({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, (function (x) { - return x + 1 | 0; - })); - -var partial_arg = { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } -}; - -function partial(param) { - return map(partial_arg, param); -} - -var ll = partial(function (x) { - return x + 1 | 0; - }); - -function withOpts(xOpt, y, zOpt, w) { - var x = xOpt !== undefined ? xOpt : 3; - var z = zOpt !== undefined ? zOpt : 4; - return ((x + y | 0) + z | 0) + w | 0; -} - -function still2Args(param, param$1) { - return withOpts(undefined, 4, param, param$1); -} - -var anInt = Curry._1(still2Args, 3)(5); - -var StandardNotation = { - testRaise: testRaise, - l: l, - partial: partial, - ll: ll, - withOpts: withOpts, - still2Args: still2Args, - anInt: anInt -}; - -function testRaise$1() { - throw { - RE_EXN_ID: E, - Error: new Error() - }; -} - -var l$1 = Belt_List.mapU({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }, (function (x) { - return x + 1 | 0; - })); - -var partial_arg$1 = { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } -}; - -function partial$1(param) { - return map(partial_arg$1, param); -} - -var ll$1 = partial$1(function (x) { - return x + 1 | 0; - }); - -function withOpts$1(xOpt, y, zOpt, w) { - var x = xOpt !== undefined ? xOpt : 3; - var z = zOpt !== undefined ? zOpt : 4; - return ((x + y | 0) + z | 0) + w | 0; -} - -function still2Args$1(param, param$1) { - return withOpts$1(undefined, 4, param, param$1); -} - -var partial_arg$2 = 3; - -var anInt$1 = (function (param) { - return still2Args$1(partial_arg$2, param); - })(5); - -exports.Uncurried = Uncurried; -exports.E = E; -exports.StandardNotation = StandardNotation; -exports.testRaise = testRaise$1; -exports.l = l$1; -exports.partial = partial$1; -exports.ll = ll$1; -exports.withOpts = withOpts$1; -exports.still2Args = still2Args$1; -exports.anInt = anInt$1; -/* l Not a pure module */ diff --git a/jscomp/test/uncurried_cast.res b/jscomp/test/uncurried_cast.res deleted file mode 100644 index 4a4684ffd71..00000000000 --- a/jscomp/test/uncurried_cast.res +++ /dev/null @@ -1,39 +0,0 @@ -module Uncurried = { - let raise = (. e) => raise(e) - - module List = { - let map = (. l, f) => Belt.List.mapU(l, f) - } -} - -exception E - -module StandardNotation = { - open Uncurried - - let testRaise = () => raise(E) - - let l = List.map(.list{1, 2}, (. x) => x + 1) - let partial = List.map(list{1, 2}) - let ll = partial((. x) => x + 1) - - let withOpts = (. ~x=3, y, ~z=4, w) => x + y + z + w - type unc2 = (. ~z: int=?, int) => int - let still2Args : unc2 = withOpts(4) - let anInt = still2Args(~z=3)(. 5) -} - -@@uncurried.swap - -open Uncurried - -let testRaise = () => raise(E) - -let l = List.map(list{1, 2}, x => x + 1) -let partial = List.map(. list{1, 2}) -let ll = partial(.x => x + 1) - -let withOpts = (~x=3, y, ~z=4, w) => x + y + z + w -type unc2 = (~z: int=?, int) => int -let still2Args : unc2 = withOpts(. 4) -let anInt = still2Args(. ~z=3)(5) diff --git a/lib/es6/belt.js b/lib/es6/belt.js deleted file mode 100644 index 84802e81902..00000000000 --- a/lib/es6/belt.js +++ /dev/null @@ -1,57 +0,0 @@ - - - -var Id; - -var $$Array; - -var SortArray; - -var MutableQueue; - -var MutableStack; - -var List; - -var $$Range; - -var $$Set; - -var $$Map; - -var MutableSet; - -var MutableMap; - -var HashSet; - -var HashMap; - -var $$Option; - -var Result; - -var Int; - -var Float; - -export { - Id , - $$Array , - SortArray , - MutableQueue , - MutableStack , - List , - $$Range , - $$Set , - $$Map , - MutableSet , - MutableMap , - HashSet , - HashMap , - $$Option , - Result , - Int , - Float , -} -/* No side effect */ diff --git a/lib/es6/belt_Array.js b/lib/es6/belt_Array.js deleted file mode 100644 index 899f3996091..00000000000 --- a/lib/es6/belt_Array.js +++ /dev/null @@ -1,764 +0,0 @@ - - -import * as Caml from "./caml.js"; -import * as Curry from "./curry.js"; -import * as Js_math from "./js_math.js"; -import * as Caml_option from "./caml_option.js"; - -function get(arr, i) { - if (i >= 0 && i < arr.length) { - return Caml_option.some(arr[i]); - } - -} - -function getExn(arr, i) { - if (!(i >= 0 && i < arr.length)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_Array.res", - 36, - 2 - ], - Error: new Error() - }; - } - return arr[i]; -} - -function set(arr, i, v) { - if (i >= 0 && i < arr.length) { - arr[i] = v; - return true; - } else { - return false; - } -} - -function setExn(arr, i, v) { - if (!(i >= 0 && i < arr.length)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_Array.res", - 49, - 2 - ], - Error: new Error() - }; - } - arr[i] = v; -} - -function swapUnsafe(xs, i, j) { - var tmp = xs[i]; - xs[i] = xs[j]; - xs[j] = tmp; -} - -function shuffleInPlace(xs) { - var len = xs.length; - for(var i = 0; i < len; ++i){ - swapUnsafe(xs, i, Js_math.random_int(i, len)); - } -} - -function shuffle(xs) { - var result = xs.slice(0); - shuffleInPlace(result); - return result; -} - -function reverseInPlace(xs) { - var len = xs.length; - var ofs = 0; - for(var i = 0 ,i_finish = len / 2 | 0; i < i_finish; ++i){ - swapUnsafe(xs, ofs + i | 0, ((ofs + len | 0) - i | 0) - 1 | 0); - } -} - -function reverse(xs) { - var len = xs.length; - var result = new Array(len); - for(var i = 0; i < len; ++i){ - result[i] = xs[(len - 1 | 0) - i | 0]; - } - return result; -} - -function make(l, f) { - if (l <= 0) { - return []; - } - var res = new Array(l); - for(var i = 0; i < l; ++i){ - res[i] = f; - } - return res; -} - -function makeByU(l, f) { - if (l <= 0) { - return []; - } - var res = new Array(l); - for(var i = 0; i < l; ++i){ - res[i] = f(i); - } - return res; -} - -function makeBy(l, f) { - return makeByU(l, Curry.__1(f)); -} - -function makeByAndShuffleU(l, f) { - var u = makeByU(l, f); - shuffleInPlace(u); - return u; -} - -function makeByAndShuffle(l, f) { - return makeByAndShuffleU(l, Curry.__1(f)); -} - -function range(start, finish) { - var cut = finish - start | 0; - if (cut < 0) { - return []; - } - var arr = new Array(cut + 1 | 0); - for(var i = 0; i <= cut; ++i){ - arr[i] = start + i | 0; - } - return arr; -} - -function rangeBy(start, finish, step) { - var cut = finish - start | 0; - if (cut < 0 || step <= 0) { - return []; - } - var nb = (cut / step | 0) + 1 | 0; - var arr = new Array(nb); - var cur = start; - for(var i = 0; i < nb; ++i){ - arr[i] = cur; - cur = cur + step | 0; - } - return arr; -} - -function zip(xs, ys) { - var lenx = xs.length; - var leny = ys.length; - var len = lenx < leny ? lenx : leny; - var s = new Array(len); - for(var i = 0; i < len; ++i){ - s[i] = [ - xs[i], - ys[i] - ]; - } - return s; -} - -function zipByU(xs, ys, f) { - var lenx = xs.length; - var leny = ys.length; - var len = lenx < leny ? lenx : leny; - var s = new Array(len); - for(var i = 0; i < len; ++i){ - s[i] = f(xs[i], ys[i]); - } - return s; -} - -function zipBy(xs, ys, f) { - return zipByU(xs, ys, Curry.__2(f)); -} - -function concat(a1, a2) { - var l1 = a1.length; - var l2 = a2.length; - var a1a2 = new Array(l1 + l2 | 0); - for(var i = 0; i < l1; ++i){ - a1a2[i] = a1[i]; - } - for(var i$1 = 0; i$1 < l2; ++i$1){ - a1a2[l1 + i$1 | 0] = a2[i$1]; - } - return a1a2; -} - -function concatMany(arrs) { - var lenArrs = arrs.length; - var totalLen = 0; - for(var i = 0; i < lenArrs; ++i){ - totalLen = totalLen + arrs[i].length | 0; - } - var result = new Array(totalLen); - totalLen = 0; - for(var j = 0; j < lenArrs; ++j){ - var cur = arrs[j]; - for(var k = 0 ,k_finish = cur.length; k < k_finish; ++k){ - result[totalLen] = cur[k]; - totalLen = totalLen + 1 | 0; - } - } - return result; -} - -function slice(a, offset, len) { - if (len <= 0) { - return []; - } - var lena = a.length; - var ofs = offset < 0 ? Caml.int_max(lena + offset | 0, 0) : offset; - var hasLen = lena - ofs | 0; - var copyLength = hasLen < len ? hasLen : len; - if (copyLength <= 0) { - return []; - } - var result = new Array(copyLength); - for(var i = 0; i < copyLength; ++i){ - result[i] = a[ofs + i | 0]; - } - return result; -} - -function sliceToEnd(a, offset) { - var lena = a.length; - var ofs = offset < 0 ? Caml.int_max(lena + offset | 0, 0) : offset; - var len = lena > ofs ? lena - ofs | 0 : 0; - var result = new Array(len); - for(var i = 0; i < len; ++i){ - result[i] = a[ofs + i | 0]; - } - return result; -} - -function fill(a, offset, len, v) { - if (len <= 0) { - return ; - } - var lena = a.length; - var ofs = offset < 0 ? Caml.int_max(lena + offset | 0, 0) : offset; - var hasLen = lena - ofs | 0; - var fillLength = hasLen < len ? hasLen : len; - if (fillLength <= 0) { - return ; - } - for(var i = ofs ,i_finish = ofs + fillLength | 0; i < i_finish; ++i){ - a[i] = v; - } -} - -function blitUnsafe(a1, srcofs1, a2, srcofs2, blitLength) { - if (srcofs2 <= srcofs1) { - for(var j = 0; j < blitLength; ++j){ - a2[j + srcofs2 | 0] = a1[j + srcofs1 | 0]; - } - return ; - } - for(var j$1 = blitLength - 1 | 0; j$1 >= 0; --j$1){ - a2[j$1 + srcofs2 | 0] = a1[j$1 + srcofs1 | 0]; - } -} - -function blit(a1, ofs1, a2, ofs2, len) { - var lena1 = a1.length; - var lena2 = a2.length; - var srcofs1 = ofs1 < 0 ? Caml.int_max(lena1 + ofs1 | 0, 0) : ofs1; - var srcofs2 = ofs2 < 0 ? Caml.int_max(lena2 + ofs2 | 0, 0) : ofs2; - var blitLength = Caml.int_min(len, Caml.int_min(lena1 - srcofs1 | 0, lena2 - srcofs2 | 0)); - if (srcofs2 <= srcofs1) { - for(var j = 0; j < blitLength; ++j){ - a2[j + srcofs2 | 0] = a1[j + srcofs1 | 0]; - } - return ; - } - for(var j$1 = blitLength - 1 | 0; j$1 >= 0; --j$1){ - a2[j$1 + srcofs2 | 0] = a1[j$1 + srcofs1 | 0]; - } -} - -function forEachU(a, f) { - for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(a[i]); - } -} - -function forEach(a, f) { - forEachU(a, Curry.__1(f)); -} - -function mapU(a, f) { - var l = a.length; - var r = new Array(l); - for(var i = 0; i < l; ++i){ - r[i] = f(a[i]); - } - return r; -} - -function map(a, f) { - return mapU(a, Curry.__1(f)); -} - -function flatMapU(a, f) { - return concatMany(mapU(a, f)); -} - -function flatMap(a, f) { - return concatMany(mapU(a, Curry.__1(f))); -} - -function getByU(a, p) { - var l = a.length; - var i = 0; - var r; - while(r === undefined && i < l) { - var v = a[i]; - if (p(v)) { - r = Caml_option.some(v); - } - i = i + 1 | 0; - }; - return r; -} - -function getBy(a, p) { - return getByU(a, Curry.__1(p)); -} - -function getIndexByU(a, p) { - var l = a.length; - var i = 0; - var r; - while(r === undefined && i < l) { - var v = a[i]; - if (p(v)) { - r = i; - } - i = i + 1 | 0; - }; - return r; -} - -function getIndexBy(a, p) { - return getIndexByU(a, Curry.__1(p)); -} - -function keepU(a, f) { - var l = a.length; - var r = new Array(l); - var j = 0; - for(var i = 0; i < l; ++i){ - var v = a[i]; - if (f(v)) { - r[j] = v; - j = j + 1 | 0; - } - - } - r.length = j; - return r; -} - -function keep(a, f) { - return keepU(a, Curry.__1(f)); -} - -function keepWithIndexU(a, f) { - var l = a.length; - var r = new Array(l); - var j = 0; - for(var i = 0; i < l; ++i){ - var v = a[i]; - if (f(v, i)) { - r[j] = v; - j = j + 1 | 0; - } - - } - r.length = j; - return r; -} - -function keepWithIndex(a, f) { - return keepWithIndexU(a, Curry.__2(f)); -} - -function keepMapU(a, f) { - var l = a.length; - var r = new Array(l); - var j = 0; - for(var i = 0; i < l; ++i){ - var v = a[i]; - var v$1 = f(v); - if (v$1 !== undefined) { - r[j] = Caml_option.valFromOption(v$1); - j = j + 1 | 0; - } - - } - r.length = j; - return r; -} - -function keepMap(a, f) { - return keepMapU(a, Curry.__1(f)); -} - -function forEachWithIndexU(a, f) { - for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(i, a[i]); - } -} - -function forEachWithIndex(a, f) { - forEachWithIndexU(a, Curry.__2(f)); -} - -function mapWithIndexU(a, f) { - var l = a.length; - var r = new Array(l); - for(var i = 0; i < l; ++i){ - r[i] = f(i, a[i]); - } - return r; -} - -function mapWithIndex(a, f) { - return mapWithIndexU(a, Curry.__2(f)); -} - -function reduceU(a, x, f) { - var r = x; - for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ - r = f(r, a[i]); - } - return r; -} - -function reduce(a, x, f) { - return reduceU(a, x, Curry.__2(f)); -} - -function reduceReverseU(a, x, f) { - var r = x; - for(var i = a.length - 1 | 0; i >= 0; --i){ - r = f(r, a[i]); - } - return r; -} - -function reduceReverse(a, x, f) { - return reduceReverseU(a, x, Curry.__2(f)); -} - -function reduceReverse2U(a, b, x, f) { - var r = x; - var len = Caml.int_min(a.length, b.length); - for(var i = len - 1 | 0; i >= 0; --i){ - r = f(r, a[i], b[i]); - } - return r; -} - -function reduceReverse2(a, b, x, f) { - return reduceReverse2U(a, b, x, Curry.__3(f)); -} - -function reduceWithIndexU(a, x, f) { - var r = x; - for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ - r = f(r, a[i], i); - } - return r; -} - -function reduceWithIndex(a, x, f) { - return reduceWithIndexU(a, x, Curry.__3(f)); -} - -function everyU(arr, b) { - var len = arr.length; - var _i = 0; - while(true) { - var i = _i; - if (i === len) { - return true; - } - if (!b(arr[i])) { - return false; - } - _i = i + 1 | 0; - continue ; - }; -} - -function every(arr, f) { - return everyU(arr, Curry.__1(f)); -} - -function someU(arr, b) { - var len = arr.length; - var _i = 0; - while(true) { - var i = _i; - if (i === len) { - return false; - } - if (b(arr[i])) { - return true; - } - _i = i + 1 | 0; - continue ; - }; -} - -function some(arr, f) { - return someU(arr, Curry.__1(f)); -} - -function everyAux2(arr1, arr2, _i, b, len) { - while(true) { - var i = _i; - if (i === len) { - return true; - } - if (!b(arr1[i], arr2[i])) { - return false; - } - _i = i + 1 | 0; - continue ; - }; -} - -function every2U(a, b, p) { - return everyAux2(a, b, 0, p, Caml.int_min(a.length, b.length)); -} - -function every2(a, b, p) { - return every2U(a, b, Curry.__2(p)); -} - -function some2U(a, b, p) { - var _i = 0; - var len = Caml.int_min(a.length, b.length); - while(true) { - var i = _i; - if (i === len) { - return false; - } - if (p(a[i], b[i])) { - return true; - } - _i = i + 1 | 0; - continue ; - }; -} - -function some2(a, b, p) { - return some2U(a, b, Curry.__2(p)); -} - -function eqU(a, b, p) { - var lena = a.length; - var lenb = b.length; - if (lena === lenb) { - return everyAux2(a, b, 0, p, lena); - } else { - return false; - } -} - -function eq(a, b, p) { - return eqU(a, b, Curry.__2(p)); -} - -function cmpU(a, b, p) { - var lena = a.length; - var lenb = b.length; - if (lena > lenb) { - return 1; - } else if (lena < lenb) { - return -1; - } else { - var _i = 0; - while(true) { - var i = _i; - if (i === lena) { - return 0; - } - var c = p(a[i], b[i]); - if (c !== 0) { - return c; - } - _i = i + 1 | 0; - continue ; - }; - } -} - -function cmp(a, b, p) { - return cmpU(a, b, Curry.__2(p)); -} - -function partitionU(a, f) { - var l = a.length; - var i = 0; - var j = 0; - var a1 = new Array(l); - var a2 = new Array(l); - for(var ii = 0; ii < l; ++ii){ - var v = a[ii]; - if (f(v)) { - a1[i] = v; - i = i + 1 | 0; - } else { - a2[j] = v; - j = j + 1 | 0; - } - } - a1.length = i; - a2.length = j; - return [ - a1, - a2 - ]; -} - -function partition(a, f) { - return partitionU(a, Curry.__1(f)); -} - -function unzip(a) { - var l = a.length; - var a1 = new Array(l); - var a2 = new Array(l); - for(var i = 0; i < l; ++i){ - var match = a[i]; - a1[i] = match[0]; - a2[i] = match[1]; - } - return [ - a1, - a2 - ]; -} - -function joinWithU(a, sep, toString) { - var l = a.length; - if (l === 0) { - return ""; - } - var lastIndex = l - 1 | 0; - var _i = 0; - var _res = ""; - while(true) { - var res = _res; - var i = _i; - if (i === lastIndex) { - return res + toString(a[i]); - } - _res = res + (toString(a[i]) + sep); - _i = i + 1 | 0; - continue ; - }; -} - -function joinWith(a, sep, toString) { - return joinWithU(a, sep, Curry.__1(toString)); -} - -function initU(n, f) { - var v = new Array(n); - for(var i = 0; i < n; ++i){ - v[i] = f(i); - } - return v; -} - -function init(n, f) { - return initU(n, Curry.__1(f)); -} - -export { - get , - getExn , - set , - setExn , - shuffleInPlace , - shuffle , - reverseInPlace , - reverse , - make , - range , - rangeBy , - makeByU , - makeBy , - makeByAndShuffleU , - makeByAndShuffle , - zip , - zipByU , - zipBy , - unzip , - concat , - concatMany , - slice , - sliceToEnd , - fill , - blit , - blitUnsafe , - forEachU , - forEach , - mapU , - map , - flatMapU , - flatMap , - getByU , - getBy , - getIndexByU , - getIndexBy , - keepU , - keep , - keepWithIndexU , - keepWithIndex , - keepMapU , - keepMap , - forEachWithIndexU , - forEachWithIndex , - mapWithIndexU , - mapWithIndex , - partitionU , - partition , - reduceU , - reduce , - reduceReverseU , - reduceReverse , - reduceReverse2U , - reduceReverse2 , - reduceWithIndexU , - reduceWithIndex , - joinWithU , - joinWith , - someU , - some , - everyU , - every , - every2U , - every2 , - some2U , - some2 , - cmpU , - cmp , - eqU , - eq , - initU , - init , -} -/* No side effect */ diff --git a/lib/es6/belt_Float.js b/lib/es6/belt_Float.js deleted file mode 100644 index 97b395d9ab1..00000000000 --- a/lib/es6/belt_Float.js +++ /dev/null @@ -1,16 +0,0 @@ - - - -function fromString(i) { - var i$1 = parseFloat(i); - if (isNaN(i$1)) { - return ; - } else { - return i$1; - } -} - -export { - fromString , -} -/* No side effect */ diff --git a/lib/es6/belt_HashMap.js b/lib/es6/belt_HashMap.js deleted file mode 100644 index 2ee1cc064e2..00000000000 --- a/lib/es6/belt_HashMap.js +++ /dev/null @@ -1,280 +0,0 @@ - - -import * as Caml_option from "./caml_option.js"; -import * as Belt_internalBuckets from "./belt_internalBuckets.js"; -import * as Belt_internalBucketsType from "./belt_internalBucketsType.js"; - -function size(h) { - return h.size; -} - -function copyBucketReHash(hash, h_buckets, ndata_tail, _old_bucket) { - while(true) { - var old_bucket = _old_bucket; - if (old_bucket === undefined) { - return ; - } - var nidx = hash(old_bucket.key) & (h_buckets.length - 1 | 0); - var tail = ndata_tail[nidx]; - if (tail !== undefined) { - tail.next = old_bucket; - } else { - h_buckets[nidx] = old_bucket; - } - ndata_tail[nidx] = old_bucket; - _old_bucket = old_bucket.next; - continue ; - }; -} - -function replaceInBucket(eq, key, info, _cell) { - while(true) { - var cell = _cell; - if (eq(cell.key, key)) { - cell.value = info; - return false; - } - var cell$1 = cell.next; - if (cell$1 === undefined) { - return true; - } - _cell = cell$1; - continue ; - }; -} - -function set0(h, key, value, eq, hash) { - var h_buckets = h.buckets; - var buckets_len = h_buckets.length; - var i = hash(key) & (buckets_len - 1 | 0); - var l = h_buckets[i]; - if (l !== undefined) { - if (replaceInBucket(eq, key, value, l)) { - h_buckets[i] = { - key: key, - value: value, - next: l - }; - h.size = h.size + 1 | 0; - } - - } else { - h_buckets[i] = { - key: key, - value: value, - next: undefined - }; - h.size = h.size + 1 | 0; - } - if (h.size > (buckets_len << 1)) { - var odata = h.buckets; - var osize = odata.length; - var nsize = (osize << 1); - if (nsize < osize) { - return ; - } - var h_buckets$1 = new Array(nsize); - var ndata_tail = new Array(nsize); - h.buckets = h_buckets$1; - for(var i$1 = 0; i$1 < osize; ++i$1){ - copyBucketReHash(hash, h_buckets$1, ndata_tail, odata[i$1]); - } - for(var i$2 = 0; i$2 < nsize; ++i$2){ - var tail = ndata_tail[i$2]; - if (tail !== undefined) { - tail.next = undefined; - } - - } - return ; - } - -} - -function set(h, key, value) { - set0(h, key, value, h.eq, h.hash); -} - -function remove(h, key) { - var h_buckets = h.buckets; - var i = h.hash(key) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[i]; - if (bucket === undefined) { - return ; - } - var eq = h.eq; - if (eq(bucket.key, key)) { - h_buckets[i] = bucket.next; - h.size = h.size - 1 | 0; - return ; - } else { - var _prec = bucket; - var _bucket = bucket.next; - while(true) { - var bucket$1 = _bucket; - var prec = _prec; - if (bucket$1 === undefined) { - return ; - } - var cell_next = bucket$1.next; - if (eq(bucket$1.key, key)) { - prec.next = cell_next; - h.size = h.size - 1 | 0; - return ; - } - _bucket = cell_next; - _prec = bucket$1; - continue ; - }; - } -} - -function get(h, key) { - var h_buckets = h.buckets; - var nid = h.hash(key) & (h_buckets.length - 1 | 0); - var cell1 = h_buckets[nid]; - if (cell1 === undefined) { - return ; - } - var eq = h.eq; - if (eq(key, cell1.key)) { - return Caml_option.some(cell1.value); - } - var cell2 = cell1.next; - if (cell2 === undefined) { - return ; - } - if (eq(key, cell2.key)) { - return Caml_option.some(cell2.value); - } - var cell3 = cell2.next; - if (cell3 !== undefined) { - if (eq(key, cell3.key)) { - return Caml_option.some(cell3.value); - } else { - var _buckets = cell3.next; - while(true) { - var buckets = _buckets; - if (buckets === undefined) { - return ; - } - if (eq(key, buckets.key)) { - return Caml_option.some(buckets.value); - } - _buckets = buckets.next; - continue ; - }; - } - } - -} - -function has(h, key) { - var h_buckets = h.buckets; - var nid = h.hash(key) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[nid]; - if (bucket !== undefined) { - var _cell = bucket; - var eq = h.eq; - while(true) { - var cell = _cell; - if (eq(cell.key, key)) { - return true; - } - var nextCell = cell.next; - if (nextCell === undefined) { - return false; - } - _cell = nextCell; - continue ; - }; - } else { - return false; - } -} - -function make(hintSize, id) { - return Belt_internalBucketsType.make(id.hash, id.eq, hintSize); -} - -function fromArray(arr, id) { - var hash = id.hash; - var eq = id.eq; - var len = arr.length; - var v = Belt_internalBucketsType.make(hash, eq, len); - for(var i = 0; i < len; ++i){ - var match = arr[i]; - set0(v, match[0], match[1], eq, hash); - } - return v; -} - -function mergeMany(h, arr) { - var hash = h.hash; - var eq = h.eq; - var len = arr.length; - for(var i = 0; i < len; ++i){ - var match = arr[i]; - set0(h, match[0], match[1], eq, hash); - } -} - -var Int; - -var $$String; - -var clear = Belt_internalBucketsType.clear; - -var isEmpty = Belt_internalBucketsType.isEmpty; - -var copy = Belt_internalBuckets.copy; - -var forEachU = Belt_internalBuckets.forEachU; - -var forEach = Belt_internalBuckets.forEach; - -var reduceU = Belt_internalBuckets.reduceU; - -var reduce = Belt_internalBuckets.reduce; - -var keepMapInPlaceU = Belt_internalBuckets.keepMapInPlaceU; - -var keepMapInPlace = Belt_internalBuckets.keepMapInPlace; - -var toArray = Belt_internalBuckets.toArray; - -var keysToArray = Belt_internalBuckets.keysToArray; - -var valuesToArray = Belt_internalBuckets.valuesToArray; - -var getBucketHistogram = Belt_internalBuckets.getBucketHistogram; - -var logStats = Belt_internalBuckets.logStats; - -export { - Int , - $$String , - make , - clear , - isEmpty , - set , - copy , - get , - has , - remove , - forEachU , - forEach , - reduceU , - reduce , - keepMapInPlaceU , - keepMapInPlace , - size , - toArray , - keysToArray , - valuesToArray , - fromArray , - mergeMany , - getBucketHistogram , - logStats , -} -/* No side effect */ diff --git a/lib/es6/belt_HashMapInt.js b/lib/es6/belt_HashMapInt.js deleted file mode 100644 index 86d6c6f07e2..00000000000 --- a/lib/es6/belt_HashMapInt.js +++ /dev/null @@ -1,264 +0,0 @@ - - -import * as Caml_option from "./caml_option.js"; -import * as Caml_hash_primitive from "./caml_hash_primitive.js"; -import * as Belt_internalBuckets from "./belt_internalBuckets.js"; -import * as Belt_internalBucketsType from "./belt_internalBucketsType.js"; - -function copyBucketReHash(h_buckets, ndata_tail, _old_bucket) { - while(true) { - var old_bucket = _old_bucket; - if (old_bucket === undefined) { - return ; - } - var nidx = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, old_bucket.key)) & (h_buckets.length - 1 | 0); - var tail = ndata_tail[nidx]; - if (tail !== undefined) { - tail.next = old_bucket; - } else { - h_buckets[nidx] = old_bucket; - } - ndata_tail[nidx] = old_bucket; - _old_bucket = old_bucket.next; - continue ; - }; -} - -function replaceInBucket(key, info, _cell) { - while(true) { - var cell = _cell; - if (cell.key === key) { - cell.value = info; - return false; - } - var cell$1 = cell.next; - if (cell$1 === undefined) { - return true; - } - _cell = cell$1; - continue ; - }; -} - -function set(h, key, value) { - var h_buckets = h.buckets; - var buckets_len = h_buckets.length; - var i = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, key)) & (buckets_len - 1 | 0); - var l = h_buckets[i]; - if (l !== undefined) { - if (replaceInBucket(key, value, l)) { - h_buckets[i] = { - key: key, - value: value, - next: l - }; - h.size = h.size + 1 | 0; - } - - } else { - h_buckets[i] = { - key: key, - value: value, - next: undefined - }; - h.size = h.size + 1 | 0; - } - if (h.size > (buckets_len << 1)) { - var odata = h.buckets; - var osize = odata.length; - var nsize = (osize << 1); - if (nsize < osize) { - return ; - } - var h_buckets$1 = new Array(nsize); - var ndata_tail = new Array(nsize); - h.buckets = h_buckets$1; - for(var i$1 = 0; i$1 < osize; ++i$1){ - copyBucketReHash(h_buckets$1, ndata_tail, odata[i$1]); - } - for(var i$2 = 0; i$2 < nsize; ++i$2){ - var tail = ndata_tail[i$2]; - if (tail !== undefined) { - tail.next = undefined; - } - - } - return ; - } - -} - -function remove(h, key) { - var h_buckets = h.buckets; - var i = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[i]; - if (bucket !== undefined) { - if (bucket.key === key) { - h_buckets[i] = bucket.next; - h.size = h.size - 1 | 0; - return ; - } else { - var _prec = bucket; - var _buckets = bucket.next; - while(true) { - var buckets = _buckets; - var prec = _prec; - if (buckets === undefined) { - return ; - } - var cell_next = buckets.next; - if (buckets.key === key) { - prec.next = cell_next; - h.size = h.size - 1 | 0; - return ; - } - _buckets = cell_next; - _prec = buckets; - continue ; - }; - } - } - -} - -function get(h, key) { - var h_buckets = h.buckets; - var nid = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); - var cell1 = h_buckets[nid]; - if (cell1 === undefined) { - return ; - } - if (key === cell1.key) { - return Caml_option.some(cell1.value); - } - var cell2 = cell1.next; - if (cell2 === undefined) { - return ; - } - if (key === cell2.key) { - return Caml_option.some(cell2.value); - } - var cell3 = cell2.next; - if (cell3 !== undefined) { - if (key === cell3.key) { - return Caml_option.some(cell3.value); - } else { - var _buckets = cell3.next; - while(true) { - var buckets = _buckets; - if (buckets === undefined) { - return ; - } - if (key === buckets.key) { - return Caml_option.some(buckets.value); - } - _buckets = buckets.next; - continue ; - }; - } - } - -} - -function has(h, key) { - var h_buckets = h.buckets; - var nid = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[nid]; - if (bucket !== undefined) { - var _cell = bucket; - while(true) { - var cell = _cell; - if (cell.key === key) { - return true; - } - var nextCell = cell.next; - if (nextCell === undefined) { - return false; - } - _cell = nextCell; - continue ; - }; - } else { - return false; - } -} - -function make(hintSize) { - return Belt_internalBucketsType.make(undefined, undefined, hintSize); -} - -function size(h) { - return h.size; -} - -function fromArray(arr) { - var len = arr.length; - var v = Belt_internalBucketsType.make(undefined, undefined, len); - for(var i = 0; i < len; ++i){ - var match = arr[i]; - set(v, match[0], match[1]); - } - return v; -} - -function mergeMany(h, arr) { - var len = arr.length; - for(var i = 0; i < len; ++i){ - var match = arr[i]; - set(h, match[0], match[1]); - } -} - -var clear = Belt_internalBucketsType.clear; - -var isEmpty = Belt_internalBucketsType.isEmpty; - -var copy = Belt_internalBuckets.copy; - -var forEachU = Belt_internalBuckets.forEachU; - -var forEach = Belt_internalBuckets.forEach; - -var reduceU = Belt_internalBuckets.reduceU; - -var reduce = Belt_internalBuckets.reduce; - -var keepMapInPlaceU = Belt_internalBuckets.keepMapInPlaceU; - -var keepMapInPlace = Belt_internalBuckets.keepMapInPlace; - -var toArray = Belt_internalBuckets.toArray; - -var keysToArray = Belt_internalBuckets.keysToArray; - -var valuesToArray = Belt_internalBuckets.valuesToArray; - -var getBucketHistogram = Belt_internalBuckets.getBucketHistogram; - -var logStats = Belt_internalBuckets.logStats; - -export { - make , - clear , - isEmpty , - set , - copy , - get , - has , - remove , - forEachU , - forEach , - reduceU , - reduce , - keepMapInPlaceU , - keepMapInPlace , - size , - toArray , - keysToArray , - valuesToArray , - fromArray , - mergeMany , - getBucketHistogram , - logStats , -} -/* No side effect */ diff --git a/lib/es6/belt_HashMapString.js b/lib/es6/belt_HashMapString.js deleted file mode 100644 index 81d09694df4..00000000000 --- a/lib/es6/belt_HashMapString.js +++ /dev/null @@ -1,264 +0,0 @@ - - -import * as Caml_option from "./caml_option.js"; -import * as Caml_hash_primitive from "./caml_hash_primitive.js"; -import * as Belt_internalBuckets from "./belt_internalBuckets.js"; -import * as Belt_internalBucketsType from "./belt_internalBucketsType.js"; - -function copyBucketReHash(h_buckets, ndata_tail, _old_bucket) { - while(true) { - var old_bucket = _old_bucket; - if (old_bucket === undefined) { - return ; - } - var nidx = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, old_bucket.key)) & (h_buckets.length - 1 | 0); - var tail = ndata_tail[nidx]; - if (tail !== undefined) { - tail.next = old_bucket; - } else { - h_buckets[nidx] = old_bucket; - } - ndata_tail[nidx] = old_bucket; - _old_bucket = old_bucket.next; - continue ; - }; -} - -function replaceInBucket(key, info, _cell) { - while(true) { - var cell = _cell; - if (cell.key === key) { - cell.value = info; - return false; - } - var cell$1 = cell.next; - if (cell$1 === undefined) { - return true; - } - _cell = cell$1; - continue ; - }; -} - -function set(h, key, value) { - var h_buckets = h.buckets; - var buckets_len = h_buckets.length; - var i = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, key)) & (buckets_len - 1 | 0); - var l = h_buckets[i]; - if (l !== undefined) { - if (replaceInBucket(key, value, l)) { - h_buckets[i] = { - key: key, - value: value, - next: l - }; - h.size = h.size + 1 | 0; - } - - } else { - h_buckets[i] = { - key: key, - value: value, - next: undefined - }; - h.size = h.size + 1 | 0; - } - if (h.size > (buckets_len << 1)) { - var odata = h.buckets; - var osize = odata.length; - var nsize = (osize << 1); - if (nsize < osize) { - return ; - } - var h_buckets$1 = new Array(nsize); - var ndata_tail = new Array(nsize); - h.buckets = h_buckets$1; - for(var i$1 = 0; i$1 < osize; ++i$1){ - copyBucketReHash(h_buckets$1, ndata_tail, odata[i$1]); - } - for(var i$2 = 0; i$2 < nsize; ++i$2){ - var tail = ndata_tail[i$2]; - if (tail !== undefined) { - tail.next = undefined; - } - - } - return ; - } - -} - -function remove(h, key) { - var h_buckets = h.buckets; - var i = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[i]; - if (bucket !== undefined) { - if (bucket.key === key) { - h_buckets[i] = bucket.next; - h.size = h.size - 1 | 0; - return ; - } else { - var _prec = bucket; - var _buckets = bucket.next; - while(true) { - var buckets = _buckets; - var prec = _prec; - if (buckets === undefined) { - return ; - } - var cell_next = buckets.next; - if (buckets.key === key) { - prec.next = cell_next; - h.size = h.size - 1 | 0; - return ; - } - _buckets = cell_next; - _prec = buckets; - continue ; - }; - } - } - -} - -function get(h, key) { - var h_buckets = h.buckets; - var nid = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); - var cell1 = h_buckets[nid]; - if (cell1 === undefined) { - return ; - } - if (key === cell1.key) { - return Caml_option.some(cell1.value); - } - var cell2 = cell1.next; - if (cell2 === undefined) { - return ; - } - if (key === cell2.key) { - return Caml_option.some(cell2.value); - } - var cell3 = cell2.next; - if (cell3 !== undefined) { - if (key === cell3.key) { - return Caml_option.some(cell3.value); - } else { - var _buckets = cell3.next; - while(true) { - var buckets = _buckets; - if (buckets === undefined) { - return ; - } - if (key === buckets.key) { - return Caml_option.some(buckets.value); - } - _buckets = buckets.next; - continue ; - }; - } - } - -} - -function has(h, key) { - var h_buckets = h.buckets; - var nid = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[nid]; - if (bucket !== undefined) { - var _cell = bucket; - while(true) { - var cell = _cell; - if (cell.key === key) { - return true; - } - var nextCell = cell.next; - if (nextCell === undefined) { - return false; - } - _cell = nextCell; - continue ; - }; - } else { - return false; - } -} - -function make(hintSize) { - return Belt_internalBucketsType.make(undefined, undefined, hintSize); -} - -function size(h) { - return h.size; -} - -function fromArray(arr) { - var len = arr.length; - var v = Belt_internalBucketsType.make(undefined, undefined, len); - for(var i = 0; i < len; ++i){ - var match = arr[i]; - set(v, match[0], match[1]); - } - return v; -} - -function mergeMany(h, arr) { - var len = arr.length; - for(var i = 0; i < len; ++i){ - var match = arr[i]; - set(h, match[0], match[1]); - } -} - -var clear = Belt_internalBucketsType.clear; - -var isEmpty = Belt_internalBucketsType.isEmpty; - -var copy = Belt_internalBuckets.copy; - -var forEachU = Belt_internalBuckets.forEachU; - -var forEach = Belt_internalBuckets.forEach; - -var reduceU = Belt_internalBuckets.reduceU; - -var reduce = Belt_internalBuckets.reduce; - -var keepMapInPlaceU = Belt_internalBuckets.keepMapInPlaceU; - -var keepMapInPlace = Belt_internalBuckets.keepMapInPlace; - -var toArray = Belt_internalBuckets.toArray; - -var keysToArray = Belt_internalBuckets.keysToArray; - -var valuesToArray = Belt_internalBuckets.valuesToArray; - -var getBucketHistogram = Belt_internalBuckets.getBucketHistogram; - -var logStats = Belt_internalBuckets.logStats; - -export { - make , - clear , - isEmpty , - set , - copy , - get , - has , - remove , - forEachU , - forEach , - reduceU , - reduce , - keepMapInPlaceU , - keepMapInPlace , - size , - toArray , - keysToArray , - valuesToArray , - fromArray , - mergeMany , - getBucketHistogram , - logStats , -} -/* No side effect */ diff --git a/lib/es6/belt_HashSet.js b/lib/es6/belt_HashSet.js deleted file mode 100644 index 035ed4d2a68..00000000000 --- a/lib/es6/belt_HashSet.js +++ /dev/null @@ -1,222 +0,0 @@ - - -import * as Belt_internalSetBuckets from "./belt_internalSetBuckets.js"; -import * as Belt_internalBucketsType from "./belt_internalBucketsType.js"; - -function copyBucket(hash, h_buckets, ndata_tail, _old_bucket) { - while(true) { - var old_bucket = _old_bucket; - if (old_bucket === undefined) { - return ; - } - var nidx = hash(old_bucket.key) & (h_buckets.length - 1 | 0); - var tail = ndata_tail[nidx]; - if (tail !== undefined) { - tail.next = old_bucket; - } else { - h_buckets[nidx] = old_bucket; - } - ndata_tail[nidx] = old_bucket; - _old_bucket = old_bucket.next; - continue ; - }; -} - -function remove(h, key) { - var eq = h.eq; - var h_buckets = h.buckets; - var i = h.hash(key) & (h_buckets.length - 1 | 0); - var l = h_buckets[i]; - if (l === undefined) { - return ; - } - var next_cell = l.next; - if (eq(l.key, key)) { - h.size = h.size - 1 | 0; - h_buckets[i] = next_cell; - return ; - } else if (next_cell !== undefined) { - var _prec = l; - var _cell = next_cell; - while(true) { - var cell = _cell; - var prec = _prec; - var cell_next = cell.next; - if (eq(cell.key, key)) { - prec.next = cell_next; - h.size = h.size - 1 | 0; - return ; - } - if (cell_next === undefined) { - return ; - } - _cell = cell_next; - _prec = cell; - continue ; - }; - } else { - return ; - } -} - -function addBucket(h, key, _cell, eq) { - while(true) { - var cell = _cell; - if (eq(cell.key, key)) { - return ; - } - var n = cell.next; - if (n !== undefined) { - _cell = n; - continue ; - } - h.size = h.size + 1 | 0; - cell.next = { - key: key, - next: undefined - }; - return ; - }; -} - -function add0(h, key, hash, eq) { - var h_buckets = h.buckets; - var buckets_len = h_buckets.length; - var i = hash(key) & (buckets_len - 1 | 0); - var l = h_buckets[i]; - if (l !== undefined) { - addBucket(h, key, l, eq); - } else { - h.size = h.size + 1 | 0; - h_buckets[i] = { - key: key, - next: undefined - }; - } - if (h.size > (buckets_len << 1)) { - var odata = h.buckets; - var osize = odata.length; - var nsize = (osize << 1); - if (nsize < osize) { - return ; - } - var h_buckets$1 = new Array(nsize); - var ndata_tail = new Array(nsize); - h.buckets = h_buckets$1; - for(var i$1 = 0; i$1 < osize; ++i$1){ - copyBucket(hash, h_buckets$1, ndata_tail, odata[i$1]); - } - for(var i$2 = 0; i$2 < nsize; ++i$2){ - var tail = ndata_tail[i$2]; - if (tail !== undefined) { - tail.next = undefined; - } - - } - return ; - } - -} - -function add(h, key) { - add0(h, key, h.hash, h.eq); -} - -function has(h, key) { - var eq = h.eq; - var h_buckets = h.buckets; - var nid = h.hash(key) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[nid]; - if (bucket !== undefined) { - var _cell = bucket; - while(true) { - var cell = _cell; - if (eq(cell.key, key)) { - return true; - } - var nextCell = cell.next; - if (nextCell === undefined) { - return false; - } - _cell = nextCell; - continue ; - }; - } else { - return false; - } -} - -function make(hintSize, id) { - return Belt_internalBucketsType.make(id.hash, id.eq, hintSize); -} - -function size(h) { - return h.size; -} - -function fromArray(arr, id) { - var eq = id.eq; - var hash = id.hash; - var len = arr.length; - var v = Belt_internalBucketsType.make(hash, eq, len); - for(var i = 0; i < len; ++i){ - add0(v, arr[i], hash, eq); - } - return v; -} - -function mergeMany(h, arr) { - var eq = h.eq; - var hash = h.hash; - var len = arr.length; - for(var i = 0; i < len; ++i){ - add0(h, arr[i], hash, eq); - } -} - -var Int; - -var $$String; - -var clear = Belt_internalBucketsType.clear; - -var isEmpty = Belt_internalBucketsType.isEmpty; - -var copy = Belt_internalSetBuckets.copy; - -var forEachU = Belt_internalSetBuckets.forEachU; - -var forEach = Belt_internalSetBuckets.forEach; - -var reduceU = Belt_internalSetBuckets.reduceU; - -var reduce = Belt_internalSetBuckets.reduce; - -var logStats = Belt_internalSetBuckets.logStats; - -var toArray = Belt_internalSetBuckets.toArray; - -var getBucketHistogram = Belt_internalSetBuckets.getBucketHistogram; - -export { - Int , - $$String , - make , - clear , - isEmpty , - add , - copy , - has , - remove , - forEachU , - forEach , - reduceU , - reduce , - size , - logStats , - toArray , - fromArray , - mergeMany , - getBucketHistogram , -} -/* No side effect */ diff --git a/lib/es6/belt_HashSetInt.js b/lib/es6/belt_HashSetInt.js deleted file mode 100644 index e550d44329a..00000000000 --- a/lib/es6/belt_HashSetInt.js +++ /dev/null @@ -1,207 +0,0 @@ - - -import * as Caml_hash_primitive from "./caml_hash_primitive.js"; -import * as Belt_internalSetBuckets from "./belt_internalSetBuckets.js"; -import * as Belt_internalBucketsType from "./belt_internalBucketsType.js"; - -function copyBucket(h_buckets, ndata_tail, _old_bucket) { - while(true) { - var old_bucket = _old_bucket; - if (old_bucket === undefined) { - return ; - } - var nidx = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, old_bucket.key)) & (h_buckets.length - 1 | 0); - var tail = ndata_tail[nidx]; - if (tail !== undefined) { - tail.next = old_bucket; - } else { - h_buckets[nidx] = old_bucket; - } - ndata_tail[nidx] = old_bucket; - _old_bucket = old_bucket.next; - continue ; - }; -} - -function remove(h, key) { - var h_buckets = h.buckets; - var i = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); - var l = h_buckets[i]; - if (l === undefined) { - return ; - } - var next_cell = l.next; - if (l.key === key) { - h.size = h.size - 1 | 0; - h_buckets[i] = next_cell; - return ; - } else if (next_cell !== undefined) { - var _prec = l; - var _cell = next_cell; - while(true) { - var cell = _cell; - var prec = _prec; - var cell_next = cell.next; - if (cell.key === key) { - prec.next = cell_next; - h.size = h.size - 1 | 0; - return ; - } - if (cell_next === undefined) { - return ; - } - _cell = cell_next; - _prec = cell; - continue ; - }; - } else { - return ; - } -} - -function addBucket(h, key, _cell) { - while(true) { - var cell = _cell; - if (cell.key === key) { - return ; - } - var n = cell.next; - if (n !== undefined) { - _cell = n; - continue ; - } - h.size = h.size + 1 | 0; - cell.next = { - key: key, - next: undefined - }; - return ; - }; -} - -function add(h, key) { - var h_buckets = h.buckets; - var buckets_len = h_buckets.length; - var i = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, key)) & (buckets_len - 1 | 0); - var l = h_buckets[i]; - if (l !== undefined) { - addBucket(h, key, l); - } else { - h_buckets[i] = { - key: key, - next: undefined - }; - h.size = h.size + 1 | 0; - } - if (h.size > (buckets_len << 1)) { - var odata = h.buckets; - var osize = odata.length; - var nsize = (osize << 1); - if (nsize < osize) { - return ; - } - var h_buckets$1 = new Array(nsize); - var ndata_tail = new Array(nsize); - h.buckets = h_buckets$1; - for(var i$1 = 0; i$1 < osize; ++i$1){ - copyBucket(h_buckets$1, ndata_tail, odata[i$1]); - } - for(var i$2 = 0; i$2 < nsize; ++i$2){ - var tail = ndata_tail[i$2]; - if (tail !== undefined) { - tail.next = undefined; - } - - } - return ; - } - -} - -function has(h, key) { - var h_buckets = h.buckets; - var nid = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[nid]; - if (bucket !== undefined) { - var _cell = bucket; - while(true) { - var cell = _cell; - if (cell.key === key) { - return true; - } - var nextCell = cell.next; - if (nextCell === undefined) { - return false; - } - _cell = nextCell; - continue ; - }; - } else { - return false; - } -} - -function make(hintSize) { - return Belt_internalBucketsType.make(undefined, undefined, hintSize); -} - -function size(h) { - return h.size; -} - -function fromArray(arr) { - var len = arr.length; - var v = Belt_internalBucketsType.make(undefined, undefined, len); - for(var i = 0; i < len; ++i){ - add(v, arr[i]); - } - return v; -} - -function mergeMany(h, arr) { - var len = arr.length; - for(var i = 0; i < len; ++i){ - add(h, arr[i]); - } -} - -var clear = Belt_internalBucketsType.clear; - -var isEmpty = Belt_internalBucketsType.isEmpty; - -var copy = Belt_internalSetBuckets.copy; - -var forEachU = Belt_internalSetBuckets.forEachU; - -var forEach = Belt_internalSetBuckets.forEach; - -var reduceU = Belt_internalSetBuckets.reduceU; - -var reduce = Belt_internalSetBuckets.reduce; - -var logStats = Belt_internalSetBuckets.logStats; - -var toArray = Belt_internalSetBuckets.toArray; - -var getBucketHistogram = Belt_internalSetBuckets.getBucketHistogram; - -export { - make , - clear , - isEmpty , - add , - copy , - has , - remove , - forEachU , - forEach , - reduceU , - reduce , - size , - logStats , - toArray , - fromArray , - mergeMany , - getBucketHistogram , -} -/* No side effect */ diff --git a/lib/es6/belt_HashSetString.js b/lib/es6/belt_HashSetString.js deleted file mode 100644 index f8ded0626ae..00000000000 --- a/lib/es6/belt_HashSetString.js +++ /dev/null @@ -1,207 +0,0 @@ - - -import * as Caml_hash_primitive from "./caml_hash_primitive.js"; -import * as Belt_internalSetBuckets from "./belt_internalSetBuckets.js"; -import * as Belt_internalBucketsType from "./belt_internalBucketsType.js"; - -function copyBucket(h_buckets, ndata_tail, _old_bucket) { - while(true) { - var old_bucket = _old_bucket; - if (old_bucket === undefined) { - return ; - } - var nidx = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, old_bucket.key)) & (h_buckets.length - 1 | 0); - var tail = ndata_tail[nidx]; - if (tail !== undefined) { - tail.next = old_bucket; - } else { - h_buckets[nidx] = old_bucket; - } - ndata_tail[nidx] = old_bucket; - _old_bucket = old_bucket.next; - continue ; - }; -} - -function remove(h, key) { - var h_buckets = h.buckets; - var i = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); - var l = h_buckets[i]; - if (l === undefined) { - return ; - } - var next_cell = l.next; - if (l.key === key) { - h.size = h.size - 1 | 0; - h_buckets[i] = next_cell; - return ; - } else if (next_cell !== undefined) { - var _prec = l; - var _cell = next_cell; - while(true) { - var cell = _cell; - var prec = _prec; - var cell_next = cell.next; - if (cell.key === key) { - prec.next = cell_next; - h.size = h.size - 1 | 0; - return ; - } - if (cell_next === undefined) { - return ; - } - _cell = cell_next; - _prec = cell; - continue ; - }; - } else { - return ; - } -} - -function addBucket(h, key, _cell) { - while(true) { - var cell = _cell; - if (cell.key === key) { - return ; - } - var n = cell.next; - if (n !== undefined) { - _cell = n; - continue ; - } - h.size = h.size + 1 | 0; - cell.next = { - key: key, - next: undefined - }; - return ; - }; -} - -function add(h, key) { - var h_buckets = h.buckets; - var buckets_len = h_buckets.length; - var i = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, key)) & (buckets_len - 1 | 0); - var l = h_buckets[i]; - if (l !== undefined) { - addBucket(h, key, l); - } else { - h_buckets[i] = { - key: key, - next: undefined - }; - h.size = h.size + 1 | 0; - } - if (h.size > (buckets_len << 1)) { - var odata = h.buckets; - var osize = odata.length; - var nsize = (osize << 1); - if (nsize < osize) { - return ; - } - var h_buckets$1 = new Array(nsize); - var ndata_tail = new Array(nsize); - h.buckets = h_buckets$1; - for(var i$1 = 0; i$1 < osize; ++i$1){ - copyBucket(h_buckets$1, ndata_tail, odata[i$1]); - } - for(var i$2 = 0; i$2 < nsize; ++i$2){ - var tail = ndata_tail[i$2]; - if (tail !== undefined) { - tail.next = undefined; - } - - } - return ; - } - -} - -function has(h, key) { - var h_buckets = h.buckets; - var nid = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[nid]; - if (bucket !== undefined) { - var _cell = bucket; - while(true) { - var cell = _cell; - if (cell.key === key) { - return true; - } - var nextCell = cell.next; - if (nextCell === undefined) { - return false; - } - _cell = nextCell; - continue ; - }; - } else { - return false; - } -} - -function make(hintSize) { - return Belt_internalBucketsType.make(undefined, undefined, hintSize); -} - -function size(h) { - return h.size; -} - -function fromArray(arr) { - var len = arr.length; - var v = Belt_internalBucketsType.make(undefined, undefined, len); - for(var i = 0; i < len; ++i){ - add(v, arr[i]); - } - return v; -} - -function mergeMany(h, arr) { - var len = arr.length; - for(var i = 0; i < len; ++i){ - add(h, arr[i]); - } -} - -var clear = Belt_internalBucketsType.clear; - -var isEmpty = Belt_internalBucketsType.isEmpty; - -var copy = Belt_internalSetBuckets.copy; - -var forEachU = Belt_internalSetBuckets.forEachU; - -var forEach = Belt_internalSetBuckets.forEach; - -var reduceU = Belt_internalSetBuckets.reduceU; - -var reduce = Belt_internalSetBuckets.reduce; - -var logStats = Belt_internalSetBuckets.logStats; - -var toArray = Belt_internalSetBuckets.toArray; - -var getBucketHistogram = Belt_internalSetBuckets.getBucketHistogram; - -export { - make , - clear , - isEmpty , - add , - copy , - has , - remove , - forEachU , - forEach , - reduceU , - reduce , - size , - logStats , - toArray , - fromArray , - mergeMany , - getBucketHistogram , -} -/* No side effect */ diff --git a/lib/es6/belt_Id.js b/lib/es6/belt_Id.js deleted file mode 100644 index 0c54f005e10..00000000000 --- a/lib/es6/belt_Id.js +++ /dev/null @@ -1,71 +0,0 @@ - - -import * as Curry from "./curry.js"; - -function MakeComparableU(M) { - return M; -} - -function MakeComparable(M) { - var cmp = M.cmp; - var cmp$1 = Curry.__2(cmp); - return { - cmp: cmp$1 - }; -} - -function comparableU(cmp) { - return { - cmp: cmp - }; -} - -function comparable(cmp) { - var cmp$1 = Curry.__2(cmp); - return { - cmp: cmp$1 - }; -} - -function MakeHashableU(M) { - return M; -} - -function MakeHashable(M) { - var hash = M.hash; - var hash$1 = Curry.__1(hash); - var eq = M.eq; - var eq$1 = Curry.__2(eq); - return { - hash: hash$1, - eq: eq$1 - }; -} - -function hashableU(hash, eq) { - return { - hash: hash, - eq: eq - }; -} - -function hashable(hash, eq) { - var hash$1 = Curry.__1(hash); - var eq$1 = Curry.__2(eq); - return { - hash: hash$1, - eq: eq$1 - }; -} - -export { - MakeComparableU , - MakeComparable , - comparableU , - comparable , - MakeHashableU , - MakeHashable , - hashableU , - hashable , -} -/* No side effect */ diff --git a/lib/es6/belt_Int.js b/lib/es6/belt_Int.js deleted file mode 100644 index 18782ec8ee3..00000000000 --- a/lib/es6/belt_Int.js +++ /dev/null @@ -1,16 +0,0 @@ - - - -function fromString(i) { - var i$1 = parseInt(i, 10); - if (isNaN(i$1)) { - return ; - } else { - return i$1; - } -} - -export { - fromString , -} -/* No side effect */ diff --git a/lib/es6/belt_List.js b/lib/es6/belt_List.js deleted file mode 100644 index 2b1e59ea520..00000000000 --- a/lib/es6/belt_List.js +++ /dev/null @@ -1,1512 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Belt_Array from "./belt_Array.js"; -import * as Caml_option from "./caml_option.js"; -import * as Belt_SortArray from "./belt_SortArray.js"; - -function head(x) { - if (x) { - return Caml_option.some(x.hd); - } - -} - -function headExn(x) { - if (x) { - return x.hd; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -function tail(x) { - if (x) { - return x.tl; - } - -} - -function tailExn(x) { - if (x) { - return x.tl; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -function add(xs, x) { - return { - hd: x, - tl: xs - }; -} - -function get(x, n) { - if (n < 0) { - return ; - } else { - var _x = x; - var _n = n; - while(true) { - var n$1 = _n; - var x$1 = _x; - if (!x$1) { - return ; - } - if (n$1 === 0) { - return Caml_option.some(x$1.hd); - } - _n = n$1 - 1 | 0; - _x = x$1.tl; - continue ; - }; - } -} - -function getExn(x, n) { - if (n < 0) { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - var _x = x; - var _n = n; - while(true) { - var n$1 = _n; - var x$1 = _x; - if (x$1) { - if (n$1 === 0) { - return x$1.hd; - } - _n = n$1 - 1 | 0; - _x = x$1.tl; - continue ; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function partitionAux(p, _cell, _precX, _precY) { - while(true) { - var precY = _precY; - var precX = _precX; - var cell = _cell; - if (!cell) { - return ; - } - var t = cell.tl; - var h = cell.hd; - var next = { - hd: h, - tl: /* [] */0 - }; - if (p(h)) { - precX.tl = next; - _precX = next; - _cell = t; - continue ; - } - precY.tl = next; - _precY = next; - _cell = t; - continue ; - }; -} - -function splitAux(_cell, _precX, _precY) { - while(true) { - var precY = _precY; - var precX = _precX; - var cell = _cell; - if (!cell) { - return ; - } - var match = cell.hd; - var nextA = { - hd: match[0], - tl: /* [] */0 - }; - var nextB = { - hd: match[1], - tl: /* [] */0 - }; - precX.tl = nextA; - precY.tl = nextB; - _precY = nextB; - _precX = nextA; - _cell = cell.tl; - continue ; - }; -} - -function copyAuxCont(_cellX, _prec) { - while(true) { - var prec = _prec; - var cellX = _cellX; - if (!cellX) { - return prec; - } - var next = { - hd: cellX.hd, - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellX = cellX.tl; - continue ; - }; -} - -function copyAuxWitFilter(f, _cellX, _prec) { - while(true) { - var prec = _prec; - var cellX = _cellX; - if (!cellX) { - return ; - } - var t = cellX.tl; - var h = cellX.hd; - if (f(h)) { - var next = { - hd: h, - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellX = t; - continue ; - } - _cellX = t; - continue ; - }; -} - -function copyAuxWithFilterIndex(f, _cellX, _prec, _i) { - while(true) { - var i = _i; - var prec = _prec; - var cellX = _cellX; - if (!cellX) { - return ; - } - var t = cellX.tl; - var h = cellX.hd; - if (f(h, i)) { - var next = { - hd: h, - tl: /* [] */0 - }; - prec.tl = next; - _i = i + 1 | 0; - _prec = next; - _cellX = t; - continue ; - } - _i = i + 1 | 0; - _cellX = t; - continue ; - }; -} - -function copyAuxWitFilterMap(f, _cellX, _prec) { - while(true) { - var prec = _prec; - var cellX = _cellX; - if (!cellX) { - return ; - } - var t = cellX.tl; - var h = f(cellX.hd); - if (h !== undefined) { - var next = { - hd: Caml_option.valFromOption(h), - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellX = t; - continue ; - } - _cellX = t; - continue ; - }; -} - -function removeAssocAuxWithMap(_cellX, x, _prec, f) { - while(true) { - var prec = _prec; - var cellX = _cellX; - if (!cellX) { - return false; - } - var t = cellX.tl; - var h = cellX.hd; - if (f(h[0], x)) { - prec.tl = t; - return true; - } - var next = { - hd: h, - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellX = t; - continue ; - }; -} - -function setAssocAuxWithMap(_cellX, x, k, _prec, eq) { - while(true) { - var prec = _prec; - var cellX = _cellX; - if (!cellX) { - return false; - } - var t = cellX.tl; - var h = cellX.hd; - if (eq(h[0], x)) { - prec.tl = { - hd: [ - x, - k - ], - tl: t - }; - return true; - } - var next = { - hd: h, - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellX = t; - continue ; - }; -} - -function copyAuxWithMap(_cellX, _prec, f) { - while(true) { - var prec = _prec; - var cellX = _cellX; - if (!cellX) { - return ; - } - var next = { - hd: f(cellX.hd), - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellX = cellX.tl; - continue ; - }; -} - -function zipAux(_cellX, _cellY, _prec) { - while(true) { - var prec = _prec; - var cellY = _cellY; - var cellX = _cellX; - if (!cellX) { - return ; - } - if (!cellY) { - return ; - } - var next = { - hd: [ - cellX.hd, - cellY.hd - ], - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellY = cellY.tl; - _cellX = cellX.tl; - continue ; - }; -} - -function copyAuxWithMap2(f, _cellX, _cellY, _prec) { - while(true) { - var prec = _prec; - var cellY = _cellY; - var cellX = _cellX; - if (!cellX) { - return ; - } - if (!cellY) { - return ; - } - var next = { - hd: f(cellX.hd, cellY.hd), - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellY = cellY.tl; - _cellX = cellX.tl; - continue ; - }; -} - -function copyAuxWithMapI(f, _i, _cellX, _prec) { - while(true) { - var prec = _prec; - var cellX = _cellX; - var i = _i; - if (!cellX) { - return ; - } - var next = { - hd: f(i, cellX.hd), - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellX = cellX.tl; - _i = i + 1 | 0; - continue ; - }; -} - -function takeAux(_n, _cell, _prec) { - while(true) { - var prec = _prec; - var cell = _cell; - var n = _n; - if (n === 0) { - return true; - } - if (!cell) { - return false; - } - var cell$1 = { - hd: cell.hd, - tl: /* [] */0 - }; - prec.tl = cell$1; - _prec = cell$1; - _cell = cell.tl; - _n = n - 1 | 0; - continue ; - }; -} - -function splitAtAux(_n, _cell, _prec) { - while(true) { - var prec = _prec; - var cell = _cell; - var n = _n; - if (n === 0) { - return cell; - } - if (!cell) { - return ; - } - var cell$1 = { - hd: cell.hd, - tl: /* [] */0 - }; - prec.tl = cell$1; - _prec = cell$1; - _cell = cell.tl; - _n = n - 1 | 0; - continue ; - }; -} - -function take(lst, n) { - if (n < 0) { - return ; - } - if (n === 0) { - return /* [] */0; - } - if (!lst) { - return ; - } - var cell = { - hd: lst.hd, - tl: /* [] */0 - }; - var has = takeAux(n - 1 | 0, lst.tl, cell); - if (has) { - return cell; - } - -} - -function drop(lst, n) { - if (n < 0) { - return ; - } else { - var _l = lst; - var _n = n; - while(true) { - var n$1 = _n; - var l = _l; - if (n$1 === 0) { - return l; - } - if (!l) { - return ; - } - _n = n$1 - 1 | 0; - _l = l.tl; - continue ; - }; - } -} - -function splitAt(lst, n) { - if (n < 0) { - return ; - } - if (n === 0) { - return [ - /* [] */0, - lst - ]; - } - if (!lst) { - return ; - } - var cell = { - hd: lst.hd, - tl: /* [] */0 - }; - var rest = splitAtAux(n - 1 | 0, lst.tl, cell); - if (rest !== undefined) { - return [ - cell, - rest - ]; - } - -} - -function concat(xs, ys) { - if (!xs) { - return ys; - } - var cell = { - hd: xs.hd, - tl: /* [] */0 - }; - copyAuxCont(xs.tl, cell).tl = ys; - return cell; -} - -function mapU(xs, f) { - if (!xs) { - return /* [] */0; - } - var cell = { - hd: f(xs.hd), - tl: /* [] */0 - }; - copyAuxWithMap(xs.tl, cell, f); - return cell; -} - -function map(xs, f) { - return mapU(xs, Curry.__1(f)); -} - -function zipByU(l1, l2, f) { - if (!l1) { - return /* [] */0; - } - if (!l2) { - return /* [] */0; - } - var cell = { - hd: f(l1.hd, l2.hd), - tl: /* [] */0 - }; - copyAuxWithMap2(f, l1.tl, l2.tl, cell); - return cell; -} - -function zipBy(l1, l2, f) { - return zipByU(l1, l2, Curry.__2(f)); -} - -function mapWithIndexU(xs, f) { - if (!xs) { - return /* [] */0; - } - var cell = { - hd: f(0, xs.hd), - tl: /* [] */0 - }; - copyAuxWithMapI(f, 1, xs.tl, cell); - return cell; -} - -function mapWithIndex(xs, f) { - return mapWithIndexU(xs, Curry.__2(f)); -} - -function makeByU(n, f) { - if (n <= 0) { - return /* [] */0; - } - var headX = { - hd: f(0), - tl: /* [] */0 - }; - var cur = headX; - var i = 1; - while(i < n) { - var v = { - hd: f(i), - tl: /* [] */0 - }; - cur.tl = v; - cur = v; - i = i + 1 | 0; - }; - return headX; -} - -function makeBy(n, f) { - return makeByU(n, Curry.__1(f)); -} - -function make(n, v) { - if (n <= 0) { - return /* [] */0; - } - var headX = { - hd: v, - tl: /* [] */0 - }; - var cur = headX; - var i = 1; - while(i < n) { - var v$1 = { - hd: v, - tl: /* [] */0 - }; - cur.tl = v$1; - cur = v$1; - i = i + 1 | 0; - }; - return headX; -} - -function length(xs) { - var _x = xs; - var _acc = 0; - while(true) { - var acc = _acc; - var x = _x; - if (!x) { - return acc; - } - _acc = acc + 1 | 0; - _x = x.tl; - continue ; - }; -} - -function fillAux(arr, _i, _x) { - while(true) { - var x = _x; - var i = _i; - if (!x) { - return ; - } - arr[i] = x.hd; - _x = x.tl; - _i = i + 1 | 0; - continue ; - }; -} - -function fromArray(a) { - var _i = a.length - 1 | 0; - var _res = /* [] */0; - while(true) { - var res = _res; - var i = _i; - if (i < 0) { - return res; - } - _res = { - hd: a[i], - tl: res - }; - _i = i - 1 | 0; - continue ; - }; -} - -function toArray(x) { - var len = length(x); - var arr = new Array(len); - fillAux(arr, 0, x); - return arr; -} - -function shuffle(xs) { - var v = toArray(xs); - Belt_Array.shuffleInPlace(v); - return fromArray(v); -} - -function reverseConcat(_l1, _l2) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (!l1) { - return l2; - } - _l2 = { - hd: l1.hd, - tl: l2 - }; - _l1 = l1.tl; - continue ; - }; -} - -function reverse(l) { - return reverseConcat(l, /* [] */0); -} - -function flattenAux(_prec, _xs) { - while(true) { - var xs = _xs; - var prec = _prec; - if (xs) { - _xs = xs.tl; - _prec = copyAuxCont(xs.hd, prec); - continue ; - } - prec.tl = /* [] */0; - return ; - }; -} - -function flatten(_xs) { - while(true) { - var xs = _xs; - if (!xs) { - return /* [] */0; - } - var match = xs.hd; - if (match) { - var cell = { - hd: match.hd, - tl: /* [] */0 - }; - flattenAux(copyAuxCont(match.tl, cell), xs.tl); - return cell; - } - _xs = xs.tl; - continue ; - }; -} - -function concatMany(xs) { - var len = xs.length; - if (len === 1) { - return xs[0]; - } - if (len === 0) { - return /* [] */0; - } - var len$1 = xs.length; - var v = xs[len$1 - 1 | 0]; - for(var i = len$1 - 2 | 0; i >= 0; --i){ - v = concat(xs[i], v); - } - return v; -} - -function mapReverseU(l, f) { - var _accu = /* [] */0; - var _xs = l; - while(true) { - var xs = _xs; - var accu = _accu; - if (!xs) { - return accu; - } - _xs = xs.tl; - _accu = { - hd: f(xs.hd), - tl: accu - }; - continue ; - }; -} - -function mapReverse(l, f) { - return mapReverseU(l, Curry.__1(f)); -} - -function forEachU(_xs, f) { - while(true) { - var xs = _xs; - if (!xs) { - return ; - } - f(xs.hd); - _xs = xs.tl; - continue ; - }; -} - -function forEach(xs, f) { - forEachU(xs, Curry.__1(f)); -} - -function forEachWithIndexU(l, f) { - var _xs = l; - var _i = 0; - while(true) { - var i = _i; - var xs = _xs; - if (!xs) { - return ; - } - f(i, xs.hd); - _i = i + 1 | 0; - _xs = xs.tl; - continue ; - }; -} - -function forEachWithIndex(l, f) { - forEachWithIndexU(l, Curry.__2(f)); -} - -function reduceU(_l, _accu, f) { - while(true) { - var accu = _accu; - var l = _l; - if (!l) { - return accu; - } - _accu = f(accu, l.hd); - _l = l.tl; - continue ; - }; -} - -function reduce(l, accu, f) { - return reduceU(l, accu, Curry.__2(f)); -} - -function reduceReverseUnsafeU(l, accu, f) { - if (l) { - return f(reduceReverseUnsafeU(l.tl, accu, f), l.hd); - } else { - return accu; - } -} - -function reduceReverseU(l, acc, f) { - var len = length(l); - if (len < 1000) { - return reduceReverseUnsafeU(l, acc, f); - } else { - return Belt_Array.reduceReverseU(toArray(l), acc, f); - } -} - -function reduceReverse(l, accu, f) { - return reduceReverseU(l, accu, Curry.__2(f)); -} - -function reduceWithIndexU(l, acc, f) { - var _l = l; - var _acc = acc; - var _i = 0; - while(true) { - var i = _i; - var acc$1 = _acc; - var l$1 = _l; - if (!l$1) { - return acc$1; - } - _i = i + 1 | 0; - _acc = f(acc$1, l$1.hd, i); - _l = l$1.tl; - continue ; - }; -} - -function reduceWithIndex(l, acc, f) { - return reduceWithIndexU(l, acc, Curry.__3(f)); -} - -function mapReverse2U(l1, l2, f) { - var _l1 = l1; - var _l2 = l2; - var _accu = /* [] */0; - while(true) { - var accu = _accu; - var l2$1 = _l2; - var l1$1 = _l1; - if (!l1$1) { - return accu; - } - if (!l2$1) { - return accu; - } - _accu = { - hd: f(l1$1.hd, l2$1.hd), - tl: accu - }; - _l2 = l2$1.tl; - _l1 = l1$1.tl; - continue ; - }; -} - -function mapReverse2(l1, l2, f) { - return mapReverse2U(l1, l2, Curry.__2(f)); -} - -function forEach2U(_l1, _l2, f) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (!l1) { - return ; - } - if (!l2) { - return ; - } - f(l1.hd, l2.hd); - _l2 = l2.tl; - _l1 = l1.tl; - continue ; - }; -} - -function forEach2(l1, l2, f) { - forEach2U(l1, l2, Curry.__2(f)); -} - -function reduce2U(_l1, _l2, _accu, f) { - while(true) { - var accu = _accu; - var l2 = _l2; - var l1 = _l1; - if (!l1) { - return accu; - } - if (!l2) { - return accu; - } - _accu = f(accu, l1.hd, l2.hd); - _l2 = l2.tl; - _l1 = l1.tl; - continue ; - }; -} - -function reduce2(l1, l2, acc, f) { - return reduce2U(l1, l2, acc, Curry.__3(f)); -} - -function reduceReverse2UnsafeU(l1, l2, accu, f) { - if (l1 && l2) { - return f(reduceReverse2UnsafeU(l1.tl, l2.tl, accu, f), l1.hd, l2.hd); - } else { - return accu; - } -} - -function reduceReverse2U(l1, l2, acc, f) { - var len = length(l1); - if (len < 1000) { - return reduceReverse2UnsafeU(l1, l2, acc, f); - } else { - return Belt_Array.reduceReverse2U(toArray(l1), toArray(l2), acc, f); - } -} - -function reduceReverse2(l1, l2, acc, f) { - return reduceReverse2U(l1, l2, acc, Curry.__3(f)); -} - -function everyU(_xs, p) { - while(true) { - var xs = _xs; - if (!xs) { - return true; - } - if (!p(xs.hd)) { - return false; - } - _xs = xs.tl; - continue ; - }; -} - -function every(xs, p) { - return everyU(xs, Curry.__1(p)); -} - -function someU(_xs, p) { - while(true) { - var xs = _xs; - if (!xs) { - return false; - } - if (p(xs.hd)) { - return true; - } - _xs = xs.tl; - continue ; - }; -} - -function some(xs, p) { - return someU(xs, Curry.__1(p)); -} - -function every2U(_l1, _l2, p) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (!l1) { - return true; - } - if (!l2) { - return true; - } - if (!p(l1.hd, l2.hd)) { - return false; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue ; - }; -} - -function every2(l1, l2, p) { - return every2U(l1, l2, Curry.__2(p)); -} - -function cmpByLength(_l1, _l2) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (!l1) { - if (l2) { - return -1; - } else { - return 0; - } - } - if (!l2) { - return 1; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue ; - }; -} - -function cmpU(_l1, _l2, p) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (!l1) { - if (l2) { - return -1; - } else { - return 0; - } - } - if (!l2) { - return 1; - } - var c = p(l1.hd, l2.hd); - if (c !== 0) { - return c; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue ; - }; -} - -function cmp(l1, l2, f) { - return cmpU(l1, l2, Curry.__2(f)); -} - -function eqU(_l1, _l2, p) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (!l1) { - if (l2) { - return false; - } else { - return true; - } - } - if (!l2) { - return false; - } - if (!p(l1.hd, l2.hd)) { - return false; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue ; - }; -} - -function eq(l1, l2, f) { - return eqU(l1, l2, Curry.__2(f)); -} - -function some2U(_l1, _l2, p) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (!l1) { - return false; - } - if (!l2) { - return false; - } - if (p(l1.hd, l2.hd)) { - return true; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue ; - }; -} - -function some2(l1, l2, p) { - return some2U(l1, l2, Curry.__2(p)); -} - -function hasU(_xs, x, eq) { - while(true) { - var xs = _xs; - if (!xs) { - return false; - } - if (eq(xs.hd, x)) { - return true; - } - _xs = xs.tl; - continue ; - }; -} - -function has(xs, x, eq) { - return hasU(xs, x, Curry.__2(eq)); -} - -function getAssocU(_xs, x, eq) { - while(true) { - var xs = _xs; - if (!xs) { - return ; - } - var match = xs.hd; - if (eq(match[0], x)) { - return Caml_option.some(match[1]); - } - _xs = xs.tl; - continue ; - }; -} - -function getAssoc(xs, x, eq) { - return getAssocU(xs, x, Curry.__2(eq)); -} - -function hasAssocU(_xs, x, eq) { - while(true) { - var xs = _xs; - if (!xs) { - return false; - } - if (eq(xs.hd[0], x)) { - return true; - } - _xs = xs.tl; - continue ; - }; -} - -function hasAssoc(xs, x, eq) { - return hasAssocU(xs, x, Curry.__2(eq)); -} - -function removeAssocU(xs, x, eq) { - if (!xs) { - return /* [] */0; - } - var l = xs.tl; - var pair = xs.hd; - if (eq(pair[0], x)) { - return l; - } - var cell = { - hd: pair, - tl: /* [] */0 - }; - var removed = removeAssocAuxWithMap(l, x, cell, eq); - if (removed) { - return cell; - } else { - return xs; - } -} - -function removeAssoc(xs, x, eq) { - return removeAssocU(xs, x, Curry.__2(eq)); -} - -function setAssocU(xs, x, k, eq) { - if (!xs) { - return { - hd: [ - x, - k - ], - tl: /* [] */0 - }; - } - var l = xs.tl; - var pair = xs.hd; - if (eq(pair[0], x)) { - return { - hd: [ - x, - k - ], - tl: l - }; - } - var cell = { - hd: pair, - tl: /* [] */0 - }; - var replaced = setAssocAuxWithMap(l, x, k, cell, eq); - if (replaced) { - return cell; - } else { - return { - hd: [ - x, - k - ], - tl: xs - }; - } -} - -function setAssoc(xs, x, k, eq) { - return setAssocU(xs, x, k, Curry.__2(eq)); -} - -function sortU(xs, cmp) { - var arr = toArray(xs); - Belt_SortArray.stableSortInPlaceByU(arr, cmp); - return fromArray(arr); -} - -function sort(xs, cmp) { - return sortU(xs, Curry.__2(cmp)); -} - -function getByU(_xs, p) { - while(true) { - var xs = _xs; - if (!xs) { - return ; - } - var x = xs.hd; - if (p(x)) { - return Caml_option.some(x); - } - _xs = xs.tl; - continue ; - }; -} - -function getBy(xs, p) { - return getByU(xs, Curry.__1(p)); -} - -function keepU(_xs, p) { - while(true) { - var xs = _xs; - if (!xs) { - return /* [] */0; - } - var t = xs.tl; - var h = xs.hd; - if (p(h)) { - var cell = { - hd: h, - tl: /* [] */0 - }; - copyAuxWitFilter(p, t, cell); - return cell; - } - _xs = t; - continue ; - }; -} - -function keep(xs, p) { - return keepU(xs, Curry.__1(p)); -} - -function keepWithIndexU(xs, p) { - var _xs = xs; - var _i = 0; - while(true) { - var i = _i; - var xs$1 = _xs; - if (!xs$1) { - return /* [] */0; - } - var t = xs$1.tl; - var h = xs$1.hd; - if (p(h, i)) { - var cell = { - hd: h, - tl: /* [] */0 - }; - copyAuxWithFilterIndex(p, t, cell, i + 1 | 0); - return cell; - } - _i = i + 1 | 0; - _xs = t; - continue ; - }; -} - -function keepWithIndex(xs, p) { - return keepWithIndexU(xs, Curry.__2(p)); -} - -function keepMapU(_xs, p) { - while(true) { - var xs = _xs; - if (!xs) { - return /* [] */0; - } - var t = xs.tl; - var h = p(xs.hd); - if (h !== undefined) { - var cell = { - hd: Caml_option.valFromOption(h), - tl: /* [] */0 - }; - copyAuxWitFilterMap(p, t, cell); - return cell; - } - _xs = t; - continue ; - }; -} - -function keepMap(xs, p) { - return keepMapU(xs, Curry.__1(p)); -} - -function partitionU(l, p) { - if (!l) { - return [ - /* [] */0, - /* [] */0 - ]; - } - var h = l.hd; - var nextX = { - hd: h, - tl: /* [] */0 - }; - var nextY = { - hd: h, - tl: /* [] */0 - }; - var b = p(h); - partitionAux(p, l.tl, nextX, nextY); - if (b) { - return [ - nextX, - nextY.tl - ]; - } else { - return [ - nextX.tl, - nextY - ]; - } -} - -function partition(l, p) { - return partitionU(l, Curry.__1(p)); -} - -function unzip(xs) { - if (!xs) { - return [ - /* [] */0, - /* [] */0 - ]; - } - var match = xs.hd; - var cellX = { - hd: match[0], - tl: /* [] */0 - }; - var cellY = { - hd: match[1], - tl: /* [] */0 - }; - splitAux(xs.tl, cellX, cellY); - return [ - cellX, - cellY - ]; -} - -function zip(l1, l2) { - if (!l1) { - return /* [] */0; - } - if (!l2) { - return /* [] */0; - } - var cell = { - hd: [ - l1.hd, - l2.hd - ], - tl: /* [] */0 - }; - zipAux(l1.tl, l2.tl, cell); - return cell; -} - -var size = length; - -var filter = keep; - -var filterWithIndex = keepWithIndex; - -export { - length , - size , - head , - headExn , - tail , - tailExn , - add , - get , - getExn , - make , - makeByU , - makeBy , - shuffle , - drop , - take , - splitAt , - concat , - concatMany , - reverseConcat , - flatten , - mapU , - map , - zip , - zipByU , - zipBy , - mapWithIndexU , - mapWithIndex , - fromArray , - toArray , - reverse , - mapReverseU , - mapReverse , - forEachU , - forEach , - forEachWithIndexU , - forEachWithIndex , - reduceU , - reduce , - reduceWithIndexU , - reduceWithIndex , - reduceReverseU , - reduceReverse , - mapReverse2U , - mapReverse2 , - forEach2U , - forEach2 , - reduce2U , - reduce2 , - reduceReverse2U , - reduceReverse2 , - everyU , - every , - someU , - some , - every2U , - every2 , - some2U , - some2 , - cmpByLength , - cmpU , - cmp , - eqU , - eq , - hasU , - has , - getByU , - getBy , - keepU , - keep , - filter , - keepWithIndexU , - keepWithIndex , - filterWithIndex , - keepMapU , - keepMap , - partitionU , - partition , - unzip , - getAssocU , - getAssoc , - hasAssocU , - hasAssoc , - removeAssocU , - removeAssoc , - setAssocU , - setAssoc , - sortU , - sort , -} -/* No side effect */ diff --git a/lib/es6/belt_Map.js b/lib/es6/belt_Map.js deleted file mode 100644 index c62b4dcb65b..00000000000 --- a/lib/es6/belt_Map.js +++ /dev/null @@ -1,376 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Belt_MapDict from "./belt_MapDict.js"; - -function fromArray(data, id) { - var cmp = id.cmp; - return { - cmp: cmp, - data: Belt_MapDict.fromArray(data, cmp) - }; -} - -function remove(m, x) { - var odata = m.data; - var cmp = m.cmp; - var newData = Belt_MapDict.remove(odata, x, cmp); - if (newData === odata) { - return m; - } else { - return { - cmp: cmp, - data: newData - }; - } -} - -function removeMany(m, x) { - var cmp = m.cmp; - var newData = Belt_MapDict.removeMany(m.data, x, cmp); - return { - cmp: cmp, - data: newData - }; -} - -function set(m, key, d) { - var cmp = m.cmp; - return { - cmp: cmp, - data: Belt_MapDict.set(m.data, key, d, cmp) - }; -} - -function mergeMany(m, e) { - var cmp = m.cmp; - return { - cmp: cmp, - data: Belt_MapDict.mergeMany(m.data, e, cmp) - }; -} - -function updateU(m, key, f) { - var cmp = m.cmp; - return { - cmp: cmp, - data: Belt_MapDict.updateU(m.data, key, f, cmp) - }; -} - -function update(m, key, f) { - return updateU(m, key, Curry.__1(f)); -} - -function split(m, x) { - var cmp = m.cmp; - var match = Belt_MapDict.split(m.data, x, cmp); - var match$1 = match[0]; - return [ - [ - { - cmp: cmp, - data: match$1[0] - }, - { - cmp: cmp, - data: match$1[1] - } - ], - match[1] - ]; -} - -function mergeU(s1, s2, f) { - var cmp = s1.cmp; - return { - cmp: cmp, - data: Belt_MapDict.mergeU(s1.data, s2.data, f, cmp) - }; -} - -function merge(s1, s2, f) { - return mergeU(s1, s2, Curry.__3(f)); -} - -function make(id) { - return { - cmp: id.cmp, - data: undefined - }; -} - -function isEmpty(map) { - return Belt_MapDict.isEmpty(map.data); -} - -function findFirstByU(m, f) { - return Belt_MapDict.findFirstByU(m.data, f); -} - -function findFirstBy(m, f) { - return Belt_MapDict.findFirstByU(m.data, Curry.__2(f)); -} - -function forEachU(m, f) { - Belt_MapDict.forEachU(m.data, f); -} - -function forEach(m, f) { - Belt_MapDict.forEachU(m.data, Curry.__2(f)); -} - -function reduceU(m, acc, f) { - return Belt_MapDict.reduceU(m.data, acc, f); -} - -function reduce(m, acc, f) { - return reduceU(m, acc, Curry.__3(f)); -} - -function everyU(m, f) { - return Belt_MapDict.everyU(m.data, f); -} - -function every(m, f) { - return Belt_MapDict.everyU(m.data, Curry.__2(f)); -} - -function someU(m, f) { - return Belt_MapDict.someU(m.data, f); -} - -function some(m, f) { - return Belt_MapDict.someU(m.data, Curry.__2(f)); -} - -function keepU(m, f) { - return { - cmp: m.cmp, - data: Belt_MapDict.keepU(m.data, f) - }; -} - -function keep(m, f) { - return keepU(m, Curry.__2(f)); -} - -function partitionU(m, p) { - var cmp = m.cmp; - var match = Belt_MapDict.partitionU(m.data, p); - return [ - { - cmp: cmp, - data: match[0] - }, - { - cmp: cmp, - data: match[1] - } - ]; -} - -function partition(m, p) { - return partitionU(m, Curry.__2(p)); -} - -function mapU(m, f) { - return { - cmp: m.cmp, - data: Belt_MapDict.mapU(m.data, f) - }; -} - -function map(m, f) { - return mapU(m, Curry.__1(f)); -} - -function mapWithKeyU(m, f) { - return { - cmp: m.cmp, - data: Belt_MapDict.mapWithKeyU(m.data, f) - }; -} - -function mapWithKey(m, f) { - return mapWithKeyU(m, Curry.__2(f)); -} - -function size(map) { - return Belt_MapDict.size(map.data); -} - -function toList(map) { - return Belt_MapDict.toList(map.data); -} - -function toArray(m) { - return Belt_MapDict.toArray(m.data); -} - -function keysToArray(m) { - return Belt_MapDict.keysToArray(m.data); -} - -function valuesToArray(m) { - return Belt_MapDict.valuesToArray(m.data); -} - -function minKey(m) { - return Belt_MapDict.minKey(m.data); -} - -function minKeyUndefined(m) { - return Belt_MapDict.minKeyUndefined(m.data); -} - -function maxKey(m) { - return Belt_MapDict.maxKey(m.data); -} - -function maxKeyUndefined(m) { - return Belt_MapDict.maxKeyUndefined(m.data); -} - -function minimum(m) { - return Belt_MapDict.minimum(m.data); -} - -function minUndefined(m) { - return Belt_MapDict.minUndefined(m.data); -} - -function maximum(m) { - return Belt_MapDict.maximum(m.data); -} - -function maxUndefined(m) { - return Belt_MapDict.maxUndefined(m.data); -} - -function get(map, x) { - return Belt_MapDict.get(map.data, x, map.cmp); -} - -function getUndefined(map, x) { - return Belt_MapDict.getUndefined(map.data, x, map.cmp); -} - -function getWithDefault(map, x, def) { - return Belt_MapDict.getWithDefault(map.data, x, def, map.cmp); -} - -function getExn(map, x) { - return Belt_MapDict.getExn(map.data, x, map.cmp); -} - -function has(map, x) { - return Belt_MapDict.has(map.data, x, map.cmp); -} - -function checkInvariantInternal(m) { - Belt_MapDict.checkInvariantInternal(m.data); -} - -function eqU(m1, m2, veq) { - return Belt_MapDict.eqU(m1.data, m2.data, m1.cmp, veq); -} - -function eq(m1, m2, veq) { - return eqU(m1, m2, Curry.__2(veq)); -} - -function cmpU(m1, m2, vcmp) { - return Belt_MapDict.cmpU(m1.data, m2.data, m1.cmp, vcmp); -} - -function cmp(m1, m2, vcmp) { - return cmpU(m1, m2, Curry.__2(vcmp)); -} - -function getData(m) { - return m.data; -} - -function getId(m) { - var cmp = m.cmp; - return { - cmp: cmp - }; -} - -function packIdData(id, data) { - return { - cmp: id.cmp, - data: data - }; -} - -var Int; - -var $$String; - -var Dict; - -export { - Int , - $$String , - Dict , - make , - isEmpty , - has , - cmpU , - cmp , - eqU , - eq , - findFirstByU , - findFirstBy , - forEachU , - forEach , - reduceU , - reduce , - everyU , - every , - someU , - some , - size , - toArray , - toList , - fromArray , - keysToArray , - valuesToArray , - minKey , - minKeyUndefined , - maxKey , - maxKeyUndefined , - minimum , - minUndefined , - maximum , - maxUndefined , - get , - getUndefined , - getWithDefault , - getExn , - remove , - removeMany , - set , - updateU , - update , - mergeMany , - mergeU , - merge , - keepU , - keep , - partitionU , - partition , - split , - mapU , - map , - mapWithKeyU , - mapWithKey , - getData , - getId , - packIdData , - checkInvariantInternal , -} -/* No side effect */ diff --git a/lib/es6/belt_MapDict.js b/lib/es6/belt_MapDict.js deleted file mode 100644 index 2d93c85ba8d..00000000000 --- a/lib/es6/belt_MapDict.js +++ /dev/null @@ -1,417 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Caml_option from "./caml_option.js"; -import * as Belt_internalAVLtree from "./belt_internalAVLtree.js"; - -function set(t, newK, newD, cmp) { - if (t === undefined) { - return Belt_internalAVLtree.singleton(newK, newD); - } - var k = t.k; - var c = cmp(newK, k); - if (c === 0) { - return Belt_internalAVLtree.updateValue(t, newD); - } - var l = t.l; - var r = t.r; - var v = t.v; - if (c < 0) { - return Belt_internalAVLtree.bal(set(l, newK, newD, cmp), k, v, r); - } else { - return Belt_internalAVLtree.bal(l, k, v, set(r, newK, newD, cmp)); - } -} - -function updateU(t, newK, f, cmp) { - if (t !== undefined) { - var k = t.k; - var c = cmp(newK, k); - if (c === 0) { - var newD = f(Caml_option.some(t.v)); - if (newD !== undefined) { - return Belt_internalAVLtree.updateValue(t, Caml_option.valFromOption(newD)); - } - var l = t.l; - var r = t.r; - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var kr = { - contents: r.k - }; - var vr = { - contents: r.v - }; - var r$1 = Belt_internalAVLtree.removeMinAuxWithRef(r, kr, vr); - return Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); - } - var l$1 = t.l; - var r$2 = t.r; - var v = t.v; - if (c < 0) { - var ll = updateU(l$1, newK, f, cmp); - if (l$1 === ll) { - return t; - } else { - return Belt_internalAVLtree.bal(ll, k, v, r$2); - } - } - var rr = updateU(r$2, newK, f, cmp); - if (r$2 === rr) { - return t; - } else { - return Belt_internalAVLtree.bal(l$1, k, v, rr); - } - } - var newD$1 = f(undefined); - if (newD$1 !== undefined) { - return Belt_internalAVLtree.singleton(newK, Caml_option.valFromOption(newD$1)); - } else { - return t; - } -} - -function update(t, newK, f, cmp) { - return updateU(t, newK, Curry.__1(f), cmp); -} - -function removeAux0(n, x, cmp) { - var v = n.k; - var l = n.l; - var r = n.r; - var c = cmp(x, v); - if (c === 0) { - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var kr = { - contents: r.k - }; - var vr = { - contents: r.v - }; - var r$1 = Belt_internalAVLtree.removeMinAuxWithRef(r, kr, vr); - return Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); - } - if (c < 0) { - if (l === undefined) { - return n; - } - var ll = removeAux0(l, x, cmp); - if (ll === l) { - return n; - } else { - return Belt_internalAVLtree.bal(ll, v, n.v, r); - } - } - if (r === undefined) { - return n; - } - var rr = removeAux0(r, x, cmp); - if (rr === r) { - return n; - } else { - return Belt_internalAVLtree.bal(l, v, n.v, rr); - } -} - -function remove(n, x, cmp) { - if (n !== undefined) { - return removeAux0(n, x, cmp); - } - -} - -function mergeMany(h, arr, cmp) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var match = arr[i]; - v = set(v, match[0], match[1], cmp); - } - return v; -} - -function splitAuxPivot(n, x, pres, cmp) { - var v = n.k; - var d = n.v; - var l = n.l; - var r = n.r; - var c = cmp(x, v); - if (c === 0) { - pres.contents = Caml_option.some(d); - return [ - l, - r - ]; - } - if (c < 0) { - if (l === undefined) { - return [ - undefined, - n - ]; - } - var match = splitAuxPivot(l, x, pres, cmp); - return [ - match[0], - Belt_internalAVLtree.join(match[1], v, d, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined - ]; - } - var match$1 = splitAuxPivot(r, x, pres, cmp); - return [ - Belt_internalAVLtree.join(l, v, d, match$1[0]), - match$1[1] - ]; -} - -function split(n, x, cmp) { - if (n === undefined) { - return [ - [ - undefined, - undefined - ], - undefined - ]; - } - var pres = { - contents: undefined - }; - var v = splitAuxPivot(n, x, pres, cmp); - return [ - v, - pres.contents - ]; -} - -function mergeU(s1, s2, f, cmp) { - if (s1 === undefined) { - if (s2 !== undefined) { - return Belt_internalAVLtree.keepMapU(s2, (function (k, v) { - return f(k, undefined, Caml_option.some(v)); - })); - } else { - return ; - } - } - if (s2 === undefined) { - return Belt_internalAVLtree.keepMapU(s1, (function (k, v) { - return f(k, Caml_option.some(v), undefined); - })); - } - if (s1.h >= s2.h) { - var v1 = s1.k; - var d1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var d2 = { - contents: undefined - }; - var match = splitAuxPivot(s2, v1, d2, cmp); - var d2$1 = d2.contents; - var newLeft = mergeU(l1, match[0], f, cmp); - var newD = f(v1, Caml_option.some(d1), d2$1); - var newRight = mergeU(r1, match[1], f, cmp); - return Belt_internalAVLtree.concatOrJoin(newLeft, v1, newD, newRight); - } - var v2 = s2.k; - var d2$2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - var d1$1 = { - contents: undefined - }; - var match$1 = splitAuxPivot(s1, v2, d1$1, cmp); - var d1$2 = d1$1.contents; - var newLeft$1 = mergeU(match$1[0], l2, f, cmp); - var newD$1 = f(v2, d1$2, Caml_option.some(d2$2)); - var newRight$1 = mergeU(match$1[1], r2, f, cmp); - return Belt_internalAVLtree.concatOrJoin(newLeft$1, v2, newD$1, newRight$1); -} - -function merge(s1, s2, f, cmp) { - return mergeU(s1, s2, Curry.__3(f), cmp); -} - -function removeMany(t, keys, cmp) { - var len = keys.length; - if (t !== undefined) { - var _t = t; - var _i = 0; - while(true) { - var i = _i; - var t$1 = _t; - if (i >= len) { - return t$1; - } - var ele = keys[i]; - var u = removeAux0(t$1, ele, cmp); - if (u === undefined) { - return u; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; - } - -} - -var empty; - -var isEmpty = Belt_internalAVLtree.isEmpty; - -var has = Belt_internalAVLtree.has; - -var cmpU = Belt_internalAVLtree.cmpU; - -var cmp = Belt_internalAVLtree.cmp; - -var eqU = Belt_internalAVLtree.eqU; - -var eq = Belt_internalAVLtree.eq; - -var findFirstByU = Belt_internalAVLtree.findFirstByU; - -var findFirstBy = Belt_internalAVLtree.findFirstBy; - -var forEachU = Belt_internalAVLtree.forEachU; - -var forEach = Belt_internalAVLtree.forEach; - -var reduceU = Belt_internalAVLtree.reduceU; - -var reduce = Belt_internalAVLtree.reduce; - -var everyU = Belt_internalAVLtree.everyU; - -var every = Belt_internalAVLtree.every; - -var someU = Belt_internalAVLtree.someU; - -var some = Belt_internalAVLtree.some; - -var size = Belt_internalAVLtree.size; - -var toList = Belt_internalAVLtree.toList; - -var toArray = Belt_internalAVLtree.toArray; - -var fromArray = Belt_internalAVLtree.fromArray; - -var keysToArray = Belt_internalAVLtree.keysToArray; - -var valuesToArray = Belt_internalAVLtree.valuesToArray; - -var minKey = Belt_internalAVLtree.minKey; - -var minKeyUndefined = Belt_internalAVLtree.minKeyUndefined; - -var maxKey = Belt_internalAVLtree.maxKey; - -var maxKeyUndefined = Belt_internalAVLtree.maxKeyUndefined; - -var minimum = Belt_internalAVLtree.minimum; - -var minUndefined = Belt_internalAVLtree.minUndefined; - -var maximum = Belt_internalAVLtree.maximum; - -var maxUndefined = Belt_internalAVLtree.maxUndefined; - -var get = Belt_internalAVLtree.get; - -var getUndefined = Belt_internalAVLtree.getUndefined; - -var getWithDefault = Belt_internalAVLtree.getWithDefault; - -var getExn = Belt_internalAVLtree.getExn; - -var checkInvariantInternal = Belt_internalAVLtree.checkInvariantInternal; - -var keepU = Belt_internalAVLtree.keepSharedU; - -var keep = Belt_internalAVLtree.keepShared; - -var partitionU = Belt_internalAVLtree.partitionSharedU; - -var partition = Belt_internalAVLtree.partitionShared; - -var mapU = Belt_internalAVLtree.mapU; - -var map = Belt_internalAVLtree.map; - -var mapWithKeyU = Belt_internalAVLtree.mapWithKeyU; - -var mapWithKey = Belt_internalAVLtree.mapWithKey; - -export { - empty , - isEmpty , - has , - cmpU , - cmp , - eqU , - eq , - findFirstByU , - findFirstBy , - forEachU , - forEach , - reduceU , - reduce , - everyU , - every , - someU , - some , - size , - toList , - toArray , - fromArray , - keysToArray , - valuesToArray , - minKey , - minKeyUndefined , - maxKey , - maxKeyUndefined , - minimum , - minUndefined , - maximum , - maxUndefined , - get , - getUndefined , - getWithDefault , - getExn , - checkInvariantInternal , - remove , - removeMany , - set , - updateU , - update , - mergeU , - merge , - mergeMany , - keepU , - keep , - partitionU , - partition , - split , - mapU , - map , - mapWithKeyU , - mapWithKey , -} -/* No side effect */ diff --git a/lib/es6/belt_MapInt.js b/lib/es6/belt_MapInt.js deleted file mode 100644 index 97f186d1412..00000000000 --- a/lib/es6/belt_MapInt.js +++ /dev/null @@ -1,307 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Caml_option from "./caml_option.js"; -import * as Belt_internalMapInt from "./belt_internalMapInt.js"; -import * as Belt_internalAVLtree from "./belt_internalAVLtree.js"; - -function set(t, newK, newD) { - if (t === undefined) { - return Belt_internalAVLtree.singleton(newK, newD); - } - var k = t.k; - if (newK === k) { - return Belt_internalAVLtree.updateValue(t, newD); - } - var v = t.v; - if (newK < k) { - return Belt_internalAVLtree.bal(set(t.l, newK, newD), k, v, t.r); - } else { - return Belt_internalAVLtree.bal(t.l, k, v, set(t.r, newK, newD)); - } -} - -function updateU(t, x, f) { - if (t !== undefined) { - var k = t.k; - if (x === k) { - var data = f(Caml_option.some(t.v)); - if (data !== undefined) { - return Belt_internalAVLtree.updateValue(t, Caml_option.valFromOption(data)); - } - var l = t.l; - var r = t.r; - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var kr = { - contents: r.k - }; - var vr = { - contents: r.v - }; - var r$1 = Belt_internalAVLtree.removeMinAuxWithRef(r, kr, vr); - return Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); - } - var v = t.v; - var l$1 = t.l; - var r$2 = t.r; - if (x < k) { - var ll = updateU(l$1, x, f); - if (l$1 === ll) { - return t; - } else { - return Belt_internalAVLtree.bal(ll, k, v, r$2); - } - } - var rr = updateU(r$2, x, f); - if (r$2 === rr) { - return t; - } else { - return Belt_internalAVLtree.bal(l$1, k, v, rr); - } - } - var data$1 = f(undefined); - if (data$1 !== undefined) { - return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); - } else { - return t; - } -} - -function update(t, x, f) { - return updateU(t, x, Curry.__1(f)); -} - -function removeAux(n, x) { - var v = n.k; - var l = n.l; - var r = n.r; - if (x === v) { - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var kr = { - contents: r.k - }; - var vr = { - contents: r.v - }; - var r$1 = Belt_internalAVLtree.removeMinAuxWithRef(r, kr, vr); - return Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); - } - if (x < v) { - if (l === undefined) { - return n; - } - var ll = removeAux(l, x); - if (ll === l) { - return n; - } else { - return Belt_internalAVLtree.bal(ll, v, n.v, r); - } - } - if (r === undefined) { - return n; - } - var rr = removeAux(r, x); - return Belt_internalAVLtree.bal(l, v, n.v, rr); -} - -function remove(n, x) { - if (n !== undefined) { - return removeAux(n, x); - } - -} - -function removeMany(t, keys) { - var len = keys.length; - if (t !== undefined) { - var _t = t; - var _i = 0; - while(true) { - var i = _i; - var t$1 = _t; - if (i >= len) { - return t$1; - } - var ele = keys[i]; - var u = removeAux(t$1, ele); - if (u === undefined) { - return u; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; - } - -} - -function mergeMany(h, arr) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var match = arr[i]; - v = set(v, match[0], match[1]); - } - return v; -} - -var empty; - -var isEmpty = Belt_internalAVLtree.isEmpty; - -var has = Belt_internalMapInt.has; - -var cmpU = Belt_internalMapInt.cmpU; - -var cmp = Belt_internalMapInt.cmp; - -var eqU = Belt_internalMapInt.eqU; - -var eq = Belt_internalMapInt.eq; - -var findFirstByU = Belt_internalAVLtree.findFirstByU; - -var findFirstBy = Belt_internalAVLtree.findFirstBy; - -var forEachU = Belt_internalAVLtree.forEachU; - -var forEach = Belt_internalAVLtree.forEach; - -var reduceU = Belt_internalAVLtree.reduceU; - -var reduce = Belt_internalAVLtree.reduce; - -var everyU = Belt_internalAVLtree.everyU; - -var every = Belt_internalAVLtree.every; - -var someU = Belt_internalAVLtree.someU; - -var some = Belt_internalAVLtree.some; - -var size = Belt_internalAVLtree.size; - -var toList = Belt_internalAVLtree.toList; - -var toArray = Belt_internalAVLtree.toArray; - -var fromArray = Belt_internalMapInt.fromArray; - -var keysToArray = Belt_internalAVLtree.keysToArray; - -var valuesToArray = Belt_internalAVLtree.valuesToArray; - -var minKey = Belt_internalAVLtree.minKey; - -var minKeyUndefined = Belt_internalAVLtree.minKeyUndefined; - -var maxKey = Belt_internalAVLtree.maxKey; - -var maxKeyUndefined = Belt_internalAVLtree.maxKeyUndefined; - -var minimum = Belt_internalAVLtree.minimum; - -var minUndefined = Belt_internalAVLtree.minUndefined; - -var maximum = Belt_internalAVLtree.maximum; - -var maxUndefined = Belt_internalAVLtree.maxUndefined; - -var get = Belt_internalMapInt.get; - -var getUndefined = Belt_internalMapInt.getUndefined; - -var getWithDefault = Belt_internalMapInt.getWithDefault; - -var getExn = Belt_internalMapInt.getExn; - -var checkInvariantInternal = Belt_internalAVLtree.checkInvariantInternal; - -var mergeU = Belt_internalMapInt.mergeU; - -var merge = Belt_internalMapInt.merge; - -var keepU = Belt_internalAVLtree.keepSharedU; - -var keep = Belt_internalAVLtree.keepShared; - -var partitionU = Belt_internalAVLtree.partitionSharedU; - -var partition = Belt_internalAVLtree.partitionShared; - -var split = Belt_internalMapInt.split; - -var mapU = Belt_internalAVLtree.mapU; - -var map = Belt_internalAVLtree.map; - -var mapWithKeyU = Belt_internalAVLtree.mapWithKeyU; - -var mapWithKey = Belt_internalAVLtree.mapWithKey; - -export { - empty , - isEmpty , - has , - cmpU , - cmp , - eqU , - eq , - findFirstByU , - findFirstBy , - forEachU , - forEach , - reduceU , - reduce , - everyU , - every , - someU , - some , - size , - toList , - toArray , - fromArray , - keysToArray , - valuesToArray , - minKey , - minKeyUndefined , - maxKey , - maxKeyUndefined , - minimum , - minUndefined , - maximum , - maxUndefined , - get , - getUndefined , - getWithDefault , - getExn , - checkInvariantInternal , - remove , - removeMany , - set , - updateU , - update , - mergeU , - merge , - mergeMany , - keepU , - keep , - partitionU , - partition , - split , - mapU , - map , - mapWithKeyU , - mapWithKey , -} -/* No side effect */ diff --git a/lib/es6/belt_MapString.js b/lib/es6/belt_MapString.js deleted file mode 100644 index b6e5e056714..00000000000 --- a/lib/es6/belt_MapString.js +++ /dev/null @@ -1,307 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Caml_option from "./caml_option.js"; -import * as Belt_internalAVLtree from "./belt_internalAVLtree.js"; -import * as Belt_internalMapString from "./belt_internalMapString.js"; - -function set(t, newK, newD) { - if (t === undefined) { - return Belt_internalAVLtree.singleton(newK, newD); - } - var k = t.k; - if (newK === k) { - return Belt_internalAVLtree.updateValue(t, newD); - } - var v = t.v; - if (newK < k) { - return Belt_internalAVLtree.bal(set(t.l, newK, newD), k, v, t.r); - } else { - return Belt_internalAVLtree.bal(t.l, k, v, set(t.r, newK, newD)); - } -} - -function updateU(t, x, f) { - if (t !== undefined) { - var k = t.k; - if (x === k) { - var data = f(Caml_option.some(t.v)); - if (data !== undefined) { - return Belt_internalAVLtree.updateValue(t, Caml_option.valFromOption(data)); - } - var l = t.l; - var r = t.r; - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var kr = { - contents: r.k - }; - var vr = { - contents: r.v - }; - var r$1 = Belt_internalAVLtree.removeMinAuxWithRef(r, kr, vr); - return Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); - } - var v = t.v; - var l$1 = t.l; - var r$2 = t.r; - if (x < k) { - var ll = updateU(l$1, x, f); - if (l$1 === ll) { - return t; - } else { - return Belt_internalAVLtree.bal(ll, k, v, r$2); - } - } - var rr = updateU(r$2, x, f); - if (r$2 === rr) { - return t; - } else { - return Belt_internalAVLtree.bal(l$1, k, v, rr); - } - } - var data$1 = f(undefined); - if (data$1 !== undefined) { - return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); - } else { - return t; - } -} - -function update(t, x, f) { - return updateU(t, x, Curry.__1(f)); -} - -function removeAux(n, x) { - var v = n.k; - var l = n.l; - var r = n.r; - if (x === v) { - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var kr = { - contents: r.k - }; - var vr = { - contents: r.v - }; - var r$1 = Belt_internalAVLtree.removeMinAuxWithRef(r, kr, vr); - return Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); - } - if (x < v) { - if (l === undefined) { - return n; - } - var ll = removeAux(l, x); - if (ll === l) { - return n; - } else { - return Belt_internalAVLtree.bal(ll, v, n.v, r); - } - } - if (r === undefined) { - return n; - } - var rr = removeAux(r, x); - return Belt_internalAVLtree.bal(l, v, n.v, rr); -} - -function remove(n, x) { - if (n !== undefined) { - return removeAux(n, x); - } - -} - -function removeMany(t, keys) { - var len = keys.length; - if (t !== undefined) { - var _t = t; - var _i = 0; - while(true) { - var i = _i; - var t$1 = _t; - if (i >= len) { - return t$1; - } - var ele = keys[i]; - var u = removeAux(t$1, ele); - if (u === undefined) { - return u; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; - } - -} - -function mergeMany(h, arr) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var match = arr[i]; - v = set(v, match[0], match[1]); - } - return v; -} - -var empty; - -var isEmpty = Belt_internalAVLtree.isEmpty; - -var has = Belt_internalMapString.has; - -var cmpU = Belt_internalMapString.cmpU; - -var cmp = Belt_internalMapString.cmp; - -var eqU = Belt_internalMapString.eqU; - -var eq = Belt_internalMapString.eq; - -var findFirstByU = Belt_internalAVLtree.findFirstByU; - -var findFirstBy = Belt_internalAVLtree.findFirstBy; - -var forEachU = Belt_internalAVLtree.forEachU; - -var forEach = Belt_internalAVLtree.forEach; - -var reduceU = Belt_internalAVLtree.reduceU; - -var reduce = Belt_internalAVLtree.reduce; - -var everyU = Belt_internalAVLtree.everyU; - -var every = Belt_internalAVLtree.every; - -var someU = Belt_internalAVLtree.someU; - -var some = Belt_internalAVLtree.some; - -var size = Belt_internalAVLtree.size; - -var toList = Belt_internalAVLtree.toList; - -var toArray = Belt_internalAVLtree.toArray; - -var fromArray = Belt_internalMapString.fromArray; - -var keysToArray = Belt_internalAVLtree.keysToArray; - -var valuesToArray = Belt_internalAVLtree.valuesToArray; - -var minKey = Belt_internalAVLtree.minKey; - -var minKeyUndefined = Belt_internalAVLtree.minKeyUndefined; - -var maxKey = Belt_internalAVLtree.maxKey; - -var maxKeyUndefined = Belt_internalAVLtree.maxKeyUndefined; - -var minimum = Belt_internalAVLtree.minimum; - -var minUndefined = Belt_internalAVLtree.minUndefined; - -var maximum = Belt_internalAVLtree.maximum; - -var maxUndefined = Belt_internalAVLtree.maxUndefined; - -var get = Belt_internalMapString.get; - -var getUndefined = Belt_internalMapString.getUndefined; - -var getWithDefault = Belt_internalMapString.getWithDefault; - -var getExn = Belt_internalMapString.getExn; - -var checkInvariantInternal = Belt_internalAVLtree.checkInvariantInternal; - -var mergeU = Belt_internalMapString.mergeU; - -var merge = Belt_internalMapString.merge; - -var keepU = Belt_internalAVLtree.keepSharedU; - -var keep = Belt_internalAVLtree.keepShared; - -var partitionU = Belt_internalAVLtree.partitionSharedU; - -var partition = Belt_internalAVLtree.partitionShared; - -var split = Belt_internalMapString.split; - -var mapU = Belt_internalAVLtree.mapU; - -var map = Belt_internalAVLtree.map; - -var mapWithKeyU = Belt_internalAVLtree.mapWithKeyU; - -var mapWithKey = Belt_internalAVLtree.mapWithKey; - -export { - empty , - isEmpty , - has , - cmpU , - cmp , - eqU , - eq , - findFirstByU , - findFirstBy , - forEachU , - forEach , - reduceU , - reduce , - everyU , - every , - someU , - some , - size , - toList , - toArray , - fromArray , - keysToArray , - valuesToArray , - minKey , - minKeyUndefined , - maxKey , - maxKeyUndefined , - minimum , - minUndefined , - maximum , - maxUndefined , - get , - getUndefined , - getWithDefault , - getExn , - checkInvariantInternal , - remove , - removeMany , - set , - updateU , - update , - mergeU , - merge , - mergeMany , - keepU , - keep , - partitionU , - partition , - split , - mapU , - map , - mapWithKeyU , - mapWithKey , -} -/* No side effect */ diff --git a/lib/es6/belt_MutableMap.js b/lib/es6/belt_MutableMap.js deleted file mode 100644 index f12cf3fa0d8..00000000000 --- a/lib/es6/belt_MutableMap.js +++ /dev/null @@ -1,395 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Caml_option from "./caml_option.js"; -import * as Belt_internalAVLtree from "./belt_internalAVLtree.js"; - -function removeMutateAux(nt, x, cmp) { - var k = nt.k; - var c = cmp(x, k); - if (c === 0) { - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLtree.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLtree.balMutate(nt); - } else { - return l; - } - } else if (r !== undefined) { - return r; - } else { - return l; - } - } - if (c < 0) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = removeMutateAux(l$1, x, cmp); - return Belt_internalAVLtree.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = removeMutateAux(r$1, x, cmp); - return Belt_internalAVLtree.balMutate(nt); - } else { - return nt; - } -} - -function remove(d, k) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var newRoot = removeMutateAux(oldRoot, k, d.cmp); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function removeArrayMutateAux(_t, xs, _i, len, cmp) { - while(true) { - var i = _i; - var t = _t; - if (i >= len) { - return t; - } - var ele = xs[i]; - var u = removeMutateAux(t, ele, cmp); - if (u === undefined) { - return ; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; -} - -function removeMany(d, xs) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var len = xs.length; - var newRoot = removeArrayMutateAux(oldRoot, xs, 0, len, d.cmp); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function updateDone(t, x, f, cmp) { - if (t !== undefined) { - var k = t.k; - var c = cmp(x, k); - if (c === 0) { - var data = f(Caml_option.some(t.v)); - if (data !== undefined) { - t.v = Caml_option.valFromOption(data); - return t; - } - var l = t.l; - var r = t.r; - if (l !== undefined) { - if (r !== undefined) { - t.r = Belt_internalAVLtree.removeMinAuxWithRootMutate(t, r); - return Belt_internalAVLtree.balMutate(t); - } else { - return l; - } - } else if (r !== undefined) { - return r; - } else { - return l; - } - } - if (c < 0) { - t.l = updateDone(t.l, x, f, cmp); - } else { - t.r = updateDone(t.r, x, f, cmp); - } - return Belt_internalAVLtree.balMutate(t); - } - var data$1 = f(undefined); - if (data$1 !== undefined) { - return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); - } else { - return t; - } -} - -function updateU(t, x, f) { - var oldRoot = t.data; - var newRoot = updateDone(oldRoot, x, f, t.cmp); - if (newRoot !== oldRoot) { - t.data = newRoot; - return ; - } - -} - -function update(t, x, f) { - updateU(t, x, Curry.__1(f)); -} - -function make(id) { - return { - cmp: id.cmp, - data: undefined - }; -} - -function clear(m) { - m.data = undefined; -} - -function isEmpty(d) { - var x = d.data; - return x === undefined; -} - -function minKey(m) { - return Belt_internalAVLtree.minKey(m.data); -} - -function minKeyUndefined(m) { - return Belt_internalAVLtree.minKeyUndefined(m.data); -} - -function maxKey(m) { - return Belt_internalAVLtree.maxKey(m.data); -} - -function maxKeyUndefined(m) { - return Belt_internalAVLtree.maxKeyUndefined(m.data); -} - -function minimum(m) { - return Belt_internalAVLtree.minimum(m.data); -} - -function minUndefined(m) { - return Belt_internalAVLtree.minUndefined(m.data); -} - -function maximum(m) { - return Belt_internalAVLtree.maximum(m.data); -} - -function maxUndefined(m) { - return Belt_internalAVLtree.maxUndefined(m.data); -} - -function forEachU(d, f) { - Belt_internalAVLtree.forEachU(d.data, f); -} - -function forEach(d, f) { - Belt_internalAVLtree.forEachU(d.data, Curry.__2(f)); -} - -function reduceU(d, acc, cb) { - return Belt_internalAVLtree.reduceU(d.data, acc, cb); -} - -function reduce(d, acc, cb) { - return reduceU(d, acc, Curry.__3(cb)); -} - -function everyU(d, p) { - return Belt_internalAVLtree.everyU(d.data, p); -} - -function every(d, p) { - return Belt_internalAVLtree.everyU(d.data, Curry.__2(p)); -} - -function someU(d, p) { - return Belt_internalAVLtree.someU(d.data, p); -} - -function some(d, p) { - return Belt_internalAVLtree.someU(d.data, Curry.__2(p)); -} - -function size(d) { - return Belt_internalAVLtree.size(d.data); -} - -function toList(d) { - return Belt_internalAVLtree.toList(d.data); -} - -function toArray(d) { - return Belt_internalAVLtree.toArray(d.data); -} - -function keysToArray(d) { - return Belt_internalAVLtree.keysToArray(d.data); -} - -function valuesToArray(d) { - return Belt_internalAVLtree.valuesToArray(d.data); -} - -function checkInvariantInternal(d) { - Belt_internalAVLtree.checkInvariantInternal(d.data); -} - -function cmpU(m1, m2, cmp) { - return Belt_internalAVLtree.cmpU(m1.data, m2.data, m1.cmp, cmp); -} - -function cmp(m1, m2, cmp$1) { - return cmpU(m1, m2, Curry.__2(cmp$1)); -} - -function eqU(m1, m2, cmp) { - return Belt_internalAVLtree.eqU(m1.data, m2.data, m1.cmp, cmp); -} - -function eq(m1, m2, cmp) { - return eqU(m1, m2, Curry.__2(cmp)); -} - -function mapU(m, f) { - return { - cmp: m.cmp, - data: Belt_internalAVLtree.mapU(m.data, f) - }; -} - -function map(m, f) { - return mapU(m, Curry.__1(f)); -} - -function mapWithKeyU(m, f) { - return { - cmp: m.cmp, - data: Belt_internalAVLtree.mapWithKeyU(m.data, f) - }; -} - -function mapWithKey(m, f) { - return mapWithKeyU(m, Curry.__2(f)); -} - -function get(m, x) { - return Belt_internalAVLtree.get(m.data, x, m.cmp); -} - -function getUndefined(m, x) { - return Belt_internalAVLtree.getUndefined(m.data, x, m.cmp); -} - -function getWithDefault(m, x, def) { - return Belt_internalAVLtree.getWithDefault(m.data, x, def, m.cmp); -} - -function getExn(m, x) { - return Belt_internalAVLtree.getExn(m.data, x, m.cmp); -} - -function has(m, x) { - return Belt_internalAVLtree.has(m.data, x, m.cmp); -} - -function fromArray(data, id) { - var cmp = id.cmp; - return { - cmp: cmp, - data: Belt_internalAVLtree.fromArray(data, cmp) - }; -} - -function set(m, e, v) { - var oldRoot = m.data; - var newRoot = Belt_internalAVLtree.updateMutate(oldRoot, e, v, m.cmp); - if (newRoot !== oldRoot) { - m.data = newRoot; - return ; - } - -} - -function mergeManyAux(t, xs, cmp) { - var v = t; - for(var i = 0 ,i_finish = xs.length; i < i_finish; ++i){ - var match = xs[i]; - v = Belt_internalAVLtree.updateMutate(v, match[0], match[1], cmp); - } - return v; -} - -function mergeMany(d, xs) { - var oldRoot = d.data; - var newRoot = mergeManyAux(oldRoot, xs, d.cmp); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -var Int; - -var $$String; - -export { - Int , - $$String , - make , - clear , - isEmpty , - has , - cmpU , - cmp , - eqU , - eq , - forEachU , - forEach , - reduceU , - reduce , - everyU , - every , - someU , - some , - size , - toList , - toArray , - fromArray , - keysToArray , - valuesToArray , - minKey , - minKeyUndefined , - maxKey , - maxKeyUndefined , - minimum , - minUndefined , - maximum , - maxUndefined , - get , - getUndefined , - getWithDefault , - getExn , - checkInvariantInternal , - remove , - removeMany , - set , - updateU , - update , - mergeMany , - mapU , - map , - mapWithKeyU , - mapWithKey , -} -/* No side effect */ diff --git a/lib/es6/belt_MutableMapInt.js b/lib/es6/belt_MutableMapInt.js deleted file mode 100644 index 6dbcb14769d..00000000000 --- a/lib/es6/belt_MutableMapInt.js +++ /dev/null @@ -1,362 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Caml_option from "./caml_option.js"; -import * as Belt_internalMapInt from "./belt_internalMapInt.js"; -import * as Belt_internalAVLtree from "./belt_internalAVLtree.js"; - -function make(param) { - return { - data: undefined - }; -} - -function isEmpty(m) { - var x = m.data; - return x === undefined; -} - -function clear(m) { - m.data = undefined; -} - -function minKeyUndefined(m) { - return Belt_internalAVLtree.minKeyUndefined(m.data); -} - -function minKey(m) { - return Belt_internalAVLtree.minKey(m.data); -} - -function maxKeyUndefined(m) { - return Belt_internalAVLtree.maxKeyUndefined(m.data); -} - -function maxKey(m) { - return Belt_internalAVLtree.maxKey(m.data); -} - -function minimum(m) { - return Belt_internalAVLtree.minimum(m.data); -} - -function minUndefined(m) { - return Belt_internalAVLtree.minUndefined(m.data); -} - -function maximum(m) { - return Belt_internalAVLtree.maximum(m.data); -} - -function maxUndefined(m) { - return Belt_internalAVLtree.maxUndefined(m.data); -} - -function set(m, k, v) { - var old_data = m.data; - var v$1 = Belt_internalMapInt.addMutate(old_data, k, v); - if (v$1 !== old_data) { - m.data = v$1; - return ; - } - -} - -function forEachU(d, f) { - Belt_internalAVLtree.forEachU(d.data, f); -} - -function forEach(d, f) { - Belt_internalAVLtree.forEachU(d.data, Curry.__2(f)); -} - -function mapU(d, f) { - return { - data: Belt_internalAVLtree.mapU(d.data, f) - }; -} - -function map(d, f) { - return mapU(d, Curry.__1(f)); -} - -function mapWithKeyU(d, f) { - return { - data: Belt_internalAVLtree.mapWithKeyU(d.data, f) - }; -} - -function mapWithKey(d, f) { - return mapWithKeyU(d, Curry.__2(f)); -} - -function reduceU(d, acc, f) { - return Belt_internalAVLtree.reduceU(d.data, acc, f); -} - -function reduce(d, acc, f) { - return reduceU(d, acc, Curry.__3(f)); -} - -function everyU(d, f) { - return Belt_internalAVLtree.everyU(d.data, f); -} - -function every(d, f) { - return Belt_internalAVLtree.everyU(d.data, Curry.__2(f)); -} - -function someU(d, f) { - return Belt_internalAVLtree.someU(d.data, f); -} - -function some(d, f) { - return Belt_internalAVLtree.someU(d.data, Curry.__2(f)); -} - -function size(d) { - return Belt_internalAVLtree.size(d.data); -} - -function toList(d) { - return Belt_internalAVLtree.toList(d.data); -} - -function toArray(d) { - return Belt_internalAVLtree.toArray(d.data); -} - -function keysToArray(d) { - return Belt_internalAVLtree.keysToArray(d.data); -} - -function valuesToArray(d) { - return Belt_internalAVLtree.valuesToArray(d.data); -} - -function checkInvariantInternal(d) { - Belt_internalAVLtree.checkInvariantInternal(d.data); -} - -function has(d, v) { - return Belt_internalMapInt.has(d.data, v); -} - -function removeMutateAux(nt, x) { - var k = nt.k; - if (x === k) { - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLtree.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLtree.balMutate(nt); - } else { - return l; - } - } else { - return r; - } - } - if (x < k) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = removeMutateAux(l$1, x); - return Belt_internalAVLtree.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = removeMutateAux(r$1, x); - return Belt_internalAVLtree.balMutate(nt); - } else { - return nt; - } -} - -function remove(d, v) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var newRoot = removeMutateAux(oldRoot, v); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function updateDone(t, x, f) { - if (t !== undefined) { - var k = t.k; - if (k === x) { - var data = f(Caml_option.some(t.v)); - if (data !== undefined) { - t.v = Caml_option.valFromOption(data); - return t; - } - var l = t.l; - var r = t.r; - if (l !== undefined) { - if (r !== undefined) { - t.r = Belt_internalAVLtree.removeMinAuxWithRootMutate(t, r); - return Belt_internalAVLtree.balMutate(t); - } else { - return l; - } - } else { - return r; - } - } - var l$1 = t.l; - var r$1 = t.r; - if (x < k) { - var ll = updateDone(l$1, x, f); - t.l = ll; - } else { - t.r = updateDone(r$1, x, f); - } - return Belt_internalAVLtree.balMutate(t); - } - var data$1 = f(undefined); - if (data$1 !== undefined) { - return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); - } else { - return t; - } -} - -function updateU(t, x, f) { - var oldRoot = t.data; - var newRoot = updateDone(oldRoot, x, f); - if (newRoot !== oldRoot) { - t.data = newRoot; - return ; - } - -} - -function update(t, x, f) { - updateU(t, x, Curry.__1(f)); -} - -function removeArrayMutateAux(_t, xs, _i, len) { - while(true) { - var i = _i; - var t = _t; - if (i >= len) { - return t; - } - var ele = xs[i]; - var u = removeMutateAux(t, ele); - if (u === undefined) { - return ; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; -} - -function removeMany(d, xs) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var len = xs.length; - var newRoot = removeArrayMutateAux(oldRoot, xs, 0, len); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function fromArray(xs) { - return { - data: Belt_internalMapInt.fromArray(xs) - }; -} - -function cmpU(d0, d1, f) { - return Belt_internalMapInt.cmpU(d0.data, d1.data, f); -} - -function cmp(d0, d1, f) { - return cmpU(d0, d1, Curry.__2(f)); -} - -function eqU(d0, d1, f) { - return Belt_internalMapInt.eqU(d0.data, d1.data, f); -} - -function eq(d0, d1, f) { - return eqU(d0, d1, Curry.__2(f)); -} - -function get(d, x) { - return Belt_internalMapInt.get(d.data, x); -} - -function getUndefined(d, x) { - return Belt_internalMapInt.getUndefined(d.data, x); -} - -function getWithDefault(d, x, def) { - return Belt_internalMapInt.getWithDefault(d.data, x, def); -} - -function getExn(d, x) { - return Belt_internalMapInt.getExn(d.data, x); -} - -export { - make , - clear , - isEmpty , - has , - cmpU , - cmp , - eqU , - eq , - forEachU , - forEach , - reduceU , - reduce , - everyU , - every , - someU , - some , - size , - toList , - toArray , - fromArray , - keysToArray , - valuesToArray , - minKey , - minKeyUndefined , - maxKey , - maxKeyUndefined , - minimum , - minUndefined , - maximum , - maxUndefined , - get , - getUndefined , - getWithDefault , - getExn , - checkInvariantInternal , - remove , - removeMany , - set , - updateU , - update , - mapU , - map , - mapWithKeyU , - mapWithKey , -} -/* No side effect */ diff --git a/lib/es6/belt_MutableMapString.js b/lib/es6/belt_MutableMapString.js deleted file mode 100644 index 8d1fe7a5786..00000000000 --- a/lib/es6/belt_MutableMapString.js +++ /dev/null @@ -1,362 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Caml_option from "./caml_option.js"; -import * as Belt_internalAVLtree from "./belt_internalAVLtree.js"; -import * as Belt_internalMapString from "./belt_internalMapString.js"; - -function make(param) { - return { - data: undefined - }; -} - -function isEmpty(m) { - var x = m.data; - return x === undefined; -} - -function clear(m) { - m.data = undefined; -} - -function minKeyUndefined(m) { - return Belt_internalAVLtree.minKeyUndefined(m.data); -} - -function minKey(m) { - return Belt_internalAVLtree.minKey(m.data); -} - -function maxKeyUndefined(m) { - return Belt_internalAVLtree.maxKeyUndefined(m.data); -} - -function maxKey(m) { - return Belt_internalAVLtree.maxKey(m.data); -} - -function minimum(m) { - return Belt_internalAVLtree.minimum(m.data); -} - -function minUndefined(m) { - return Belt_internalAVLtree.minUndefined(m.data); -} - -function maximum(m) { - return Belt_internalAVLtree.maximum(m.data); -} - -function maxUndefined(m) { - return Belt_internalAVLtree.maxUndefined(m.data); -} - -function set(m, k, v) { - var old_data = m.data; - var v$1 = Belt_internalMapString.addMutate(old_data, k, v); - if (v$1 !== old_data) { - m.data = v$1; - return ; - } - -} - -function forEachU(d, f) { - Belt_internalAVLtree.forEachU(d.data, f); -} - -function forEach(d, f) { - Belt_internalAVLtree.forEachU(d.data, Curry.__2(f)); -} - -function mapU(d, f) { - return { - data: Belt_internalAVLtree.mapU(d.data, f) - }; -} - -function map(d, f) { - return mapU(d, Curry.__1(f)); -} - -function mapWithKeyU(d, f) { - return { - data: Belt_internalAVLtree.mapWithKeyU(d.data, f) - }; -} - -function mapWithKey(d, f) { - return mapWithKeyU(d, Curry.__2(f)); -} - -function reduceU(d, acc, f) { - return Belt_internalAVLtree.reduceU(d.data, acc, f); -} - -function reduce(d, acc, f) { - return reduceU(d, acc, Curry.__3(f)); -} - -function everyU(d, f) { - return Belt_internalAVLtree.everyU(d.data, f); -} - -function every(d, f) { - return Belt_internalAVLtree.everyU(d.data, Curry.__2(f)); -} - -function someU(d, f) { - return Belt_internalAVLtree.someU(d.data, f); -} - -function some(d, f) { - return Belt_internalAVLtree.someU(d.data, Curry.__2(f)); -} - -function size(d) { - return Belt_internalAVLtree.size(d.data); -} - -function toList(d) { - return Belt_internalAVLtree.toList(d.data); -} - -function toArray(d) { - return Belt_internalAVLtree.toArray(d.data); -} - -function keysToArray(d) { - return Belt_internalAVLtree.keysToArray(d.data); -} - -function valuesToArray(d) { - return Belt_internalAVLtree.valuesToArray(d.data); -} - -function checkInvariantInternal(d) { - Belt_internalAVLtree.checkInvariantInternal(d.data); -} - -function has(d, v) { - return Belt_internalMapString.has(d.data, v); -} - -function removeMutateAux(nt, x) { - var k = nt.k; - if (x === k) { - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLtree.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLtree.balMutate(nt); - } else { - return l; - } - } else { - return r; - } - } - if (x < k) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = removeMutateAux(l$1, x); - return Belt_internalAVLtree.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = removeMutateAux(r$1, x); - return Belt_internalAVLtree.balMutate(nt); - } else { - return nt; - } -} - -function remove(d, v) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var newRoot = removeMutateAux(oldRoot, v); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function updateDone(t, x, f) { - if (t !== undefined) { - var k = t.k; - if (k === x) { - var data = f(Caml_option.some(t.v)); - if (data !== undefined) { - t.v = Caml_option.valFromOption(data); - return t; - } - var l = t.l; - var r = t.r; - if (l !== undefined) { - if (r !== undefined) { - t.r = Belt_internalAVLtree.removeMinAuxWithRootMutate(t, r); - return Belt_internalAVLtree.balMutate(t); - } else { - return l; - } - } else { - return r; - } - } - var l$1 = t.l; - var r$1 = t.r; - if (x < k) { - var ll = updateDone(l$1, x, f); - t.l = ll; - } else { - t.r = updateDone(r$1, x, f); - } - return Belt_internalAVLtree.balMutate(t); - } - var data$1 = f(undefined); - if (data$1 !== undefined) { - return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); - } else { - return t; - } -} - -function updateU(t, x, f) { - var oldRoot = t.data; - var newRoot = updateDone(oldRoot, x, f); - if (newRoot !== oldRoot) { - t.data = newRoot; - return ; - } - -} - -function update(t, x, f) { - updateU(t, x, Curry.__1(f)); -} - -function removeArrayMutateAux(_t, xs, _i, len) { - while(true) { - var i = _i; - var t = _t; - if (i >= len) { - return t; - } - var ele = xs[i]; - var u = removeMutateAux(t, ele); - if (u === undefined) { - return ; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; -} - -function removeMany(d, xs) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var len = xs.length; - var newRoot = removeArrayMutateAux(oldRoot, xs, 0, len); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function fromArray(xs) { - return { - data: Belt_internalMapString.fromArray(xs) - }; -} - -function cmpU(d0, d1, f) { - return Belt_internalMapString.cmpU(d0.data, d1.data, f); -} - -function cmp(d0, d1, f) { - return cmpU(d0, d1, Curry.__2(f)); -} - -function eqU(d0, d1, f) { - return Belt_internalMapString.eqU(d0.data, d1.data, f); -} - -function eq(d0, d1, f) { - return eqU(d0, d1, Curry.__2(f)); -} - -function get(d, x) { - return Belt_internalMapString.get(d.data, x); -} - -function getUndefined(d, x) { - return Belt_internalMapString.getUndefined(d.data, x); -} - -function getWithDefault(d, x, def) { - return Belt_internalMapString.getWithDefault(d.data, x, def); -} - -function getExn(d, x) { - return Belt_internalMapString.getExn(d.data, x); -} - -export { - make , - clear , - isEmpty , - has , - cmpU , - cmp , - eqU , - eq , - forEachU , - forEach , - reduceU , - reduce , - everyU , - every , - someU , - some , - size , - toList , - toArray , - fromArray , - keysToArray , - valuesToArray , - minKey , - minKeyUndefined , - maxKey , - maxKeyUndefined , - minimum , - minUndefined , - maximum , - maxUndefined , - get , - getUndefined , - getWithDefault , - getExn , - checkInvariantInternal , - remove , - removeMany , - set , - updateU , - update , - mapU , - map , - mapWithKeyU , - mapWithKey , -} -/* No side effect */ diff --git a/lib/es6/belt_MutableQueue.js b/lib/es6/belt_MutableQueue.js deleted file mode 100644 index eca9b3e2722..00000000000 --- a/lib/es6/belt_MutableQueue.js +++ /dev/null @@ -1,299 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Caml_option from "./caml_option.js"; - -function make(param) { - return { - length: 0, - first: undefined, - last: undefined - }; -} - -function clear(q) { - q.length = 0; - q.first = undefined; - q.last = undefined; -} - -function add(q, x) { - var cell = { - content: x, - next: undefined - }; - var last = q.last; - if (last !== undefined) { - q.length = q.length + 1 | 0; - last.next = cell; - q.last = cell; - } else { - q.length = 1; - q.first = cell; - q.last = cell; - } -} - -function peek(q) { - var v = q.first; - if (v !== undefined) { - return Caml_option.some(v.content); - } - -} - -function peekUndefined(q) { - var v = q.first; - if (v !== undefined) { - return v.content; - } - -} - -function peekExn(q) { - var v = q.first; - if (v !== undefined) { - return v.content; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -function pop(q) { - var x = q.first; - if (x === undefined) { - return ; - } - var next = x.next; - if (next === undefined) { - clear(q); - return Caml_option.some(x.content); - } else { - q.length = q.length - 1 | 0; - q.first = next; - return Caml_option.some(x.content); - } -} - -function popExn(q) { - var x = q.first; - if (x !== undefined) { - var next = x.next; - if (next === undefined) { - clear(q); - return x.content; - } else { - q.length = q.length - 1 | 0; - q.first = next; - return x.content; - } - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -function popUndefined(q) { - var x = q.first; - if (x === undefined) { - return ; - } - var next = x.next; - if (next === undefined) { - clear(q); - return x.content; - } else { - q.length = q.length - 1 | 0; - q.first = next; - return x.content; - } -} - -function copy(q) { - var qRes = { - length: q.length, - first: undefined, - last: undefined - }; - var _prev; - var _cell = q.first; - while(true) { - var cell = _cell; - var prev = _prev; - if (cell !== undefined) { - var content = cell.content; - var res = { - content: content, - next: undefined - }; - if (prev !== undefined) { - prev.next = res; - } else { - qRes.first = res; - } - _cell = cell.next; - _prev = res; - continue ; - } - qRes.last = prev; - return qRes; - }; -} - -function mapU(q, f) { - var qRes = { - length: q.length, - first: undefined, - last: undefined - }; - var _prev; - var _cell = q.first; - while(true) { - var cell = _cell; - var prev = _prev; - if (cell !== undefined) { - var content = f(cell.content); - var res = { - content: content, - next: undefined - }; - if (prev !== undefined) { - prev.next = res; - } else { - qRes.first = res; - } - _cell = cell.next; - _prev = res; - continue ; - } - qRes.last = prev; - return qRes; - }; -} - -function map(q, f) { - return mapU(q, Curry.__1(f)); -} - -function isEmpty(q) { - return q.length === 0; -} - -function size(q) { - return q.length; -} - -function forEachU(q, f) { - var _cell = q.first; - while(true) { - var cell = _cell; - if (cell === undefined) { - return ; - } - f(cell.content); - _cell = cell.next; - continue ; - }; -} - -function forEach(q, f) { - forEachU(q, Curry.__1(f)); -} - -function reduceU(q, accu, f) { - var _accu = accu; - var _cell = q.first; - while(true) { - var cell = _cell; - var accu$1 = _accu; - if (cell === undefined) { - return accu$1; - } - var accu$2 = f(accu$1, cell.content); - _cell = cell.next; - _accu = accu$2; - continue ; - }; -} - -function reduce(q, accu, f) { - return reduceU(q, accu, Curry.__2(f)); -} - -function transfer(q1, q2) { - if (q1.length <= 0) { - return ; - } - var l = q2.last; - if (l !== undefined) { - q2.length = q2.length + q1.length | 0; - l.next = q1.first; - q2.last = q1.last; - return clear(q1); - } else { - q2.length = q1.length; - q2.first = q1.first; - q2.last = q1.last; - return clear(q1); - } -} - -function fillAux(_i, arr, _cell) { - while(true) { - var cell = _cell; - var i = _i; - if (cell === undefined) { - return ; - } - arr[i] = cell.content; - _cell = cell.next; - _i = i + 1 | 0; - continue ; - }; -} - -function toArray(x) { - var v = new Array(x.length); - fillAux(0, v, x.first); - return v; -} - -function fromArray(arr) { - var q = { - length: 0, - first: undefined, - last: undefined - }; - for(var i = 0 ,i_finish = arr.length; i < i_finish; ++i){ - add(q, arr[i]); - } - return q; -} - -export { - make , - clear , - isEmpty , - fromArray , - add , - peek , - peekUndefined , - peekExn , - pop , - popUndefined , - popExn , - copy , - size , - mapU , - map , - forEachU , - forEach , - reduceU , - reduce , - transfer , - toArray , -} -/* No side effect */ diff --git a/lib/es6/belt_MutableSet.js b/lib/es6/belt_MutableSet.js deleted file mode 100644 index 8c200c57a14..00000000000 --- a/lib/es6/belt_MutableSet.js +++ /dev/null @@ -1,538 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Belt_SortArray from "./belt_SortArray.js"; -import * as Belt_internalAVLset from "./belt_internalAVLset.js"; - -function remove0(nt, x, cmp) { - var k = nt.v; - var c = cmp(x, k); - if (c === 0) { - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLset.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLset.balMutate(nt); - } else { - return l; - } - } else { - return r; - } - } - if (c < 0) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = remove0(l$1, x, cmp); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = remove0(r$1, x, cmp); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } -} - -function remove(d, v) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var newRoot = remove0(oldRoot, v, d.cmp); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function removeMany0(_t, xs, _i, len, cmp) { - while(true) { - var i = _i; - var t = _t; - if (i >= len) { - return t; - } - var ele = xs[i]; - var u = remove0(t, ele, cmp); - if (u === undefined) { - return ; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; -} - -function removeMany(d, xs) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var len = xs.length; - d.data = removeMany0(oldRoot, xs, 0, len, d.cmp); -} - -function removeCheck0(nt, x, removed, cmp) { - var k = nt.v; - var c = cmp(x, k); - if (c === 0) { - removed.contents = true; - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLset.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLset.balMutate(nt); - } else { - return l; - } - } else { - return r; - } - } - if (c < 0) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = removeCheck0(l$1, x, removed, cmp); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = removeCheck0(r$1, x, removed, cmp); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } -} - -function removeCheck(d, v) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return false; - } - var removed = { - contents: false - }; - var newRoot = removeCheck0(oldRoot, v, removed, d.cmp); - if (newRoot !== oldRoot) { - d.data = newRoot; - } - return removed.contents; -} - -function addCheck0(t, x, added, cmp) { - if (t !== undefined) { - var k = t.v; - var c = cmp(x, k); - if (c === 0) { - return t; - } - var l = t.l; - var r = t.r; - if (c < 0) { - var ll = addCheck0(l, x, added, cmp); - t.l = ll; - } else { - t.r = addCheck0(r, x, added, cmp); - } - return Belt_internalAVLset.balMutate(t); - } - added.contents = true; - return Belt_internalAVLset.singleton(x); -} - -function addCheck(m, e) { - var oldRoot = m.data; - var added = { - contents: false - }; - var newRoot = addCheck0(oldRoot, e, added, m.cmp); - if (newRoot !== oldRoot) { - m.data = newRoot; - } - return added.contents; -} - -function add(m, e) { - var oldRoot = m.data; - var newRoot = Belt_internalAVLset.addMutate(m.cmp, oldRoot, e); - if (newRoot !== oldRoot) { - m.data = newRoot; - return ; - } - -} - -function addArrayMutate(t, xs, cmp) { - var v = t; - for(var i = 0 ,i_finish = xs.length; i < i_finish; ++i){ - v = Belt_internalAVLset.addMutate(cmp, v, xs[i]); - } - return v; -} - -function mergeMany(d, xs) { - d.data = addArrayMutate(d.data, xs, d.cmp); -} - -function make(id) { - return { - cmp: id.cmp, - data: undefined - }; -} - -function isEmpty(d) { - var n = d.data; - return n === undefined; -} - -function minimum(d) { - return Belt_internalAVLset.minimum(d.data); -} - -function minUndefined(d) { - return Belt_internalAVLset.minUndefined(d.data); -} - -function maximum(d) { - return Belt_internalAVLset.maximum(d.data); -} - -function maxUndefined(d) { - return Belt_internalAVLset.maxUndefined(d.data); -} - -function forEachU(d, f) { - Belt_internalAVLset.forEachU(d.data, f); -} - -function forEach(d, f) { - Belt_internalAVLset.forEachU(d.data, Curry.__1(f)); -} - -function reduceU(d, acc, cb) { - return Belt_internalAVLset.reduceU(d.data, acc, cb); -} - -function reduce(d, acc, cb) { - return reduceU(d, acc, Curry.__2(cb)); -} - -function everyU(d, p) { - return Belt_internalAVLset.everyU(d.data, p); -} - -function every(d, p) { - return Belt_internalAVLset.everyU(d.data, Curry.__1(p)); -} - -function someU(d, p) { - return Belt_internalAVLset.someU(d.data, p); -} - -function some(d, p) { - return Belt_internalAVLset.someU(d.data, Curry.__1(p)); -} - -function size(d) { - return Belt_internalAVLset.size(d.data); -} - -function toList(d) { - return Belt_internalAVLset.toList(d.data); -} - -function toArray(d) { - return Belt_internalAVLset.toArray(d.data); -} - -function fromSortedArrayUnsafe(xs, id) { - return { - cmp: id.cmp, - data: Belt_internalAVLset.fromSortedArrayUnsafe(xs) - }; -} - -function checkInvariantInternal(d) { - Belt_internalAVLset.checkInvariantInternal(d.data); -} - -function fromArray(data, id) { - var cmp = id.cmp; - return { - cmp: cmp, - data: Belt_internalAVLset.fromArray(data, cmp) - }; -} - -function cmp(d0, d1) { - return Belt_internalAVLset.cmp(d0.data, d1.data, d0.cmp); -} - -function eq(d0, d1) { - return Belt_internalAVLset.eq(d0.data, d1.data, d0.cmp); -} - -function get(d, x) { - return Belt_internalAVLset.get(d.data, x, d.cmp); -} - -function getUndefined(d, x) { - return Belt_internalAVLset.getUndefined(d.data, x, d.cmp); -} - -function getExn(d, x) { - return Belt_internalAVLset.getExn(d.data, x, d.cmp); -} - -function split(d, key) { - var arr = Belt_internalAVLset.toArray(d.data); - var cmp = d.cmp; - var i = Belt_SortArray.binarySearchByU(arr, key, cmp); - var len = arr.length; - if (i >= 0) { - return [ - [ - { - cmp: cmp, - data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, i) - }, - { - cmp: cmp, - data: Belt_internalAVLset.fromSortedArrayAux(arr, i + 1 | 0, (len - i | 0) - 1 | 0) - } - ], - true - ]; - } - var next = (-i | 0) - 1 | 0; - return [ - [ - { - cmp: cmp, - data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, next) - }, - { - cmp: cmp, - data: Belt_internalAVLset.fromSortedArrayAux(arr, next, len - next | 0) - } - ], - false - ]; -} - -function keepU(d, p) { - return { - cmp: d.cmp, - data: Belt_internalAVLset.keepCopyU(d.data, p) - }; -} - -function keep(d, p) { - return keepU(d, Curry.__1(p)); -} - -function partitionU(d, p) { - var cmp = d.cmp; - var match = Belt_internalAVLset.partitionCopyU(d.data, p); - return [ - { - cmp: cmp, - data: match[0] - }, - { - cmp: cmp, - data: match[1] - } - ]; -} - -function partition(d, p) { - return partitionU(d, Curry.__1(p)); -} - -function subset(a, b) { - return Belt_internalAVLset.subset(a.data, b.data, a.cmp); -} - -function intersect(a, b) { - var cmp = a.cmp; - var match = a.data; - var match$1 = b.data; - if (match === undefined) { - return { - cmp: cmp, - data: undefined - }; - } - if (match$1 === undefined) { - return { - cmp: cmp, - data: undefined - }; - } - var sizea = Belt_internalAVLset.lengthNode(match); - var sizeb = Belt_internalAVLset.lengthNode(match$1); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(match, 0, tmp); - Belt_internalAVLset.fillArray(match$1, sizea, tmp); - if (cmp(tmp[sizea - 1 | 0], tmp[sizea]) < 0 || cmp(tmp[totalSize - 1 | 0], tmp[0]) < 0) { - return { - cmp: cmp, - data: undefined - }; - } - var tmp2 = new Array(sizea < sizeb ? sizea : sizeb); - var k = Belt_SortArray.intersectU(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0, cmp); - return { - cmp: cmp, - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function diff(a, b) { - var cmp = a.cmp; - var dataa = a.data; - var match = b.data; - if (dataa === undefined) { - return { - cmp: cmp, - data: undefined - }; - } - if (match === undefined) { - return { - cmp: cmp, - data: Belt_internalAVLset.copy(dataa) - }; - } - var sizea = Belt_internalAVLset.lengthNode(dataa); - var sizeb = Belt_internalAVLset.lengthNode(match); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(dataa, 0, tmp); - Belt_internalAVLset.fillArray(match, sizea, tmp); - if (cmp(tmp[sizea - 1 | 0], tmp[sizea]) < 0 || cmp(tmp[totalSize - 1 | 0], tmp[0]) < 0) { - return { - cmp: cmp, - data: Belt_internalAVLset.copy(dataa) - }; - } - var tmp2 = new Array(sizea); - var k = Belt_SortArray.diffU(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0, cmp); - return { - cmp: cmp, - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function union(a, b) { - var cmp = a.cmp; - var dataa = a.data; - var datab = b.data; - if (dataa === undefined) { - return { - cmp: cmp, - data: Belt_internalAVLset.copy(datab) - }; - } - if (datab === undefined) { - return { - cmp: cmp, - data: Belt_internalAVLset.copy(dataa) - }; - } - var sizea = Belt_internalAVLset.lengthNode(dataa); - var sizeb = Belt_internalAVLset.lengthNode(datab); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(dataa, 0, tmp); - Belt_internalAVLset.fillArray(datab, sizea, tmp); - if (cmp(tmp[sizea - 1 | 0], tmp[sizea]) < 0) { - return { - cmp: cmp, - data: Belt_internalAVLset.fromSortedArrayAux(tmp, 0, totalSize) - }; - } - var tmp2 = new Array(totalSize); - var k = Belt_SortArray.unionU(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0, cmp); - return { - cmp: cmp, - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function has(d, x) { - return Belt_internalAVLset.has(d.data, x, d.cmp); -} - -function copy(d) { - return { - cmp: d.cmp, - data: Belt_internalAVLset.copy(d.data) - }; -} - -var Int; - -var $$String; - -export { - Int , - $$String , - make , - fromArray , - fromSortedArrayUnsafe , - copy , - isEmpty , - has , - add , - addCheck , - mergeMany , - remove , - removeCheck , - removeMany , - union , - intersect , - diff , - subset , - cmp , - eq , - forEachU , - forEach , - reduceU , - reduce , - everyU , - every , - someU , - some , - keepU , - keep , - partitionU , - partition , - size , - toList , - toArray , - minimum , - minUndefined , - maximum , - maxUndefined , - get , - getUndefined , - getExn , - split , - checkInvariantInternal , -} -/* No side effect */ diff --git a/lib/es6/belt_MutableSetInt.js b/lib/es6/belt_MutableSetInt.js deleted file mode 100644 index 9e7489221d4..00000000000 --- a/lib/es6/belt_MutableSetInt.js +++ /dev/null @@ -1,501 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Belt_SortArrayInt from "./belt_SortArrayInt.js"; -import * as Belt_internalAVLset from "./belt_internalAVLset.js"; -import * as Belt_internalSetInt from "./belt_internalSetInt.js"; - -function remove0(nt, x) { - var k = nt.v; - if (x === k) { - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLset.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLset.balMutate(nt); - } else { - return l; - } - } else { - return r; - } - } - if (x < k) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = remove0(l$1, x); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = remove0(r$1, x); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } -} - -function remove(d, v) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var newRoot = remove0(oldRoot, v); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function removeMany0(_t, xs, _i, len) { - while(true) { - var i = _i; - var t = _t; - if (i >= len) { - return t; - } - var ele = xs[i]; - var u = remove0(t, ele); - if (u === undefined) { - return ; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; -} - -function removeMany(d, xs) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var len = xs.length; - d.data = removeMany0(oldRoot, xs, 0, len); -} - -function removeCheck0(nt, x, removed) { - var k = nt.v; - if (x === k) { - removed.contents = true; - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLset.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLset.balMutate(nt); - } else { - return l; - } - } else { - return r; - } - } - if (x < k) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = removeCheck0(l$1, x, removed); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = removeCheck0(r$1, x, removed); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } -} - -function removeCheck(d, v) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return false; - } - var removed = { - contents: false - }; - var newRoot = removeCheck0(oldRoot, v, removed); - if (newRoot !== oldRoot) { - d.data = newRoot; - } - return removed.contents; -} - -function addCheck0(t, x, added) { - if (t !== undefined) { - var k = t.v; - if (x === k) { - return t; - } - var l = t.l; - var r = t.r; - if (x < k) { - var ll = addCheck0(l, x, added); - t.l = ll; - } else { - t.r = addCheck0(r, x, added); - } - return Belt_internalAVLset.balMutate(t); - } - added.contents = true; - return Belt_internalAVLset.singleton(x); -} - -function addCheck(m, e) { - var oldRoot = m.data; - var added = { - contents: false - }; - var newRoot = addCheck0(oldRoot, e, added); - if (newRoot !== oldRoot) { - m.data = newRoot; - } - return added.contents; -} - -function add(d, k) { - var oldRoot = d.data; - var v = Belt_internalSetInt.addMutate(oldRoot, k); - if (v !== oldRoot) { - d.data = v; - return ; - } - -} - -function addArrayMutate(t, xs) { - var v = t; - for(var i = 0 ,i_finish = xs.length; i < i_finish; ++i){ - v = Belt_internalSetInt.addMutate(v, xs[i]); - } - return v; -} - -function mergeMany(d, arr) { - d.data = addArrayMutate(d.data, arr); -} - -function make(param) { - return { - data: undefined - }; -} - -function isEmpty(d) { - var n = d.data; - return n === undefined; -} - -function minimum(d) { - return Belt_internalAVLset.minimum(d.data); -} - -function minUndefined(d) { - return Belt_internalAVLset.minUndefined(d.data); -} - -function maximum(d) { - return Belt_internalAVLset.maximum(d.data); -} - -function maxUndefined(d) { - return Belt_internalAVLset.maxUndefined(d.data); -} - -function forEachU(d, f) { - Belt_internalAVLset.forEachU(d.data, f); -} - -function forEach(d, f) { - Belt_internalAVLset.forEachU(d.data, Curry.__1(f)); -} - -function reduceU(d, acc, cb) { - return Belt_internalAVLset.reduceU(d.data, acc, cb); -} - -function reduce(d, acc, cb) { - return reduceU(d, acc, Curry.__2(cb)); -} - -function everyU(d, p) { - return Belt_internalAVLset.everyU(d.data, p); -} - -function every(d, p) { - return Belt_internalAVLset.everyU(d.data, Curry.__1(p)); -} - -function someU(d, p) { - return Belt_internalAVLset.someU(d.data, p); -} - -function some(d, p) { - return Belt_internalAVLset.someU(d.data, Curry.__1(p)); -} - -function size(d) { - return Belt_internalAVLset.size(d.data); -} - -function toList(d) { - return Belt_internalAVLset.toList(d.data); -} - -function toArray(d) { - return Belt_internalAVLset.toArray(d.data); -} - -function fromSortedArrayUnsafe(xs) { - return { - data: Belt_internalAVLset.fromSortedArrayUnsafe(xs) - }; -} - -function checkInvariantInternal(d) { - Belt_internalAVLset.checkInvariantInternal(d.data); -} - -function fromArray(xs) { - return { - data: Belt_internalSetInt.fromArray(xs) - }; -} - -function cmp(d0, d1) { - return Belt_internalSetInt.cmp(d0.data, d1.data); -} - -function eq(d0, d1) { - return Belt_internalSetInt.eq(d0.data, d1.data); -} - -function get(d, x) { - return Belt_internalSetInt.get(d.data, x); -} - -function getUndefined(d, x) { - return Belt_internalSetInt.getUndefined(d.data, x); -} - -function getExn(d, x) { - return Belt_internalSetInt.getExn(d.data, x); -} - -function split(d, key) { - var arr = Belt_internalAVLset.toArray(d.data); - var i = Belt_SortArrayInt.binarySearch(arr, key); - var len = arr.length; - if (i >= 0) { - return [ - [ - { - data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, i) - }, - { - data: Belt_internalAVLset.fromSortedArrayAux(arr, i + 1 | 0, (len - i | 0) - 1 | 0) - } - ], - true - ]; - } - var next = (-i | 0) - 1 | 0; - return [ - [ - { - data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, next) - }, - { - data: Belt_internalAVLset.fromSortedArrayAux(arr, next, len - next | 0) - } - ], - false - ]; -} - -function keepU(d, p) { - return { - data: Belt_internalAVLset.keepCopyU(d.data, p) - }; -} - -function keep(d, p) { - return keepU(d, Curry.__1(p)); -} - -function partitionU(d, p) { - var match = Belt_internalAVLset.partitionCopyU(d.data, p); - return [ - { - data: match[0] - }, - { - data: match[1] - } - ]; -} - -function partition(d, p) { - return partitionU(d, Curry.__1(p)); -} - -function subset(a, b) { - return Belt_internalSetInt.subset(a.data, b.data); -} - -function intersect(dataa, datab) { - var dataa$1 = dataa.data; - var datab$1 = datab.data; - if (dataa$1 === undefined) { - return { - data: undefined - }; - } - if (datab$1 === undefined) { - return { - data: undefined - }; - } - var sizea = Belt_internalAVLset.lengthNode(dataa$1); - var sizeb = Belt_internalAVLset.lengthNode(datab$1); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(dataa$1, 0, tmp); - Belt_internalAVLset.fillArray(datab$1, sizea, tmp); - if (tmp[sizea - 1 | 0] < tmp[sizea] || tmp[totalSize - 1 | 0] < tmp[0]) { - return { - data: undefined - }; - } - var tmp2 = new Array(sizea < sizeb ? sizea : sizeb); - var k = Belt_SortArrayInt.intersect(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); - return { - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function diff(dataa, datab) { - var dataa$1 = dataa.data; - var datab$1 = datab.data; - if (dataa$1 === undefined) { - return { - data: undefined - }; - } - if (datab$1 === undefined) { - return { - data: Belt_internalAVLset.copy(dataa$1) - }; - } - var sizea = Belt_internalAVLset.lengthNode(dataa$1); - var sizeb = Belt_internalAVLset.lengthNode(datab$1); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(dataa$1, 0, tmp); - Belt_internalAVLset.fillArray(datab$1, sizea, tmp); - if (tmp[sizea - 1 | 0] < tmp[sizea] || tmp[totalSize - 1 | 0] < tmp[0]) { - return { - data: Belt_internalAVLset.copy(dataa$1) - }; - } - var tmp2 = new Array(sizea); - var k = Belt_SortArrayInt.diff(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); - return { - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function union(dataa, datab) { - var dataa$1 = dataa.data; - var datab$1 = datab.data; - if (dataa$1 === undefined) { - return { - data: Belt_internalAVLset.copy(datab$1) - }; - } - if (datab$1 === undefined) { - return { - data: Belt_internalAVLset.copy(dataa$1) - }; - } - var sizea = Belt_internalAVLset.lengthNode(dataa$1); - var sizeb = Belt_internalAVLset.lengthNode(datab$1); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(dataa$1, 0, tmp); - Belt_internalAVLset.fillArray(datab$1, sizea, tmp); - if (tmp[sizea - 1 | 0] < tmp[sizea]) { - return { - data: Belt_internalAVLset.fromSortedArrayAux(tmp, 0, totalSize) - }; - } - var tmp2 = new Array(totalSize); - var k = Belt_SortArrayInt.union(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); - return { - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function has(d, x) { - return Belt_internalSetInt.has(d.data, x); -} - -function copy(d) { - return { - data: Belt_internalAVLset.copy(d.data) - }; -} - -export { - make , - fromArray , - fromSortedArrayUnsafe , - copy , - isEmpty , - has , - add , - addCheck , - mergeMany , - remove , - removeCheck , - removeMany , - union , - intersect , - diff , - subset , - cmp , - eq , - forEachU , - forEach , - reduceU , - reduce , - everyU , - every , - someU , - some , - keepU , - keep , - partitionU , - partition , - size , - toList , - toArray , - minimum , - minUndefined , - maximum , - maxUndefined , - get , - getUndefined , - getExn , - split , - checkInvariantInternal , -} -/* No side effect */ diff --git a/lib/es6/belt_MutableSetString.js b/lib/es6/belt_MutableSetString.js deleted file mode 100644 index a129f529f52..00000000000 --- a/lib/es6/belt_MutableSetString.js +++ /dev/null @@ -1,501 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Belt_internalAVLset from "./belt_internalAVLset.js"; -import * as Belt_SortArrayString from "./belt_SortArrayString.js"; -import * as Belt_internalSetString from "./belt_internalSetString.js"; - -function remove0(nt, x) { - var k = nt.v; - if (x === k) { - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLset.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLset.balMutate(nt); - } else { - return l; - } - } else { - return r; - } - } - if (x < k) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = remove0(l$1, x); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = remove0(r$1, x); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } -} - -function remove(d, v) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var newRoot = remove0(oldRoot, v); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function removeMany0(_t, xs, _i, len) { - while(true) { - var i = _i; - var t = _t; - if (i >= len) { - return t; - } - var ele = xs[i]; - var u = remove0(t, ele); - if (u === undefined) { - return ; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; -} - -function removeMany(d, xs) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var len = xs.length; - d.data = removeMany0(oldRoot, xs, 0, len); -} - -function removeCheck0(nt, x, removed) { - var k = nt.v; - if (x === k) { - removed.contents = true; - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLset.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLset.balMutate(nt); - } else { - return l; - } - } else { - return r; - } - } - if (x < k) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = removeCheck0(l$1, x, removed); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = removeCheck0(r$1, x, removed); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } -} - -function removeCheck(d, v) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return false; - } - var removed = { - contents: false - }; - var newRoot = removeCheck0(oldRoot, v, removed); - if (newRoot !== oldRoot) { - d.data = newRoot; - } - return removed.contents; -} - -function addCheck0(t, x, added) { - if (t !== undefined) { - var k = t.v; - if (x === k) { - return t; - } - var l = t.l; - var r = t.r; - if (x < k) { - var ll = addCheck0(l, x, added); - t.l = ll; - } else { - t.r = addCheck0(r, x, added); - } - return Belt_internalAVLset.balMutate(t); - } - added.contents = true; - return Belt_internalAVLset.singleton(x); -} - -function addCheck(m, e) { - var oldRoot = m.data; - var added = { - contents: false - }; - var newRoot = addCheck0(oldRoot, e, added); - if (newRoot !== oldRoot) { - m.data = newRoot; - } - return added.contents; -} - -function add(d, k) { - var oldRoot = d.data; - var v = Belt_internalSetString.addMutate(oldRoot, k); - if (v !== oldRoot) { - d.data = v; - return ; - } - -} - -function addArrayMutate(t, xs) { - var v = t; - for(var i = 0 ,i_finish = xs.length; i < i_finish; ++i){ - v = Belt_internalSetString.addMutate(v, xs[i]); - } - return v; -} - -function mergeMany(d, arr) { - d.data = addArrayMutate(d.data, arr); -} - -function make(param) { - return { - data: undefined - }; -} - -function isEmpty(d) { - var n = d.data; - return n === undefined; -} - -function minimum(d) { - return Belt_internalAVLset.minimum(d.data); -} - -function minUndefined(d) { - return Belt_internalAVLset.minUndefined(d.data); -} - -function maximum(d) { - return Belt_internalAVLset.maximum(d.data); -} - -function maxUndefined(d) { - return Belt_internalAVLset.maxUndefined(d.data); -} - -function forEachU(d, f) { - Belt_internalAVLset.forEachU(d.data, f); -} - -function forEach(d, f) { - Belt_internalAVLset.forEachU(d.data, Curry.__1(f)); -} - -function reduceU(d, acc, cb) { - return Belt_internalAVLset.reduceU(d.data, acc, cb); -} - -function reduce(d, acc, cb) { - return reduceU(d, acc, Curry.__2(cb)); -} - -function everyU(d, p) { - return Belt_internalAVLset.everyU(d.data, p); -} - -function every(d, p) { - return Belt_internalAVLset.everyU(d.data, Curry.__1(p)); -} - -function someU(d, p) { - return Belt_internalAVLset.someU(d.data, p); -} - -function some(d, p) { - return Belt_internalAVLset.someU(d.data, Curry.__1(p)); -} - -function size(d) { - return Belt_internalAVLset.size(d.data); -} - -function toList(d) { - return Belt_internalAVLset.toList(d.data); -} - -function toArray(d) { - return Belt_internalAVLset.toArray(d.data); -} - -function fromSortedArrayUnsafe(xs) { - return { - data: Belt_internalAVLset.fromSortedArrayUnsafe(xs) - }; -} - -function checkInvariantInternal(d) { - Belt_internalAVLset.checkInvariantInternal(d.data); -} - -function fromArray(xs) { - return { - data: Belt_internalSetString.fromArray(xs) - }; -} - -function cmp(d0, d1) { - return Belt_internalSetString.cmp(d0.data, d1.data); -} - -function eq(d0, d1) { - return Belt_internalSetString.eq(d0.data, d1.data); -} - -function get(d, x) { - return Belt_internalSetString.get(d.data, x); -} - -function getUndefined(d, x) { - return Belt_internalSetString.getUndefined(d.data, x); -} - -function getExn(d, x) { - return Belt_internalSetString.getExn(d.data, x); -} - -function split(d, key) { - var arr = Belt_internalAVLset.toArray(d.data); - var i = Belt_SortArrayString.binarySearch(arr, key); - var len = arr.length; - if (i >= 0) { - return [ - [ - { - data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, i) - }, - { - data: Belt_internalAVLset.fromSortedArrayAux(arr, i + 1 | 0, (len - i | 0) - 1 | 0) - } - ], - true - ]; - } - var next = (-i | 0) - 1 | 0; - return [ - [ - { - data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, next) - }, - { - data: Belt_internalAVLset.fromSortedArrayAux(arr, next, len - next | 0) - } - ], - false - ]; -} - -function keepU(d, p) { - return { - data: Belt_internalAVLset.keepCopyU(d.data, p) - }; -} - -function keep(d, p) { - return keepU(d, Curry.__1(p)); -} - -function partitionU(d, p) { - var match = Belt_internalAVLset.partitionCopyU(d.data, p); - return [ - { - data: match[0] - }, - { - data: match[1] - } - ]; -} - -function partition(d, p) { - return partitionU(d, Curry.__1(p)); -} - -function subset(a, b) { - return Belt_internalSetString.subset(a.data, b.data); -} - -function intersect(dataa, datab) { - var dataa$1 = dataa.data; - var datab$1 = datab.data; - if (dataa$1 === undefined) { - return { - data: undefined - }; - } - if (datab$1 === undefined) { - return { - data: undefined - }; - } - var sizea = Belt_internalAVLset.lengthNode(dataa$1); - var sizeb = Belt_internalAVLset.lengthNode(datab$1); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(dataa$1, 0, tmp); - Belt_internalAVLset.fillArray(datab$1, sizea, tmp); - if (tmp[sizea - 1 | 0] < tmp[sizea] || tmp[totalSize - 1 | 0] < tmp[0]) { - return { - data: undefined - }; - } - var tmp2 = new Array(sizea < sizeb ? sizea : sizeb); - var k = Belt_SortArrayString.intersect(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); - return { - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function diff(dataa, datab) { - var dataa$1 = dataa.data; - var datab$1 = datab.data; - if (dataa$1 === undefined) { - return { - data: undefined - }; - } - if (datab$1 === undefined) { - return { - data: Belt_internalAVLset.copy(dataa$1) - }; - } - var sizea = Belt_internalAVLset.lengthNode(dataa$1); - var sizeb = Belt_internalAVLset.lengthNode(datab$1); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(dataa$1, 0, tmp); - Belt_internalAVLset.fillArray(datab$1, sizea, tmp); - if (tmp[sizea - 1 | 0] < tmp[sizea] || tmp[totalSize - 1 | 0] < tmp[0]) { - return { - data: Belt_internalAVLset.copy(dataa$1) - }; - } - var tmp2 = new Array(sizea); - var k = Belt_SortArrayString.diff(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); - return { - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function union(dataa, datab) { - var dataa$1 = dataa.data; - var datab$1 = datab.data; - if (dataa$1 === undefined) { - return { - data: Belt_internalAVLset.copy(datab$1) - }; - } - if (datab$1 === undefined) { - return { - data: Belt_internalAVLset.copy(dataa$1) - }; - } - var sizea = Belt_internalAVLset.lengthNode(dataa$1); - var sizeb = Belt_internalAVLset.lengthNode(datab$1); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(dataa$1, 0, tmp); - Belt_internalAVLset.fillArray(datab$1, sizea, tmp); - if (tmp[sizea - 1 | 0] < tmp[sizea]) { - return { - data: Belt_internalAVLset.fromSortedArrayAux(tmp, 0, totalSize) - }; - } - var tmp2 = new Array(totalSize); - var k = Belt_SortArrayString.union(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); - return { - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function has(d, x) { - return Belt_internalSetString.has(d.data, x); -} - -function copy(d) { - return { - data: Belt_internalAVLset.copy(d.data) - }; -} - -export { - make , - fromArray , - fromSortedArrayUnsafe , - copy , - isEmpty , - has , - add , - addCheck , - mergeMany , - remove , - removeCheck , - removeMany , - union , - intersect , - diff , - subset , - cmp , - eq , - forEachU , - forEach , - reduceU , - reduce , - everyU , - every , - someU , - some , - keepU , - keep , - partitionU , - partition , - size , - toList , - toArray , - minimum , - minUndefined , - maximum , - maxUndefined , - get , - getUndefined , - getExn , - split , - checkInvariantInternal , -} -/* No side effect */ diff --git a/lib/es6/belt_MutableStack.js b/lib/es6/belt_MutableStack.js deleted file mode 100644 index e93726d53a2..00000000000 --- a/lib/es6/belt_MutableStack.js +++ /dev/null @@ -1,137 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Caml_option from "./caml_option.js"; - -function make(param) { - return { - root: undefined - }; -} - -function clear(s) { - s.root = undefined; -} - -function copy(s) { - return { - root: s.root - }; -} - -function push(s, x) { - s.root = { - head: x, - tail: s.root - }; -} - -function topUndefined(s) { - var x = s.root; - if (x !== undefined) { - return x.head; - } - -} - -function top(s) { - var x = s.root; - if (x !== undefined) { - return Caml_option.some(x.head); - } - -} - -function isEmpty(s) { - return s.root === undefined; -} - -function popUndefined(s) { - var x = s.root; - if (x !== undefined) { - s.root = x.tail; - return x.head; - } - -} - -function pop(s) { - var x = s.root; - if (x !== undefined) { - s.root = x.tail; - return Caml_option.some(x.head); - } - -} - -function size(s) { - var x = s.root; - if (x !== undefined) { - var _x = x; - var _acc = 0; - while(true) { - var acc = _acc; - var x$1 = _x; - var x$2 = x$1.tail; - if (x$2 === undefined) { - return acc + 1 | 0; - } - _acc = acc + 1 | 0; - _x = x$2; - continue ; - }; - } else { - return 0; - } -} - -function forEachU(s, f) { - var _s = s.root; - while(true) { - var s$1 = _s; - if (s$1 === undefined) { - return ; - } - f(s$1.head); - _s = s$1.tail; - continue ; - }; -} - -function forEach(s, f) { - forEachU(s, Curry.__1(f)); -} - -function dynamicPopIterU(s, f) { - while(true) { - var match = s.root; - if (match === undefined) { - return ; - } - s.root = match.tail; - f(match.head); - continue ; - }; -} - -function dynamicPopIter(s, f) { - dynamicPopIterU(s, Curry.__1(f)); -} - -export { - make , - clear , - copy , - push , - popUndefined , - pop , - topUndefined , - top , - isEmpty , - size , - forEachU , - forEach , - dynamicPopIterU , - dynamicPopIter , -} -/* No side effect */ diff --git a/lib/es6/belt_Option.js b/lib/es6/belt_Option.js deleted file mode 100644 index 44fe68a886d..00000000000 --- a/lib/es6/belt_Option.js +++ /dev/null @@ -1,151 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Caml_option from "./caml_option.js"; - -function keepU(opt, p) { - if (opt !== undefined && p(Caml_option.valFromOption(opt))) { - return opt; - } - -} - -function keep(opt, p) { - return keepU(opt, Curry.__1(p)); -} - -function forEachU(opt, f) { - if (opt !== undefined) { - return f(Caml_option.valFromOption(opt)); - } - -} - -function forEach(opt, f) { - forEachU(opt, Curry.__1(f)); -} - -function getExn(x) { - if (x !== undefined) { - return Caml_option.valFromOption(x); - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -function mapWithDefaultU(opt, $$default, f) { - if (opt !== undefined) { - return f(Caml_option.valFromOption(opt)); - } else { - return $$default; - } -} - -function mapWithDefault(opt, $$default, f) { - return mapWithDefaultU(opt, $$default, Curry.__1(f)); -} - -function mapU(opt, f) { - if (opt !== undefined) { - return Caml_option.some(f(Caml_option.valFromOption(opt))); - } - -} - -function map(opt, f) { - return mapU(opt, Curry.__1(f)); -} - -function flatMapU(opt, f) { - if (opt !== undefined) { - return f(Caml_option.valFromOption(opt)); - } - -} - -function flatMap(opt, f) { - return flatMapU(opt, Curry.__1(f)); -} - -function getWithDefault(opt, $$default) { - if (opt !== undefined) { - return Caml_option.valFromOption(opt); - } else { - return $$default; - } -} - -function orElse(opt, other) { - if (opt !== undefined) { - return opt; - } else { - return other; - } -} - -function isSome(x) { - return x !== undefined; -} - -function isNone(x) { - return x === undefined; -} - -function eqU(a, b, f) { - if (a !== undefined) { - if (b !== undefined) { - return f(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); - } else { - return false; - } - } else { - return b === undefined; - } -} - -function eq(a, b, f) { - return eqU(a, b, Curry.__2(f)); -} - -function cmpU(a, b, f) { - if (a !== undefined) { - if (b !== undefined) { - return f(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); - } else { - return 1; - } - } else if (b !== undefined) { - return -1; - } else { - return 0; - } -} - -function cmp(a, b, f) { - return cmpU(a, b, Curry.__2(f)); -} - -export { - keepU , - keep , - forEachU , - forEach , - getExn , - mapWithDefaultU , - mapWithDefault , - mapU , - map , - flatMapU , - flatMap , - getWithDefault , - orElse , - isSome , - isNone , - eqU , - eq , - cmpU , - cmp , -} -/* No side effect */ diff --git a/lib/es6/belt_Range.js b/lib/es6/belt_Range.js deleted file mode 100644 index 37290f0909e..00000000000 --- a/lib/es6/belt_Range.js +++ /dev/null @@ -1,109 +0,0 @@ - - -import * as Curry from "./curry.js"; - -function forEachU(s, f, action) { - for(var i = s; i <= f; ++i){ - action(i); - } -} - -function forEach(s, f, action) { - forEachU(s, f, Curry.__1(action)); -} - -function everyU(_s, f, p) { - while(true) { - var s = _s; - if (s > f) { - return true; - } - if (!p(s)) { - return false; - } - _s = s + 1 | 0; - continue ; - }; -} - -function every(s, f, p) { - return everyU(s, f, Curry.__1(p)); -} - -function everyByU(s, f, step, p) { - if (step > 0) { - var _s = s; - while(true) { - var s$1 = _s; - if (s$1 > f) { - return true; - } - if (!p(s$1)) { - return false; - } - _s = s$1 + step | 0; - continue ; - }; - } else { - return true; - } -} - -function everyBy(s, f, step, p) { - return everyByU(s, f, step, Curry.__1(p)); -} - -function someU(_s, f, p) { - while(true) { - var s = _s; - if (s > f) { - return false; - } - if (p(s)) { - return true; - } - _s = s + 1 | 0; - continue ; - }; -} - -function some(s, f, p) { - return someU(s, f, Curry.__1(p)); -} - -function someByU(s, f, step, p) { - if (step > 0) { - var _s = s; - while(true) { - var s$1 = _s; - if (s$1 > f) { - return false; - } - if (p(s$1)) { - return true; - } - _s = s$1 + step | 0; - continue ; - }; - } else { - return false; - } -} - -function someBy(s, f, step, p) { - return someByU(s, f, step, Curry.__1(p)); -} - -export { - forEachU , - forEach , - everyU , - every , - everyByU , - everyBy , - someU , - some , - someByU , - someBy , -} -/* No side effect */ diff --git a/lib/es6/belt_Result.js b/lib/es6/belt_Result.js deleted file mode 100644 index f31cdd55116..00000000000 --- a/lib/es6/belt_Result.js +++ /dev/null @@ -1,136 +0,0 @@ - - -import * as Curry from "./curry.js"; - -function getExn(x) { - if (x.TAG === "Ok") { - return x._0; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -function mapWithDefaultU(opt, $$default, f) { - if (opt.TAG === "Ok") { - return f(opt._0); - } else { - return $$default; - } -} - -function mapWithDefault(opt, $$default, f) { - return mapWithDefaultU(opt, $$default, Curry.__1(f)); -} - -function mapU(opt, f) { - if (opt.TAG === "Ok") { - return { - TAG: "Ok", - _0: f(opt._0) - }; - } else { - return { - TAG: "Error", - _0: opt._0 - }; - } -} - -function map(opt, f) { - return mapU(opt, Curry.__1(f)); -} - -function flatMapU(opt, f) { - if (opt.TAG === "Ok") { - return f(opt._0); - } else { - return { - TAG: "Error", - _0: opt._0 - }; - } -} - -function flatMap(opt, f) { - return flatMapU(opt, Curry.__1(f)); -} - -function getWithDefault(opt, $$default) { - if (opt.TAG === "Ok") { - return opt._0; - } else { - return $$default; - } -} - -function isOk(x) { - if (x.TAG === "Ok") { - return true; - } else { - return false; - } -} - -function isError(x) { - if (x.TAG === "Ok") { - return false; - } else { - return true; - } -} - -function eqU(a, b, f) { - if (a.TAG === "Ok") { - if (b.TAG === "Ok") { - return f(a._0, b._0); - } else { - return false; - } - } else if (b.TAG === "Ok") { - return false; - } else { - return true; - } -} - -function eq(a, b, f) { - return eqU(a, b, Curry.__2(f)); -} - -function cmpU(a, b, f) { - if (a.TAG === "Ok") { - if (b.TAG === "Ok") { - return f(a._0, b._0); - } else { - return 1; - } - } else if (b.TAG === "Ok") { - return -1; - } else { - return 0; - } -} - -function cmp(a, b, f) { - return cmpU(a, b, Curry.__2(f)); -} - -export { - getExn , - mapWithDefaultU , - mapWithDefault , - mapU , - map , - flatMapU , - flatMap , - getWithDefault , - isOk , - isError , - eqU , - eq , - cmpU , - cmp , -} -/* No side effect */ diff --git a/lib/es6/belt_Set.js b/lib/es6/belt_Set.js deleted file mode 100644 index 48b0311aba0..00000000000 --- a/lib/es6/belt_Set.js +++ /dev/null @@ -1,314 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Belt_SetDict from "./belt_SetDict.js"; - -function fromArray(data, id) { - var cmp = id.cmp; - return { - cmp: cmp, - data: Belt_SetDict.fromArray(data, cmp) - }; -} - -function remove(m, e) { - var data = m.data; - var cmp = m.cmp; - var newData = Belt_SetDict.remove(data, e, cmp); - if (newData === data) { - return m; - } else { - return { - cmp: cmp, - data: newData - }; - } -} - -function add(m, e) { - var data = m.data; - var cmp = m.cmp; - var newData = Belt_SetDict.add(data, e, cmp); - if (newData === data) { - return m; - } else { - return { - cmp: cmp, - data: newData - }; - } -} - -function mergeMany(m, e) { - var cmp = m.cmp; - return { - cmp: cmp, - data: Belt_SetDict.mergeMany(m.data, e, cmp) - }; -} - -function removeMany(m, e) { - var cmp = m.cmp; - return { - cmp: cmp, - data: Belt_SetDict.removeMany(m.data, e, cmp) - }; -} - -function union(m, n) { - var cmp = m.cmp; - return { - cmp: cmp, - data: Belt_SetDict.union(m.data, n.data, cmp) - }; -} - -function intersect(m, n) { - var cmp = m.cmp; - return { - cmp: cmp, - data: Belt_SetDict.intersect(m.data, n.data, cmp) - }; -} - -function diff(m, n) { - var cmp = m.cmp; - return { - cmp: cmp, - data: Belt_SetDict.diff(m.data, n.data, cmp) - }; -} - -function subset(m, n) { - var cmp = m.cmp; - return Belt_SetDict.subset(m.data, n.data, cmp); -} - -function split(m, e) { - var cmp = m.cmp; - var match = Belt_SetDict.split(m.data, e, cmp); - var match$1 = match[0]; - return [ - [ - { - cmp: cmp, - data: match$1[0] - }, - { - cmp: cmp, - data: match$1[1] - } - ], - match[1] - ]; -} - -function make(id) { - return { - cmp: id.cmp, - data: undefined - }; -} - -function isEmpty(m) { - return Belt_SetDict.isEmpty(m.data); -} - -function cmp(m, n) { - var cmp$1 = m.cmp; - return Belt_SetDict.cmp(m.data, n.data, cmp$1); -} - -function eq(m, n) { - return Belt_SetDict.eq(m.data, n.data, m.cmp); -} - -function forEachU(m, f) { - Belt_SetDict.forEachU(m.data, f); -} - -function forEach(m, f) { - Belt_SetDict.forEachU(m.data, Curry.__1(f)); -} - -function reduceU(m, acc, f) { - return Belt_SetDict.reduceU(m.data, acc, f); -} - -function reduce(m, acc, f) { - return reduceU(m, acc, Curry.__2(f)); -} - -function everyU(m, f) { - return Belt_SetDict.everyU(m.data, f); -} - -function every(m, f) { - return Belt_SetDict.everyU(m.data, Curry.__1(f)); -} - -function someU(m, f) { - return Belt_SetDict.someU(m.data, f); -} - -function some(m, f) { - return Belt_SetDict.someU(m.data, Curry.__1(f)); -} - -function keepU(m, f) { - return { - cmp: m.cmp, - data: Belt_SetDict.keepU(m.data, f) - }; -} - -function keep(m, f) { - return keepU(m, Curry.__1(f)); -} - -function partitionU(m, f) { - var match = Belt_SetDict.partitionU(m.data, f); - var cmp = m.cmp; - return [ - { - cmp: cmp, - data: match[0] - }, - { - cmp: cmp, - data: match[1] - } - ]; -} - -function partition(m, f) { - return partitionU(m, Curry.__1(f)); -} - -function size(m) { - return Belt_SetDict.size(m.data); -} - -function toList(m) { - return Belt_SetDict.toList(m.data); -} - -function toArray(m) { - return Belt_SetDict.toArray(m.data); -} - -function minimum(m) { - return Belt_SetDict.minimum(m.data); -} - -function minUndefined(m) { - return Belt_SetDict.minUndefined(m.data); -} - -function maximum(m) { - return Belt_SetDict.maximum(m.data); -} - -function maxUndefined(m) { - return Belt_SetDict.maxUndefined(m.data); -} - -function get(m, e) { - return Belt_SetDict.get(m.data, e, m.cmp); -} - -function getUndefined(m, e) { - return Belt_SetDict.getUndefined(m.data, e, m.cmp); -} - -function getExn(m, e) { - return Belt_SetDict.getExn(m.data, e, m.cmp); -} - -function has(m, e) { - return Belt_SetDict.has(m.data, e, m.cmp); -} - -function fromSortedArrayUnsafe(xs, id) { - return { - cmp: id.cmp, - data: Belt_SetDict.fromSortedArrayUnsafe(xs) - }; -} - -function getData(m) { - return m.data; -} - -function getId(m) { - var cmp = m.cmp; - return { - cmp: cmp - }; -} - -function packIdData(id, data) { - return { - cmp: id.cmp, - data: data - }; -} - -function checkInvariantInternal(d) { - Belt_SetDict.checkInvariantInternal(d.data); -} - -var Int; - -var $$String; - -var Dict; - -export { - Int , - $$String , - Dict , - make , - fromArray , - fromSortedArrayUnsafe , - isEmpty , - has , - add , - mergeMany , - remove , - removeMany , - union , - intersect , - diff , - subset , - cmp , - eq , - forEachU , - forEach , - reduceU , - reduce , - everyU , - every , - someU , - some , - keepU , - keep , - partitionU , - partition , - size , - toArray , - toList , - minimum , - minUndefined , - maximum , - maxUndefined , - get , - getUndefined , - getExn , - split , - checkInvariantInternal , - getData , - getId , - packIdData , -} -/* No side effect */ diff --git a/lib/es6/belt_SetDict.js b/lib/es6/belt_SetDict.js deleted file mode 100644 index c00356209b9..00000000000 --- a/lib/es6/belt_SetDict.js +++ /dev/null @@ -1,362 +0,0 @@ - - -import * as Belt_internalAVLset from "./belt_internalAVLset.js"; - -function add(t, x, cmp) { - if (t === undefined) { - return Belt_internalAVLset.singleton(x); - } - var k = t.v; - var c = cmp(x, k); - if (c === 0) { - return t; - } - var l = t.l; - var r = t.r; - if (c < 0) { - var ll = add(l, x, cmp); - if (ll === l) { - return t; - } else { - return Belt_internalAVLset.bal(ll, k, r); - } - } - var rr = add(r, x, cmp); - if (rr === r) { - return t; - } else { - return Belt_internalAVLset.bal(l, k, rr); - } -} - -function remove(t, x, cmp) { - if (t === undefined) { - return t; - } - var v = t.v; - var l = t.l; - var r = t.r; - var c = cmp(x, v); - if (c === 0) { - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var v$1 = { - contents: r.v - }; - var r$1 = Belt_internalAVLset.removeMinAuxWithRef(r, v$1); - return Belt_internalAVLset.bal(l, v$1.contents, r$1); - } - if (c < 0) { - var ll = remove(l, x, cmp); - if (ll === l) { - return t; - } else { - return Belt_internalAVLset.bal(ll, v, r); - } - } - var rr = remove(r, x, cmp); - if (rr === r) { - return t; - } else { - return Belt_internalAVLset.bal(l, v, rr); - } -} - -function mergeMany(h, arr, cmp) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var key = arr[i]; - v = add(v, key, cmp); - } - return v; -} - -function removeMany(h, arr, cmp) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var key = arr[i]; - v = remove(v, key, cmp); - } - return v; -} - -function splitAuxNoPivot(cmp, n, x) { - var v = n.v; - var l = n.l; - var r = n.r; - var c = cmp(x, v); - if (c === 0) { - return [ - l, - r - ]; - } - if (c < 0) { - if (l === undefined) { - return [ - undefined, - n - ]; - } - var match = splitAuxNoPivot(cmp, l, x); - return [ - match[0], - Belt_internalAVLset.joinShared(match[1], v, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined - ]; - } - var match$1 = splitAuxNoPivot(cmp, r, x); - return [ - Belt_internalAVLset.joinShared(l, v, match$1[0]), - match$1[1] - ]; -} - -function splitAuxPivot(cmp, n, x, pres) { - var v = n.v; - var l = n.l; - var r = n.r; - var c = cmp(x, v); - if (c === 0) { - pres.contents = true; - return [ - l, - r - ]; - } - if (c < 0) { - if (l === undefined) { - return [ - undefined, - n - ]; - } - var match = splitAuxPivot(cmp, l, x, pres); - return [ - match[0], - Belt_internalAVLset.joinShared(match[1], v, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined - ]; - } - var match$1 = splitAuxPivot(cmp, r, x, pres); - return [ - Belt_internalAVLset.joinShared(l, v, match$1[0]), - match$1[1] - ]; -} - -function split(t, x, cmp) { - if (t === undefined) { - return [ - [ - undefined, - undefined - ], - false - ]; - } - var pres = { - contents: false - }; - var v = splitAuxPivot(cmp, t, x, pres); - return [ - v, - pres.contents - ]; -} - -function union(s1, s2, cmp) { - if (s1 === undefined) { - return s2; - } - if (s2 === undefined) { - return s1; - } - var h1 = s1.h; - var h2 = s2.h; - if (h1 >= h2) { - if (h2 === 1) { - return add(s1, s2.v, cmp); - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var match = splitAuxNoPivot(cmp, s2, v1); - return Belt_internalAVLset.joinShared(union(l1, match[0], cmp), v1, union(r1, match[1], cmp)); - } - if (h1 === 1) { - return add(s2, s1.v, cmp); - } - var v2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - var match$1 = splitAuxNoPivot(cmp, s1, v2); - return Belt_internalAVLset.joinShared(union(match$1[0], l2, cmp), v2, union(match$1[1], r2, cmp)); -} - -function intersect(s1, s2, cmp) { - if (s1 === undefined) { - return ; - } - if (s2 === undefined) { - return ; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var pres = { - contents: false - }; - var match = splitAuxPivot(cmp, s2, v1, pres); - var ll = intersect(l1, match[0], cmp); - var rr = intersect(r1, match[1], cmp); - if (pres.contents) { - return Belt_internalAVLset.joinShared(ll, v1, rr); - } else { - return Belt_internalAVLset.concatShared(ll, rr); - } -} - -function diff(s1, s2, cmp) { - if (s1 === undefined) { - return s1; - } - if (s2 === undefined) { - return s1; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var pres = { - contents: false - }; - var match = splitAuxPivot(cmp, s2, v1, pres); - var ll = diff(l1, match[0], cmp); - var rr = diff(r1, match[1], cmp); - if (pres.contents) { - return Belt_internalAVLset.concatShared(ll, rr); - } else { - return Belt_internalAVLset.joinShared(ll, v1, rr); - } -} - -var empty; - -var fromArray = Belt_internalAVLset.fromArray; - -var fromSortedArrayUnsafe = Belt_internalAVLset.fromSortedArrayUnsafe; - -var isEmpty = Belt_internalAVLset.isEmpty; - -var has = Belt_internalAVLset.has; - -var subset = Belt_internalAVLset.subset; - -var cmp = Belt_internalAVLset.cmp; - -var eq = Belt_internalAVLset.eq; - -var forEachU = Belt_internalAVLset.forEachU; - -var forEach = Belt_internalAVLset.forEach; - -var reduceU = Belt_internalAVLset.reduceU; - -var reduce = Belt_internalAVLset.reduce; - -var everyU = Belt_internalAVLset.everyU; - -var every = Belt_internalAVLset.every; - -var someU = Belt_internalAVLset.someU; - -var some = Belt_internalAVLset.some; - -var keepU = Belt_internalAVLset.keepSharedU; - -var keep = Belt_internalAVLset.keepShared; - -var partitionU = Belt_internalAVLset.partitionSharedU; - -var partition = Belt_internalAVLset.partitionShared; - -var size = Belt_internalAVLset.size; - -var toList = Belt_internalAVLset.toList; - -var toArray = Belt_internalAVLset.toArray; - -var minimum = Belt_internalAVLset.minimum; - -var minUndefined = Belt_internalAVLset.minUndefined; - -var maximum = Belt_internalAVLset.maximum; - -var maxUndefined = Belt_internalAVLset.maxUndefined; - -var get = Belt_internalAVLset.get; - -var getUndefined = Belt_internalAVLset.getUndefined; - -var getExn = Belt_internalAVLset.getExn; - -var checkInvariantInternal = Belt_internalAVLset.checkInvariantInternal; - -export { - empty , - fromArray , - fromSortedArrayUnsafe , - isEmpty , - has , - add , - mergeMany , - remove , - removeMany , - union , - intersect , - diff , - subset , - cmp , - eq , - forEachU , - forEach , - reduceU , - reduce , - everyU , - every , - someU , - some , - keepU , - keep , - partitionU , - partition , - size , - toList , - toArray , - minimum , - minUndefined , - maximum , - maxUndefined , - get , - getUndefined , - getExn , - split , - checkInvariantInternal , -} -/* No side effect */ diff --git a/lib/es6/belt_SetInt.js b/lib/es6/belt_SetInt.js deleted file mode 100644 index be6bc9f5dfd..00000000000 --- a/lib/es6/belt_SetInt.js +++ /dev/null @@ -1,359 +0,0 @@ - - -import * as Belt_internalAVLset from "./belt_internalAVLset.js"; -import * as Belt_internalSetInt from "./belt_internalSetInt.js"; - -function add(t, x) { - if (t === undefined) { - return Belt_internalAVLset.singleton(x); - } - var v = t.v; - if (x === v) { - return t; - } - var l = t.l; - var r = t.r; - if (x < v) { - var ll = add(l, x); - if (ll === l) { - return t; - } else { - return Belt_internalAVLset.bal(ll, v, r); - } - } - var rr = add(r, x); - if (rr === r) { - return t; - } else { - return Belt_internalAVLset.bal(l, v, rr); - } -} - -function mergeMany(h, arr) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var key = arr[i]; - v = add(v, key); - } - return v; -} - -function remove(t, x) { - if (t === undefined) { - return t; - } - var v = t.v; - var l = t.l; - var r = t.r; - if (x === v) { - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var v$1 = { - contents: r.v - }; - var r$1 = Belt_internalAVLset.removeMinAuxWithRef(r, v$1); - return Belt_internalAVLset.bal(l, v$1.contents, r$1); - } - if (x < v) { - var ll = remove(l, x); - if (ll === l) { - return t; - } else { - return Belt_internalAVLset.bal(ll, v, r); - } - } - var rr = remove(r, x); - if (rr === r) { - return t; - } else { - return Belt_internalAVLset.bal(l, v, rr); - } -} - -function removeMany(h, arr) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var key = arr[i]; - v = remove(v, key); - } - return v; -} - -function splitAuxNoPivot(n, x) { - var v = n.v; - var l = n.l; - var r = n.r; - if (x === v) { - return [ - l, - r - ]; - } - if (x < v) { - if (l === undefined) { - return [ - undefined, - n - ]; - } - var match = splitAuxNoPivot(l, x); - return [ - match[0], - Belt_internalAVLset.joinShared(match[1], v, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined - ]; - } - var match$1 = splitAuxNoPivot(r, x); - return [ - Belt_internalAVLset.joinShared(l, v, match$1[0]), - match$1[1] - ]; -} - -function splitAuxPivot(n, x, pres) { - var v = n.v; - var l = n.l; - var r = n.r; - if (x === v) { - pres.contents = true; - return [ - l, - r - ]; - } - if (x < v) { - if (l === undefined) { - return [ - undefined, - n - ]; - } - var match = splitAuxPivot(l, x, pres); - return [ - match[0], - Belt_internalAVLset.joinShared(match[1], v, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined - ]; - } - var match$1 = splitAuxPivot(r, x, pres); - return [ - Belt_internalAVLset.joinShared(l, v, match$1[0]), - match$1[1] - ]; -} - -function split(t, x) { - if (t === undefined) { - return [ - [ - undefined, - undefined - ], - false - ]; - } - var pres = { - contents: false - }; - var v = splitAuxPivot(t, x, pres); - return [ - v, - pres.contents - ]; -} - -function union(s1, s2) { - if (s1 === undefined) { - return s2; - } - if (s2 === undefined) { - return s1; - } - var h1 = s1.h; - var h2 = s2.h; - if (h1 >= h2) { - if (h2 === 1) { - return add(s1, s2.v); - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var match = splitAuxNoPivot(s2, v1); - return Belt_internalAVLset.joinShared(union(l1, match[0]), v1, union(r1, match[1])); - } - if (h1 === 1) { - return add(s2, s1.v); - } - var v2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - var match$1 = splitAuxNoPivot(s1, v2); - return Belt_internalAVLset.joinShared(union(match$1[0], l2), v2, union(match$1[1], r2)); -} - -function intersect(s1, s2) { - if (s1 === undefined) { - return ; - } - if (s2 === undefined) { - return ; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var pres = { - contents: false - }; - var match = splitAuxPivot(s2, v1, pres); - var ll = intersect(l1, match[0]); - var rr = intersect(r1, match[1]); - if (pres.contents) { - return Belt_internalAVLset.joinShared(ll, v1, rr); - } else { - return Belt_internalAVLset.concatShared(ll, rr); - } -} - -function diff(s1, s2) { - if (s1 === undefined) { - return s1; - } - if (s2 === undefined) { - return s1; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var pres = { - contents: false - }; - var match = splitAuxPivot(s2, v1, pres); - var ll = diff(l1, match[0]); - var rr = diff(r1, match[1]); - if (pres.contents) { - return Belt_internalAVLset.concatShared(ll, rr); - } else { - return Belt_internalAVLset.joinShared(ll, v1, rr); - } -} - -var empty; - -var fromArray = Belt_internalSetInt.fromArray; - -var fromSortedArrayUnsafe = Belt_internalAVLset.fromSortedArrayUnsafe; - -var isEmpty = Belt_internalAVLset.isEmpty; - -var has = Belt_internalSetInt.has; - -var subset = Belt_internalSetInt.subset; - -var cmp = Belt_internalSetInt.cmp; - -var eq = Belt_internalSetInt.eq; - -var forEachU = Belt_internalAVLset.forEachU; - -var forEach = Belt_internalAVLset.forEach; - -var reduceU = Belt_internalAVLset.reduceU; - -var reduce = Belt_internalAVLset.reduce; - -var everyU = Belt_internalAVLset.everyU; - -var every = Belt_internalAVLset.every; - -var someU = Belt_internalAVLset.someU; - -var some = Belt_internalAVLset.some; - -var keepU = Belt_internalAVLset.keepSharedU; - -var keep = Belt_internalAVLset.keepShared; - -var partitionU = Belt_internalAVLset.partitionSharedU; - -var partition = Belt_internalAVLset.partitionShared; - -var size = Belt_internalAVLset.size; - -var toList = Belt_internalAVLset.toList; - -var toArray = Belt_internalAVLset.toArray; - -var minimum = Belt_internalAVLset.minimum; - -var minUndefined = Belt_internalAVLset.minUndefined; - -var maximum = Belt_internalAVLset.maximum; - -var maxUndefined = Belt_internalAVLset.maxUndefined; - -var get = Belt_internalSetInt.get; - -var getUndefined = Belt_internalSetInt.getUndefined; - -var getExn = Belt_internalSetInt.getExn; - -var checkInvariantInternal = Belt_internalAVLset.checkInvariantInternal; - -export { - empty , - fromArray , - fromSortedArrayUnsafe , - isEmpty , - has , - add , - mergeMany , - remove , - removeMany , - union , - intersect , - diff , - subset , - cmp , - eq , - forEachU , - forEach , - reduceU , - reduce , - everyU , - every , - someU , - some , - keepU , - keep , - partitionU , - partition , - size , - toList , - toArray , - minimum , - minUndefined , - maximum , - maxUndefined , - get , - getUndefined , - getExn , - split , - checkInvariantInternal , -} -/* No side effect */ diff --git a/lib/es6/belt_SetString.js b/lib/es6/belt_SetString.js deleted file mode 100644 index 6236c00c0a9..00000000000 --- a/lib/es6/belt_SetString.js +++ /dev/null @@ -1,359 +0,0 @@ - - -import * as Belt_internalAVLset from "./belt_internalAVLset.js"; -import * as Belt_internalSetString from "./belt_internalSetString.js"; - -function add(t, x) { - if (t === undefined) { - return Belt_internalAVLset.singleton(x); - } - var v = t.v; - if (x === v) { - return t; - } - var l = t.l; - var r = t.r; - if (x < v) { - var ll = add(l, x); - if (ll === l) { - return t; - } else { - return Belt_internalAVLset.bal(ll, v, r); - } - } - var rr = add(r, x); - if (rr === r) { - return t; - } else { - return Belt_internalAVLset.bal(l, v, rr); - } -} - -function mergeMany(h, arr) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var key = arr[i]; - v = add(v, key); - } - return v; -} - -function remove(t, x) { - if (t === undefined) { - return t; - } - var v = t.v; - var l = t.l; - var r = t.r; - if (x === v) { - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var v$1 = { - contents: r.v - }; - var r$1 = Belt_internalAVLset.removeMinAuxWithRef(r, v$1); - return Belt_internalAVLset.bal(l, v$1.contents, r$1); - } - if (x < v) { - var ll = remove(l, x); - if (ll === l) { - return t; - } else { - return Belt_internalAVLset.bal(ll, v, r); - } - } - var rr = remove(r, x); - if (rr === r) { - return t; - } else { - return Belt_internalAVLset.bal(l, v, rr); - } -} - -function removeMany(h, arr) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var key = arr[i]; - v = remove(v, key); - } - return v; -} - -function splitAuxNoPivot(n, x) { - var v = n.v; - var l = n.l; - var r = n.r; - if (x === v) { - return [ - l, - r - ]; - } - if (x < v) { - if (l === undefined) { - return [ - undefined, - n - ]; - } - var match = splitAuxNoPivot(l, x); - return [ - match[0], - Belt_internalAVLset.joinShared(match[1], v, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined - ]; - } - var match$1 = splitAuxNoPivot(r, x); - return [ - Belt_internalAVLset.joinShared(l, v, match$1[0]), - match$1[1] - ]; -} - -function splitAuxPivot(n, x, pres) { - var v = n.v; - var l = n.l; - var r = n.r; - if (x === v) { - pres.contents = true; - return [ - l, - r - ]; - } - if (x < v) { - if (l === undefined) { - return [ - undefined, - n - ]; - } - var match = splitAuxPivot(l, x, pres); - return [ - match[0], - Belt_internalAVLset.joinShared(match[1], v, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined - ]; - } - var match$1 = splitAuxPivot(r, x, pres); - return [ - Belt_internalAVLset.joinShared(l, v, match$1[0]), - match$1[1] - ]; -} - -function split(t, x) { - if (t === undefined) { - return [ - [ - undefined, - undefined - ], - false - ]; - } - var pres = { - contents: false - }; - var v = splitAuxPivot(t, x, pres); - return [ - v, - pres.contents - ]; -} - -function union(s1, s2) { - if (s1 === undefined) { - return s2; - } - if (s2 === undefined) { - return s1; - } - var h1 = s1.h; - var h2 = s2.h; - if (h1 >= h2) { - if (h2 === 1) { - return add(s1, s2.v); - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var match = splitAuxNoPivot(s2, v1); - return Belt_internalAVLset.joinShared(union(l1, match[0]), v1, union(r1, match[1])); - } - if (h1 === 1) { - return add(s2, s1.v); - } - var v2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - var match$1 = splitAuxNoPivot(s1, v2); - return Belt_internalAVLset.joinShared(union(match$1[0], l2), v2, union(match$1[1], r2)); -} - -function intersect(s1, s2) { - if (s1 === undefined) { - return ; - } - if (s2 === undefined) { - return ; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var pres = { - contents: false - }; - var match = splitAuxPivot(s2, v1, pres); - var ll = intersect(l1, match[0]); - var rr = intersect(r1, match[1]); - if (pres.contents) { - return Belt_internalAVLset.joinShared(ll, v1, rr); - } else { - return Belt_internalAVLset.concatShared(ll, rr); - } -} - -function diff(s1, s2) { - if (s1 === undefined) { - return s1; - } - if (s2 === undefined) { - return s1; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var pres = { - contents: false - }; - var match = splitAuxPivot(s2, v1, pres); - var ll = diff(l1, match[0]); - var rr = diff(r1, match[1]); - if (pres.contents) { - return Belt_internalAVLset.concatShared(ll, rr); - } else { - return Belt_internalAVLset.joinShared(ll, v1, rr); - } -} - -var empty; - -var fromArray = Belt_internalSetString.fromArray; - -var fromSortedArrayUnsafe = Belt_internalAVLset.fromSortedArrayUnsafe; - -var isEmpty = Belt_internalAVLset.isEmpty; - -var has = Belt_internalSetString.has; - -var subset = Belt_internalSetString.subset; - -var cmp = Belt_internalSetString.cmp; - -var eq = Belt_internalSetString.eq; - -var forEachU = Belt_internalAVLset.forEachU; - -var forEach = Belt_internalAVLset.forEach; - -var reduceU = Belt_internalAVLset.reduceU; - -var reduce = Belt_internalAVLset.reduce; - -var everyU = Belt_internalAVLset.everyU; - -var every = Belt_internalAVLset.every; - -var someU = Belt_internalAVLset.someU; - -var some = Belt_internalAVLset.some; - -var keepU = Belt_internalAVLset.keepSharedU; - -var keep = Belt_internalAVLset.keepShared; - -var partitionU = Belt_internalAVLset.partitionSharedU; - -var partition = Belt_internalAVLset.partitionShared; - -var size = Belt_internalAVLset.size; - -var toList = Belt_internalAVLset.toList; - -var toArray = Belt_internalAVLset.toArray; - -var minimum = Belt_internalAVLset.minimum; - -var minUndefined = Belt_internalAVLset.minUndefined; - -var maximum = Belt_internalAVLset.maximum; - -var maxUndefined = Belt_internalAVLset.maxUndefined; - -var get = Belt_internalSetString.get; - -var getUndefined = Belt_internalSetString.getUndefined; - -var getExn = Belt_internalSetString.getExn; - -var checkInvariantInternal = Belt_internalAVLset.checkInvariantInternal; - -export { - empty , - fromArray , - fromSortedArrayUnsafe , - isEmpty , - has , - add , - mergeMany , - remove , - removeMany , - union , - intersect , - diff , - subset , - cmp , - eq , - forEachU , - forEach , - reduceU , - reduce , - everyU , - every , - someU , - some , - keepU , - keep , - partitionU , - partition , - size , - toList , - toArray , - minimum , - minUndefined , - maximum , - maxUndefined , - get , - getUndefined , - getExn , - split , - checkInvariantInternal , -} -/* No side effect */ diff --git a/lib/es6/belt_SortArray.js b/lib/es6/belt_SortArray.js deleted file mode 100644 index 44b1458c0f1..00000000000 --- a/lib/es6/belt_SortArray.js +++ /dev/null @@ -1,427 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Belt_Array from "./belt_Array.js"; - -function sortedLengthAuxMore(xs, _prec, _acc, len, lt) { - while(true) { - var acc = _acc; - var prec = _prec; - if (acc >= len) { - return acc; - } - var v = xs[acc]; - if (!lt(v, prec)) { - return acc; - } - _acc = acc + 1 | 0; - _prec = v; - continue ; - }; -} - -function strictlySortedLengthU(xs, lt) { - var len = xs.length; - if (len === 0 || len === 1) { - return len; - } - var x0 = xs[0]; - var x1 = xs[1]; - if (lt(x0, x1)) { - var _prec = x1; - var _acc = 2; - while(true) { - var acc = _acc; - var prec = _prec; - if (acc >= len) { - return acc; - } - var v = xs[acc]; - if (!lt(prec, v)) { - return acc; - } - _acc = acc + 1 | 0; - _prec = v; - continue ; - }; - } else if (lt(x1, x0)) { - return -sortedLengthAuxMore(xs, x1, 2, len, lt) | 0; - } else { - return 1; - } -} - -function strictlySortedLength(xs, lt) { - return strictlySortedLengthU(xs, Curry.__2(lt)); -} - -function isSortedU(a, cmp) { - var len = a.length; - if (len === 0) { - return true; - } else { - var _i = 0; - var last_bound = len - 1 | 0; - while(true) { - var i = _i; - if (i === last_bound) { - return true; - } - if (cmp(a[i], a[i + 1 | 0]) > 0) { - return false; - } - _i = i + 1 | 0; - continue ; - }; - } -} - -function isSorted(a, cmp) { - return isSortedU(a, Curry.__2(cmp)); -} - -function merge(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (cmp(s1, s2) <= 0) { - dst[d] = s1; - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return Belt_Array.blitUnsafe(src2, i2, dst, d + 1 | 0, src2r - i2 | 0); - } - _d = d + 1 | 0; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - dst[d] = s2; - var i2$1 = i2 + 1 | 0; - if (i2$1 >= src2r) { - return Belt_Array.blitUnsafe(src, i1, dst, d + 1 | 0, src1r - i1 | 0); - } - _d = d + 1 | 0; - _s2 = src2[i2$1]; - _i2 = i2$1; - continue ; - }; -} - -function unionU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - var c = cmp(s1, s2); - if (c < 0) { - dst[d] = s1; - var i1$1 = i1 + 1 | 0; - var d$1 = d + 1 | 0; - if (i1$1 < src1r) { - _d = d$1; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - Belt_Array.blitUnsafe(src2, i2, dst, d$1, src2r - i2 | 0); - return (d$1 + src2r | 0) - i2 | 0; - } - if (c === 0) { - dst[d] = s1; - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - var d$2 = d + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - if (i1$2 === src1r) { - Belt_Array.blitUnsafe(src2, i2$1, dst, d$2, src2r - i2$1 | 0); - return (d$2 + src2r | 0) - i2$1 | 0; - } else { - Belt_Array.blitUnsafe(src, i1$2, dst, d$2, src1r - i1$2 | 0); - return (d$2 + src1r | 0) - i1$2 | 0; - } - } - _d = d$2; - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - dst[d] = s2; - var i2$2 = i2 + 1 | 0; - var d$3 = d + 1 | 0; - if (i2$2 < src2r) { - _d = d$3; - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - } - Belt_Array.blitUnsafe(src, i1, dst, d$3, src1r - i1 | 0); - return (d$3 + src1r | 0) - i1 | 0; - }; -} - -function union(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - return unionU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, Curry.__2(cmp)); -} - -function intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - var c = cmp(s1, s2); - if (c < 0) { - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return d; - } - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - if (c === 0) { - dst[d] = s1; - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - var d$1 = d + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - return d$1; - } - _d = d$1; - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - var i2$2 = i2 + 1 | 0; - if (i2$2 >= src2r) { - return d; - } - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - }; -} - -function intersect(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - return intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, Curry.__2(cmp)); -} - -function diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - var c = cmp(s1, s2); - if (c < 0) { - dst[d] = s1; - var d$1 = d + 1 | 0; - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return d$1; - } - _d = d$1; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - if (c === 0) { - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - if (i1$2 === src1r) { - return d; - } else { - Belt_Array.blitUnsafe(src, i1$2, dst, d, src1r - i1$2 | 0); - return (d + src1r | 0) - i1$2 | 0; - } - } - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - var i2$2 = i2 + 1 | 0; - if (i2$2 < src2r) { - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - } - Belt_Array.blitUnsafe(src, i1, dst, d, src1r - i1 | 0); - return (d + src1r | 0) - i1 | 0; - }; -} - -function diff(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - return diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, Curry.__2(cmp)); -} - -function insertionSort(src, srcofs, dst, dstofs, len, cmp) { - for(var i = 0; i < len; ++i){ - var e = src[srcofs + i | 0]; - var j = (dstofs + i | 0) - 1 | 0; - while(j >= dstofs && cmp(dst[j], e) > 0) { - dst[j + 1 | 0] = dst[j]; - j = j - 1 | 0; - }; - dst[j + 1 | 0] = e; - } -} - -function sortTo(src, srcofs, dst, dstofs, len, cmp) { - if (len <= 5) { - return insertionSort(src, srcofs, dst, dstofs, len, cmp); - } - var l1 = len / 2 | 0; - var l2 = len - l1 | 0; - sortTo(src, srcofs + l1 | 0, dst, dstofs + l1 | 0, l2, cmp); - sortTo(src, srcofs, src, srcofs + l2 | 0, l1, cmp); - merge(src, srcofs + l2 | 0, l1, dst, dstofs + l1 | 0, l2, dst, dstofs, cmp); -} - -function stableSortInPlaceByU(a, cmp) { - var l = a.length; - if (l <= 5) { - return insertionSort(a, 0, a, 0, l, cmp); - } - var l1 = l / 2 | 0; - var l2 = l - l1 | 0; - var t = new Array(l2); - sortTo(a, l1, t, 0, l2, cmp); - sortTo(a, 0, a, l2, l1, cmp); - merge(a, l2, l1, t, 0, l2, a, 0, cmp); -} - -function stableSortInPlaceBy(a, cmp) { - stableSortInPlaceByU(a, Curry.__2(cmp)); -} - -function stableSortByU(a, cmp) { - var b = a.slice(0); - stableSortInPlaceByU(b, cmp); - return b; -} - -function stableSortBy(a, cmp) { - return stableSortByU(a, Curry.__2(cmp)); -} - -function binarySearchByU(sorted, key, cmp) { - var len = sorted.length; - if (len === 0) { - return -1; - } - var lo = sorted[0]; - var c = cmp(key, lo); - if (c < 0) { - return -1; - } - var hi = sorted[len - 1 | 0]; - var c2 = cmp(key, hi); - if (c2 > 0) { - return -(len + 1 | 0) | 0; - } else { - var _lo = 0; - var _hi = len - 1 | 0; - while(true) { - var hi$1 = _hi; - var lo$1 = _lo; - var mid = (lo$1 + hi$1 | 0) / 2 | 0; - var midVal = sorted[mid]; - var c$1 = cmp(key, midVal); - if (c$1 === 0) { - return mid; - } - if (c$1 < 0) { - if (hi$1 === mid) { - if (cmp(sorted[lo$1], key) === 0) { - return lo$1; - } else { - return -(hi$1 + 1 | 0) | 0; - } - } - _hi = mid; - continue ; - } - if (lo$1 === mid) { - if (cmp(sorted[hi$1], key) === 0) { - return hi$1; - } else { - return -(hi$1 + 1 | 0) | 0; - } - } - _lo = mid; - continue ; - }; - } -} - -function binarySearchBy(sorted, key, cmp) { - return binarySearchByU(sorted, key, Curry.__2(cmp)); -} - -var Int; - -var $$String; - -export { - Int , - $$String , - strictlySortedLengthU , - strictlySortedLength , - isSortedU , - isSorted , - stableSortInPlaceByU , - stableSortInPlaceBy , - stableSortByU , - stableSortBy , - binarySearchByU , - binarySearchBy , - unionU , - union , - intersectU , - intersect , - diffU , - diff , -} -/* No side effect */ diff --git a/lib/es6/belt_SortArrayInt.js b/lib/es6/belt_SortArrayInt.js deleted file mode 100644 index fa13cacfb8a..00000000000 --- a/lib/es6/belt_SortArrayInt.js +++ /dev/null @@ -1,374 +0,0 @@ - - -import * as Belt_Array from "./belt_Array.js"; - -function sortedLengthAuxMore(xs, _prec, _acc, len) { - while(true) { - var acc = _acc; - var prec = _prec; - if (acc >= len) { - return acc; - } - var v = xs[acc]; - if (prec <= v) { - return acc; - } - _acc = acc + 1 | 0; - _prec = v; - continue ; - }; -} - -function strictlySortedLength(xs) { - var len = xs.length; - if (len === 0 || len === 1) { - return len; - } - var x0 = xs[0]; - var x1 = xs[1]; - if (x0 < x1) { - var _prec = x1; - var _acc = 2; - while(true) { - var acc = _acc; - var prec = _prec; - if (acc >= len) { - return acc; - } - var v = xs[acc]; - if (prec >= v) { - return acc; - } - _acc = acc + 1 | 0; - _prec = v; - continue ; - }; - } else if (x0 > x1) { - return -sortedLengthAuxMore(xs, x1, 2, len) | 0; - } else { - return 1; - } -} - -function isSorted(a) { - var len = a.length; - if (len === 0) { - return true; - } else { - var _i = 0; - var last_bound = len - 1 | 0; - while(true) { - var i = _i; - if (i === last_bound) { - return true; - } - if (a[i] > a[i + 1 | 0]) { - return false; - } - _i = i + 1 | 0; - continue ; - }; - } -} - -function merge(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (s1 <= s2) { - dst[d] = s1; - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return Belt_Array.blitUnsafe(src2, i2, dst, d + 1 | 0, src2r - i2 | 0); - } - _d = d + 1 | 0; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - dst[d] = s2; - var i2$1 = i2 + 1 | 0; - if (i2$1 >= src2r) { - return Belt_Array.blitUnsafe(src, i1, dst, d + 1 | 0, src1r - i1 | 0); - } - _d = d + 1 | 0; - _s2 = src2[i2$1]; - _i2 = i2$1; - continue ; - }; -} - -function union(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (s1 < s2) { - dst[d] = s1; - var i1$1 = i1 + 1 | 0; - var d$1 = d + 1 | 0; - if (i1$1 < src1r) { - _d = d$1; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - Belt_Array.blitUnsafe(src2, i2, dst, d$1, src2r - i2 | 0); - return (d$1 + src2r | 0) - i2 | 0; - } - if (s1 === s2) { - dst[d] = s1; - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - var d$2 = d + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - if (i1$2 === src1r) { - Belt_Array.blitUnsafe(src2, i2$1, dst, d$2, src2r - i2$1 | 0); - return (d$2 + src2r | 0) - i2$1 | 0; - } else { - Belt_Array.blitUnsafe(src, i1$2, dst, d$2, src1r - i1$2 | 0); - return (d$2 + src1r | 0) - i1$2 | 0; - } - } - _d = d$2; - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - dst[d] = s2; - var i2$2 = i2 + 1 | 0; - var d$3 = d + 1 | 0; - if (i2$2 < src2r) { - _d = d$3; - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - } - Belt_Array.blitUnsafe(src, i1, dst, d$3, src1r - i1 | 0); - return (d$3 + src1r | 0) - i1 | 0; - }; -} - -function intersect(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (s1 < s2) { - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return d; - } - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - if (s1 === s2) { - dst[d] = s1; - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - var d$1 = d + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - return d$1; - } - _d = d$1; - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - var i2$2 = i2 + 1 | 0; - if (i2$2 >= src2r) { - return d; - } - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - }; -} - -function diff(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (s1 < s2) { - dst[d] = s1; - var d$1 = d + 1 | 0; - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return d$1; - } - _d = d$1; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - if (s1 === s2) { - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - if (i1$2 === src1r) { - return d; - } else { - Belt_Array.blitUnsafe(src, i1$2, dst, d, src1r - i1$2 | 0); - return (d + src1r | 0) - i1$2 | 0; - } - } - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - var i2$2 = i2 + 1 | 0; - if (i2$2 < src2r) { - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - } - Belt_Array.blitUnsafe(src, i1, dst, d, src1r - i1 | 0); - return (d + src1r | 0) - i1 | 0; - }; -} - -function insertionSort(src, srcofs, dst, dstofs, len) { - for(var i = 0; i < len; ++i){ - var e = src[srcofs + i | 0]; - var j = (dstofs + i | 0) - 1 | 0; - while(j >= dstofs && dst[j] > e) { - dst[j + 1 | 0] = dst[j]; - j = j - 1 | 0; - }; - dst[j + 1 | 0] = e; - } -} - -function sortTo(src, srcofs, dst, dstofs, len) { - if (len <= 5) { - return insertionSort(src, srcofs, dst, dstofs, len); - } - var l1 = len / 2 | 0; - var l2 = len - l1 | 0; - sortTo(src, srcofs + l1 | 0, dst, dstofs + l1 | 0, l2); - sortTo(src, srcofs, src, srcofs + l2 | 0, l1); - merge(src, srcofs + l2 | 0, l1, dst, dstofs + l1 | 0, l2, dst, dstofs); -} - -function stableSortInPlace(a) { - var l = a.length; - if (l <= 5) { - return insertionSort(a, 0, a, 0, l); - } - var l1 = l / 2 | 0; - var l2 = l - l1 | 0; - var t = new Array(l2); - sortTo(a, l1, t, 0, l2); - sortTo(a, 0, a, l2, l1); - merge(a, l2, l1, t, 0, l2, a, 0); -} - -function stableSort(a) { - var b = a.slice(0); - stableSortInPlace(b); - return b; -} - -function binarySearch(sorted, key) { - var len = sorted.length; - if (len === 0) { - return -1; - } - var lo = sorted[0]; - if (key < lo) { - return -1; - } - var hi = sorted[len - 1 | 0]; - if (key > hi) { - return -(len + 1 | 0) | 0; - } else { - var _lo = 0; - var _hi = len - 1 | 0; - while(true) { - var hi$1 = _hi; - var lo$1 = _lo; - var mid = (lo$1 + hi$1 | 0) / 2 | 0; - var midVal = sorted[mid]; - if (key === midVal) { - return mid; - } - if (key < midVal) { - if (hi$1 === mid) { - if (sorted[lo$1] === key) { - return lo$1; - } else { - return -(hi$1 + 1 | 0) | 0; - } - } - _hi = mid; - continue ; - } - if (lo$1 === mid) { - if (sorted[hi$1] === key) { - return hi$1; - } else { - return -(hi$1 + 1 | 0) | 0; - } - } - _lo = mid; - continue ; - }; - } -} - -export { - strictlySortedLength , - isSorted , - stableSortInPlace , - stableSort , - binarySearch , - union , - intersect , - diff , -} -/* No side effect */ diff --git a/lib/es6/belt_SortArrayString.js b/lib/es6/belt_SortArrayString.js deleted file mode 100644 index fa13cacfb8a..00000000000 --- a/lib/es6/belt_SortArrayString.js +++ /dev/null @@ -1,374 +0,0 @@ - - -import * as Belt_Array from "./belt_Array.js"; - -function sortedLengthAuxMore(xs, _prec, _acc, len) { - while(true) { - var acc = _acc; - var prec = _prec; - if (acc >= len) { - return acc; - } - var v = xs[acc]; - if (prec <= v) { - return acc; - } - _acc = acc + 1 | 0; - _prec = v; - continue ; - }; -} - -function strictlySortedLength(xs) { - var len = xs.length; - if (len === 0 || len === 1) { - return len; - } - var x0 = xs[0]; - var x1 = xs[1]; - if (x0 < x1) { - var _prec = x1; - var _acc = 2; - while(true) { - var acc = _acc; - var prec = _prec; - if (acc >= len) { - return acc; - } - var v = xs[acc]; - if (prec >= v) { - return acc; - } - _acc = acc + 1 | 0; - _prec = v; - continue ; - }; - } else if (x0 > x1) { - return -sortedLengthAuxMore(xs, x1, 2, len) | 0; - } else { - return 1; - } -} - -function isSorted(a) { - var len = a.length; - if (len === 0) { - return true; - } else { - var _i = 0; - var last_bound = len - 1 | 0; - while(true) { - var i = _i; - if (i === last_bound) { - return true; - } - if (a[i] > a[i + 1 | 0]) { - return false; - } - _i = i + 1 | 0; - continue ; - }; - } -} - -function merge(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (s1 <= s2) { - dst[d] = s1; - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return Belt_Array.blitUnsafe(src2, i2, dst, d + 1 | 0, src2r - i2 | 0); - } - _d = d + 1 | 0; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - dst[d] = s2; - var i2$1 = i2 + 1 | 0; - if (i2$1 >= src2r) { - return Belt_Array.blitUnsafe(src, i1, dst, d + 1 | 0, src1r - i1 | 0); - } - _d = d + 1 | 0; - _s2 = src2[i2$1]; - _i2 = i2$1; - continue ; - }; -} - -function union(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (s1 < s2) { - dst[d] = s1; - var i1$1 = i1 + 1 | 0; - var d$1 = d + 1 | 0; - if (i1$1 < src1r) { - _d = d$1; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - Belt_Array.blitUnsafe(src2, i2, dst, d$1, src2r - i2 | 0); - return (d$1 + src2r | 0) - i2 | 0; - } - if (s1 === s2) { - dst[d] = s1; - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - var d$2 = d + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - if (i1$2 === src1r) { - Belt_Array.blitUnsafe(src2, i2$1, dst, d$2, src2r - i2$1 | 0); - return (d$2 + src2r | 0) - i2$1 | 0; - } else { - Belt_Array.blitUnsafe(src, i1$2, dst, d$2, src1r - i1$2 | 0); - return (d$2 + src1r | 0) - i1$2 | 0; - } - } - _d = d$2; - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - dst[d] = s2; - var i2$2 = i2 + 1 | 0; - var d$3 = d + 1 | 0; - if (i2$2 < src2r) { - _d = d$3; - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - } - Belt_Array.blitUnsafe(src, i1, dst, d$3, src1r - i1 | 0); - return (d$3 + src1r | 0) - i1 | 0; - }; -} - -function intersect(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (s1 < s2) { - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return d; - } - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - if (s1 === s2) { - dst[d] = s1; - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - var d$1 = d + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - return d$1; - } - _d = d$1; - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - var i2$2 = i2 + 1 | 0; - if (i2$2 >= src2r) { - return d; - } - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - }; -} - -function diff(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (s1 < s2) { - dst[d] = s1; - var d$1 = d + 1 | 0; - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return d$1; - } - _d = d$1; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - if (s1 === s2) { - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - if (i1$2 === src1r) { - return d; - } else { - Belt_Array.blitUnsafe(src, i1$2, dst, d, src1r - i1$2 | 0); - return (d + src1r | 0) - i1$2 | 0; - } - } - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - var i2$2 = i2 + 1 | 0; - if (i2$2 < src2r) { - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - } - Belt_Array.blitUnsafe(src, i1, dst, d, src1r - i1 | 0); - return (d + src1r | 0) - i1 | 0; - }; -} - -function insertionSort(src, srcofs, dst, dstofs, len) { - for(var i = 0; i < len; ++i){ - var e = src[srcofs + i | 0]; - var j = (dstofs + i | 0) - 1 | 0; - while(j >= dstofs && dst[j] > e) { - dst[j + 1 | 0] = dst[j]; - j = j - 1 | 0; - }; - dst[j + 1 | 0] = e; - } -} - -function sortTo(src, srcofs, dst, dstofs, len) { - if (len <= 5) { - return insertionSort(src, srcofs, dst, dstofs, len); - } - var l1 = len / 2 | 0; - var l2 = len - l1 | 0; - sortTo(src, srcofs + l1 | 0, dst, dstofs + l1 | 0, l2); - sortTo(src, srcofs, src, srcofs + l2 | 0, l1); - merge(src, srcofs + l2 | 0, l1, dst, dstofs + l1 | 0, l2, dst, dstofs); -} - -function stableSortInPlace(a) { - var l = a.length; - if (l <= 5) { - return insertionSort(a, 0, a, 0, l); - } - var l1 = l / 2 | 0; - var l2 = l - l1 | 0; - var t = new Array(l2); - sortTo(a, l1, t, 0, l2); - sortTo(a, 0, a, l2, l1); - merge(a, l2, l1, t, 0, l2, a, 0); -} - -function stableSort(a) { - var b = a.slice(0); - stableSortInPlace(b); - return b; -} - -function binarySearch(sorted, key) { - var len = sorted.length; - if (len === 0) { - return -1; - } - var lo = sorted[0]; - if (key < lo) { - return -1; - } - var hi = sorted[len - 1 | 0]; - if (key > hi) { - return -(len + 1 | 0) | 0; - } else { - var _lo = 0; - var _hi = len - 1 | 0; - while(true) { - var hi$1 = _hi; - var lo$1 = _lo; - var mid = (lo$1 + hi$1 | 0) / 2 | 0; - var midVal = sorted[mid]; - if (key === midVal) { - return mid; - } - if (key < midVal) { - if (hi$1 === mid) { - if (sorted[lo$1] === key) { - return lo$1; - } else { - return -(hi$1 + 1 | 0) | 0; - } - } - _hi = mid; - continue ; - } - if (lo$1 === mid) { - if (sorted[hi$1] === key) { - return hi$1; - } else { - return -(hi$1 + 1 | 0) | 0; - } - } - _lo = mid; - continue ; - }; - } -} - -export { - strictlySortedLength , - isSorted , - stableSortInPlace , - stableSort , - binarySearch , - union , - intersect , - diff , -} -/* No side effect */ diff --git a/lib/es6/belt_internalAVLset.js b/lib/es6/belt_internalAVLset.js deleted file mode 100644 index fa889cc4be1..00000000000 --- a/lib/es6/belt_internalAVLset.js +++ /dev/null @@ -1,940 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Caml_option from "./caml_option.js"; -import * as Belt_SortArray from "./belt_SortArray.js"; - -function copy(n) { - if (n !== undefined) { - return { - v: n.v, - h: n.h, - l: copy(n.l), - r: copy(n.r) - }; - } else { - return n; - } -} - -function create(l, v, r) { - var hl = l !== undefined ? l.h : 0; - var hr = r !== undefined ? r.h : 0; - return { - v: v, - h: ( - hl >= hr ? hl : hr - ) + 1 | 0, - l: l, - r: r - }; -} - -function singleton(x) { - return { - v: x, - h: 1, - l: undefined, - r: undefined - }; -} - -function heightGe(l, r) { - if (r !== undefined) { - if (l !== undefined) { - return l.h >= r.h; - } else { - return false; - } - } else { - return true; - } -} - -function bal(l, v, r) { - var hl = l !== undefined ? l.h : 0; - var hr = r !== undefined ? r.h : 0; - if (hl > (hr + 2 | 0)) { - var ll = l.l; - var 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)); - } - } - if (hr <= (hl + 2 | 0)) { - return { - v: v, - h: ( - hl >= hr ? hl : hr - ) + 1 | 0, - l: l, - r: r - }; - } - var rl = r.l; - var 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)); - } -} - -function min0Aux(_n) { - while(true) { - var n = _n; - var n$1 = n.l; - if (n$1 === undefined) { - return n.v; - } - _n = n$1; - continue ; - }; -} - -function minimum(n) { - if (n !== undefined) { - return Caml_option.some(min0Aux(n)); - } - -} - -function minUndefined(n) { - if (n !== undefined) { - return min0Aux(n); - } - -} - -function max0Aux(_n) { - while(true) { - var n = _n; - var n$1 = n.r; - if (n$1 === undefined) { - return n.v; - } - _n = n$1; - continue ; - }; -} - -function maximum(n) { - if (n !== undefined) { - return Caml_option.some(max0Aux(n)); - } - -} - -function maxUndefined(n) { - if (n !== undefined) { - return max0Aux(n); - } - -} - -function removeMinAuxWithRef(n, v) { - var ln = n.l; - if (ln !== undefined) { - return bal(removeMinAuxWithRef(ln, v), n.v, n.r); - } else { - v.contents = n.v; - return n.r; - } -} - -function isEmpty(n) { - return n === undefined; -} - -function stackAllLeft(_v, _s) { - while(true) { - var s = _s; - var v = _v; - if (v === undefined) { - return s; - } - _s = { - hd: v, - tl: s - }; - _v = v.l; - continue ; - }; -} - -function forEachU(_n, f) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - forEachU(n.l, f); - f(n.v); - _n = n.r; - continue ; - }; -} - -function forEach(n, f) { - forEachU(n, Curry.__1(f)); -} - -function reduceU(_s, _accu, f) { - while(true) { - var accu = _accu; - var s = _s; - if (s === undefined) { - return accu; - } - _accu = f(reduceU(s.l, accu, f), s.v); - _s = s.r; - continue ; - }; -} - -function reduce(s, accu, f) { - return reduceU(s, accu, Curry.__2(f)); -} - -function everyU(_n, p) { - while(true) { - var n = _n; - if (n === undefined) { - return true; - } - if (!p(n.v)) { - return false; - } - if (!everyU(n.l, p)) { - return false; - } - _n = n.r; - continue ; - }; -} - -function every(n, p) { - return everyU(n, Curry.__1(p)); -} - -function someU(_n, p) { - while(true) { - var n = _n; - if (n === undefined) { - return false; - } - if (p(n.v)) { - return true; - } - if (someU(n.l, p)) { - return true; - } - _n = n.r; - continue ; - }; -} - -function some(n, p) { - return someU(n, Curry.__1(p)); -} - -function addMinElement(n, v) { - if (n !== undefined) { - return bal(addMinElement(n.l, v), n.v, n.r); - } else { - return singleton(v); - } -} - -function addMaxElement(n, v) { - if (n !== undefined) { - return bal(n.l, n.v, addMaxElement(n.r, v)); - } else { - return singleton(v); - } -} - -function joinShared(ln, v, rn) { - if (ln === undefined) { - return addMinElement(rn, v); - } - if (rn === undefined) { - return addMaxElement(ln, v); - } - var lh = ln.h; - var rh = rn.h; - if (lh > (rh + 2 | 0)) { - return bal(ln.l, ln.v, joinShared(ln.r, v, rn)); - } else if (rh > (lh + 2 | 0)) { - return bal(joinShared(ln, v, rn.l), rn.v, rn.r); - } else { - return create(ln, v, rn); - } -} - -function concatShared(t1, t2) { - if (t1 === undefined) { - return t2; - } - if (t2 === undefined) { - return t1; - } - var v = { - contents: t2.v - }; - var t2r = removeMinAuxWithRef(t2, v); - return joinShared(t1, v.contents, t2r); -} - -function partitionSharedU(n, p) { - if (n === undefined) { - return [ - undefined, - undefined - ]; - } - var value = n.v; - var match = partitionSharedU(n.l, p); - var lf = match[1]; - var lt = match[0]; - var pv = p(value); - var match$1 = partitionSharedU(n.r, p); - var rf = match$1[1]; - var rt = match$1[0]; - if (pv) { - return [ - joinShared(lt, value, rt), - concatShared(lf, rf) - ]; - } else { - return [ - concatShared(lt, rt), - joinShared(lf, value, rf) - ]; - } -} - -function partitionShared(n, p) { - return partitionSharedU(n, Curry.__1(p)); -} - -function lengthNode(n) { - var l = n.l; - var r = n.r; - var sizeL = l !== undefined ? lengthNode(l) : 0; - var sizeR = r !== undefined ? lengthNode(r) : 0; - return (1 + sizeL | 0) + sizeR | 0; -} - -function size(n) { - if (n !== undefined) { - return lengthNode(n); - } else { - return 0; - } -} - -function toListAux(_n, _accu) { - while(true) { - var accu = _accu; - var n = _n; - if (n === undefined) { - return accu; - } - _accu = { - hd: n.v, - tl: toListAux(n.r, accu) - }; - _n = n.l; - continue ; - }; -} - -function toList(s) { - return toListAux(s, /* [] */0); -} - -function checkInvariantInternal(_v) { - while(true) { - var v = _v; - if (v === undefined) { - return ; - } - var l = v.l; - var r = v.r; - var diff = ( - l !== undefined ? l.h : 0 - ) - ( - r !== undefined ? r.h : 0 - ) | 0; - if (!(diff <= 2 && diff >= -2)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLset.res", - 319, - 4 - ], - Error: new Error() - }; - } - checkInvariantInternal(l); - _v = r; - continue ; - }; -} - -function fillArray(_n, _i, arr) { - while(true) { - var i = _i; - var n = _n; - var v = n.v; - var l = n.l; - var r = n.r; - var next = l !== undefined ? fillArray(l, i, arr) : i; - arr[next] = v; - var rnext = next + 1 | 0; - if (r === undefined) { - return rnext; - } - _i = rnext; - _n = r; - continue ; - }; -} - -function fillArrayWithPartition(_n, cursor, arr, p) { - while(true) { - var n = _n; - var v = n.v; - var l = n.l; - var r = n.r; - if (l !== undefined) { - fillArrayWithPartition(l, cursor, arr, p); - } - if (p(v)) { - var c = cursor.forward; - arr[c] = v; - cursor.forward = c + 1 | 0; - } else { - var c$1 = cursor.backward; - arr[c$1] = v; - cursor.backward = c$1 - 1 | 0; - } - if (r === undefined) { - return ; - } - _n = r; - continue ; - }; -} - -function fillArrayWithFilter(_n, _i, arr, p) { - while(true) { - var i = _i; - var n = _n; - var v = n.v; - var l = n.l; - var r = n.r; - var next = l !== undefined ? fillArrayWithFilter(l, i, arr, p) : i; - var rnext = p(v) ? (arr[next] = v, next + 1 | 0) : next; - if (r === undefined) { - return rnext; - } - _i = rnext; - _n = r; - continue ; - }; -} - -function toArray(n) { - if (n === undefined) { - return []; - } - var size = lengthNode(n); - var v = new Array(size); - fillArray(n, 0, v); - return v; -} - -function fromSortedArrayRevAux(arr, off, len) { - switch (len) { - case 0 : - return ; - case 1 : - return singleton(arr[off]); - case 2 : - var x0 = arr[off]; - var x1 = arr[off - 1 | 0]; - return { - v: x1, - h: 2, - l: singleton(x0), - r: undefined - }; - case 3 : - var x0$1 = arr[off]; - var x1$1 = arr[off - 1 | 0]; - var x2 = arr[off - 2 | 0]; - return { - v: x1$1, - h: 2, - l: singleton(x0$1), - r: singleton(x2) - }; - default: - var nl = len / 2 | 0; - var left = fromSortedArrayRevAux(arr, off, nl); - var mid = arr[off - nl | 0]; - var right = fromSortedArrayRevAux(arr, (off - nl | 0) - 1 | 0, (len - nl | 0) - 1 | 0); - return create(left, mid, right); - } -} - -function fromSortedArrayAux(arr, off, len) { - switch (len) { - case 0 : - return ; - case 1 : - return singleton(arr[off]); - case 2 : - var x0 = arr[off]; - var x1 = arr[off + 1 | 0]; - return { - v: x1, - h: 2, - l: singleton(x0), - r: undefined - }; - case 3 : - var x0$1 = arr[off]; - var x1$1 = arr[off + 1 | 0]; - var x2 = arr[off + 2 | 0]; - return { - v: x1$1, - h: 2, - l: singleton(x0$1), - r: singleton(x2) - }; - default: - var nl = len / 2 | 0; - var left = fromSortedArrayAux(arr, off, nl); - var mid = arr[off + nl | 0]; - var right = fromSortedArrayAux(arr, (off + nl | 0) + 1 | 0, (len - nl | 0) - 1 | 0); - return create(left, mid, right); - } -} - -function fromSortedArrayUnsafe(arr) { - return fromSortedArrayAux(arr, 0, arr.length); -} - -function keepSharedU(n, p) { - if (n === undefined) { - return ; - } - var v = n.v; - var l = n.l; - var r = n.r; - var newL = keepSharedU(l, p); - var pv = p(v); - var newR = keepSharedU(r, p); - if (pv) { - if (l === newL && r === newR) { - return n; - } else { - return joinShared(newL, v, newR); - } - } else { - return concatShared(newL, newR); - } -} - -function keepShared(n, p) { - return keepSharedU(n, Curry.__1(p)); -} - -function keepCopyU(n, p) { - if (n === undefined) { - return ; - } - var size = lengthNode(n); - var v = new Array(size); - var last = fillArrayWithFilter(n, 0, v, p); - return fromSortedArrayAux(v, 0, last); -} - -function keepCopy(n, p) { - return keepCopyU(n, Curry.__1(p)); -} - -function partitionCopyU(n, p) { - if (n === undefined) { - return [ - undefined, - undefined - ]; - } - var size = lengthNode(n); - var v = new Array(size); - var backward = size - 1 | 0; - var cursor = { - forward: 0, - backward: backward - }; - fillArrayWithPartition(n, cursor, v, p); - var forwardLen = cursor.forward; - return [ - fromSortedArrayAux(v, 0, forwardLen), - fromSortedArrayRevAux(v, backward, size - forwardLen | 0) - ]; -} - -function partitionCopy(n, p) { - return partitionCopyU(n, Curry.__1(p)); -} - -function has(_t, x, cmp) { - while(true) { - var t = _t; - if (t === undefined) { - return false; - } - var v = t.v; - var c = cmp(x, v); - if (c === 0) { - return true; - } - _t = c < 0 ? t.l : t.r; - continue ; - }; -} - -function cmp(s1, s2, cmp$1) { - var len1 = size(s1); - var len2 = size(s2); - if (len1 === len2) { - var _e1 = stackAllLeft(s1, /* [] */0); - var _e2 = stackAllLeft(s2, /* [] */0); - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return 0; - } - if (!e2) { - return 0; - } - var h2 = e2.hd; - var h1 = e1.hd; - var c = cmp$1(h1.v, h2.v); - if (c !== 0) { - return c; - } - _e2 = stackAllLeft(h2.r, e2.tl); - _e1 = stackAllLeft(h1.r, e1.tl); - continue ; - }; - } else if (len1 < len2) { - return -1; - } else { - return 1; - } -} - -function eq(s1, s2, c) { - return cmp(s1, s2, c) === 0; -} - -function subset(_s1, _s2, cmp) { - while(true) { - var s2 = _s2; - var s1 = _s1; - if (s1 === undefined) { - return true; - } - if (s2 === undefined) { - return false; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var v2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - var c = cmp(v1, v2); - if (c === 0) { - if (!subset(l1, l2, cmp)) { - return false; - } - _s2 = r2; - _s1 = r1; - continue ; - } - if (c < 0) { - if (!subset(create(l1, v1, undefined), l2, cmp)) { - return false; - } - _s1 = r1; - continue ; - } - if (!subset(create(undefined, v1, r1), r2, cmp)) { - return false; - } - _s1 = l1; - continue ; - }; -} - -function get(_n, x, cmp) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.v; - var c = cmp(x, v); - if (c === 0) { - return Caml_option.some(v); - } - _n = c < 0 ? n.l : n.r; - continue ; - }; -} - -function getUndefined(_n, x, cmp) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.v; - var c = cmp(x, v); - if (c === 0) { - return v; - } - _n = c < 0 ? n.l : n.r; - continue ; - }; -} - -function getExn(_n, x, cmp) { - while(true) { - var n = _n; - if (n !== undefined) { - var v = n.v; - var c = cmp(x, v); - if (c === 0) { - return v; - } - _n = c < 0 ? n.l : n.r; - continue ; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function rotateWithLeftChild(k2) { - var k1 = k2.l; - k2.l = k1.r; - k1.r = k2; - var n = k2.l; - var hlk2 = n !== undefined ? n.h : 0; - var n$1 = k2.r; - var hrk2 = n$1 !== undefined ? n$1.h : 0; - k2.h = ( - hlk2 > hrk2 ? hlk2 : hrk2 - ) + 1 | 0; - var n$2 = k1.l; - var hlk1 = n$2 !== undefined ? n$2.h : 0; - var hk2 = k2.h; - k1.h = ( - hlk1 > hk2 ? hlk1 : hk2 - ) + 1 | 0; - return k1; -} - -function rotateWithRightChild(k1) { - var k2 = k1.r; - k1.r = k2.l; - k2.l = k1; - var n = k1.l; - var hlk1 = n !== undefined ? n.h : 0; - var n$1 = k1.r; - var hrk1 = n$1 !== undefined ? n$1.h : 0; - k1.h = ( - hlk1 > hrk1 ? hlk1 : hrk1 - ) + 1 | 0; - var n$2 = k2.r; - var hrk2 = n$2 !== undefined ? n$2.h : 0; - var hk1 = k1.h; - k2.h = ( - hrk2 > hk1 ? hrk2 : hk1 - ) + 1 | 0; - return k2; -} - -function doubleWithLeftChild(k3) { - var k3l = k3.l; - var v = rotateWithRightChild(k3l); - k3.l = v; - return rotateWithLeftChild(k3); -} - -function doubleWithRightChild(k2) { - var k2r = k2.r; - var v = rotateWithLeftChild(k2r); - k2.r = v; - return rotateWithRightChild(k2); -} - -function heightUpdateMutate(t) { - var n = t.l; - var hlt = n !== undefined ? n.h : 0; - var n$1 = t.r; - var hrt = n$1 !== undefined ? n$1.h : 0; - t.h = ( - hlt > hrt ? hlt : hrt - ) + 1 | 0; - return t; -} - -function balMutate(nt) { - var l = nt.l; - var r = nt.r; - var hl = l !== undefined ? l.h : 0; - var hr = r !== undefined ? r.h : 0; - if (hl > (2 + hr | 0)) { - var ll = l.l; - var lr = l.r; - if (heightGe(ll, lr)) { - return heightUpdateMutate(rotateWithLeftChild(nt)); - } else { - return heightUpdateMutate(doubleWithLeftChild(nt)); - } - } - if (hr > (2 + hl | 0)) { - var rl = r.l; - var rr = r.r; - if (heightGe(rr, rl)) { - return heightUpdateMutate(rotateWithRightChild(nt)); - } else { - return heightUpdateMutate(doubleWithRightChild(nt)); - } - } - nt.h = ( - hl > hr ? hl : hr - ) + 1 | 0; - return nt; -} - -function addMutate(cmp, t, x) { - if (t === undefined) { - return singleton(x); - } - var k = t.v; - var c = cmp(x, k); - if (c === 0) { - return t; - } - var l = t.l; - var r = t.r; - if (c < 0) { - var ll = addMutate(cmp, l, x); - t.l = ll; - } else { - t.r = addMutate(cmp, r, x); - } - return balMutate(t); -} - -function fromArray(xs, cmp) { - var len = xs.length; - if (len === 0) { - return ; - } - var next = Belt_SortArray.strictlySortedLengthU(xs, (function (x, y) { - return cmp(x, y) < 0; - })); - var result; - if (next >= 0) { - result = fromSortedArrayAux(xs, 0, next); - } else { - next = -next | 0; - result = fromSortedArrayRevAux(xs, next - 1 | 0, next); - } - for(var i = next; i < len; ++i){ - result = addMutate(cmp, result, xs[i]); - } - return result; -} - -function removeMinAuxWithRootMutate(nt, n) { - var ln = n.l; - var rn = n.r; - if (ln !== undefined) { - n.l = removeMinAuxWithRootMutate(nt, ln); - return balMutate(n); - } else { - nt.v = n.v; - return rn; - } -} - -export { - copy , - create , - bal , - singleton , - minimum , - minUndefined , - maximum , - maxUndefined , - removeMinAuxWithRef , - isEmpty , - stackAllLeft , - forEachU , - forEach , - reduceU , - reduce , - everyU , - every , - someU , - some , - joinShared , - concatShared , - keepSharedU , - keepShared , - keepCopyU , - keepCopy , - partitionSharedU , - partitionShared , - partitionCopyU , - partitionCopy , - lengthNode , - size , - toList , - checkInvariantInternal , - fillArray , - toArray , - fromSortedArrayAux , - fromSortedArrayRevAux , - fromSortedArrayUnsafe , - has , - cmp , - eq , - subset , - get , - getUndefined , - getExn , - fromArray , - addMutate , - balMutate , - removeMinAuxWithRootMutate , -} -/* No side effect */ diff --git a/lib/es6/belt_internalAVLtree.js b/lib/es6/belt_internalAVLtree.js deleted file mode 100644 index b3ec80eaff5..00000000000 --- a/lib/es6/belt_internalAVLtree.js +++ /dev/null @@ -1,1146 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Caml_option from "./caml_option.js"; -import * as Belt_SortArray from "./belt_SortArray.js"; - -function treeHeight(n) { - if (n !== undefined) { - return n.h; - } else { - return 0; - } -} - -function copy(n) { - if (n !== undefined) { - return { - k: n.k, - v: n.v, - h: n.h, - l: copy(n.l), - r: copy(n.r) - }; - } else { - return n; - } -} - -function create(l, x, d, r) { - var hl = treeHeight(l); - var hr = treeHeight(r); - return { - k: x, - v: d, - h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0, - l: l, - r: r - }; -} - -function singleton(x, d) { - return { - k: x, - v: d, - h: 1, - l: undefined, - r: undefined - }; -} - -function heightGe(l, r) { - if (r !== undefined) { - if (l !== undefined) { - return l.h >= r.h; - } else { - return false; - } - } else { - return true; - } -} - -function updateValue(n, newValue) { - if (n.v === newValue) { - return n; - } else { - return { - k: n.k, - v: newValue, - h: n.h, - l: n.l, - r: n.r - }; - } -} - -function bal(l, x, d, r) { - var hl = l !== undefined ? l.h : 0; - var hr = r !== undefined ? r.h : 0; - if (hl > (hr + 2 | 0)) { - var ll = l.l; - var 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)); - } - } - if (hr <= (hl + 2 | 0)) { - return { - k: x, - v: d, - h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0, - l: l, - r: r - }; - } - var rl = r.l; - var 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)); - } -} - -function minKey0Aux(_n) { - while(true) { - var n = _n; - var n$1 = n.l; - if (n$1 === undefined) { - return n.k; - } - _n = n$1; - continue ; - }; -} - -function minKey(n) { - if (n !== undefined) { - return Caml_option.some(minKey0Aux(n)); - } - -} - -function minKeyUndefined(n) { - if (n !== undefined) { - return minKey0Aux(n); - } - -} - -function maxKey0Aux(_n) { - while(true) { - var n = _n; - var n$1 = n.r; - if (n$1 === undefined) { - return n.k; - } - _n = n$1; - continue ; - }; -} - -function maxKey(n) { - if (n !== undefined) { - return Caml_option.some(maxKey0Aux(n)); - } - -} - -function maxKeyUndefined(n) { - if (n !== undefined) { - return maxKey0Aux(n); - } - -} - -function minKV0Aux(_n) { - while(true) { - var n = _n; - var n$1 = n.l; - if (n$1 === undefined) { - return [ - n.k, - n.v - ]; - } - _n = n$1; - continue ; - }; -} - -function minimum(n) { - if (n !== undefined) { - return minKV0Aux(n); - } - -} - -function minUndefined(n) { - if (n !== undefined) { - return minKV0Aux(n); - } - -} - -function maxKV0Aux(_n) { - while(true) { - var n = _n; - var n$1 = n.r; - if (n$1 === undefined) { - return [ - n.k, - n.v - ]; - } - _n = n$1; - continue ; - }; -} - -function maximum(n) { - if (n !== undefined) { - return maxKV0Aux(n); - } - -} - -function maxUndefined(n) { - if (n !== undefined) { - return maxKV0Aux(n); - } - -} - -function removeMinAuxWithRef(n, kr, vr) { - var ln = n.l; - if (ln !== undefined) { - return bal(removeMinAuxWithRef(ln, kr, vr), n.k, n.v, n.r); - } else { - kr.contents = n.k; - vr.contents = n.v; - return n.r; - } -} - -function isEmpty(x) { - return x === undefined; -} - -function stackAllLeft(_v, _s) { - while(true) { - var s = _s; - var v = _v; - if (v === undefined) { - return s; - } - _s = { - hd: v, - tl: s - }; - _v = v.l; - continue ; - }; -} - -function findFirstByU(n, p) { - if (n === undefined) { - return ; - } - var left = findFirstByU(n.l, p); - if (left !== undefined) { - return left; - } - var v = n.k; - var d = n.v; - var pvd = p(v, d); - if (pvd) { - return [ - v, - d - ]; - } - var right = findFirstByU(n.r, p); - if (right !== undefined) { - return right; - } - -} - -function findFirstBy(n, p) { - return findFirstByU(n, Curry.__2(p)); -} - -function forEachU(_n, f) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - forEachU(n.l, f); - f(n.k, n.v); - _n = n.r; - continue ; - }; -} - -function forEach(n, f) { - forEachU(n, Curry.__2(f)); -} - -function mapU(n, f) { - if (n === undefined) { - return ; - } - var newLeft = mapU(n.l, f); - var newD = f(n.v); - var newRight = mapU(n.r, f); - return { - k: n.k, - v: newD, - h: n.h, - l: newLeft, - r: newRight - }; -} - -function map(n, f) { - return mapU(n, Curry.__1(f)); -} - -function mapWithKeyU(n, f) { - if (n === undefined) { - return ; - } - var key = n.k; - var newLeft = mapWithKeyU(n.l, f); - var newD = f(key, n.v); - var newRight = mapWithKeyU(n.r, f); - return { - k: key, - v: newD, - h: n.h, - l: newLeft, - r: newRight - }; -} - -function mapWithKey(n, f) { - return mapWithKeyU(n, Curry.__2(f)); -} - -function reduceU(_m, _accu, f) { - while(true) { - var accu = _accu; - var m = _m; - if (m === undefined) { - return accu; - } - var v = m.k; - var d = m.v; - var l = m.l; - var r = m.r; - _accu = f(reduceU(l, accu, f), v, d); - _m = r; - continue ; - }; -} - -function reduce(m, accu, f) { - return reduceU(m, accu, Curry.__3(f)); -} - -function everyU(_n, p) { - while(true) { - var n = _n; - if (n === undefined) { - return true; - } - if (!p(n.k, n.v)) { - return false; - } - if (!everyU(n.l, p)) { - return false; - } - _n = n.r; - continue ; - }; -} - -function every(n, p) { - return everyU(n, Curry.__2(p)); -} - -function someU(_n, p) { - while(true) { - var n = _n; - if (n === undefined) { - return false; - } - if (p(n.k, n.v)) { - return true; - } - if (someU(n.l, p)) { - return true; - } - _n = n.r; - continue ; - }; -} - -function some(n, p) { - return someU(n, Curry.__2(p)); -} - -function addMinElement(n, k, v) { - if (n !== undefined) { - return bal(addMinElement(n.l, k, v), n.k, n.v, n.r); - } else { - return singleton(k, v); - } -} - -function addMaxElement(n, k, v) { - if (n !== undefined) { - return bal(n.l, n.k, n.v, addMaxElement(n.r, k, v)); - } else { - return singleton(k, v); - } -} - -function join(ln, v, d, rn) { - if (ln === undefined) { - return addMinElement(rn, v, d); - } - if (rn === undefined) { - return addMaxElement(ln, v, d); - } - var lv = ln.k; - var ld = ln.v; - var lh = ln.h; - var ll = ln.l; - var lr = ln.r; - var rv = rn.k; - var rd = rn.v; - var rh = rn.h; - var rl = rn.l; - var rr = rn.r; - if (lh > (rh + 2 | 0)) { - return bal(ll, lv, ld, join(lr, v, d, rn)); - } else if (rh > (lh + 2 | 0)) { - return bal(join(ln, v, d, rl), rv, rd, rr); - } else { - return create(ln, v, d, rn); - } -} - -function concat(t1, t2) { - if (t1 === undefined) { - return t2; - } - if (t2 === undefined) { - return t1; - } - var kr = { - contents: t2.k - }; - var vr = { - contents: t2.v - }; - var t2r = removeMinAuxWithRef(t2, kr, vr); - return join(t1, kr.contents, vr.contents, t2r); -} - -function concatOrJoin(t1, v, d, t2) { - if (d !== undefined) { - return join(t1, v, Caml_option.valFromOption(d), t2); - } else { - return concat(t1, t2); - } -} - -function keepSharedU(n, p) { - if (n === undefined) { - return ; - } - var v = n.k; - var d = n.v; - var newLeft = keepSharedU(n.l, p); - var pvd = p(v, d); - var newRight = keepSharedU(n.r, p); - if (pvd) { - return join(newLeft, v, d, newRight); - } else { - return concat(newLeft, newRight); - } -} - -function keepShared(n, p) { - return keepSharedU(n, Curry.__2(p)); -} - -function keepMapU(n, p) { - if (n === undefined) { - return ; - } - var v = n.k; - var d = n.v; - var newLeft = keepMapU(n.l, p); - var pvd = p(v, d); - var newRight = keepMapU(n.r, p); - if (pvd !== undefined) { - return join(newLeft, v, Caml_option.valFromOption(pvd), newRight); - } else { - return concat(newLeft, newRight); - } -} - -function keepMap(n, p) { - return keepMapU(n, Curry.__2(p)); -} - -function partitionSharedU(n, p) { - if (n === undefined) { - return [ - undefined, - undefined - ]; - } - var key = n.k; - var value = n.v; - var match = partitionSharedU(n.l, p); - var lf = match[1]; - var lt = match[0]; - var pvd = p(key, value); - var match$1 = partitionSharedU(n.r, p); - var rf = match$1[1]; - var rt = match$1[0]; - if (pvd) { - return [ - join(lt, key, value, rt), - concat(lf, rf) - ]; - } else { - return [ - concat(lt, rt), - join(lf, key, value, rf) - ]; - } -} - -function partitionShared(n, p) { - return partitionSharedU(n, Curry.__2(p)); -} - -function lengthNode(n) { - var l = n.l; - var r = n.r; - var sizeL = l !== undefined ? lengthNode(l) : 0; - var sizeR = r !== undefined ? lengthNode(r) : 0; - return (1 + sizeL | 0) + sizeR | 0; -} - -function size(n) { - if (n !== undefined) { - return lengthNode(n); - } else { - return 0; - } -} - -function toListAux(_n, _accu) { - while(true) { - var accu = _accu; - var n = _n; - if (n === undefined) { - return accu; - } - var k = n.k; - var v = n.v; - var l = n.l; - var r = n.r; - _accu = { - hd: [ - k, - v - ], - tl: toListAux(r, accu) - }; - _n = l; - continue ; - }; -} - -function toList(s) { - return toListAux(s, /* [] */0); -} - -function checkInvariantInternal(_v) { - while(true) { - var v = _v; - if (v === undefined) { - return ; - } - var l = v.l; - var r = v.r; - var diff = treeHeight(l) - treeHeight(r) | 0; - if (!(diff <= 2 && diff >= -2)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLtree.res", - 457, - 4 - ], - Error: new Error() - }; - } - checkInvariantInternal(l); - _v = r; - continue ; - }; -} - -function fillArrayKey(_n, _i, arr) { - while(true) { - var i = _i; - var n = _n; - var v = n.k; - var l = n.l; - var r = n.r; - var next = l !== undefined ? fillArrayKey(l, i, arr) : i; - arr[next] = v; - var rnext = next + 1 | 0; - if (r === undefined) { - return rnext; - } - _i = rnext; - _n = r; - continue ; - }; -} - -function fillArrayValue(_n, _i, arr) { - while(true) { - var i = _i; - var n = _n; - var l = n.l; - var r = n.r; - var next = l !== undefined ? fillArrayValue(l, i, arr) : i; - arr[next] = n.v; - var rnext = next + 1 | 0; - if (r === undefined) { - return rnext; - } - _i = rnext; - _n = r; - continue ; - }; -} - -function fillArray(_n, _i, arr) { - while(true) { - var i = _i; - var n = _n; - var l = n.l; - var v = n.k; - var r = n.r; - var next = l !== undefined ? fillArray(l, i, arr) : i; - arr[next] = [ - v, - n.v - ]; - var rnext = next + 1 | 0; - if (r === undefined) { - return rnext; - } - _i = rnext; - _n = r; - continue ; - }; -} - -function toArray(n) { - if (n === undefined) { - return []; - } - var size = lengthNode(n); - var v = new Array(size); - fillArray(n, 0, v); - return v; -} - -function keysToArray(n) { - if (n === undefined) { - return []; - } - var size = lengthNode(n); - var v = new Array(size); - fillArrayKey(n, 0, v); - return v; -} - -function valuesToArray(n) { - if (n === undefined) { - return []; - } - var size = lengthNode(n); - var v = new Array(size); - fillArrayValue(n, 0, v); - return v; -} - -function fromSortedArrayRevAux(arr, off, len) { - switch (len) { - case 0 : - return ; - case 1 : - var match = arr[off]; - return singleton(match[0], match[1]); - case 2 : - var match_0 = arr[off]; - var match_1 = arr[off - 1 | 0]; - var match$1 = match_1; - var match$2 = match_0; - return { - k: match$1[0], - v: match$1[1], - h: 2, - l: singleton(match$2[0], match$2[1]), - r: undefined - }; - case 3 : - var match_0$1 = arr[off]; - var match_1$1 = arr[off - 1 | 0]; - var match_2 = arr[off - 2 | 0]; - var match$3 = match_2; - var match$4 = match_1$1; - var match$5 = match_0$1; - return { - k: match$4[0], - v: match$4[1], - h: 2, - l: singleton(match$5[0], match$5[1]), - r: singleton(match$3[0], match$3[1]) - }; - default: - var nl = len / 2 | 0; - var left = fromSortedArrayRevAux(arr, off, nl); - var match$6 = arr[off - nl | 0]; - var right = fromSortedArrayRevAux(arr, (off - nl | 0) - 1 | 0, (len - nl | 0) - 1 | 0); - return create(left, match$6[0], match$6[1], right); - } -} - -function fromSortedArrayAux(arr, off, len) { - switch (len) { - case 0 : - return ; - case 1 : - var match = arr[off]; - return singleton(match[0], match[1]); - case 2 : - var match_0 = arr[off]; - var match_1 = arr[off + 1 | 0]; - var match$1 = match_1; - var match$2 = match_0; - return { - k: match$1[0], - v: match$1[1], - h: 2, - l: singleton(match$2[0], match$2[1]), - r: undefined - }; - case 3 : - var match_0$1 = arr[off]; - var match_1$1 = arr[off + 1 | 0]; - var match_2 = arr[off + 2 | 0]; - var match$3 = match_2; - var match$4 = match_1$1; - var match$5 = match_0$1; - return { - k: match$4[0], - v: match$4[1], - h: 2, - l: singleton(match$5[0], match$5[1]), - r: singleton(match$3[0], match$3[1]) - }; - default: - var nl = len / 2 | 0; - var left = fromSortedArrayAux(arr, off, nl); - var match$6 = arr[off + nl | 0]; - var right = fromSortedArrayAux(arr, (off + nl | 0) + 1 | 0, (len - nl | 0) - 1 | 0); - return create(left, match$6[0], match$6[1], right); - } -} - -function fromSortedArrayUnsafe(arr) { - return fromSortedArrayAux(arr, 0, arr.length); -} - -function cmpU(s1, s2, kcmp, vcmp) { - var len1 = size(s1); - var len2 = size(s2); - if (len1 === len2) { - var _e1 = stackAllLeft(s1, /* [] */0); - var _e2 = stackAllLeft(s2, /* [] */0); - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return 0; - } - if (!e2) { - return 0; - } - var h2 = e2.hd; - var h1 = e1.hd; - var c = kcmp(h1.k, h2.k); - if (c !== 0) { - return c; - } - var cx = vcmp(h1.v, h2.v); - if (cx !== 0) { - return cx; - } - _e2 = stackAllLeft(h2.r, e2.tl); - _e1 = stackAllLeft(h1.r, e1.tl); - continue ; - }; - } else if (len1 < len2) { - return -1; - } else { - return 1; - } -} - -function cmp(s1, s2, kcmp, vcmp) { - return cmpU(s1, s2, kcmp, Curry.__2(vcmp)); -} - -function eqU(s1, s2, kcmp, veq) { - var len1 = size(s1); - var len2 = size(s2); - if (len1 === len2) { - var _e1 = stackAllLeft(s1, /* [] */0); - var _e2 = stackAllLeft(s2, /* [] */0); - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return true; - } - if (!e2) { - return true; - } - var h2 = e2.hd; - var h1 = e1.hd; - if (!(kcmp(h1.k, h2.k) === 0 && veq(h1.v, h2.v))) { - return false; - } - _e2 = stackAllLeft(h2.r, e2.tl); - _e1 = stackAllLeft(h1.r, e1.tl); - continue ; - }; - } else { - return false; - } -} - -function eq(s1, s2, kcmp, veq) { - return eqU(s1, s2, kcmp, Curry.__2(veq)); -} - -function get(_n, x, cmp) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.k; - var c = cmp(x, v); - if (c === 0) { - return Caml_option.some(n.v); - } - _n = c < 0 ? n.l : n.r; - continue ; - }; -} - -function getUndefined(_n, x, cmp) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.k; - var c = cmp(x, v); - if (c === 0) { - return n.v; - } - _n = c < 0 ? n.l : n.r; - continue ; - }; -} - -function getExn(_n, x, cmp) { - while(true) { - var n = _n; - if (n !== undefined) { - var v = n.k; - var c = cmp(x, v); - if (c === 0) { - return n.v; - } - _n = c < 0 ? n.l : n.r; - continue ; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function getWithDefault(_n, x, def, cmp) { - while(true) { - var n = _n; - if (n === undefined) { - return def; - } - var v = n.k; - var c = cmp(x, v); - if (c === 0) { - return n.v; - } - _n = c < 0 ? n.l : n.r; - continue ; - }; -} - -function has(_n, x, cmp) { - while(true) { - var n = _n; - if (n === undefined) { - return false; - } - var v = n.k; - var c = cmp(x, v); - if (c === 0) { - return true; - } - _n = c < 0 ? n.l : n.r; - continue ; - }; -} - -function rotateWithLeftChild(k2) { - var k1 = k2.l; - k2.l = k1.r; - k1.r = k2; - var hlk2 = treeHeight(k2.l); - var hrk2 = treeHeight(k2.r); - k2.h = ( - hlk2 > hrk2 ? hlk2 : hrk2 - ) + 1 | 0; - var hlk1 = treeHeight(k1.l); - var hk2 = k2.h; - k1.h = ( - hlk1 > hk2 ? hlk1 : hk2 - ) + 1 | 0; - return k1; -} - -function rotateWithRightChild(k1) { - var k2 = k1.r; - k1.r = k2.l; - k2.l = k1; - var hlk1 = treeHeight(k1.l); - var hrk1 = treeHeight(k1.r); - k1.h = ( - hlk1 > hrk1 ? hlk1 : hrk1 - ) + 1 | 0; - var hrk2 = treeHeight(k2.r); - var hk1 = k1.h; - k2.h = ( - hrk2 > hk1 ? hrk2 : hk1 - ) + 1 | 0; - return k2; -} - -function doubleWithLeftChild(k3) { - var x = k3.l; - var v = rotateWithRightChild(x); - k3.l = v; - return rotateWithLeftChild(k3); -} - -function doubleWithRightChild(k2) { - var x = k2.r; - var v = rotateWithLeftChild(x); - k2.r = v; - return rotateWithRightChild(k2); -} - -function heightUpdateMutate(t) { - var hlt = treeHeight(t.l); - var hrt = treeHeight(t.r); - t.h = ( - hlt > hrt ? hlt : hrt - ) + 1 | 0; - return t; -} - -function balMutate(nt) { - var l = nt.l; - var r = nt.r; - var hl = treeHeight(l); - var hr = treeHeight(r); - if (hl > (2 + hr | 0)) { - var ll = l.l; - var lr = l.r; - if (heightGe(ll, lr)) { - return heightUpdateMutate(rotateWithLeftChild(nt)); - } else { - return heightUpdateMutate(doubleWithLeftChild(nt)); - } - } - if (hr > (2 + hl | 0)) { - var rl = r.l; - var rr = r.r; - if (heightGe(rr, rl)) { - return heightUpdateMutate(rotateWithRightChild(nt)); - } else { - return heightUpdateMutate(doubleWithRightChild(nt)); - } - } - nt.h = ( - hl > hr ? hl : hr - ) + 1 | 0; - return nt; -} - -function updateMutate(t, x, data, cmp) { - if (t === undefined) { - return singleton(x, data); - } - var k = t.k; - var c = cmp(x, k); - if (c === 0) { - t.v = data; - return t; - } - var l = t.l; - var r = t.r; - if (c < 0) { - var ll = updateMutate(l, x, data, cmp); - t.l = ll; - } else { - t.r = updateMutate(r, x, data, cmp); - } - return balMutate(t); -} - -function fromArray(xs, cmp) { - var len = xs.length; - if (len === 0) { - return ; - } - var next = Belt_SortArray.strictlySortedLengthU(xs, (function (param, param$1) { - return cmp(param[0], param$1[0]) < 0; - })); - var result; - if (next >= 0) { - result = fromSortedArrayAux(xs, 0, next); - } else { - next = -next | 0; - result = fromSortedArrayRevAux(xs, next - 1 | 0, next); - } - for(var i = next; i < len; ++i){ - var match = xs[i]; - result = updateMutate(result, match[0], match[1], cmp); - } - return result; -} - -function removeMinAuxWithRootMutate(nt, n) { - var rn = n.r; - var ln = n.l; - if (ln !== undefined) { - n.l = removeMinAuxWithRootMutate(nt, ln); - return balMutate(n); - } else { - nt.k = n.k; - nt.v = n.v; - return rn; - } -} - -export { - copy , - create , - bal , - singleton , - updateValue , - minKey , - minKeyUndefined , - maxKey , - maxKeyUndefined , - minimum , - minUndefined , - maximum , - maxUndefined , - removeMinAuxWithRef , - isEmpty , - stackAllLeft , - findFirstByU , - findFirstBy , - forEachU , - forEach , - mapU , - map , - mapWithKeyU , - mapWithKey , - reduceU , - reduce , - everyU , - every , - someU , - some , - join , - concat , - concatOrJoin , - keepSharedU , - keepShared , - keepMapU , - keepMap , - partitionSharedU , - partitionShared , - lengthNode , - size , - toList , - checkInvariantInternal , - fillArray , - toArray , - keysToArray , - valuesToArray , - fromSortedArrayAux , - fromSortedArrayRevAux , - fromSortedArrayUnsafe , - cmpU , - cmp , - eqU , - eq , - get , - getUndefined , - getWithDefault , - getExn , - has , - fromArray , - updateMutate , - balMutate , - removeMinAuxWithRootMutate , -} -/* No side effect */ diff --git a/lib/es6/belt_internalBuckets.js b/lib/es6/belt_internalBuckets.js deleted file mode 100644 index 302642266ac..00000000000 --- a/lib/es6/belt_internalBuckets.js +++ /dev/null @@ -1,287 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Belt_Array from "./belt_Array.js"; -import * as Caml_option from "./caml_option.js"; - -function copyBucket(c) { - if (c === undefined) { - return c; - } - var head = { - key: c.key, - value: c.value, - next: undefined - }; - copyAuxCont(c.next, head); - return head; -} - -function copyAuxCont(_c, _prec) { - while(true) { - var prec = _prec; - var c = _c; - if (c === undefined) { - return ; - } - var ncopy = { - key: c.key, - value: c.value, - next: undefined - }; - prec.next = ncopy; - _prec = ncopy; - _c = c.next; - continue ; - }; -} - -function copyBuckets(buckets) { - var len = buckets.length; - var newBuckets = new Array(len); - for(var i = 0; i < len; ++i){ - newBuckets[i] = copyBucket(buckets[i]); - } - return newBuckets; -} - -function copy(x) { - return { - size: x.size, - buckets: copyBuckets(x.buckets), - hash: x.hash, - eq: x.eq - }; -} - -function bucketLength(_accu, _buckets) { - while(true) { - var buckets = _buckets; - var accu = _accu; - if (buckets === undefined) { - return accu; - } - _buckets = buckets.next; - _accu = accu + 1 | 0; - continue ; - }; -} - -function do_bucket_iter(f, _buckets) { - while(true) { - var buckets = _buckets; - if (buckets === undefined) { - return ; - } - f(buckets.key, buckets.value); - _buckets = buckets.next; - continue ; - }; -} - -function forEachU(h, f) { - var d = h.buckets; - for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ - do_bucket_iter(f, d[i]); - } -} - -function forEach(h, f) { - forEachU(h, Curry.__2(f)); -} - -function do_bucket_fold(f, _b, _accu) { - while(true) { - var accu = _accu; - var b = _b; - if (b === undefined) { - return accu; - } - _accu = f(accu, b.key, b.value); - _b = b.next; - continue ; - }; -} - -function reduceU(h, init, f) { - var d = h.buckets; - var accu = init; - for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ - accu = do_bucket_fold(f, d[i], accu); - } - return accu; -} - -function reduce(h, init, f) { - return reduceU(h, init, Curry.__3(f)); -} - -function getMaxBucketLength(h) { - return Belt_Array.reduceU(h.buckets, 0, (function (m, b) { - var len = bucketLength(0, b); - if (m > len) { - return m; - } else { - return len; - } - })); -} - -function getBucketHistogram(h) { - var mbl = getMaxBucketLength(h); - var histo = Belt_Array.makeByU(mbl + 1 | 0, (function (param) { - return 0; - })); - Belt_Array.forEachU(h.buckets, (function (b) { - var l = bucketLength(0, b); - histo[l] = histo[l] + 1 | 0; - })); - return histo; -} - -function logStats(h) { - var histogram = getBucketHistogram(h); - console.log({ - bindings: h.size, - buckets: h.buckets.length, - histogram: histogram - }); -} - -function filterMapInplaceBucket(f, h, i, _prec, _cell) { - while(true) { - var cell = _cell; - var prec = _prec; - var n = cell.next; - var data = f(cell.key, cell.value); - if (data !== undefined) { - if (prec !== undefined) { - cell.next = cell; - } else { - h.buckets[i] = cell; - } - cell.value = Caml_option.valFromOption(data); - if (n === undefined) { - cell.next = n; - return ; - } - _cell = n; - _prec = cell; - continue ; - } - h.size = h.size - 1 | 0; - if (n === undefined) { - if (prec !== undefined) { - prec.next = n; - } else { - h.buckets[i] = prec; - } - return ; - } - _cell = n; - continue ; - }; -} - -function keepMapInPlaceU(h, f) { - var h_buckets = h.buckets; - for(var i = 0 ,i_finish = h_buckets.length; i < i_finish; ++i){ - var v = h_buckets[i]; - if (v !== undefined) { - filterMapInplaceBucket(f, h, i, undefined, v); - } - - } -} - -function keepMapInPlace(h, f) { - keepMapInPlaceU(h, Curry.__2(f)); -} - -function fillArray(_i, arr, _cell) { - while(true) { - var cell = _cell; - var i = _i; - arr[i] = [ - cell.key, - cell.value - ]; - var v = cell.next; - if (v === undefined) { - return i + 1 | 0; - } - _cell = v; - _i = i + 1 | 0; - continue ; - }; -} - -function fillArrayMap(_i, arr, _cell, f) { - while(true) { - var cell = _cell; - var i = _i; - arr[i] = f(cell); - var v = cell.next; - if (v === undefined) { - return i + 1 | 0; - } - _cell = v; - _i = i + 1 | 0; - continue ; - }; -} - -function linear(h, f) { - var d = h.buckets; - var current = 0; - var arr = new Array(h.size); - for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ - var cell = d[i]; - if (cell !== undefined) { - current = fillArrayMap(current, arr, cell, f); - } - - } - return arr; -} - -function keysToArray(h) { - return linear(h, (function (x) { - return x.key; - })); -} - -function valuesToArray(h) { - return linear(h, (function (x) { - return x.value; - })); -} - -function toArray(h) { - return linear(h, (function (x) { - return [ - x.key, - x.value - ]; - })); -} - -var C; - -export { - C , - copy , - forEachU , - forEach , - reduceU , - reduce , - logStats , - keepMapInPlaceU , - keepMapInPlace , - fillArray , - keysToArray , - valuesToArray , - toArray , - getBucketHistogram , -} -/* No side effect */ diff --git a/lib/es6/belt_internalBucketsType.js b/lib/es6/belt_internalBucketsType.js deleted file mode 100644 index 2a1c30d5244..00000000000 --- a/lib/es6/belt_internalBucketsType.js +++ /dev/null @@ -1,49 +0,0 @@ - - - -function power_2_above(_x, n) { - while(true) { - var x = _x; - if (x >= n) { - return x; - } - if ((x << 1) < x) { - return x; - } - _x = (x << 1); - continue ; - }; -} - -function make(hash, eq, hintSize) { - var s = power_2_above(16, hintSize); - return { - size: 0, - buckets: new Array(s), - hash: hash, - eq: eq - }; -} - -function clear(h) { - h.size = 0; - var h_buckets = h.buckets; - var len = h_buckets.length; - for(var i = 0; i < len; ++i){ - h_buckets[i] = undefined; - } -} - -function isEmpty(h) { - return h.size === 0; -} - -var emptyOpt; - -export { - emptyOpt , - make , - clear , - isEmpty , -} -/* No side effect */ diff --git a/lib/es6/belt_internalMapInt.js b/lib/es6/belt_internalMapInt.js deleted file mode 100644 index e8eb3b07d49..00000000000 --- a/lib/es6/belt_internalMapInt.js +++ /dev/null @@ -1,365 +0,0 @@ - - -import * as Caml from "./caml.js"; -import * as Curry from "./curry.js"; -import * as Caml_option from "./caml_option.js"; -import * as Belt_SortArray from "./belt_SortArray.js"; -import * as Belt_internalAVLtree from "./belt_internalAVLtree.js"; - -function add(t, x, data) { - if (t === undefined) { - return Belt_internalAVLtree.singleton(x, data); - } - var k = t.k; - if (x === k) { - return Belt_internalAVLtree.updateValue(t, data); - } - var v = t.v; - if (x < k) { - return Belt_internalAVLtree.bal(add(t.l, x, data), k, v, t.r); - } else { - return Belt_internalAVLtree.bal(t.l, k, v, add(t.r, x, data)); - } -} - -function get(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.k; - if (x === v) { - return Caml_option.some(n.v); - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function getUndefined(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.k; - if (x === v) { - return n.v; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function getExn(_n, x) { - while(true) { - var n = _n; - if (n !== undefined) { - var v = n.k; - if (x === v) { - return n.v; - } - _n = x < v ? n.l : n.r; - continue ; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function getWithDefault(_n, x, def) { - while(true) { - var n = _n; - if (n === undefined) { - return def; - } - var v = n.k; - if (x === v) { - return n.v; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function has(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return false; - } - var v = n.k; - if (x === v) { - return true; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function remove(n, x) { - if (n === undefined) { - return n; - } - var v = n.k; - var l = n.l; - var r = n.r; - if (x !== v) { - if (x < v) { - return Belt_internalAVLtree.bal(remove(l, x), v, n.v, r); - } else { - return Belt_internalAVLtree.bal(l, v, n.v, remove(r, x)); - } - } - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var kr = { - contents: r.k - }; - var vr = { - contents: r.v - }; - var r$1 = Belt_internalAVLtree.removeMinAuxWithRef(r, kr, vr); - return Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); -} - -function splitAux(x, n) { - var v = n.k; - var d = n.v; - var l = n.l; - var r = n.r; - if (x === v) { - return [ - l, - Caml_option.some(d), - r - ]; - } - if (x < v) { - if (l === undefined) { - return [ - undefined, - undefined, - n - ]; - } - var match = splitAux(x, l); - return [ - match[0], - match[1], - Belt_internalAVLtree.join(match[2], v, d, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined, - undefined - ]; - } - var match$1 = splitAux(x, r); - return [ - Belt_internalAVLtree.join(l, v, d, match$1[0]), - match$1[1], - match$1[2] - ]; -} - -function split(x, n) { - if (n !== undefined) { - return splitAux(x, n); - } else { - return [ - undefined, - undefined, - undefined - ]; - } -} - -function mergeU(s1, s2, f) { - if (s1 !== undefined) { - if (s1.h >= ( - s2 !== undefined ? s2.h : 0 - )) { - var v1 = s1.k; - var d1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var match = split(v1, s2); - return Belt_internalAVLtree.concatOrJoin(mergeU(l1, match[0], f), v1, f(v1, Caml_option.some(d1), match[1]), mergeU(r1, match[2], f)); - } - - } else if (s2 === undefined) { - return ; - } - var v2 = s2.k; - var d2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - var 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) { - return mergeU(s1, s2, Curry.__3(f)); -} - -function compareAux(_e1, _e2, vcmp) { - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return 0; - } - if (!e2) { - return 0; - } - var h2 = e2.hd; - var h1 = e1.hd; - var c = Caml.int_compare(h1.k, h2.k); - if (c !== 0) { - return c; - } - var cx = vcmp(h1.v, h2.v); - if (cx !== 0) { - return cx; - } - _e2 = Belt_internalAVLtree.stackAllLeft(h2.r, e2.tl); - _e1 = Belt_internalAVLtree.stackAllLeft(h1.r, e1.tl); - continue ; - }; -} - -function cmpU(s1, s2, cmp) { - var len1 = Belt_internalAVLtree.size(s1); - var len2 = Belt_internalAVLtree.size(s2); - if (len1 === len2) { - return compareAux(Belt_internalAVLtree.stackAllLeft(s1, /* [] */0), Belt_internalAVLtree.stackAllLeft(s2, /* [] */0), cmp); - } else if (len1 < len2) { - return -1; - } else { - return 1; - } -} - -function cmp(s1, s2, f) { - return cmpU(s1, s2, Curry.__2(f)); -} - -function eqAux(_e1, _e2, eq) { - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return true; - } - if (!e2) { - return true; - } - var h2 = e2.hd; - var h1 = e1.hd; - if (!(h1.k === h2.k && eq(h1.v, h2.v))) { - return false; - } - _e2 = Belt_internalAVLtree.stackAllLeft(h2.r, e2.tl); - _e1 = Belt_internalAVLtree.stackAllLeft(h1.r, e1.tl); - continue ; - }; -} - -function eqU(s1, s2, eq) { - var len1 = Belt_internalAVLtree.size(s1); - var len2 = Belt_internalAVLtree.size(s2); - if (len1 === len2) { - return eqAux(Belt_internalAVLtree.stackAllLeft(s1, /* [] */0), Belt_internalAVLtree.stackAllLeft(s2, /* [] */0), eq); - } else { - return false; - } -} - -function eq(s1, s2, f) { - return eqU(s1, s2, Curry.__2(f)); -} - -function addMutate(t, x, data) { - if (t === undefined) { - return Belt_internalAVLtree.singleton(x, data); - } - var k = t.k; - if (x === k) { - t.k = x; - t.v = data; - return t; - } - var l = t.l; - var r = t.r; - if (x < k) { - var ll = addMutate(l, x, data); - t.l = ll; - } else { - t.r = addMutate(r, x, data); - } - return Belt_internalAVLtree.balMutate(t); -} - -function fromArray(xs) { - var len = xs.length; - if (len === 0) { - return ; - } - var next = Belt_SortArray.strictlySortedLengthU(xs, (function (param, param$1) { - return param[0] < param$1[0]; - })); - var result; - if (next >= 0) { - result = Belt_internalAVLtree.fromSortedArrayAux(xs, 0, next); - } else { - next = -next | 0; - result = Belt_internalAVLtree.fromSortedArrayRevAux(xs, next - 1 | 0, next); - } - for(var i = next; i < len; ++i){ - var match = xs[i]; - result = addMutate(result, match[0], match[1]); - } - return result; -} - -var N; - -var A; - -var S; - -export { - N , - A , - S , - add , - get , - getUndefined , - getExn , - getWithDefault , - has , - remove , - splitAux , - split , - mergeU , - merge , - compareAux , - cmpU , - cmp , - eqAux , - eqU , - eq , - addMutate , - fromArray , -} -/* No side effect */ diff --git a/lib/es6/belt_internalMapString.js b/lib/es6/belt_internalMapString.js deleted file mode 100644 index 8c0a4c3703c..00000000000 --- a/lib/es6/belt_internalMapString.js +++ /dev/null @@ -1,365 +0,0 @@ - - -import * as Caml from "./caml.js"; -import * as Curry from "./curry.js"; -import * as Caml_option from "./caml_option.js"; -import * as Belt_SortArray from "./belt_SortArray.js"; -import * as Belt_internalAVLtree from "./belt_internalAVLtree.js"; - -function add(t, x, data) { - if (t === undefined) { - return Belt_internalAVLtree.singleton(x, data); - } - var k = t.k; - if (x === k) { - return Belt_internalAVLtree.updateValue(t, data); - } - var v = t.v; - if (x < k) { - return Belt_internalAVLtree.bal(add(t.l, x, data), k, v, t.r); - } else { - return Belt_internalAVLtree.bal(t.l, k, v, add(t.r, x, data)); - } -} - -function get(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.k; - if (x === v) { - return Caml_option.some(n.v); - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function getUndefined(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.k; - if (x === v) { - return n.v; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function getExn(_n, x) { - while(true) { - var n = _n; - if (n !== undefined) { - var v = n.k; - if (x === v) { - return n.v; - } - _n = x < v ? n.l : n.r; - continue ; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function getWithDefault(_n, x, def) { - while(true) { - var n = _n; - if (n === undefined) { - return def; - } - var v = n.k; - if (x === v) { - return n.v; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function has(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return false; - } - var v = n.k; - if (x === v) { - return true; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function remove(n, x) { - if (n === undefined) { - return n; - } - var v = n.k; - var l = n.l; - var r = n.r; - if (x !== v) { - if (x < v) { - return Belt_internalAVLtree.bal(remove(l, x), v, n.v, r); - } else { - return Belt_internalAVLtree.bal(l, v, n.v, remove(r, x)); - } - } - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var kr = { - contents: r.k - }; - var vr = { - contents: r.v - }; - var r$1 = Belt_internalAVLtree.removeMinAuxWithRef(r, kr, vr); - return Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); -} - -function splitAux(x, n) { - var v = n.k; - var d = n.v; - var l = n.l; - var r = n.r; - if (x === v) { - return [ - l, - Caml_option.some(d), - r - ]; - } - if (x < v) { - if (l === undefined) { - return [ - undefined, - undefined, - n - ]; - } - var match = splitAux(x, l); - return [ - match[0], - match[1], - Belt_internalAVLtree.join(match[2], v, d, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined, - undefined - ]; - } - var match$1 = splitAux(x, r); - return [ - Belt_internalAVLtree.join(l, v, d, match$1[0]), - match$1[1], - match$1[2] - ]; -} - -function split(x, n) { - if (n !== undefined) { - return splitAux(x, n); - } else { - return [ - undefined, - undefined, - undefined - ]; - } -} - -function mergeU(s1, s2, f) { - if (s1 !== undefined) { - if (s1.h >= ( - s2 !== undefined ? s2.h : 0 - )) { - var v1 = s1.k; - var d1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var match = split(v1, s2); - return Belt_internalAVLtree.concatOrJoin(mergeU(l1, match[0], f), v1, f(v1, Caml_option.some(d1), match[1]), mergeU(r1, match[2], f)); - } - - } else if (s2 === undefined) { - return ; - } - var v2 = s2.k; - var d2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - var 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) { - return mergeU(s1, s2, Curry.__3(f)); -} - -function compareAux(_e1, _e2, vcmp) { - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return 0; - } - if (!e2) { - return 0; - } - var h2 = e2.hd; - var h1 = e1.hd; - var c = Caml.string_compare(h1.k, h2.k); - if (c !== 0) { - return c; - } - var cx = vcmp(h1.v, h2.v); - if (cx !== 0) { - return cx; - } - _e2 = Belt_internalAVLtree.stackAllLeft(h2.r, e2.tl); - _e1 = Belt_internalAVLtree.stackAllLeft(h1.r, e1.tl); - continue ; - }; -} - -function cmpU(s1, s2, cmp) { - var len1 = Belt_internalAVLtree.size(s1); - var len2 = Belt_internalAVLtree.size(s2); - if (len1 === len2) { - return compareAux(Belt_internalAVLtree.stackAllLeft(s1, /* [] */0), Belt_internalAVLtree.stackAllLeft(s2, /* [] */0), cmp); - } else if (len1 < len2) { - return -1; - } else { - return 1; - } -} - -function cmp(s1, s2, f) { - return cmpU(s1, s2, Curry.__2(f)); -} - -function eqAux(_e1, _e2, eq) { - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return true; - } - if (!e2) { - return true; - } - var h2 = e2.hd; - var h1 = e1.hd; - if (!(h1.k === h2.k && eq(h1.v, h2.v))) { - return false; - } - _e2 = Belt_internalAVLtree.stackAllLeft(h2.r, e2.tl); - _e1 = Belt_internalAVLtree.stackAllLeft(h1.r, e1.tl); - continue ; - }; -} - -function eqU(s1, s2, eq) { - var len1 = Belt_internalAVLtree.size(s1); - var len2 = Belt_internalAVLtree.size(s2); - if (len1 === len2) { - return eqAux(Belt_internalAVLtree.stackAllLeft(s1, /* [] */0), Belt_internalAVLtree.stackAllLeft(s2, /* [] */0), eq); - } else { - return false; - } -} - -function eq(s1, s2, f) { - return eqU(s1, s2, Curry.__2(f)); -} - -function addMutate(t, x, data) { - if (t === undefined) { - return Belt_internalAVLtree.singleton(x, data); - } - var k = t.k; - if (x === k) { - t.k = x; - t.v = data; - return t; - } - var l = t.l; - var r = t.r; - if (x < k) { - var ll = addMutate(l, x, data); - t.l = ll; - } else { - t.r = addMutate(r, x, data); - } - return Belt_internalAVLtree.balMutate(t); -} - -function fromArray(xs) { - var len = xs.length; - if (len === 0) { - return ; - } - var next = Belt_SortArray.strictlySortedLengthU(xs, (function (param, param$1) { - return param[0] < param$1[0]; - })); - var result; - if (next >= 0) { - result = Belt_internalAVLtree.fromSortedArrayAux(xs, 0, next); - } else { - next = -next | 0; - result = Belt_internalAVLtree.fromSortedArrayRevAux(xs, next - 1 | 0, next); - } - for(var i = next; i < len; ++i){ - var match = xs[i]; - result = addMutate(result, match[0], match[1]); - } - return result; -} - -var N; - -var A; - -var S; - -export { - N , - A , - S , - add , - get , - getUndefined , - getExn , - getWithDefault , - has , - remove , - splitAux , - split , - mergeU , - merge , - compareAux , - cmpU , - cmp , - eqAux , - eqU , - eq , - addMutate , - fromArray , -} -/* No side effect */ diff --git a/lib/es6/belt_internalSetBuckets.js b/lib/es6/belt_internalSetBuckets.js deleted file mode 100644 index ae76208ed62..00000000000 --- a/lib/es6/belt_internalSetBuckets.js +++ /dev/null @@ -1,191 +0,0 @@ - - -import * as Curry from "./curry.js"; -import * as Belt_Array from "./belt_Array.js"; - -function copyAuxCont(_c, _prec) { - while(true) { - var prec = _prec; - var c = _c; - if (c === undefined) { - return ; - } - var ncopy = { - key: c.key, - next: undefined - }; - prec.next = ncopy; - _prec = ncopy; - _c = c.next; - continue ; - }; -} - -function copyBucket(c) { - if (c === undefined) { - return c; - } - var head = { - key: c.key, - next: undefined - }; - copyAuxCont(c.next, head); - return head; -} - -function copyBuckets(buckets) { - var len = buckets.length; - var newBuckets = new Array(len); - for(var i = 0; i < len; ++i){ - newBuckets[i] = copyBucket(buckets[i]); - } - return newBuckets; -} - -function copy(x) { - return { - size: x.size, - buckets: copyBuckets(x.buckets), - hash: x.hash, - eq: x.eq - }; -} - -function bucketLength(_accu, _buckets) { - while(true) { - var buckets = _buckets; - var accu = _accu; - if (buckets === undefined) { - return accu; - } - _buckets = buckets.next; - _accu = accu + 1 | 0; - continue ; - }; -} - -function doBucketIter(f, _buckets) { - while(true) { - var buckets = _buckets; - if (buckets === undefined) { - return ; - } - f(buckets.key); - _buckets = buckets.next; - continue ; - }; -} - -function forEachU(h, f) { - var d = h.buckets; - for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ - doBucketIter(f, d[i]); - } -} - -function forEach(h, f) { - forEachU(h, Curry.__1(f)); -} - -function fillArray(_i, arr, _cell) { - while(true) { - var cell = _cell; - var i = _i; - arr[i] = cell.key; - var v = cell.next; - if (v === undefined) { - return i + 1 | 0; - } - _cell = v; - _i = i + 1 | 0; - continue ; - }; -} - -function toArray(h) { - var d = h.buckets; - var current = 0; - var arr = new Array(h.size); - for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ - var cell = d[i]; - if (cell !== undefined) { - current = fillArray(current, arr, cell); - } - - } - return arr; -} - -function doBucketFold(f, _b, _accu) { - while(true) { - var accu = _accu; - var b = _b; - if (b === undefined) { - return accu; - } - _accu = f(accu, b.key); - _b = b.next; - continue ; - }; -} - -function reduceU(h, init, f) { - var d = h.buckets; - var accu = init; - for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ - accu = doBucketFold(f, d[i], accu); - } - return accu; -} - -function reduce(h, init, f) { - return reduceU(h, init, Curry.__2(f)); -} - -function getMaxBucketLength(h) { - return Belt_Array.reduceU(h.buckets, 0, (function (m, b) { - var len = bucketLength(0, b); - if (m > len) { - return m; - } else { - return len; - } - })); -} - -function getBucketHistogram(h) { - var mbl = getMaxBucketLength(h); - var histo = Belt_Array.makeByU(mbl + 1 | 0, (function (param) { - return 0; - })); - Belt_Array.forEachU(h.buckets, (function (b) { - var l = bucketLength(0, b); - histo[l] = histo[l] + 1 | 0; - })); - return histo; -} - -function logStats(h) { - var histogram = getBucketHistogram(h); - console.log({ - bindings: h.size, - buckets: h.buckets.length, - histogram: histogram - }); -} - -var C; - -export { - C , - copy , - forEachU , - forEach , - fillArray , - toArray , - reduceU , - reduce , - logStats , - getBucketHistogram , -} -/* No side effect */ diff --git a/lib/es6/belt_internalSetInt.js b/lib/es6/belt_internalSetInt.js deleted file mode 100644 index 6a271f00212..00000000000 --- a/lib/es6/belt_internalSetInt.js +++ /dev/null @@ -1,209 +0,0 @@ - - -import * as Belt_SortArrayInt from "./belt_SortArrayInt.js"; -import * as Belt_internalAVLset from "./belt_internalAVLset.js"; - -function has(_t, x) { - while(true) { - var t = _t; - if (t === undefined) { - return false; - } - var v = t.v; - if (x === v) { - return true; - } - _t = x < v ? t.l : t.r; - continue ; - }; -} - -function compareAux(_e1, _e2) { - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return 0; - } - if (!e2) { - return 0; - } - var h2 = e2.hd; - var h1 = e1.hd; - var k1 = h1.v; - var k2 = h2.v; - if (k1 !== k2) { - if (k1 < k2) { - return -1; - } else { - return 1; - } - } - _e2 = Belt_internalAVLset.stackAllLeft(h2.r, e2.tl); - _e1 = Belt_internalAVLset.stackAllLeft(h1.r, e1.tl); - continue ; - }; -} - -function cmp(s1, s2) { - var len1 = Belt_internalAVLset.size(s1); - var len2 = Belt_internalAVLset.size(s2); - if (len1 === len2) { - return compareAux(Belt_internalAVLset.stackAllLeft(s1, /* [] */0), Belt_internalAVLset.stackAllLeft(s2, /* [] */0)); - } else if (len1 < len2) { - return -1; - } else { - return 1; - } -} - -function eq(s1, s2) { - return cmp(s1, s2) === 0; -} - -function subset(_s1, _s2) { - while(true) { - var s2 = _s2; - var s1 = _s1; - if (s1 === undefined) { - return true; - } - if (s2 === undefined) { - return false; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var v2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - if (v1 === v2) { - if (!subset(l1, l2)) { - return false; - } - _s2 = r2; - _s1 = r1; - continue ; - } - if (v1 < v2) { - if (!subset(Belt_internalAVLset.create(l1, v1, undefined), l2)) { - return false; - } - _s1 = r1; - continue ; - } - if (!subset(Belt_internalAVLset.create(undefined, v1, r1), r2)) { - return false; - } - _s1 = l1; - continue ; - }; -} - -function get(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.v; - if (x === v) { - return v; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function getUndefined(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.v; - if (x === v) { - return v; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function getExn(_n, x) { - while(true) { - var n = _n; - if (n !== undefined) { - var v = n.v; - if (x === v) { - return v; - } - _n = x < v ? n.l : n.r; - continue ; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function addMutate(t, x) { - if (t === undefined) { - return Belt_internalAVLset.singleton(x); - } - var k = t.v; - if (x === k) { - return t; - } - var l = t.l; - var r = t.r; - if (x < k) { - t.l = addMutate(l, x); - } else { - t.r = addMutate(r, x); - } - return Belt_internalAVLset.balMutate(t); -} - -function fromArray(xs) { - var len = xs.length; - if (len === 0) { - return ; - } - var next = Belt_SortArrayInt.strictlySortedLength(xs); - var result; - if (next >= 0) { - result = Belt_internalAVLset.fromSortedArrayAux(xs, 0, next); - } else { - next = -next | 0; - result = Belt_internalAVLset.fromSortedArrayRevAux(xs, next - 1 | 0, next); - } - for(var i = next; i < len; ++i){ - result = addMutate(result, xs[i]); - } - return result; -} - -var S; - -var N; - -var A; - -export { - S , - N , - A , - has , - compareAux , - cmp , - eq , - subset , - get , - getUndefined , - getExn , - addMutate , - fromArray , -} -/* No side effect */ diff --git a/lib/es6/belt_internalSetString.js b/lib/es6/belt_internalSetString.js deleted file mode 100644 index bd5096a72d6..00000000000 --- a/lib/es6/belt_internalSetString.js +++ /dev/null @@ -1,209 +0,0 @@ - - -import * as Belt_internalAVLset from "./belt_internalAVLset.js"; -import * as Belt_SortArrayString from "./belt_SortArrayString.js"; - -function has(_t, x) { - while(true) { - var t = _t; - if (t === undefined) { - return false; - } - var v = t.v; - if (x === v) { - return true; - } - _t = x < v ? t.l : t.r; - continue ; - }; -} - -function compareAux(_e1, _e2) { - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return 0; - } - if (!e2) { - return 0; - } - var h2 = e2.hd; - var h1 = e1.hd; - var k1 = h1.v; - var k2 = h2.v; - if (k1 !== k2) { - if (k1 < k2) { - return -1; - } else { - return 1; - } - } - _e2 = Belt_internalAVLset.stackAllLeft(h2.r, e2.tl); - _e1 = Belt_internalAVLset.stackAllLeft(h1.r, e1.tl); - continue ; - }; -} - -function cmp(s1, s2) { - var len1 = Belt_internalAVLset.size(s1); - var len2 = Belt_internalAVLset.size(s2); - if (len1 === len2) { - return compareAux(Belt_internalAVLset.stackAllLeft(s1, /* [] */0), Belt_internalAVLset.stackAllLeft(s2, /* [] */0)); - } else if (len1 < len2) { - return -1; - } else { - return 1; - } -} - -function eq(s1, s2) { - return cmp(s1, s2) === 0; -} - -function subset(_s1, _s2) { - while(true) { - var s2 = _s2; - var s1 = _s1; - if (s1 === undefined) { - return true; - } - if (s2 === undefined) { - return false; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var v2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - if (v1 === v2) { - if (!subset(l1, l2)) { - return false; - } - _s2 = r2; - _s1 = r1; - continue ; - } - if (v1 < v2) { - if (!subset(Belt_internalAVLset.create(l1, v1, undefined), l2)) { - return false; - } - _s1 = r1; - continue ; - } - if (!subset(Belt_internalAVLset.create(undefined, v1, r1), r2)) { - return false; - } - _s1 = l1; - continue ; - }; -} - -function get(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.v; - if (x === v) { - return v; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function getUndefined(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.v; - if (x === v) { - return v; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function getExn(_n, x) { - while(true) { - var n = _n; - if (n !== undefined) { - var v = n.v; - if (x === v) { - return v; - } - _n = x < v ? n.l : n.r; - continue ; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function addMutate(t, x) { - if (t === undefined) { - return Belt_internalAVLset.singleton(x); - } - var k = t.v; - if (x === k) { - return t; - } - var l = t.l; - var r = t.r; - if (x < k) { - t.l = addMutate(l, x); - } else { - t.r = addMutate(r, x); - } - return Belt_internalAVLset.balMutate(t); -} - -function fromArray(xs) { - var len = xs.length; - if (len === 0) { - return ; - } - var next = Belt_SortArrayString.strictlySortedLength(xs); - var result; - if (next >= 0) { - result = Belt_internalAVLset.fromSortedArrayAux(xs, 0, next); - } else { - next = -next | 0; - result = Belt_internalAVLset.fromSortedArrayRevAux(xs, next - 1 | 0, next); - } - for(var i = next; i < len; ++i){ - result = addMutate(result, xs[i]); - } - return result; -} - -var S; - -var N; - -var A; - -export { - S , - N , - A , - has , - compareAux , - cmp , - eq , - subset , - get , - getUndefined , - getExn , - addMutate , - fromArray , -} -/* No side effect */ diff --git a/lib/js/belt.js b/lib/js/belt.js deleted file mode 100644 index fab992f7869..00000000000 --- a/lib/js/belt.js +++ /dev/null @@ -1,55 +0,0 @@ -'use strict'; - - -var Id; - -var $$Array; - -var SortArray; - -var MutableQueue; - -var MutableStack; - -var List; - -var $$Range; - -var $$Set; - -var $$Map; - -var MutableSet; - -var MutableMap; - -var HashSet; - -var HashMap; - -var $$Option; - -var Result; - -var Int; - -var Float; - -exports.Id = Id; -exports.$$Array = $$Array; -exports.SortArray = SortArray; -exports.MutableQueue = MutableQueue; -exports.MutableStack = MutableStack; -exports.List = List; -exports.$$Range = $$Range; -exports.$$Set = $$Set; -exports.$$Map = $$Map; -exports.MutableSet = MutableSet; -exports.MutableMap = MutableMap; -exports.HashSet = HashSet; -exports.HashMap = HashMap; -exports.$$Option = $$Option; -exports.Result = Result; -exports.Int = Int; -exports.Float = Float; -/* No side effect */ diff --git a/lib/js/belt_Array.js b/lib/js/belt_Array.js deleted file mode 100644 index c0cf35d5a3a..00000000000 --- a/lib/js/belt_Array.js +++ /dev/null @@ -1,762 +0,0 @@ -'use strict'; - -var Caml = require("./caml.js"); -var Curry = require("./curry.js"); -var Js_math = require("./js_math.js"); -var Caml_option = require("./caml_option.js"); - -function get(arr, i) { - if (i >= 0 && i < arr.length) { - return Caml_option.some(arr[i]); - } - -} - -function getExn(arr, i) { - if (!(i >= 0 && i < arr.length)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_Array.res", - 36, - 2 - ], - Error: new Error() - }; - } - return arr[i]; -} - -function set(arr, i, v) { - if (i >= 0 && i < arr.length) { - arr[i] = v; - return true; - } else { - return false; - } -} - -function setExn(arr, i, v) { - if (!(i >= 0 && i < arr.length)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_Array.res", - 49, - 2 - ], - Error: new Error() - }; - } - arr[i] = v; -} - -function swapUnsafe(xs, i, j) { - var tmp = xs[i]; - xs[i] = xs[j]; - xs[j] = tmp; -} - -function shuffleInPlace(xs) { - var len = xs.length; - for(var i = 0; i < len; ++i){ - swapUnsafe(xs, i, Js_math.random_int(i, len)); - } -} - -function shuffle(xs) { - var result = xs.slice(0); - shuffleInPlace(result); - return result; -} - -function reverseInPlace(xs) { - var len = xs.length; - var ofs = 0; - for(var i = 0 ,i_finish = len / 2 | 0; i < i_finish; ++i){ - swapUnsafe(xs, ofs + i | 0, ((ofs + len | 0) - i | 0) - 1 | 0); - } -} - -function reverse(xs) { - var len = xs.length; - var result = new Array(len); - for(var i = 0; i < len; ++i){ - result[i] = xs[(len - 1 | 0) - i | 0]; - } - return result; -} - -function make(l, f) { - if (l <= 0) { - return []; - } - var res = new Array(l); - for(var i = 0; i < l; ++i){ - res[i] = f; - } - return res; -} - -function makeByU(l, f) { - if (l <= 0) { - return []; - } - var res = new Array(l); - for(var i = 0; i < l; ++i){ - res[i] = f(i); - } - return res; -} - -function makeBy(l, f) { - return makeByU(l, Curry.__1(f)); -} - -function makeByAndShuffleU(l, f) { - var u = makeByU(l, f); - shuffleInPlace(u); - return u; -} - -function makeByAndShuffle(l, f) { - return makeByAndShuffleU(l, Curry.__1(f)); -} - -function range(start, finish) { - var cut = finish - start | 0; - if (cut < 0) { - return []; - } - var arr = new Array(cut + 1 | 0); - for(var i = 0; i <= cut; ++i){ - arr[i] = start + i | 0; - } - return arr; -} - -function rangeBy(start, finish, step) { - var cut = finish - start | 0; - if (cut < 0 || step <= 0) { - return []; - } - var nb = (cut / step | 0) + 1 | 0; - var arr = new Array(nb); - var cur = start; - for(var i = 0; i < nb; ++i){ - arr[i] = cur; - cur = cur + step | 0; - } - return arr; -} - -function zip(xs, ys) { - var lenx = xs.length; - var leny = ys.length; - var len = lenx < leny ? lenx : leny; - var s = new Array(len); - for(var i = 0; i < len; ++i){ - s[i] = [ - xs[i], - ys[i] - ]; - } - return s; -} - -function zipByU(xs, ys, f) { - var lenx = xs.length; - var leny = ys.length; - var len = lenx < leny ? lenx : leny; - var s = new Array(len); - for(var i = 0; i < len; ++i){ - s[i] = f(xs[i], ys[i]); - } - return s; -} - -function zipBy(xs, ys, f) { - return zipByU(xs, ys, Curry.__2(f)); -} - -function concat(a1, a2) { - var l1 = a1.length; - var l2 = a2.length; - var a1a2 = new Array(l1 + l2 | 0); - for(var i = 0; i < l1; ++i){ - a1a2[i] = a1[i]; - } - for(var i$1 = 0; i$1 < l2; ++i$1){ - a1a2[l1 + i$1 | 0] = a2[i$1]; - } - return a1a2; -} - -function concatMany(arrs) { - var lenArrs = arrs.length; - var totalLen = 0; - for(var i = 0; i < lenArrs; ++i){ - totalLen = totalLen + arrs[i].length | 0; - } - var result = new Array(totalLen); - totalLen = 0; - for(var j = 0; j < lenArrs; ++j){ - var cur = arrs[j]; - for(var k = 0 ,k_finish = cur.length; k < k_finish; ++k){ - result[totalLen] = cur[k]; - totalLen = totalLen + 1 | 0; - } - } - return result; -} - -function slice(a, offset, len) { - if (len <= 0) { - return []; - } - var lena = a.length; - var ofs = offset < 0 ? Caml.int_max(lena + offset | 0, 0) : offset; - var hasLen = lena - ofs | 0; - var copyLength = hasLen < len ? hasLen : len; - if (copyLength <= 0) { - return []; - } - var result = new Array(copyLength); - for(var i = 0; i < copyLength; ++i){ - result[i] = a[ofs + i | 0]; - } - return result; -} - -function sliceToEnd(a, offset) { - var lena = a.length; - var ofs = offset < 0 ? Caml.int_max(lena + offset | 0, 0) : offset; - var len = lena > ofs ? lena - ofs | 0 : 0; - var result = new Array(len); - for(var i = 0; i < len; ++i){ - result[i] = a[ofs + i | 0]; - } - return result; -} - -function fill(a, offset, len, v) { - if (len <= 0) { - return ; - } - var lena = a.length; - var ofs = offset < 0 ? Caml.int_max(lena + offset | 0, 0) : offset; - var hasLen = lena - ofs | 0; - var fillLength = hasLen < len ? hasLen : len; - if (fillLength <= 0) { - return ; - } - for(var i = ofs ,i_finish = ofs + fillLength | 0; i < i_finish; ++i){ - a[i] = v; - } -} - -function blitUnsafe(a1, srcofs1, a2, srcofs2, blitLength) { - if (srcofs2 <= srcofs1) { - for(var j = 0; j < blitLength; ++j){ - a2[j + srcofs2 | 0] = a1[j + srcofs1 | 0]; - } - return ; - } - for(var j$1 = blitLength - 1 | 0; j$1 >= 0; --j$1){ - a2[j$1 + srcofs2 | 0] = a1[j$1 + srcofs1 | 0]; - } -} - -function blit(a1, ofs1, a2, ofs2, len) { - var lena1 = a1.length; - var lena2 = a2.length; - var srcofs1 = ofs1 < 0 ? Caml.int_max(lena1 + ofs1 | 0, 0) : ofs1; - var srcofs2 = ofs2 < 0 ? Caml.int_max(lena2 + ofs2 | 0, 0) : ofs2; - var blitLength = Caml.int_min(len, Caml.int_min(lena1 - srcofs1 | 0, lena2 - srcofs2 | 0)); - if (srcofs2 <= srcofs1) { - for(var j = 0; j < blitLength; ++j){ - a2[j + srcofs2 | 0] = a1[j + srcofs1 | 0]; - } - return ; - } - for(var j$1 = blitLength - 1 | 0; j$1 >= 0; --j$1){ - a2[j$1 + srcofs2 | 0] = a1[j$1 + srcofs1 | 0]; - } -} - -function forEachU(a, f) { - for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(a[i]); - } -} - -function forEach(a, f) { - forEachU(a, Curry.__1(f)); -} - -function mapU(a, f) { - var l = a.length; - var r = new Array(l); - for(var i = 0; i < l; ++i){ - r[i] = f(a[i]); - } - return r; -} - -function map(a, f) { - return mapU(a, Curry.__1(f)); -} - -function flatMapU(a, f) { - return concatMany(mapU(a, f)); -} - -function flatMap(a, f) { - return concatMany(mapU(a, Curry.__1(f))); -} - -function getByU(a, p) { - var l = a.length; - var i = 0; - var r; - while(r === undefined && i < l) { - var v = a[i]; - if (p(v)) { - r = Caml_option.some(v); - } - i = i + 1 | 0; - }; - return r; -} - -function getBy(a, p) { - return getByU(a, Curry.__1(p)); -} - -function getIndexByU(a, p) { - var l = a.length; - var i = 0; - var r; - while(r === undefined && i < l) { - var v = a[i]; - if (p(v)) { - r = i; - } - i = i + 1 | 0; - }; - return r; -} - -function getIndexBy(a, p) { - return getIndexByU(a, Curry.__1(p)); -} - -function keepU(a, f) { - var l = a.length; - var r = new Array(l); - var j = 0; - for(var i = 0; i < l; ++i){ - var v = a[i]; - if (f(v)) { - r[j] = v; - j = j + 1 | 0; - } - - } - r.length = j; - return r; -} - -function keep(a, f) { - return keepU(a, Curry.__1(f)); -} - -function keepWithIndexU(a, f) { - var l = a.length; - var r = new Array(l); - var j = 0; - for(var i = 0; i < l; ++i){ - var v = a[i]; - if (f(v, i)) { - r[j] = v; - j = j + 1 | 0; - } - - } - r.length = j; - return r; -} - -function keepWithIndex(a, f) { - return keepWithIndexU(a, Curry.__2(f)); -} - -function keepMapU(a, f) { - var l = a.length; - var r = new Array(l); - var j = 0; - for(var i = 0; i < l; ++i){ - var v = a[i]; - var v$1 = f(v); - if (v$1 !== undefined) { - r[j] = Caml_option.valFromOption(v$1); - j = j + 1 | 0; - } - - } - r.length = j; - return r; -} - -function keepMap(a, f) { - return keepMapU(a, Curry.__1(f)); -} - -function forEachWithIndexU(a, f) { - for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ - f(i, a[i]); - } -} - -function forEachWithIndex(a, f) { - forEachWithIndexU(a, Curry.__2(f)); -} - -function mapWithIndexU(a, f) { - var l = a.length; - var r = new Array(l); - for(var i = 0; i < l; ++i){ - r[i] = f(i, a[i]); - } - return r; -} - -function mapWithIndex(a, f) { - return mapWithIndexU(a, Curry.__2(f)); -} - -function reduceU(a, x, f) { - var r = x; - for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ - r = f(r, a[i]); - } - return r; -} - -function reduce(a, x, f) { - return reduceU(a, x, Curry.__2(f)); -} - -function reduceReverseU(a, x, f) { - var r = x; - for(var i = a.length - 1 | 0; i >= 0; --i){ - r = f(r, a[i]); - } - return r; -} - -function reduceReverse(a, x, f) { - return reduceReverseU(a, x, Curry.__2(f)); -} - -function reduceReverse2U(a, b, x, f) { - var r = x; - var len = Caml.int_min(a.length, b.length); - for(var i = len - 1 | 0; i >= 0; --i){ - r = f(r, a[i], b[i]); - } - return r; -} - -function reduceReverse2(a, b, x, f) { - return reduceReverse2U(a, b, x, Curry.__3(f)); -} - -function reduceWithIndexU(a, x, f) { - var r = x; - for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ - r = f(r, a[i], i); - } - return r; -} - -function reduceWithIndex(a, x, f) { - return reduceWithIndexU(a, x, Curry.__3(f)); -} - -function everyU(arr, b) { - var len = arr.length; - var _i = 0; - while(true) { - var i = _i; - if (i === len) { - return true; - } - if (!b(arr[i])) { - return false; - } - _i = i + 1 | 0; - continue ; - }; -} - -function every(arr, f) { - return everyU(arr, Curry.__1(f)); -} - -function someU(arr, b) { - var len = arr.length; - var _i = 0; - while(true) { - var i = _i; - if (i === len) { - return false; - } - if (b(arr[i])) { - return true; - } - _i = i + 1 | 0; - continue ; - }; -} - -function some(arr, f) { - return someU(arr, Curry.__1(f)); -} - -function everyAux2(arr1, arr2, _i, b, len) { - while(true) { - var i = _i; - if (i === len) { - return true; - } - if (!b(arr1[i], arr2[i])) { - return false; - } - _i = i + 1 | 0; - continue ; - }; -} - -function every2U(a, b, p) { - return everyAux2(a, b, 0, p, Caml.int_min(a.length, b.length)); -} - -function every2(a, b, p) { - return every2U(a, b, Curry.__2(p)); -} - -function some2U(a, b, p) { - var _i = 0; - var len = Caml.int_min(a.length, b.length); - while(true) { - var i = _i; - if (i === len) { - return false; - } - if (p(a[i], b[i])) { - return true; - } - _i = i + 1 | 0; - continue ; - }; -} - -function some2(a, b, p) { - return some2U(a, b, Curry.__2(p)); -} - -function eqU(a, b, p) { - var lena = a.length; - var lenb = b.length; - if (lena === lenb) { - return everyAux2(a, b, 0, p, lena); - } else { - return false; - } -} - -function eq(a, b, p) { - return eqU(a, b, Curry.__2(p)); -} - -function cmpU(a, b, p) { - var lena = a.length; - var lenb = b.length; - if (lena > lenb) { - return 1; - } else if (lena < lenb) { - return -1; - } else { - var _i = 0; - while(true) { - var i = _i; - if (i === lena) { - return 0; - } - var c = p(a[i], b[i]); - if (c !== 0) { - return c; - } - _i = i + 1 | 0; - continue ; - }; - } -} - -function cmp(a, b, p) { - return cmpU(a, b, Curry.__2(p)); -} - -function partitionU(a, f) { - var l = a.length; - var i = 0; - var j = 0; - var a1 = new Array(l); - var a2 = new Array(l); - for(var ii = 0; ii < l; ++ii){ - var v = a[ii]; - if (f(v)) { - a1[i] = v; - i = i + 1 | 0; - } else { - a2[j] = v; - j = j + 1 | 0; - } - } - a1.length = i; - a2.length = j; - return [ - a1, - a2 - ]; -} - -function partition(a, f) { - return partitionU(a, Curry.__1(f)); -} - -function unzip(a) { - var l = a.length; - var a1 = new Array(l); - var a2 = new Array(l); - for(var i = 0; i < l; ++i){ - var match = a[i]; - a1[i] = match[0]; - a2[i] = match[1]; - } - return [ - a1, - a2 - ]; -} - -function joinWithU(a, sep, toString) { - var l = a.length; - if (l === 0) { - return ""; - } - var lastIndex = l - 1 | 0; - var _i = 0; - var _res = ""; - while(true) { - var res = _res; - var i = _i; - if (i === lastIndex) { - return res + toString(a[i]); - } - _res = res + (toString(a[i]) + sep); - _i = i + 1 | 0; - continue ; - }; -} - -function joinWith(a, sep, toString) { - return joinWithU(a, sep, Curry.__1(toString)); -} - -function initU(n, f) { - var v = new Array(n); - for(var i = 0; i < n; ++i){ - v[i] = f(i); - } - return v; -} - -function init(n, f) { - return initU(n, Curry.__1(f)); -} - -exports.get = get; -exports.getExn = getExn; -exports.set = set; -exports.setExn = setExn; -exports.shuffleInPlace = shuffleInPlace; -exports.shuffle = shuffle; -exports.reverseInPlace = reverseInPlace; -exports.reverse = reverse; -exports.make = make; -exports.range = range; -exports.rangeBy = rangeBy; -exports.makeByU = makeByU; -exports.makeBy = makeBy; -exports.makeByAndShuffleU = makeByAndShuffleU; -exports.makeByAndShuffle = makeByAndShuffle; -exports.zip = zip; -exports.zipByU = zipByU; -exports.zipBy = zipBy; -exports.unzip = unzip; -exports.concat = concat; -exports.concatMany = concatMany; -exports.slice = slice; -exports.sliceToEnd = sliceToEnd; -exports.fill = fill; -exports.blit = blit; -exports.blitUnsafe = blitUnsafe; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.mapU = mapU; -exports.map = map; -exports.flatMapU = flatMapU; -exports.flatMap = flatMap; -exports.getByU = getByU; -exports.getBy = getBy; -exports.getIndexByU = getIndexByU; -exports.getIndexBy = getIndexBy; -exports.keepU = keepU; -exports.keep = keep; -exports.keepWithIndexU = keepWithIndexU; -exports.keepWithIndex = keepWithIndex; -exports.keepMapU = keepMapU; -exports.keepMap = keepMap; -exports.forEachWithIndexU = forEachWithIndexU; -exports.forEachWithIndex = forEachWithIndex; -exports.mapWithIndexU = mapWithIndexU; -exports.mapWithIndex = mapWithIndex; -exports.partitionU = partitionU; -exports.partition = partition; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.reduceReverseU = reduceReverseU; -exports.reduceReverse = reduceReverse; -exports.reduceReverse2U = reduceReverse2U; -exports.reduceReverse2 = reduceReverse2; -exports.reduceWithIndexU = reduceWithIndexU; -exports.reduceWithIndex = reduceWithIndex; -exports.joinWithU = joinWithU; -exports.joinWith = joinWith; -exports.someU = someU; -exports.some = some; -exports.everyU = everyU; -exports.every = every; -exports.every2U = every2U; -exports.every2 = every2; -exports.some2U = some2U; -exports.some2 = some2; -exports.cmpU = cmpU; -exports.cmp = cmp; -exports.eqU = eqU; -exports.eq = eq; -exports.initU = initU; -exports.init = init; -/* No side effect */ diff --git a/lib/js/belt_Float.js b/lib/js/belt_Float.js deleted file mode 100644 index 82772975ff1..00000000000 --- a/lib/js/belt_Float.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - - -function fromString(i) { - var i$1 = parseFloat(i); - if (isNaN(i$1)) { - return ; - } else { - return i$1; - } -} - -exports.fromString = fromString; -/* No side effect */ diff --git a/lib/js/belt_HashMap.js b/lib/js/belt_HashMap.js deleted file mode 100644 index 29524fb71e6..00000000000 --- a/lib/js/belt_HashMap.js +++ /dev/null @@ -1,278 +0,0 @@ -'use strict'; - -var Caml_option = require("./caml_option.js"); -var Belt_internalBuckets = require("./belt_internalBuckets.js"); -var Belt_internalBucketsType = require("./belt_internalBucketsType.js"); - -function size(h) { - return h.size; -} - -function copyBucketReHash(hash, h_buckets, ndata_tail, _old_bucket) { - while(true) { - var old_bucket = _old_bucket; - if (old_bucket === undefined) { - return ; - } - var nidx = hash(old_bucket.key) & (h_buckets.length - 1 | 0); - var tail = ndata_tail[nidx]; - if (tail !== undefined) { - tail.next = old_bucket; - } else { - h_buckets[nidx] = old_bucket; - } - ndata_tail[nidx] = old_bucket; - _old_bucket = old_bucket.next; - continue ; - }; -} - -function replaceInBucket(eq, key, info, _cell) { - while(true) { - var cell = _cell; - if (eq(cell.key, key)) { - cell.value = info; - return false; - } - var cell$1 = cell.next; - if (cell$1 === undefined) { - return true; - } - _cell = cell$1; - continue ; - }; -} - -function set0(h, key, value, eq, hash) { - var h_buckets = h.buckets; - var buckets_len = h_buckets.length; - var i = hash(key) & (buckets_len - 1 | 0); - var l = h_buckets[i]; - if (l !== undefined) { - if (replaceInBucket(eq, key, value, l)) { - h_buckets[i] = { - key: key, - value: value, - next: l - }; - h.size = h.size + 1 | 0; - } - - } else { - h_buckets[i] = { - key: key, - value: value, - next: undefined - }; - h.size = h.size + 1 | 0; - } - if (h.size > (buckets_len << 1)) { - var odata = h.buckets; - var osize = odata.length; - var nsize = (osize << 1); - if (nsize < osize) { - return ; - } - var h_buckets$1 = new Array(nsize); - var ndata_tail = new Array(nsize); - h.buckets = h_buckets$1; - for(var i$1 = 0; i$1 < osize; ++i$1){ - copyBucketReHash(hash, h_buckets$1, ndata_tail, odata[i$1]); - } - for(var i$2 = 0; i$2 < nsize; ++i$2){ - var tail = ndata_tail[i$2]; - if (tail !== undefined) { - tail.next = undefined; - } - - } - return ; - } - -} - -function set(h, key, value) { - set0(h, key, value, h.eq, h.hash); -} - -function remove(h, key) { - var h_buckets = h.buckets; - var i = h.hash(key) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[i]; - if (bucket === undefined) { - return ; - } - var eq = h.eq; - if (eq(bucket.key, key)) { - h_buckets[i] = bucket.next; - h.size = h.size - 1 | 0; - return ; - } else { - var _prec = bucket; - var _bucket = bucket.next; - while(true) { - var bucket$1 = _bucket; - var prec = _prec; - if (bucket$1 === undefined) { - return ; - } - var cell_next = bucket$1.next; - if (eq(bucket$1.key, key)) { - prec.next = cell_next; - h.size = h.size - 1 | 0; - return ; - } - _bucket = cell_next; - _prec = bucket$1; - continue ; - }; - } -} - -function get(h, key) { - var h_buckets = h.buckets; - var nid = h.hash(key) & (h_buckets.length - 1 | 0); - var cell1 = h_buckets[nid]; - if (cell1 === undefined) { - return ; - } - var eq = h.eq; - if (eq(key, cell1.key)) { - return Caml_option.some(cell1.value); - } - var cell2 = cell1.next; - if (cell2 === undefined) { - return ; - } - if (eq(key, cell2.key)) { - return Caml_option.some(cell2.value); - } - var cell3 = cell2.next; - if (cell3 !== undefined) { - if (eq(key, cell3.key)) { - return Caml_option.some(cell3.value); - } else { - var _buckets = cell3.next; - while(true) { - var buckets = _buckets; - if (buckets === undefined) { - return ; - } - if (eq(key, buckets.key)) { - return Caml_option.some(buckets.value); - } - _buckets = buckets.next; - continue ; - }; - } - } - -} - -function has(h, key) { - var h_buckets = h.buckets; - var nid = h.hash(key) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[nid]; - if (bucket !== undefined) { - var _cell = bucket; - var eq = h.eq; - while(true) { - var cell = _cell; - if (eq(cell.key, key)) { - return true; - } - var nextCell = cell.next; - if (nextCell === undefined) { - return false; - } - _cell = nextCell; - continue ; - }; - } else { - return false; - } -} - -function make(hintSize, id) { - return Belt_internalBucketsType.make(id.hash, id.eq, hintSize); -} - -function fromArray(arr, id) { - var hash = id.hash; - var eq = id.eq; - var len = arr.length; - var v = Belt_internalBucketsType.make(hash, eq, len); - for(var i = 0; i < len; ++i){ - var match = arr[i]; - set0(v, match[0], match[1], eq, hash); - } - return v; -} - -function mergeMany(h, arr) { - var hash = h.hash; - var eq = h.eq; - var len = arr.length; - for(var i = 0; i < len; ++i){ - var match = arr[i]; - set0(h, match[0], match[1], eq, hash); - } -} - -var Int; - -var $$String; - -var clear = Belt_internalBucketsType.clear; - -var isEmpty = Belt_internalBucketsType.isEmpty; - -var copy = Belt_internalBuckets.copy; - -var forEachU = Belt_internalBuckets.forEachU; - -var forEach = Belt_internalBuckets.forEach; - -var reduceU = Belt_internalBuckets.reduceU; - -var reduce = Belt_internalBuckets.reduce; - -var keepMapInPlaceU = Belt_internalBuckets.keepMapInPlaceU; - -var keepMapInPlace = Belt_internalBuckets.keepMapInPlace; - -var toArray = Belt_internalBuckets.toArray; - -var keysToArray = Belt_internalBuckets.keysToArray; - -var valuesToArray = Belt_internalBuckets.valuesToArray; - -var getBucketHistogram = Belt_internalBuckets.getBucketHistogram; - -var logStats = Belt_internalBuckets.logStats; - -exports.Int = Int; -exports.$$String = $$String; -exports.make = make; -exports.clear = clear; -exports.isEmpty = isEmpty; -exports.set = set; -exports.copy = copy; -exports.get = get; -exports.has = has; -exports.remove = remove; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.keepMapInPlaceU = keepMapInPlaceU; -exports.keepMapInPlace = keepMapInPlace; -exports.size = size; -exports.toArray = toArray; -exports.keysToArray = keysToArray; -exports.valuesToArray = valuesToArray; -exports.fromArray = fromArray; -exports.mergeMany = mergeMany; -exports.getBucketHistogram = getBucketHistogram; -exports.logStats = logStats; -/* No side effect */ diff --git a/lib/js/belt_HashMapInt.js b/lib/js/belt_HashMapInt.js deleted file mode 100644 index eb1f958ff8b..00000000000 --- a/lib/js/belt_HashMapInt.js +++ /dev/null @@ -1,262 +0,0 @@ -'use strict'; - -var Caml_option = require("./caml_option.js"); -var Caml_hash_primitive = require("./caml_hash_primitive.js"); -var Belt_internalBuckets = require("./belt_internalBuckets.js"); -var Belt_internalBucketsType = require("./belt_internalBucketsType.js"); - -function copyBucketReHash(h_buckets, ndata_tail, _old_bucket) { - while(true) { - var old_bucket = _old_bucket; - if (old_bucket === undefined) { - return ; - } - var nidx = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, old_bucket.key)) & (h_buckets.length - 1 | 0); - var tail = ndata_tail[nidx]; - if (tail !== undefined) { - tail.next = old_bucket; - } else { - h_buckets[nidx] = old_bucket; - } - ndata_tail[nidx] = old_bucket; - _old_bucket = old_bucket.next; - continue ; - }; -} - -function replaceInBucket(key, info, _cell) { - while(true) { - var cell = _cell; - if (cell.key === key) { - cell.value = info; - return false; - } - var cell$1 = cell.next; - if (cell$1 === undefined) { - return true; - } - _cell = cell$1; - continue ; - }; -} - -function set(h, key, value) { - var h_buckets = h.buckets; - var buckets_len = h_buckets.length; - var i = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, key)) & (buckets_len - 1 | 0); - var l = h_buckets[i]; - if (l !== undefined) { - if (replaceInBucket(key, value, l)) { - h_buckets[i] = { - key: key, - value: value, - next: l - }; - h.size = h.size + 1 | 0; - } - - } else { - h_buckets[i] = { - key: key, - value: value, - next: undefined - }; - h.size = h.size + 1 | 0; - } - if (h.size > (buckets_len << 1)) { - var odata = h.buckets; - var osize = odata.length; - var nsize = (osize << 1); - if (nsize < osize) { - return ; - } - var h_buckets$1 = new Array(nsize); - var ndata_tail = new Array(nsize); - h.buckets = h_buckets$1; - for(var i$1 = 0; i$1 < osize; ++i$1){ - copyBucketReHash(h_buckets$1, ndata_tail, odata[i$1]); - } - for(var i$2 = 0; i$2 < nsize; ++i$2){ - var tail = ndata_tail[i$2]; - if (tail !== undefined) { - tail.next = undefined; - } - - } - return ; - } - -} - -function remove(h, key) { - var h_buckets = h.buckets; - var i = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[i]; - if (bucket !== undefined) { - if (bucket.key === key) { - h_buckets[i] = bucket.next; - h.size = h.size - 1 | 0; - return ; - } else { - var _prec = bucket; - var _buckets = bucket.next; - while(true) { - var buckets = _buckets; - var prec = _prec; - if (buckets === undefined) { - return ; - } - var cell_next = buckets.next; - if (buckets.key === key) { - prec.next = cell_next; - h.size = h.size - 1 | 0; - return ; - } - _buckets = cell_next; - _prec = buckets; - continue ; - }; - } - } - -} - -function get(h, key) { - var h_buckets = h.buckets; - var nid = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); - var cell1 = h_buckets[nid]; - if (cell1 === undefined) { - return ; - } - if (key === cell1.key) { - return Caml_option.some(cell1.value); - } - var cell2 = cell1.next; - if (cell2 === undefined) { - return ; - } - if (key === cell2.key) { - return Caml_option.some(cell2.value); - } - var cell3 = cell2.next; - if (cell3 !== undefined) { - if (key === cell3.key) { - return Caml_option.some(cell3.value); - } else { - var _buckets = cell3.next; - while(true) { - var buckets = _buckets; - if (buckets === undefined) { - return ; - } - if (key === buckets.key) { - return Caml_option.some(buckets.value); - } - _buckets = buckets.next; - continue ; - }; - } - } - -} - -function has(h, key) { - var h_buckets = h.buckets; - var nid = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[nid]; - if (bucket !== undefined) { - var _cell = bucket; - while(true) { - var cell = _cell; - if (cell.key === key) { - return true; - } - var nextCell = cell.next; - if (nextCell === undefined) { - return false; - } - _cell = nextCell; - continue ; - }; - } else { - return false; - } -} - -function make(hintSize) { - return Belt_internalBucketsType.make(undefined, undefined, hintSize); -} - -function size(h) { - return h.size; -} - -function fromArray(arr) { - var len = arr.length; - var v = Belt_internalBucketsType.make(undefined, undefined, len); - for(var i = 0; i < len; ++i){ - var match = arr[i]; - set(v, match[0], match[1]); - } - return v; -} - -function mergeMany(h, arr) { - var len = arr.length; - for(var i = 0; i < len; ++i){ - var match = arr[i]; - set(h, match[0], match[1]); - } -} - -var clear = Belt_internalBucketsType.clear; - -var isEmpty = Belt_internalBucketsType.isEmpty; - -var copy = Belt_internalBuckets.copy; - -var forEachU = Belt_internalBuckets.forEachU; - -var forEach = Belt_internalBuckets.forEach; - -var reduceU = Belt_internalBuckets.reduceU; - -var reduce = Belt_internalBuckets.reduce; - -var keepMapInPlaceU = Belt_internalBuckets.keepMapInPlaceU; - -var keepMapInPlace = Belt_internalBuckets.keepMapInPlace; - -var toArray = Belt_internalBuckets.toArray; - -var keysToArray = Belt_internalBuckets.keysToArray; - -var valuesToArray = Belt_internalBuckets.valuesToArray; - -var getBucketHistogram = Belt_internalBuckets.getBucketHistogram; - -var logStats = Belt_internalBuckets.logStats; - -exports.make = make; -exports.clear = clear; -exports.isEmpty = isEmpty; -exports.set = set; -exports.copy = copy; -exports.get = get; -exports.has = has; -exports.remove = remove; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.keepMapInPlaceU = keepMapInPlaceU; -exports.keepMapInPlace = keepMapInPlace; -exports.size = size; -exports.toArray = toArray; -exports.keysToArray = keysToArray; -exports.valuesToArray = valuesToArray; -exports.fromArray = fromArray; -exports.mergeMany = mergeMany; -exports.getBucketHistogram = getBucketHistogram; -exports.logStats = logStats; -/* No side effect */ diff --git a/lib/js/belt_HashMapString.js b/lib/js/belt_HashMapString.js deleted file mode 100644 index 3b89c0ef579..00000000000 --- a/lib/js/belt_HashMapString.js +++ /dev/null @@ -1,262 +0,0 @@ -'use strict'; - -var Caml_option = require("./caml_option.js"); -var Caml_hash_primitive = require("./caml_hash_primitive.js"); -var Belt_internalBuckets = require("./belt_internalBuckets.js"); -var Belt_internalBucketsType = require("./belt_internalBucketsType.js"); - -function copyBucketReHash(h_buckets, ndata_tail, _old_bucket) { - while(true) { - var old_bucket = _old_bucket; - if (old_bucket === undefined) { - return ; - } - var nidx = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, old_bucket.key)) & (h_buckets.length - 1 | 0); - var tail = ndata_tail[nidx]; - if (tail !== undefined) { - tail.next = old_bucket; - } else { - h_buckets[nidx] = old_bucket; - } - ndata_tail[nidx] = old_bucket; - _old_bucket = old_bucket.next; - continue ; - }; -} - -function replaceInBucket(key, info, _cell) { - while(true) { - var cell = _cell; - if (cell.key === key) { - cell.value = info; - return false; - } - var cell$1 = cell.next; - if (cell$1 === undefined) { - return true; - } - _cell = cell$1; - continue ; - }; -} - -function set(h, key, value) { - var h_buckets = h.buckets; - var buckets_len = h_buckets.length; - var i = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, key)) & (buckets_len - 1 | 0); - var l = h_buckets[i]; - if (l !== undefined) { - if (replaceInBucket(key, value, l)) { - h_buckets[i] = { - key: key, - value: value, - next: l - }; - h.size = h.size + 1 | 0; - } - - } else { - h_buckets[i] = { - key: key, - value: value, - next: undefined - }; - h.size = h.size + 1 | 0; - } - if (h.size > (buckets_len << 1)) { - var odata = h.buckets; - var osize = odata.length; - var nsize = (osize << 1); - if (nsize < osize) { - return ; - } - var h_buckets$1 = new Array(nsize); - var ndata_tail = new Array(nsize); - h.buckets = h_buckets$1; - for(var i$1 = 0; i$1 < osize; ++i$1){ - copyBucketReHash(h_buckets$1, ndata_tail, odata[i$1]); - } - for(var i$2 = 0; i$2 < nsize; ++i$2){ - var tail = ndata_tail[i$2]; - if (tail !== undefined) { - tail.next = undefined; - } - - } - return ; - } - -} - -function remove(h, key) { - var h_buckets = h.buckets; - var i = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[i]; - if (bucket !== undefined) { - if (bucket.key === key) { - h_buckets[i] = bucket.next; - h.size = h.size - 1 | 0; - return ; - } else { - var _prec = bucket; - var _buckets = bucket.next; - while(true) { - var buckets = _buckets; - var prec = _prec; - if (buckets === undefined) { - return ; - } - var cell_next = buckets.next; - if (buckets.key === key) { - prec.next = cell_next; - h.size = h.size - 1 | 0; - return ; - } - _buckets = cell_next; - _prec = buckets; - continue ; - }; - } - } - -} - -function get(h, key) { - var h_buckets = h.buckets; - var nid = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); - var cell1 = h_buckets[nid]; - if (cell1 === undefined) { - return ; - } - if (key === cell1.key) { - return Caml_option.some(cell1.value); - } - var cell2 = cell1.next; - if (cell2 === undefined) { - return ; - } - if (key === cell2.key) { - return Caml_option.some(cell2.value); - } - var cell3 = cell2.next; - if (cell3 !== undefined) { - if (key === cell3.key) { - return Caml_option.some(cell3.value); - } else { - var _buckets = cell3.next; - while(true) { - var buckets = _buckets; - if (buckets === undefined) { - return ; - } - if (key === buckets.key) { - return Caml_option.some(buckets.value); - } - _buckets = buckets.next; - continue ; - }; - } - } - -} - -function has(h, key) { - var h_buckets = h.buckets; - var nid = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[nid]; - if (bucket !== undefined) { - var _cell = bucket; - while(true) { - var cell = _cell; - if (cell.key === key) { - return true; - } - var nextCell = cell.next; - if (nextCell === undefined) { - return false; - } - _cell = nextCell; - continue ; - }; - } else { - return false; - } -} - -function make(hintSize) { - return Belt_internalBucketsType.make(undefined, undefined, hintSize); -} - -function size(h) { - return h.size; -} - -function fromArray(arr) { - var len = arr.length; - var v = Belt_internalBucketsType.make(undefined, undefined, len); - for(var i = 0; i < len; ++i){ - var match = arr[i]; - set(v, match[0], match[1]); - } - return v; -} - -function mergeMany(h, arr) { - var len = arr.length; - for(var i = 0; i < len; ++i){ - var match = arr[i]; - set(h, match[0], match[1]); - } -} - -var clear = Belt_internalBucketsType.clear; - -var isEmpty = Belt_internalBucketsType.isEmpty; - -var copy = Belt_internalBuckets.copy; - -var forEachU = Belt_internalBuckets.forEachU; - -var forEach = Belt_internalBuckets.forEach; - -var reduceU = Belt_internalBuckets.reduceU; - -var reduce = Belt_internalBuckets.reduce; - -var keepMapInPlaceU = Belt_internalBuckets.keepMapInPlaceU; - -var keepMapInPlace = Belt_internalBuckets.keepMapInPlace; - -var toArray = Belt_internalBuckets.toArray; - -var keysToArray = Belt_internalBuckets.keysToArray; - -var valuesToArray = Belt_internalBuckets.valuesToArray; - -var getBucketHistogram = Belt_internalBuckets.getBucketHistogram; - -var logStats = Belt_internalBuckets.logStats; - -exports.make = make; -exports.clear = clear; -exports.isEmpty = isEmpty; -exports.set = set; -exports.copy = copy; -exports.get = get; -exports.has = has; -exports.remove = remove; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.keepMapInPlaceU = keepMapInPlaceU; -exports.keepMapInPlace = keepMapInPlace; -exports.size = size; -exports.toArray = toArray; -exports.keysToArray = keysToArray; -exports.valuesToArray = valuesToArray; -exports.fromArray = fromArray; -exports.mergeMany = mergeMany; -exports.getBucketHistogram = getBucketHistogram; -exports.logStats = logStats; -/* No side effect */ diff --git a/lib/js/belt_HashSet.js b/lib/js/belt_HashSet.js deleted file mode 100644 index e654bee9d57..00000000000 --- a/lib/js/belt_HashSet.js +++ /dev/null @@ -1,220 +0,0 @@ -'use strict'; - -var Belt_internalSetBuckets = require("./belt_internalSetBuckets.js"); -var Belt_internalBucketsType = require("./belt_internalBucketsType.js"); - -function copyBucket(hash, h_buckets, ndata_tail, _old_bucket) { - while(true) { - var old_bucket = _old_bucket; - if (old_bucket === undefined) { - return ; - } - var nidx = hash(old_bucket.key) & (h_buckets.length - 1 | 0); - var tail = ndata_tail[nidx]; - if (tail !== undefined) { - tail.next = old_bucket; - } else { - h_buckets[nidx] = old_bucket; - } - ndata_tail[nidx] = old_bucket; - _old_bucket = old_bucket.next; - continue ; - }; -} - -function remove(h, key) { - var eq = h.eq; - var h_buckets = h.buckets; - var i = h.hash(key) & (h_buckets.length - 1 | 0); - var l = h_buckets[i]; - if (l === undefined) { - return ; - } - var next_cell = l.next; - if (eq(l.key, key)) { - h.size = h.size - 1 | 0; - h_buckets[i] = next_cell; - return ; - } else if (next_cell !== undefined) { - var _prec = l; - var _cell = next_cell; - while(true) { - var cell = _cell; - var prec = _prec; - var cell_next = cell.next; - if (eq(cell.key, key)) { - prec.next = cell_next; - h.size = h.size - 1 | 0; - return ; - } - if (cell_next === undefined) { - return ; - } - _cell = cell_next; - _prec = cell; - continue ; - }; - } else { - return ; - } -} - -function addBucket(h, key, _cell, eq) { - while(true) { - var cell = _cell; - if (eq(cell.key, key)) { - return ; - } - var n = cell.next; - if (n !== undefined) { - _cell = n; - continue ; - } - h.size = h.size + 1 | 0; - cell.next = { - key: key, - next: undefined - }; - return ; - }; -} - -function add0(h, key, hash, eq) { - var h_buckets = h.buckets; - var buckets_len = h_buckets.length; - var i = hash(key) & (buckets_len - 1 | 0); - var l = h_buckets[i]; - if (l !== undefined) { - addBucket(h, key, l, eq); - } else { - h.size = h.size + 1 | 0; - h_buckets[i] = { - key: key, - next: undefined - }; - } - if (h.size > (buckets_len << 1)) { - var odata = h.buckets; - var osize = odata.length; - var nsize = (osize << 1); - if (nsize < osize) { - return ; - } - var h_buckets$1 = new Array(nsize); - var ndata_tail = new Array(nsize); - h.buckets = h_buckets$1; - for(var i$1 = 0; i$1 < osize; ++i$1){ - copyBucket(hash, h_buckets$1, ndata_tail, odata[i$1]); - } - for(var i$2 = 0; i$2 < nsize; ++i$2){ - var tail = ndata_tail[i$2]; - if (tail !== undefined) { - tail.next = undefined; - } - - } - return ; - } - -} - -function add(h, key) { - add0(h, key, h.hash, h.eq); -} - -function has(h, key) { - var eq = h.eq; - var h_buckets = h.buckets; - var nid = h.hash(key) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[nid]; - if (bucket !== undefined) { - var _cell = bucket; - while(true) { - var cell = _cell; - if (eq(cell.key, key)) { - return true; - } - var nextCell = cell.next; - if (nextCell === undefined) { - return false; - } - _cell = nextCell; - continue ; - }; - } else { - return false; - } -} - -function make(hintSize, id) { - return Belt_internalBucketsType.make(id.hash, id.eq, hintSize); -} - -function size(h) { - return h.size; -} - -function fromArray(arr, id) { - var eq = id.eq; - var hash = id.hash; - var len = arr.length; - var v = Belt_internalBucketsType.make(hash, eq, len); - for(var i = 0; i < len; ++i){ - add0(v, arr[i], hash, eq); - } - return v; -} - -function mergeMany(h, arr) { - var eq = h.eq; - var hash = h.hash; - var len = arr.length; - for(var i = 0; i < len; ++i){ - add0(h, arr[i], hash, eq); - } -} - -var Int; - -var $$String; - -var clear = Belt_internalBucketsType.clear; - -var isEmpty = Belt_internalBucketsType.isEmpty; - -var copy = Belt_internalSetBuckets.copy; - -var forEachU = Belt_internalSetBuckets.forEachU; - -var forEach = Belt_internalSetBuckets.forEach; - -var reduceU = Belt_internalSetBuckets.reduceU; - -var reduce = Belt_internalSetBuckets.reduce; - -var logStats = Belt_internalSetBuckets.logStats; - -var toArray = Belt_internalSetBuckets.toArray; - -var getBucketHistogram = Belt_internalSetBuckets.getBucketHistogram; - -exports.Int = Int; -exports.$$String = $$String; -exports.make = make; -exports.clear = clear; -exports.isEmpty = isEmpty; -exports.add = add; -exports.copy = copy; -exports.has = has; -exports.remove = remove; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.size = size; -exports.logStats = logStats; -exports.toArray = toArray; -exports.fromArray = fromArray; -exports.mergeMany = mergeMany; -exports.getBucketHistogram = getBucketHistogram; -/* No side effect */ diff --git a/lib/js/belt_HashSetInt.js b/lib/js/belt_HashSetInt.js deleted file mode 100644 index 60e3881469f..00000000000 --- a/lib/js/belt_HashSetInt.js +++ /dev/null @@ -1,205 +0,0 @@ -'use strict'; - -var Caml_hash_primitive = require("./caml_hash_primitive.js"); -var Belt_internalSetBuckets = require("./belt_internalSetBuckets.js"); -var Belt_internalBucketsType = require("./belt_internalBucketsType.js"); - -function copyBucket(h_buckets, ndata_tail, _old_bucket) { - while(true) { - var old_bucket = _old_bucket; - if (old_bucket === undefined) { - return ; - } - var nidx = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, old_bucket.key)) & (h_buckets.length - 1 | 0); - var tail = ndata_tail[nidx]; - if (tail !== undefined) { - tail.next = old_bucket; - } else { - h_buckets[nidx] = old_bucket; - } - ndata_tail[nidx] = old_bucket; - _old_bucket = old_bucket.next; - continue ; - }; -} - -function remove(h, key) { - var h_buckets = h.buckets; - var i = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); - var l = h_buckets[i]; - if (l === undefined) { - return ; - } - var next_cell = l.next; - if (l.key === key) { - h.size = h.size - 1 | 0; - h_buckets[i] = next_cell; - return ; - } else if (next_cell !== undefined) { - var _prec = l; - var _cell = next_cell; - while(true) { - var cell = _cell; - var prec = _prec; - var cell_next = cell.next; - if (cell.key === key) { - prec.next = cell_next; - h.size = h.size - 1 | 0; - return ; - } - if (cell_next === undefined) { - return ; - } - _cell = cell_next; - _prec = cell; - continue ; - }; - } else { - return ; - } -} - -function addBucket(h, key, _cell) { - while(true) { - var cell = _cell; - if (cell.key === key) { - return ; - } - var n = cell.next; - if (n !== undefined) { - _cell = n; - continue ; - } - h.size = h.size + 1 | 0; - cell.next = { - key: key, - next: undefined - }; - return ; - }; -} - -function add(h, key) { - var h_buckets = h.buckets; - var buckets_len = h_buckets.length; - var i = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, key)) & (buckets_len - 1 | 0); - var l = h_buckets[i]; - if (l !== undefined) { - addBucket(h, key, l); - } else { - h_buckets[i] = { - key: key, - next: undefined - }; - h.size = h.size + 1 | 0; - } - if (h.size > (buckets_len << 1)) { - var odata = h.buckets; - var osize = odata.length; - var nsize = (osize << 1); - if (nsize < osize) { - return ; - } - var h_buckets$1 = new Array(nsize); - var ndata_tail = new Array(nsize); - h.buckets = h_buckets$1; - for(var i$1 = 0; i$1 < osize; ++i$1){ - copyBucket(h_buckets$1, ndata_tail, odata[i$1]); - } - for(var i$2 = 0; i$2 < nsize; ++i$2){ - var tail = ndata_tail[i$2]; - if (tail !== undefined) { - tail.next = undefined; - } - - } - return ; - } - -} - -function has(h, key) { - var h_buckets = h.buckets; - var nid = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[nid]; - if (bucket !== undefined) { - var _cell = bucket; - while(true) { - var cell = _cell; - if (cell.key === key) { - return true; - } - var nextCell = cell.next; - if (nextCell === undefined) { - return false; - } - _cell = nextCell; - continue ; - }; - } else { - return false; - } -} - -function make(hintSize) { - return Belt_internalBucketsType.make(undefined, undefined, hintSize); -} - -function size(h) { - return h.size; -} - -function fromArray(arr) { - var len = arr.length; - var v = Belt_internalBucketsType.make(undefined, undefined, len); - for(var i = 0; i < len; ++i){ - add(v, arr[i]); - } - return v; -} - -function mergeMany(h, arr) { - var len = arr.length; - for(var i = 0; i < len; ++i){ - add(h, arr[i]); - } -} - -var clear = Belt_internalBucketsType.clear; - -var isEmpty = Belt_internalBucketsType.isEmpty; - -var copy = Belt_internalSetBuckets.copy; - -var forEachU = Belt_internalSetBuckets.forEachU; - -var forEach = Belt_internalSetBuckets.forEach; - -var reduceU = Belt_internalSetBuckets.reduceU; - -var reduce = Belt_internalSetBuckets.reduce; - -var logStats = Belt_internalSetBuckets.logStats; - -var toArray = Belt_internalSetBuckets.toArray; - -var getBucketHistogram = Belt_internalSetBuckets.getBucketHistogram; - -exports.make = make; -exports.clear = clear; -exports.isEmpty = isEmpty; -exports.add = add; -exports.copy = copy; -exports.has = has; -exports.remove = remove; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.size = size; -exports.logStats = logStats; -exports.toArray = toArray; -exports.fromArray = fromArray; -exports.mergeMany = mergeMany; -exports.getBucketHistogram = getBucketHistogram; -/* No side effect */ diff --git a/lib/js/belt_HashSetString.js b/lib/js/belt_HashSetString.js deleted file mode 100644 index 6d7fbad7f9e..00000000000 --- a/lib/js/belt_HashSetString.js +++ /dev/null @@ -1,205 +0,0 @@ -'use strict'; - -var Caml_hash_primitive = require("./caml_hash_primitive.js"); -var Belt_internalSetBuckets = require("./belt_internalSetBuckets.js"); -var Belt_internalBucketsType = require("./belt_internalBucketsType.js"); - -function copyBucket(h_buckets, ndata_tail, _old_bucket) { - while(true) { - var old_bucket = _old_bucket; - if (old_bucket === undefined) { - return ; - } - var nidx = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, old_bucket.key)) & (h_buckets.length - 1 | 0); - var tail = ndata_tail[nidx]; - if (tail !== undefined) { - tail.next = old_bucket; - } else { - h_buckets[nidx] = old_bucket; - } - ndata_tail[nidx] = old_bucket; - _old_bucket = old_bucket.next; - continue ; - }; -} - -function remove(h, key) { - var h_buckets = h.buckets; - var i = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); - var l = h_buckets[i]; - if (l === undefined) { - return ; - } - var next_cell = l.next; - if (l.key === key) { - h.size = h.size - 1 | 0; - h_buckets[i] = next_cell; - return ; - } else if (next_cell !== undefined) { - var _prec = l; - var _cell = next_cell; - while(true) { - var cell = _cell; - var prec = _prec; - var cell_next = cell.next; - if (cell.key === key) { - prec.next = cell_next; - h.size = h.size - 1 | 0; - return ; - } - if (cell_next === undefined) { - return ; - } - _cell = cell_next; - _prec = cell; - continue ; - }; - } else { - return ; - } -} - -function addBucket(h, key, _cell) { - while(true) { - var cell = _cell; - if (cell.key === key) { - return ; - } - var n = cell.next; - if (n !== undefined) { - _cell = n; - continue ; - } - h.size = h.size + 1 | 0; - cell.next = { - key: key, - next: undefined - }; - return ; - }; -} - -function add(h, key) { - var h_buckets = h.buckets; - var buckets_len = h_buckets.length; - var i = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, key)) & (buckets_len - 1 | 0); - var l = h_buckets[i]; - if (l !== undefined) { - addBucket(h, key, l); - } else { - h_buckets[i] = { - key: key, - next: undefined - }; - h.size = h.size + 1 | 0; - } - if (h.size > (buckets_len << 1)) { - var odata = h.buckets; - var osize = odata.length; - var nsize = (osize << 1); - if (nsize < osize) { - return ; - } - var h_buckets$1 = new Array(nsize); - var ndata_tail = new Array(nsize); - h.buckets = h_buckets$1; - for(var i$1 = 0; i$1 < osize; ++i$1){ - copyBucket(h_buckets$1, ndata_tail, odata[i$1]); - } - for(var i$2 = 0; i$2 < nsize; ++i$2){ - var tail = ndata_tail[i$2]; - if (tail !== undefined) { - tail.next = undefined; - } - - } - return ; - } - -} - -function has(h, key) { - var h_buckets = h.buckets; - var nid = Caml_hash_primitive.hash_final_mix(Caml_hash_primitive.hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); - var bucket = h_buckets[nid]; - if (bucket !== undefined) { - var _cell = bucket; - while(true) { - var cell = _cell; - if (cell.key === key) { - return true; - } - var nextCell = cell.next; - if (nextCell === undefined) { - return false; - } - _cell = nextCell; - continue ; - }; - } else { - return false; - } -} - -function make(hintSize) { - return Belt_internalBucketsType.make(undefined, undefined, hintSize); -} - -function size(h) { - return h.size; -} - -function fromArray(arr) { - var len = arr.length; - var v = Belt_internalBucketsType.make(undefined, undefined, len); - for(var i = 0; i < len; ++i){ - add(v, arr[i]); - } - return v; -} - -function mergeMany(h, arr) { - var len = arr.length; - for(var i = 0; i < len; ++i){ - add(h, arr[i]); - } -} - -var clear = Belt_internalBucketsType.clear; - -var isEmpty = Belt_internalBucketsType.isEmpty; - -var copy = Belt_internalSetBuckets.copy; - -var forEachU = Belt_internalSetBuckets.forEachU; - -var forEach = Belt_internalSetBuckets.forEach; - -var reduceU = Belt_internalSetBuckets.reduceU; - -var reduce = Belt_internalSetBuckets.reduce; - -var logStats = Belt_internalSetBuckets.logStats; - -var toArray = Belt_internalSetBuckets.toArray; - -var getBucketHistogram = Belt_internalSetBuckets.getBucketHistogram; - -exports.make = make; -exports.clear = clear; -exports.isEmpty = isEmpty; -exports.add = add; -exports.copy = copy; -exports.has = has; -exports.remove = remove; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.size = size; -exports.logStats = logStats; -exports.toArray = toArray; -exports.fromArray = fromArray; -exports.mergeMany = mergeMany; -exports.getBucketHistogram = getBucketHistogram; -/* No side effect */ diff --git a/lib/js/belt_Id.js b/lib/js/belt_Id.js deleted file mode 100644 index 42b2ff8dd06..00000000000 --- a/lib/js/belt_Id.js +++ /dev/null @@ -1,69 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); - -function MakeComparableU(M) { - return M; -} - -function MakeComparable(M) { - var cmp = M.cmp; - var cmp$1 = Curry.__2(cmp); - return { - cmp: cmp$1 - }; -} - -function comparableU(cmp) { - return { - cmp: cmp - }; -} - -function comparable(cmp) { - var cmp$1 = Curry.__2(cmp); - return { - cmp: cmp$1 - }; -} - -function MakeHashableU(M) { - return M; -} - -function MakeHashable(M) { - var hash = M.hash; - var hash$1 = Curry.__1(hash); - var eq = M.eq; - var eq$1 = Curry.__2(eq); - return { - hash: hash$1, - eq: eq$1 - }; -} - -function hashableU(hash, eq) { - return { - hash: hash, - eq: eq - }; -} - -function hashable(hash, eq) { - var hash$1 = Curry.__1(hash); - var eq$1 = Curry.__2(eq); - return { - hash: hash$1, - eq: eq$1 - }; -} - -exports.MakeComparableU = MakeComparableU; -exports.MakeComparable = MakeComparable; -exports.comparableU = comparableU; -exports.comparable = comparable; -exports.MakeHashableU = MakeHashableU; -exports.MakeHashable = MakeHashable; -exports.hashableU = hashableU; -exports.hashable = hashable; -/* No side effect */ diff --git a/lib/js/belt_Int.js b/lib/js/belt_Int.js deleted file mode 100644 index 4268ada6909..00000000000 --- a/lib/js/belt_Int.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - - -function fromString(i) { - var i$1 = parseInt(i, 10); - if (isNaN(i$1)) { - return ; - } else { - return i$1; - } -} - -exports.fromString = fromString; -/* No side effect */ diff --git a/lib/js/belt_List.js b/lib/js/belt_List.js deleted file mode 100644 index a0baa8ed6f6..00000000000 --- a/lib/js/belt_List.js +++ /dev/null @@ -1,1510 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Belt_Array = require("./belt_Array.js"); -var Caml_option = require("./caml_option.js"); -var Belt_SortArray = require("./belt_SortArray.js"); - -function head(x) { - if (x) { - return Caml_option.some(x.hd); - } - -} - -function headExn(x) { - if (x) { - return x.hd; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -function tail(x) { - if (x) { - return x.tl; - } - -} - -function tailExn(x) { - if (x) { - return x.tl; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -function add(xs, x) { - return { - hd: x, - tl: xs - }; -} - -function get(x, n) { - if (n < 0) { - return ; - } else { - var _x = x; - var _n = n; - while(true) { - var n$1 = _n; - var x$1 = _x; - if (!x$1) { - return ; - } - if (n$1 === 0) { - return Caml_option.some(x$1.hd); - } - _n = n$1 - 1 | 0; - _x = x$1.tl; - continue ; - }; - } -} - -function getExn(x, n) { - if (n < 0) { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - } - var _x = x; - var _n = n; - while(true) { - var n$1 = _n; - var x$1 = _x; - if (x$1) { - if (n$1 === 0) { - return x$1.hd; - } - _n = n$1 - 1 | 0; - _x = x$1.tl; - continue ; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function partitionAux(p, _cell, _precX, _precY) { - while(true) { - var precY = _precY; - var precX = _precX; - var cell = _cell; - if (!cell) { - return ; - } - var t = cell.tl; - var h = cell.hd; - var next = { - hd: h, - tl: /* [] */0 - }; - if (p(h)) { - precX.tl = next; - _precX = next; - _cell = t; - continue ; - } - precY.tl = next; - _precY = next; - _cell = t; - continue ; - }; -} - -function splitAux(_cell, _precX, _precY) { - while(true) { - var precY = _precY; - var precX = _precX; - var cell = _cell; - if (!cell) { - return ; - } - var match = cell.hd; - var nextA = { - hd: match[0], - tl: /* [] */0 - }; - var nextB = { - hd: match[1], - tl: /* [] */0 - }; - precX.tl = nextA; - precY.tl = nextB; - _precY = nextB; - _precX = nextA; - _cell = cell.tl; - continue ; - }; -} - -function copyAuxCont(_cellX, _prec) { - while(true) { - var prec = _prec; - var cellX = _cellX; - if (!cellX) { - return prec; - } - var next = { - hd: cellX.hd, - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellX = cellX.tl; - continue ; - }; -} - -function copyAuxWitFilter(f, _cellX, _prec) { - while(true) { - var prec = _prec; - var cellX = _cellX; - if (!cellX) { - return ; - } - var t = cellX.tl; - var h = cellX.hd; - if (f(h)) { - var next = { - hd: h, - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellX = t; - continue ; - } - _cellX = t; - continue ; - }; -} - -function copyAuxWithFilterIndex(f, _cellX, _prec, _i) { - while(true) { - var i = _i; - var prec = _prec; - var cellX = _cellX; - if (!cellX) { - return ; - } - var t = cellX.tl; - var h = cellX.hd; - if (f(h, i)) { - var next = { - hd: h, - tl: /* [] */0 - }; - prec.tl = next; - _i = i + 1 | 0; - _prec = next; - _cellX = t; - continue ; - } - _i = i + 1 | 0; - _cellX = t; - continue ; - }; -} - -function copyAuxWitFilterMap(f, _cellX, _prec) { - while(true) { - var prec = _prec; - var cellX = _cellX; - if (!cellX) { - return ; - } - var t = cellX.tl; - var h = f(cellX.hd); - if (h !== undefined) { - var next = { - hd: Caml_option.valFromOption(h), - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellX = t; - continue ; - } - _cellX = t; - continue ; - }; -} - -function removeAssocAuxWithMap(_cellX, x, _prec, f) { - while(true) { - var prec = _prec; - var cellX = _cellX; - if (!cellX) { - return false; - } - var t = cellX.tl; - var h = cellX.hd; - if (f(h[0], x)) { - prec.tl = t; - return true; - } - var next = { - hd: h, - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellX = t; - continue ; - }; -} - -function setAssocAuxWithMap(_cellX, x, k, _prec, eq) { - while(true) { - var prec = _prec; - var cellX = _cellX; - if (!cellX) { - return false; - } - var t = cellX.tl; - var h = cellX.hd; - if (eq(h[0], x)) { - prec.tl = { - hd: [ - x, - k - ], - tl: t - }; - return true; - } - var next = { - hd: h, - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellX = t; - continue ; - }; -} - -function copyAuxWithMap(_cellX, _prec, f) { - while(true) { - var prec = _prec; - var cellX = _cellX; - if (!cellX) { - return ; - } - var next = { - hd: f(cellX.hd), - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellX = cellX.tl; - continue ; - }; -} - -function zipAux(_cellX, _cellY, _prec) { - while(true) { - var prec = _prec; - var cellY = _cellY; - var cellX = _cellX; - if (!cellX) { - return ; - } - if (!cellY) { - return ; - } - var next = { - hd: [ - cellX.hd, - cellY.hd - ], - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellY = cellY.tl; - _cellX = cellX.tl; - continue ; - }; -} - -function copyAuxWithMap2(f, _cellX, _cellY, _prec) { - while(true) { - var prec = _prec; - var cellY = _cellY; - var cellX = _cellX; - if (!cellX) { - return ; - } - if (!cellY) { - return ; - } - var next = { - hd: f(cellX.hd, cellY.hd), - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellY = cellY.tl; - _cellX = cellX.tl; - continue ; - }; -} - -function copyAuxWithMapI(f, _i, _cellX, _prec) { - while(true) { - var prec = _prec; - var cellX = _cellX; - var i = _i; - if (!cellX) { - return ; - } - var next = { - hd: f(i, cellX.hd), - tl: /* [] */0 - }; - prec.tl = next; - _prec = next; - _cellX = cellX.tl; - _i = i + 1 | 0; - continue ; - }; -} - -function takeAux(_n, _cell, _prec) { - while(true) { - var prec = _prec; - var cell = _cell; - var n = _n; - if (n === 0) { - return true; - } - if (!cell) { - return false; - } - var cell$1 = { - hd: cell.hd, - tl: /* [] */0 - }; - prec.tl = cell$1; - _prec = cell$1; - _cell = cell.tl; - _n = n - 1 | 0; - continue ; - }; -} - -function splitAtAux(_n, _cell, _prec) { - while(true) { - var prec = _prec; - var cell = _cell; - var n = _n; - if (n === 0) { - return cell; - } - if (!cell) { - return ; - } - var cell$1 = { - hd: cell.hd, - tl: /* [] */0 - }; - prec.tl = cell$1; - _prec = cell$1; - _cell = cell.tl; - _n = n - 1 | 0; - continue ; - }; -} - -function take(lst, n) { - if (n < 0) { - return ; - } - if (n === 0) { - return /* [] */0; - } - if (!lst) { - return ; - } - var cell = { - hd: lst.hd, - tl: /* [] */0 - }; - var has = takeAux(n - 1 | 0, lst.tl, cell); - if (has) { - return cell; - } - -} - -function drop(lst, n) { - if (n < 0) { - return ; - } else { - var _l = lst; - var _n = n; - while(true) { - var n$1 = _n; - var l = _l; - if (n$1 === 0) { - return l; - } - if (!l) { - return ; - } - _n = n$1 - 1 | 0; - _l = l.tl; - continue ; - }; - } -} - -function splitAt(lst, n) { - if (n < 0) { - return ; - } - if (n === 0) { - return [ - /* [] */0, - lst - ]; - } - if (!lst) { - return ; - } - var cell = { - hd: lst.hd, - tl: /* [] */0 - }; - var rest = splitAtAux(n - 1 | 0, lst.tl, cell); - if (rest !== undefined) { - return [ - cell, - rest - ]; - } - -} - -function concat(xs, ys) { - if (!xs) { - return ys; - } - var cell = { - hd: xs.hd, - tl: /* [] */0 - }; - copyAuxCont(xs.tl, cell).tl = ys; - return cell; -} - -function mapU(xs, f) { - if (!xs) { - return /* [] */0; - } - var cell = { - hd: f(xs.hd), - tl: /* [] */0 - }; - copyAuxWithMap(xs.tl, cell, f); - return cell; -} - -function map(xs, f) { - return mapU(xs, Curry.__1(f)); -} - -function zipByU(l1, l2, f) { - if (!l1) { - return /* [] */0; - } - if (!l2) { - return /* [] */0; - } - var cell = { - hd: f(l1.hd, l2.hd), - tl: /* [] */0 - }; - copyAuxWithMap2(f, l1.tl, l2.tl, cell); - return cell; -} - -function zipBy(l1, l2, f) { - return zipByU(l1, l2, Curry.__2(f)); -} - -function mapWithIndexU(xs, f) { - if (!xs) { - return /* [] */0; - } - var cell = { - hd: f(0, xs.hd), - tl: /* [] */0 - }; - copyAuxWithMapI(f, 1, xs.tl, cell); - return cell; -} - -function mapWithIndex(xs, f) { - return mapWithIndexU(xs, Curry.__2(f)); -} - -function makeByU(n, f) { - if (n <= 0) { - return /* [] */0; - } - var headX = { - hd: f(0), - tl: /* [] */0 - }; - var cur = headX; - var i = 1; - while(i < n) { - var v = { - hd: f(i), - tl: /* [] */0 - }; - cur.tl = v; - cur = v; - i = i + 1 | 0; - }; - return headX; -} - -function makeBy(n, f) { - return makeByU(n, Curry.__1(f)); -} - -function make(n, v) { - if (n <= 0) { - return /* [] */0; - } - var headX = { - hd: v, - tl: /* [] */0 - }; - var cur = headX; - var i = 1; - while(i < n) { - var v$1 = { - hd: v, - tl: /* [] */0 - }; - cur.tl = v$1; - cur = v$1; - i = i + 1 | 0; - }; - return headX; -} - -function length(xs) { - var _x = xs; - var _acc = 0; - while(true) { - var acc = _acc; - var x = _x; - if (!x) { - return acc; - } - _acc = acc + 1 | 0; - _x = x.tl; - continue ; - }; -} - -function fillAux(arr, _i, _x) { - while(true) { - var x = _x; - var i = _i; - if (!x) { - return ; - } - arr[i] = x.hd; - _x = x.tl; - _i = i + 1 | 0; - continue ; - }; -} - -function fromArray(a) { - var _i = a.length - 1 | 0; - var _res = /* [] */0; - while(true) { - var res = _res; - var i = _i; - if (i < 0) { - return res; - } - _res = { - hd: a[i], - tl: res - }; - _i = i - 1 | 0; - continue ; - }; -} - -function toArray(x) { - var len = length(x); - var arr = new Array(len); - fillAux(arr, 0, x); - return arr; -} - -function shuffle(xs) { - var v = toArray(xs); - Belt_Array.shuffleInPlace(v); - return fromArray(v); -} - -function reverseConcat(_l1, _l2) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (!l1) { - return l2; - } - _l2 = { - hd: l1.hd, - tl: l2 - }; - _l1 = l1.tl; - continue ; - }; -} - -function reverse(l) { - return reverseConcat(l, /* [] */0); -} - -function flattenAux(_prec, _xs) { - while(true) { - var xs = _xs; - var prec = _prec; - if (xs) { - _xs = xs.tl; - _prec = copyAuxCont(xs.hd, prec); - continue ; - } - prec.tl = /* [] */0; - return ; - }; -} - -function flatten(_xs) { - while(true) { - var xs = _xs; - if (!xs) { - return /* [] */0; - } - var match = xs.hd; - if (match) { - var cell = { - hd: match.hd, - tl: /* [] */0 - }; - flattenAux(copyAuxCont(match.tl, cell), xs.tl); - return cell; - } - _xs = xs.tl; - continue ; - }; -} - -function concatMany(xs) { - var len = xs.length; - if (len === 1) { - return xs[0]; - } - if (len === 0) { - return /* [] */0; - } - var len$1 = xs.length; - var v = xs[len$1 - 1 | 0]; - for(var i = len$1 - 2 | 0; i >= 0; --i){ - v = concat(xs[i], v); - } - return v; -} - -function mapReverseU(l, f) { - var _accu = /* [] */0; - var _xs = l; - while(true) { - var xs = _xs; - var accu = _accu; - if (!xs) { - return accu; - } - _xs = xs.tl; - _accu = { - hd: f(xs.hd), - tl: accu - }; - continue ; - }; -} - -function mapReverse(l, f) { - return mapReverseU(l, Curry.__1(f)); -} - -function forEachU(_xs, f) { - while(true) { - var xs = _xs; - if (!xs) { - return ; - } - f(xs.hd); - _xs = xs.tl; - continue ; - }; -} - -function forEach(xs, f) { - forEachU(xs, Curry.__1(f)); -} - -function forEachWithIndexU(l, f) { - var _xs = l; - var _i = 0; - while(true) { - var i = _i; - var xs = _xs; - if (!xs) { - return ; - } - f(i, xs.hd); - _i = i + 1 | 0; - _xs = xs.tl; - continue ; - }; -} - -function forEachWithIndex(l, f) { - forEachWithIndexU(l, Curry.__2(f)); -} - -function reduceU(_l, _accu, f) { - while(true) { - var accu = _accu; - var l = _l; - if (!l) { - return accu; - } - _accu = f(accu, l.hd); - _l = l.tl; - continue ; - }; -} - -function reduce(l, accu, f) { - return reduceU(l, accu, Curry.__2(f)); -} - -function reduceReverseUnsafeU(l, accu, f) { - if (l) { - return f(reduceReverseUnsafeU(l.tl, accu, f), l.hd); - } else { - return accu; - } -} - -function reduceReverseU(l, acc, f) { - var len = length(l); - if (len < 1000) { - return reduceReverseUnsafeU(l, acc, f); - } else { - return Belt_Array.reduceReverseU(toArray(l), acc, f); - } -} - -function reduceReverse(l, accu, f) { - return reduceReverseU(l, accu, Curry.__2(f)); -} - -function reduceWithIndexU(l, acc, f) { - var _l = l; - var _acc = acc; - var _i = 0; - while(true) { - var i = _i; - var acc$1 = _acc; - var l$1 = _l; - if (!l$1) { - return acc$1; - } - _i = i + 1 | 0; - _acc = f(acc$1, l$1.hd, i); - _l = l$1.tl; - continue ; - }; -} - -function reduceWithIndex(l, acc, f) { - return reduceWithIndexU(l, acc, Curry.__3(f)); -} - -function mapReverse2U(l1, l2, f) { - var _l1 = l1; - var _l2 = l2; - var _accu = /* [] */0; - while(true) { - var accu = _accu; - var l2$1 = _l2; - var l1$1 = _l1; - if (!l1$1) { - return accu; - } - if (!l2$1) { - return accu; - } - _accu = { - hd: f(l1$1.hd, l2$1.hd), - tl: accu - }; - _l2 = l2$1.tl; - _l1 = l1$1.tl; - continue ; - }; -} - -function mapReverse2(l1, l2, f) { - return mapReverse2U(l1, l2, Curry.__2(f)); -} - -function forEach2U(_l1, _l2, f) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (!l1) { - return ; - } - if (!l2) { - return ; - } - f(l1.hd, l2.hd); - _l2 = l2.tl; - _l1 = l1.tl; - continue ; - }; -} - -function forEach2(l1, l2, f) { - forEach2U(l1, l2, Curry.__2(f)); -} - -function reduce2U(_l1, _l2, _accu, f) { - while(true) { - var accu = _accu; - var l2 = _l2; - var l1 = _l1; - if (!l1) { - return accu; - } - if (!l2) { - return accu; - } - _accu = f(accu, l1.hd, l2.hd); - _l2 = l2.tl; - _l1 = l1.tl; - continue ; - }; -} - -function reduce2(l1, l2, acc, f) { - return reduce2U(l1, l2, acc, Curry.__3(f)); -} - -function reduceReverse2UnsafeU(l1, l2, accu, f) { - if (l1 && l2) { - return f(reduceReverse2UnsafeU(l1.tl, l2.tl, accu, f), l1.hd, l2.hd); - } else { - return accu; - } -} - -function reduceReverse2U(l1, l2, acc, f) { - var len = length(l1); - if (len < 1000) { - return reduceReverse2UnsafeU(l1, l2, acc, f); - } else { - return Belt_Array.reduceReverse2U(toArray(l1), toArray(l2), acc, f); - } -} - -function reduceReverse2(l1, l2, acc, f) { - return reduceReverse2U(l1, l2, acc, Curry.__3(f)); -} - -function everyU(_xs, p) { - while(true) { - var xs = _xs; - if (!xs) { - return true; - } - if (!p(xs.hd)) { - return false; - } - _xs = xs.tl; - continue ; - }; -} - -function every(xs, p) { - return everyU(xs, Curry.__1(p)); -} - -function someU(_xs, p) { - while(true) { - var xs = _xs; - if (!xs) { - return false; - } - if (p(xs.hd)) { - return true; - } - _xs = xs.tl; - continue ; - }; -} - -function some(xs, p) { - return someU(xs, Curry.__1(p)); -} - -function every2U(_l1, _l2, p) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (!l1) { - return true; - } - if (!l2) { - return true; - } - if (!p(l1.hd, l2.hd)) { - return false; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue ; - }; -} - -function every2(l1, l2, p) { - return every2U(l1, l2, Curry.__2(p)); -} - -function cmpByLength(_l1, _l2) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (!l1) { - if (l2) { - return -1; - } else { - return 0; - } - } - if (!l2) { - return 1; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue ; - }; -} - -function cmpU(_l1, _l2, p) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (!l1) { - if (l2) { - return -1; - } else { - return 0; - } - } - if (!l2) { - return 1; - } - var c = p(l1.hd, l2.hd); - if (c !== 0) { - return c; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue ; - }; -} - -function cmp(l1, l2, f) { - return cmpU(l1, l2, Curry.__2(f)); -} - -function eqU(_l1, _l2, p) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (!l1) { - if (l2) { - return false; - } else { - return true; - } - } - if (!l2) { - return false; - } - if (!p(l1.hd, l2.hd)) { - return false; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue ; - }; -} - -function eq(l1, l2, f) { - return eqU(l1, l2, Curry.__2(f)); -} - -function some2U(_l1, _l2, p) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (!l1) { - return false; - } - if (!l2) { - return false; - } - if (p(l1.hd, l2.hd)) { - return true; - } - _l2 = l2.tl; - _l1 = l1.tl; - continue ; - }; -} - -function some2(l1, l2, p) { - return some2U(l1, l2, Curry.__2(p)); -} - -function hasU(_xs, x, eq) { - while(true) { - var xs = _xs; - if (!xs) { - return false; - } - if (eq(xs.hd, x)) { - return true; - } - _xs = xs.tl; - continue ; - }; -} - -function has(xs, x, eq) { - return hasU(xs, x, Curry.__2(eq)); -} - -function getAssocU(_xs, x, eq) { - while(true) { - var xs = _xs; - if (!xs) { - return ; - } - var match = xs.hd; - if (eq(match[0], x)) { - return Caml_option.some(match[1]); - } - _xs = xs.tl; - continue ; - }; -} - -function getAssoc(xs, x, eq) { - return getAssocU(xs, x, Curry.__2(eq)); -} - -function hasAssocU(_xs, x, eq) { - while(true) { - var xs = _xs; - if (!xs) { - return false; - } - if (eq(xs.hd[0], x)) { - return true; - } - _xs = xs.tl; - continue ; - }; -} - -function hasAssoc(xs, x, eq) { - return hasAssocU(xs, x, Curry.__2(eq)); -} - -function removeAssocU(xs, x, eq) { - if (!xs) { - return /* [] */0; - } - var l = xs.tl; - var pair = xs.hd; - if (eq(pair[0], x)) { - return l; - } - var cell = { - hd: pair, - tl: /* [] */0 - }; - var removed = removeAssocAuxWithMap(l, x, cell, eq); - if (removed) { - return cell; - } else { - return xs; - } -} - -function removeAssoc(xs, x, eq) { - return removeAssocU(xs, x, Curry.__2(eq)); -} - -function setAssocU(xs, x, k, eq) { - if (!xs) { - return { - hd: [ - x, - k - ], - tl: /* [] */0 - }; - } - var l = xs.tl; - var pair = xs.hd; - if (eq(pair[0], x)) { - return { - hd: [ - x, - k - ], - tl: l - }; - } - var cell = { - hd: pair, - tl: /* [] */0 - }; - var replaced = setAssocAuxWithMap(l, x, k, cell, eq); - if (replaced) { - return cell; - } else { - return { - hd: [ - x, - k - ], - tl: xs - }; - } -} - -function setAssoc(xs, x, k, eq) { - return setAssocU(xs, x, k, Curry.__2(eq)); -} - -function sortU(xs, cmp) { - var arr = toArray(xs); - Belt_SortArray.stableSortInPlaceByU(arr, cmp); - return fromArray(arr); -} - -function sort(xs, cmp) { - return sortU(xs, Curry.__2(cmp)); -} - -function getByU(_xs, p) { - while(true) { - var xs = _xs; - if (!xs) { - return ; - } - var x = xs.hd; - if (p(x)) { - return Caml_option.some(x); - } - _xs = xs.tl; - continue ; - }; -} - -function getBy(xs, p) { - return getByU(xs, Curry.__1(p)); -} - -function keepU(_xs, p) { - while(true) { - var xs = _xs; - if (!xs) { - return /* [] */0; - } - var t = xs.tl; - var h = xs.hd; - if (p(h)) { - var cell = { - hd: h, - tl: /* [] */0 - }; - copyAuxWitFilter(p, t, cell); - return cell; - } - _xs = t; - continue ; - }; -} - -function keep(xs, p) { - return keepU(xs, Curry.__1(p)); -} - -function keepWithIndexU(xs, p) { - var _xs = xs; - var _i = 0; - while(true) { - var i = _i; - var xs$1 = _xs; - if (!xs$1) { - return /* [] */0; - } - var t = xs$1.tl; - var h = xs$1.hd; - if (p(h, i)) { - var cell = { - hd: h, - tl: /* [] */0 - }; - copyAuxWithFilterIndex(p, t, cell, i + 1 | 0); - return cell; - } - _i = i + 1 | 0; - _xs = t; - continue ; - }; -} - -function keepWithIndex(xs, p) { - return keepWithIndexU(xs, Curry.__2(p)); -} - -function keepMapU(_xs, p) { - while(true) { - var xs = _xs; - if (!xs) { - return /* [] */0; - } - var t = xs.tl; - var h = p(xs.hd); - if (h !== undefined) { - var cell = { - hd: Caml_option.valFromOption(h), - tl: /* [] */0 - }; - copyAuxWitFilterMap(p, t, cell); - return cell; - } - _xs = t; - continue ; - }; -} - -function keepMap(xs, p) { - return keepMapU(xs, Curry.__1(p)); -} - -function partitionU(l, p) { - if (!l) { - return [ - /* [] */0, - /* [] */0 - ]; - } - var h = l.hd; - var nextX = { - hd: h, - tl: /* [] */0 - }; - var nextY = { - hd: h, - tl: /* [] */0 - }; - var b = p(h); - partitionAux(p, l.tl, nextX, nextY); - if (b) { - return [ - nextX, - nextY.tl - ]; - } else { - return [ - nextX.tl, - nextY - ]; - } -} - -function partition(l, p) { - return partitionU(l, Curry.__1(p)); -} - -function unzip(xs) { - if (!xs) { - return [ - /* [] */0, - /* [] */0 - ]; - } - var match = xs.hd; - var cellX = { - hd: match[0], - tl: /* [] */0 - }; - var cellY = { - hd: match[1], - tl: /* [] */0 - }; - splitAux(xs.tl, cellX, cellY); - return [ - cellX, - cellY - ]; -} - -function zip(l1, l2) { - if (!l1) { - return /* [] */0; - } - if (!l2) { - return /* [] */0; - } - var cell = { - hd: [ - l1.hd, - l2.hd - ], - tl: /* [] */0 - }; - zipAux(l1.tl, l2.tl, cell); - return cell; -} - -var size = length; - -var filter = keep; - -var filterWithIndex = keepWithIndex; - -exports.length = length; -exports.size = size; -exports.head = head; -exports.headExn = headExn; -exports.tail = tail; -exports.tailExn = tailExn; -exports.add = add; -exports.get = get; -exports.getExn = getExn; -exports.make = make; -exports.makeByU = makeByU; -exports.makeBy = makeBy; -exports.shuffle = shuffle; -exports.drop = drop; -exports.take = take; -exports.splitAt = splitAt; -exports.concat = concat; -exports.concatMany = concatMany; -exports.reverseConcat = reverseConcat; -exports.flatten = flatten; -exports.mapU = mapU; -exports.map = map; -exports.zip = zip; -exports.zipByU = zipByU; -exports.zipBy = zipBy; -exports.mapWithIndexU = mapWithIndexU; -exports.mapWithIndex = mapWithIndex; -exports.fromArray = fromArray; -exports.toArray = toArray; -exports.reverse = reverse; -exports.mapReverseU = mapReverseU; -exports.mapReverse = mapReverse; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.forEachWithIndexU = forEachWithIndexU; -exports.forEachWithIndex = forEachWithIndex; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.reduceWithIndexU = reduceWithIndexU; -exports.reduceWithIndex = reduceWithIndex; -exports.reduceReverseU = reduceReverseU; -exports.reduceReverse = reduceReverse; -exports.mapReverse2U = mapReverse2U; -exports.mapReverse2 = mapReverse2; -exports.forEach2U = forEach2U; -exports.forEach2 = forEach2; -exports.reduce2U = reduce2U; -exports.reduce2 = reduce2; -exports.reduceReverse2U = reduceReverse2U; -exports.reduceReverse2 = reduceReverse2; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.every2U = every2U; -exports.every2 = every2; -exports.some2U = some2U; -exports.some2 = some2; -exports.cmpByLength = cmpByLength; -exports.cmpU = cmpU; -exports.cmp = cmp; -exports.eqU = eqU; -exports.eq = eq; -exports.hasU = hasU; -exports.has = has; -exports.getByU = getByU; -exports.getBy = getBy; -exports.keepU = keepU; -exports.keep = keep; -exports.filter = filter; -exports.keepWithIndexU = keepWithIndexU; -exports.keepWithIndex = keepWithIndex; -exports.filterWithIndex = filterWithIndex; -exports.keepMapU = keepMapU; -exports.keepMap = keepMap; -exports.partitionU = partitionU; -exports.partition = partition; -exports.unzip = unzip; -exports.getAssocU = getAssocU; -exports.getAssoc = getAssoc; -exports.hasAssocU = hasAssocU; -exports.hasAssoc = hasAssoc; -exports.removeAssocU = removeAssocU; -exports.removeAssoc = removeAssoc; -exports.setAssocU = setAssocU; -exports.setAssoc = setAssoc; -exports.sortU = sortU; -exports.sort = sort; -/* No side effect */ diff --git a/lib/js/belt_Map.js b/lib/js/belt_Map.js deleted file mode 100644 index 98e0016cc4e..00000000000 --- a/lib/js/belt_Map.js +++ /dev/null @@ -1,374 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Belt_MapDict = require("./belt_MapDict.js"); - -function fromArray(data, id) { - var cmp = id.cmp; - return { - cmp: cmp, - data: Belt_MapDict.fromArray(data, cmp) - }; -} - -function remove(m, x) { - var odata = m.data; - var cmp = m.cmp; - var newData = Belt_MapDict.remove(odata, x, cmp); - if (newData === odata) { - return m; - } else { - return { - cmp: cmp, - data: newData - }; - } -} - -function removeMany(m, x) { - var cmp = m.cmp; - var newData = Belt_MapDict.removeMany(m.data, x, cmp); - return { - cmp: cmp, - data: newData - }; -} - -function set(m, key, d) { - var cmp = m.cmp; - return { - cmp: cmp, - data: Belt_MapDict.set(m.data, key, d, cmp) - }; -} - -function mergeMany(m, e) { - var cmp = m.cmp; - return { - cmp: cmp, - data: Belt_MapDict.mergeMany(m.data, e, cmp) - }; -} - -function updateU(m, key, f) { - var cmp = m.cmp; - return { - cmp: cmp, - data: Belt_MapDict.updateU(m.data, key, f, cmp) - }; -} - -function update(m, key, f) { - return updateU(m, key, Curry.__1(f)); -} - -function split(m, x) { - var cmp = m.cmp; - var match = Belt_MapDict.split(m.data, x, cmp); - var match$1 = match[0]; - return [ - [ - { - cmp: cmp, - data: match$1[0] - }, - { - cmp: cmp, - data: match$1[1] - } - ], - match[1] - ]; -} - -function mergeU(s1, s2, f) { - var cmp = s1.cmp; - return { - cmp: cmp, - data: Belt_MapDict.mergeU(s1.data, s2.data, f, cmp) - }; -} - -function merge(s1, s2, f) { - return mergeU(s1, s2, Curry.__3(f)); -} - -function make(id) { - return { - cmp: id.cmp, - data: undefined - }; -} - -function isEmpty(map) { - return Belt_MapDict.isEmpty(map.data); -} - -function findFirstByU(m, f) { - return Belt_MapDict.findFirstByU(m.data, f); -} - -function findFirstBy(m, f) { - return Belt_MapDict.findFirstByU(m.data, Curry.__2(f)); -} - -function forEachU(m, f) { - Belt_MapDict.forEachU(m.data, f); -} - -function forEach(m, f) { - Belt_MapDict.forEachU(m.data, Curry.__2(f)); -} - -function reduceU(m, acc, f) { - return Belt_MapDict.reduceU(m.data, acc, f); -} - -function reduce(m, acc, f) { - return reduceU(m, acc, Curry.__3(f)); -} - -function everyU(m, f) { - return Belt_MapDict.everyU(m.data, f); -} - -function every(m, f) { - return Belt_MapDict.everyU(m.data, Curry.__2(f)); -} - -function someU(m, f) { - return Belt_MapDict.someU(m.data, f); -} - -function some(m, f) { - return Belt_MapDict.someU(m.data, Curry.__2(f)); -} - -function keepU(m, f) { - return { - cmp: m.cmp, - data: Belt_MapDict.keepU(m.data, f) - }; -} - -function keep(m, f) { - return keepU(m, Curry.__2(f)); -} - -function partitionU(m, p) { - var cmp = m.cmp; - var match = Belt_MapDict.partitionU(m.data, p); - return [ - { - cmp: cmp, - data: match[0] - }, - { - cmp: cmp, - data: match[1] - } - ]; -} - -function partition(m, p) { - return partitionU(m, Curry.__2(p)); -} - -function mapU(m, f) { - return { - cmp: m.cmp, - data: Belt_MapDict.mapU(m.data, f) - }; -} - -function map(m, f) { - return mapU(m, Curry.__1(f)); -} - -function mapWithKeyU(m, f) { - return { - cmp: m.cmp, - data: Belt_MapDict.mapWithKeyU(m.data, f) - }; -} - -function mapWithKey(m, f) { - return mapWithKeyU(m, Curry.__2(f)); -} - -function size(map) { - return Belt_MapDict.size(map.data); -} - -function toList(map) { - return Belt_MapDict.toList(map.data); -} - -function toArray(m) { - return Belt_MapDict.toArray(m.data); -} - -function keysToArray(m) { - return Belt_MapDict.keysToArray(m.data); -} - -function valuesToArray(m) { - return Belt_MapDict.valuesToArray(m.data); -} - -function minKey(m) { - return Belt_MapDict.minKey(m.data); -} - -function minKeyUndefined(m) { - return Belt_MapDict.minKeyUndefined(m.data); -} - -function maxKey(m) { - return Belt_MapDict.maxKey(m.data); -} - -function maxKeyUndefined(m) { - return Belt_MapDict.maxKeyUndefined(m.data); -} - -function minimum(m) { - return Belt_MapDict.minimum(m.data); -} - -function minUndefined(m) { - return Belt_MapDict.minUndefined(m.data); -} - -function maximum(m) { - return Belt_MapDict.maximum(m.data); -} - -function maxUndefined(m) { - return Belt_MapDict.maxUndefined(m.data); -} - -function get(map, x) { - return Belt_MapDict.get(map.data, x, map.cmp); -} - -function getUndefined(map, x) { - return Belt_MapDict.getUndefined(map.data, x, map.cmp); -} - -function getWithDefault(map, x, def) { - return Belt_MapDict.getWithDefault(map.data, x, def, map.cmp); -} - -function getExn(map, x) { - return Belt_MapDict.getExn(map.data, x, map.cmp); -} - -function has(map, x) { - return Belt_MapDict.has(map.data, x, map.cmp); -} - -function checkInvariantInternal(m) { - Belt_MapDict.checkInvariantInternal(m.data); -} - -function eqU(m1, m2, veq) { - return Belt_MapDict.eqU(m1.data, m2.data, m1.cmp, veq); -} - -function eq(m1, m2, veq) { - return eqU(m1, m2, Curry.__2(veq)); -} - -function cmpU(m1, m2, vcmp) { - return Belt_MapDict.cmpU(m1.data, m2.data, m1.cmp, vcmp); -} - -function cmp(m1, m2, vcmp) { - return cmpU(m1, m2, Curry.__2(vcmp)); -} - -function getData(m) { - return m.data; -} - -function getId(m) { - var cmp = m.cmp; - return { - cmp: cmp - }; -} - -function packIdData(id, data) { - return { - cmp: id.cmp, - data: data - }; -} - -var Int; - -var $$String; - -var Dict; - -exports.Int = Int; -exports.$$String = $$String; -exports.Dict = Dict; -exports.make = make; -exports.isEmpty = isEmpty; -exports.has = has; -exports.cmpU = cmpU; -exports.cmp = cmp; -exports.eqU = eqU; -exports.eq = eq; -exports.findFirstByU = findFirstByU; -exports.findFirstBy = findFirstBy; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.size = size; -exports.toArray = toArray; -exports.toList = toList; -exports.fromArray = fromArray; -exports.keysToArray = keysToArray; -exports.valuesToArray = valuesToArray; -exports.minKey = minKey; -exports.minKeyUndefined = minKeyUndefined; -exports.maxKey = maxKey; -exports.maxKeyUndefined = maxKeyUndefined; -exports.minimum = minimum; -exports.minUndefined = minUndefined; -exports.maximum = maximum; -exports.maxUndefined = maxUndefined; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getWithDefault = getWithDefault; -exports.getExn = getExn; -exports.remove = remove; -exports.removeMany = removeMany; -exports.set = set; -exports.updateU = updateU; -exports.update = update; -exports.mergeMany = mergeMany; -exports.mergeU = mergeU; -exports.merge = merge; -exports.keepU = keepU; -exports.keep = keep; -exports.partitionU = partitionU; -exports.partition = partition; -exports.split = split; -exports.mapU = mapU; -exports.map = map; -exports.mapWithKeyU = mapWithKeyU; -exports.mapWithKey = mapWithKey; -exports.getData = getData; -exports.getId = getId; -exports.packIdData = packIdData; -exports.checkInvariantInternal = checkInvariantInternal; -/* No side effect */ diff --git a/lib/js/belt_MapDict.js b/lib/js/belt_MapDict.js deleted file mode 100644 index ea4e1a614b2..00000000000 --- a/lib/js/belt_MapDict.js +++ /dev/null @@ -1,415 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Caml_option = require("./caml_option.js"); -var Belt_internalAVLtree = require("./belt_internalAVLtree.js"); - -function set(t, newK, newD, cmp) { - if (t === undefined) { - return Belt_internalAVLtree.singleton(newK, newD); - } - var k = t.k; - var c = cmp(newK, k); - if (c === 0) { - return Belt_internalAVLtree.updateValue(t, newD); - } - var l = t.l; - var r = t.r; - var v = t.v; - if (c < 0) { - return Belt_internalAVLtree.bal(set(l, newK, newD, cmp), k, v, r); - } else { - return Belt_internalAVLtree.bal(l, k, v, set(r, newK, newD, cmp)); - } -} - -function updateU(t, newK, f, cmp) { - if (t !== undefined) { - var k = t.k; - var c = cmp(newK, k); - if (c === 0) { - var newD = f(Caml_option.some(t.v)); - if (newD !== undefined) { - return Belt_internalAVLtree.updateValue(t, Caml_option.valFromOption(newD)); - } - var l = t.l; - var r = t.r; - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var kr = { - contents: r.k - }; - var vr = { - contents: r.v - }; - var r$1 = Belt_internalAVLtree.removeMinAuxWithRef(r, kr, vr); - return Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); - } - var l$1 = t.l; - var r$2 = t.r; - var v = t.v; - if (c < 0) { - var ll = updateU(l$1, newK, f, cmp); - if (l$1 === ll) { - return t; - } else { - return Belt_internalAVLtree.bal(ll, k, v, r$2); - } - } - var rr = updateU(r$2, newK, f, cmp); - if (r$2 === rr) { - return t; - } else { - return Belt_internalAVLtree.bal(l$1, k, v, rr); - } - } - var newD$1 = f(undefined); - if (newD$1 !== undefined) { - return Belt_internalAVLtree.singleton(newK, Caml_option.valFromOption(newD$1)); - } else { - return t; - } -} - -function update(t, newK, f, cmp) { - return updateU(t, newK, Curry.__1(f), cmp); -} - -function removeAux0(n, x, cmp) { - var v = n.k; - var l = n.l; - var r = n.r; - var c = cmp(x, v); - if (c === 0) { - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var kr = { - contents: r.k - }; - var vr = { - contents: r.v - }; - var r$1 = Belt_internalAVLtree.removeMinAuxWithRef(r, kr, vr); - return Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); - } - if (c < 0) { - if (l === undefined) { - return n; - } - var ll = removeAux0(l, x, cmp); - if (ll === l) { - return n; - } else { - return Belt_internalAVLtree.bal(ll, v, n.v, r); - } - } - if (r === undefined) { - return n; - } - var rr = removeAux0(r, x, cmp); - if (rr === r) { - return n; - } else { - return Belt_internalAVLtree.bal(l, v, n.v, rr); - } -} - -function remove(n, x, cmp) { - if (n !== undefined) { - return removeAux0(n, x, cmp); - } - -} - -function mergeMany(h, arr, cmp) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var match = arr[i]; - v = set(v, match[0], match[1], cmp); - } - return v; -} - -function splitAuxPivot(n, x, pres, cmp) { - var v = n.k; - var d = n.v; - var l = n.l; - var r = n.r; - var c = cmp(x, v); - if (c === 0) { - pres.contents = Caml_option.some(d); - return [ - l, - r - ]; - } - if (c < 0) { - if (l === undefined) { - return [ - undefined, - n - ]; - } - var match = splitAuxPivot(l, x, pres, cmp); - return [ - match[0], - Belt_internalAVLtree.join(match[1], v, d, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined - ]; - } - var match$1 = splitAuxPivot(r, x, pres, cmp); - return [ - Belt_internalAVLtree.join(l, v, d, match$1[0]), - match$1[1] - ]; -} - -function split(n, x, cmp) { - if (n === undefined) { - return [ - [ - undefined, - undefined - ], - undefined - ]; - } - var pres = { - contents: undefined - }; - var v = splitAuxPivot(n, x, pres, cmp); - return [ - v, - pres.contents - ]; -} - -function mergeU(s1, s2, f, cmp) { - if (s1 === undefined) { - if (s2 !== undefined) { - return Belt_internalAVLtree.keepMapU(s2, (function (k, v) { - return f(k, undefined, Caml_option.some(v)); - })); - } else { - return ; - } - } - if (s2 === undefined) { - return Belt_internalAVLtree.keepMapU(s1, (function (k, v) { - return f(k, Caml_option.some(v), undefined); - })); - } - if (s1.h >= s2.h) { - var v1 = s1.k; - var d1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var d2 = { - contents: undefined - }; - var match = splitAuxPivot(s2, v1, d2, cmp); - var d2$1 = d2.contents; - var newLeft = mergeU(l1, match[0], f, cmp); - var newD = f(v1, Caml_option.some(d1), d2$1); - var newRight = mergeU(r1, match[1], f, cmp); - return Belt_internalAVLtree.concatOrJoin(newLeft, v1, newD, newRight); - } - var v2 = s2.k; - var d2$2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - var d1$1 = { - contents: undefined - }; - var match$1 = splitAuxPivot(s1, v2, d1$1, cmp); - var d1$2 = d1$1.contents; - var newLeft$1 = mergeU(match$1[0], l2, f, cmp); - var newD$1 = f(v2, d1$2, Caml_option.some(d2$2)); - var newRight$1 = mergeU(match$1[1], r2, f, cmp); - return Belt_internalAVLtree.concatOrJoin(newLeft$1, v2, newD$1, newRight$1); -} - -function merge(s1, s2, f, cmp) { - return mergeU(s1, s2, Curry.__3(f), cmp); -} - -function removeMany(t, keys, cmp) { - var len = keys.length; - if (t !== undefined) { - var _t = t; - var _i = 0; - while(true) { - var i = _i; - var t$1 = _t; - if (i >= len) { - return t$1; - } - var ele = keys[i]; - var u = removeAux0(t$1, ele, cmp); - if (u === undefined) { - return u; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; - } - -} - -var empty; - -var isEmpty = Belt_internalAVLtree.isEmpty; - -var has = Belt_internalAVLtree.has; - -var cmpU = Belt_internalAVLtree.cmpU; - -var cmp = Belt_internalAVLtree.cmp; - -var eqU = Belt_internalAVLtree.eqU; - -var eq = Belt_internalAVLtree.eq; - -var findFirstByU = Belt_internalAVLtree.findFirstByU; - -var findFirstBy = Belt_internalAVLtree.findFirstBy; - -var forEachU = Belt_internalAVLtree.forEachU; - -var forEach = Belt_internalAVLtree.forEach; - -var reduceU = Belt_internalAVLtree.reduceU; - -var reduce = Belt_internalAVLtree.reduce; - -var everyU = Belt_internalAVLtree.everyU; - -var every = Belt_internalAVLtree.every; - -var someU = Belt_internalAVLtree.someU; - -var some = Belt_internalAVLtree.some; - -var size = Belt_internalAVLtree.size; - -var toList = Belt_internalAVLtree.toList; - -var toArray = Belt_internalAVLtree.toArray; - -var fromArray = Belt_internalAVLtree.fromArray; - -var keysToArray = Belt_internalAVLtree.keysToArray; - -var valuesToArray = Belt_internalAVLtree.valuesToArray; - -var minKey = Belt_internalAVLtree.minKey; - -var minKeyUndefined = Belt_internalAVLtree.minKeyUndefined; - -var maxKey = Belt_internalAVLtree.maxKey; - -var maxKeyUndefined = Belt_internalAVLtree.maxKeyUndefined; - -var minimum = Belt_internalAVLtree.minimum; - -var minUndefined = Belt_internalAVLtree.minUndefined; - -var maximum = Belt_internalAVLtree.maximum; - -var maxUndefined = Belt_internalAVLtree.maxUndefined; - -var get = Belt_internalAVLtree.get; - -var getUndefined = Belt_internalAVLtree.getUndefined; - -var getWithDefault = Belt_internalAVLtree.getWithDefault; - -var getExn = Belt_internalAVLtree.getExn; - -var checkInvariantInternal = Belt_internalAVLtree.checkInvariantInternal; - -var keepU = Belt_internalAVLtree.keepSharedU; - -var keep = Belt_internalAVLtree.keepShared; - -var partitionU = Belt_internalAVLtree.partitionSharedU; - -var partition = Belt_internalAVLtree.partitionShared; - -var mapU = Belt_internalAVLtree.mapU; - -var map = Belt_internalAVLtree.map; - -var mapWithKeyU = Belt_internalAVLtree.mapWithKeyU; - -var mapWithKey = Belt_internalAVLtree.mapWithKey; - -exports.empty = empty; -exports.isEmpty = isEmpty; -exports.has = has; -exports.cmpU = cmpU; -exports.cmp = cmp; -exports.eqU = eqU; -exports.eq = eq; -exports.findFirstByU = findFirstByU; -exports.findFirstBy = findFirstBy; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.size = size; -exports.toList = toList; -exports.toArray = toArray; -exports.fromArray = fromArray; -exports.keysToArray = keysToArray; -exports.valuesToArray = valuesToArray; -exports.minKey = minKey; -exports.minKeyUndefined = minKeyUndefined; -exports.maxKey = maxKey; -exports.maxKeyUndefined = maxKeyUndefined; -exports.minimum = minimum; -exports.minUndefined = minUndefined; -exports.maximum = maximum; -exports.maxUndefined = maxUndefined; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getWithDefault = getWithDefault; -exports.getExn = getExn; -exports.checkInvariantInternal = checkInvariantInternal; -exports.remove = remove; -exports.removeMany = removeMany; -exports.set = set; -exports.updateU = updateU; -exports.update = update; -exports.mergeU = mergeU; -exports.merge = merge; -exports.mergeMany = mergeMany; -exports.keepU = keepU; -exports.keep = keep; -exports.partitionU = partitionU; -exports.partition = partition; -exports.split = split; -exports.mapU = mapU; -exports.map = map; -exports.mapWithKeyU = mapWithKeyU; -exports.mapWithKey = mapWithKey; -/* No side effect */ diff --git a/lib/js/belt_MapInt.js b/lib/js/belt_MapInt.js deleted file mode 100644 index 05bcf2fd5ec..00000000000 --- a/lib/js/belt_MapInt.js +++ /dev/null @@ -1,305 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Caml_option = require("./caml_option.js"); -var Belt_internalMapInt = require("./belt_internalMapInt.js"); -var Belt_internalAVLtree = require("./belt_internalAVLtree.js"); - -function set(t, newK, newD) { - if (t === undefined) { - return Belt_internalAVLtree.singleton(newK, newD); - } - var k = t.k; - if (newK === k) { - return Belt_internalAVLtree.updateValue(t, newD); - } - var v = t.v; - if (newK < k) { - return Belt_internalAVLtree.bal(set(t.l, newK, newD), k, v, t.r); - } else { - return Belt_internalAVLtree.bal(t.l, k, v, set(t.r, newK, newD)); - } -} - -function updateU(t, x, f) { - if (t !== undefined) { - var k = t.k; - if (x === k) { - var data = f(Caml_option.some(t.v)); - if (data !== undefined) { - return Belt_internalAVLtree.updateValue(t, Caml_option.valFromOption(data)); - } - var l = t.l; - var r = t.r; - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var kr = { - contents: r.k - }; - var vr = { - contents: r.v - }; - var r$1 = Belt_internalAVLtree.removeMinAuxWithRef(r, kr, vr); - return Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); - } - var v = t.v; - var l$1 = t.l; - var r$2 = t.r; - if (x < k) { - var ll = updateU(l$1, x, f); - if (l$1 === ll) { - return t; - } else { - return Belt_internalAVLtree.bal(ll, k, v, r$2); - } - } - var rr = updateU(r$2, x, f); - if (r$2 === rr) { - return t; - } else { - return Belt_internalAVLtree.bal(l$1, k, v, rr); - } - } - var data$1 = f(undefined); - if (data$1 !== undefined) { - return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); - } else { - return t; - } -} - -function update(t, x, f) { - return updateU(t, x, Curry.__1(f)); -} - -function removeAux(n, x) { - var v = n.k; - var l = n.l; - var r = n.r; - if (x === v) { - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var kr = { - contents: r.k - }; - var vr = { - contents: r.v - }; - var r$1 = Belt_internalAVLtree.removeMinAuxWithRef(r, kr, vr); - return Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); - } - if (x < v) { - if (l === undefined) { - return n; - } - var ll = removeAux(l, x); - if (ll === l) { - return n; - } else { - return Belt_internalAVLtree.bal(ll, v, n.v, r); - } - } - if (r === undefined) { - return n; - } - var rr = removeAux(r, x); - return Belt_internalAVLtree.bal(l, v, n.v, rr); -} - -function remove(n, x) { - if (n !== undefined) { - return removeAux(n, x); - } - -} - -function removeMany(t, keys) { - var len = keys.length; - if (t !== undefined) { - var _t = t; - var _i = 0; - while(true) { - var i = _i; - var t$1 = _t; - if (i >= len) { - return t$1; - } - var ele = keys[i]; - var u = removeAux(t$1, ele); - if (u === undefined) { - return u; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; - } - -} - -function mergeMany(h, arr) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var match = arr[i]; - v = set(v, match[0], match[1]); - } - return v; -} - -var empty; - -var isEmpty = Belt_internalAVLtree.isEmpty; - -var has = Belt_internalMapInt.has; - -var cmpU = Belt_internalMapInt.cmpU; - -var cmp = Belt_internalMapInt.cmp; - -var eqU = Belt_internalMapInt.eqU; - -var eq = Belt_internalMapInt.eq; - -var findFirstByU = Belt_internalAVLtree.findFirstByU; - -var findFirstBy = Belt_internalAVLtree.findFirstBy; - -var forEachU = Belt_internalAVLtree.forEachU; - -var forEach = Belt_internalAVLtree.forEach; - -var reduceU = Belt_internalAVLtree.reduceU; - -var reduce = Belt_internalAVLtree.reduce; - -var everyU = Belt_internalAVLtree.everyU; - -var every = Belt_internalAVLtree.every; - -var someU = Belt_internalAVLtree.someU; - -var some = Belt_internalAVLtree.some; - -var size = Belt_internalAVLtree.size; - -var toList = Belt_internalAVLtree.toList; - -var toArray = Belt_internalAVLtree.toArray; - -var fromArray = Belt_internalMapInt.fromArray; - -var keysToArray = Belt_internalAVLtree.keysToArray; - -var valuesToArray = Belt_internalAVLtree.valuesToArray; - -var minKey = Belt_internalAVLtree.minKey; - -var minKeyUndefined = Belt_internalAVLtree.minKeyUndefined; - -var maxKey = Belt_internalAVLtree.maxKey; - -var maxKeyUndefined = Belt_internalAVLtree.maxKeyUndefined; - -var minimum = Belt_internalAVLtree.minimum; - -var minUndefined = Belt_internalAVLtree.minUndefined; - -var maximum = Belt_internalAVLtree.maximum; - -var maxUndefined = Belt_internalAVLtree.maxUndefined; - -var get = Belt_internalMapInt.get; - -var getUndefined = Belt_internalMapInt.getUndefined; - -var getWithDefault = Belt_internalMapInt.getWithDefault; - -var getExn = Belt_internalMapInt.getExn; - -var checkInvariantInternal = Belt_internalAVLtree.checkInvariantInternal; - -var mergeU = Belt_internalMapInt.mergeU; - -var merge = Belt_internalMapInt.merge; - -var keepU = Belt_internalAVLtree.keepSharedU; - -var keep = Belt_internalAVLtree.keepShared; - -var partitionU = Belt_internalAVLtree.partitionSharedU; - -var partition = Belt_internalAVLtree.partitionShared; - -var split = Belt_internalMapInt.split; - -var mapU = Belt_internalAVLtree.mapU; - -var map = Belt_internalAVLtree.map; - -var mapWithKeyU = Belt_internalAVLtree.mapWithKeyU; - -var mapWithKey = Belt_internalAVLtree.mapWithKey; - -exports.empty = empty; -exports.isEmpty = isEmpty; -exports.has = has; -exports.cmpU = cmpU; -exports.cmp = cmp; -exports.eqU = eqU; -exports.eq = eq; -exports.findFirstByU = findFirstByU; -exports.findFirstBy = findFirstBy; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.size = size; -exports.toList = toList; -exports.toArray = toArray; -exports.fromArray = fromArray; -exports.keysToArray = keysToArray; -exports.valuesToArray = valuesToArray; -exports.minKey = minKey; -exports.minKeyUndefined = minKeyUndefined; -exports.maxKey = maxKey; -exports.maxKeyUndefined = maxKeyUndefined; -exports.minimum = minimum; -exports.minUndefined = minUndefined; -exports.maximum = maximum; -exports.maxUndefined = maxUndefined; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getWithDefault = getWithDefault; -exports.getExn = getExn; -exports.checkInvariantInternal = checkInvariantInternal; -exports.remove = remove; -exports.removeMany = removeMany; -exports.set = set; -exports.updateU = updateU; -exports.update = update; -exports.mergeU = mergeU; -exports.merge = merge; -exports.mergeMany = mergeMany; -exports.keepU = keepU; -exports.keep = keep; -exports.partitionU = partitionU; -exports.partition = partition; -exports.split = split; -exports.mapU = mapU; -exports.map = map; -exports.mapWithKeyU = mapWithKeyU; -exports.mapWithKey = mapWithKey; -/* No side effect */ diff --git a/lib/js/belt_MapString.js b/lib/js/belt_MapString.js deleted file mode 100644 index aac72f88229..00000000000 --- a/lib/js/belt_MapString.js +++ /dev/null @@ -1,305 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Caml_option = require("./caml_option.js"); -var Belt_internalAVLtree = require("./belt_internalAVLtree.js"); -var Belt_internalMapString = require("./belt_internalMapString.js"); - -function set(t, newK, newD) { - if (t === undefined) { - return Belt_internalAVLtree.singleton(newK, newD); - } - var k = t.k; - if (newK === k) { - return Belt_internalAVLtree.updateValue(t, newD); - } - var v = t.v; - if (newK < k) { - return Belt_internalAVLtree.bal(set(t.l, newK, newD), k, v, t.r); - } else { - return Belt_internalAVLtree.bal(t.l, k, v, set(t.r, newK, newD)); - } -} - -function updateU(t, x, f) { - if (t !== undefined) { - var k = t.k; - if (x === k) { - var data = f(Caml_option.some(t.v)); - if (data !== undefined) { - return Belt_internalAVLtree.updateValue(t, Caml_option.valFromOption(data)); - } - var l = t.l; - var r = t.r; - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var kr = { - contents: r.k - }; - var vr = { - contents: r.v - }; - var r$1 = Belt_internalAVLtree.removeMinAuxWithRef(r, kr, vr); - return Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); - } - var v = t.v; - var l$1 = t.l; - var r$2 = t.r; - if (x < k) { - var ll = updateU(l$1, x, f); - if (l$1 === ll) { - return t; - } else { - return Belt_internalAVLtree.bal(ll, k, v, r$2); - } - } - var rr = updateU(r$2, x, f); - if (r$2 === rr) { - return t; - } else { - return Belt_internalAVLtree.bal(l$1, k, v, rr); - } - } - var data$1 = f(undefined); - if (data$1 !== undefined) { - return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); - } else { - return t; - } -} - -function update(t, x, f) { - return updateU(t, x, Curry.__1(f)); -} - -function removeAux(n, x) { - var v = n.k; - var l = n.l; - var r = n.r; - if (x === v) { - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var kr = { - contents: r.k - }; - var vr = { - contents: r.v - }; - var r$1 = Belt_internalAVLtree.removeMinAuxWithRef(r, kr, vr); - return Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); - } - if (x < v) { - if (l === undefined) { - return n; - } - var ll = removeAux(l, x); - if (ll === l) { - return n; - } else { - return Belt_internalAVLtree.bal(ll, v, n.v, r); - } - } - if (r === undefined) { - return n; - } - var rr = removeAux(r, x); - return Belt_internalAVLtree.bal(l, v, n.v, rr); -} - -function remove(n, x) { - if (n !== undefined) { - return removeAux(n, x); - } - -} - -function removeMany(t, keys) { - var len = keys.length; - if (t !== undefined) { - var _t = t; - var _i = 0; - while(true) { - var i = _i; - var t$1 = _t; - if (i >= len) { - return t$1; - } - var ele = keys[i]; - var u = removeAux(t$1, ele); - if (u === undefined) { - return u; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; - } - -} - -function mergeMany(h, arr) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var match = arr[i]; - v = set(v, match[0], match[1]); - } - return v; -} - -var empty; - -var isEmpty = Belt_internalAVLtree.isEmpty; - -var has = Belt_internalMapString.has; - -var cmpU = Belt_internalMapString.cmpU; - -var cmp = Belt_internalMapString.cmp; - -var eqU = Belt_internalMapString.eqU; - -var eq = Belt_internalMapString.eq; - -var findFirstByU = Belt_internalAVLtree.findFirstByU; - -var findFirstBy = Belt_internalAVLtree.findFirstBy; - -var forEachU = Belt_internalAVLtree.forEachU; - -var forEach = Belt_internalAVLtree.forEach; - -var reduceU = Belt_internalAVLtree.reduceU; - -var reduce = Belt_internalAVLtree.reduce; - -var everyU = Belt_internalAVLtree.everyU; - -var every = Belt_internalAVLtree.every; - -var someU = Belt_internalAVLtree.someU; - -var some = Belt_internalAVLtree.some; - -var size = Belt_internalAVLtree.size; - -var toList = Belt_internalAVLtree.toList; - -var toArray = Belt_internalAVLtree.toArray; - -var fromArray = Belt_internalMapString.fromArray; - -var keysToArray = Belt_internalAVLtree.keysToArray; - -var valuesToArray = Belt_internalAVLtree.valuesToArray; - -var minKey = Belt_internalAVLtree.minKey; - -var minKeyUndefined = Belt_internalAVLtree.minKeyUndefined; - -var maxKey = Belt_internalAVLtree.maxKey; - -var maxKeyUndefined = Belt_internalAVLtree.maxKeyUndefined; - -var minimum = Belt_internalAVLtree.minimum; - -var minUndefined = Belt_internalAVLtree.minUndefined; - -var maximum = Belt_internalAVLtree.maximum; - -var maxUndefined = Belt_internalAVLtree.maxUndefined; - -var get = Belt_internalMapString.get; - -var getUndefined = Belt_internalMapString.getUndefined; - -var getWithDefault = Belt_internalMapString.getWithDefault; - -var getExn = Belt_internalMapString.getExn; - -var checkInvariantInternal = Belt_internalAVLtree.checkInvariantInternal; - -var mergeU = Belt_internalMapString.mergeU; - -var merge = Belt_internalMapString.merge; - -var keepU = Belt_internalAVLtree.keepSharedU; - -var keep = Belt_internalAVLtree.keepShared; - -var partitionU = Belt_internalAVLtree.partitionSharedU; - -var partition = Belt_internalAVLtree.partitionShared; - -var split = Belt_internalMapString.split; - -var mapU = Belt_internalAVLtree.mapU; - -var map = Belt_internalAVLtree.map; - -var mapWithKeyU = Belt_internalAVLtree.mapWithKeyU; - -var mapWithKey = Belt_internalAVLtree.mapWithKey; - -exports.empty = empty; -exports.isEmpty = isEmpty; -exports.has = has; -exports.cmpU = cmpU; -exports.cmp = cmp; -exports.eqU = eqU; -exports.eq = eq; -exports.findFirstByU = findFirstByU; -exports.findFirstBy = findFirstBy; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.size = size; -exports.toList = toList; -exports.toArray = toArray; -exports.fromArray = fromArray; -exports.keysToArray = keysToArray; -exports.valuesToArray = valuesToArray; -exports.minKey = minKey; -exports.minKeyUndefined = minKeyUndefined; -exports.maxKey = maxKey; -exports.maxKeyUndefined = maxKeyUndefined; -exports.minimum = minimum; -exports.minUndefined = minUndefined; -exports.maximum = maximum; -exports.maxUndefined = maxUndefined; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getWithDefault = getWithDefault; -exports.getExn = getExn; -exports.checkInvariantInternal = checkInvariantInternal; -exports.remove = remove; -exports.removeMany = removeMany; -exports.set = set; -exports.updateU = updateU; -exports.update = update; -exports.mergeU = mergeU; -exports.merge = merge; -exports.mergeMany = mergeMany; -exports.keepU = keepU; -exports.keep = keep; -exports.partitionU = partitionU; -exports.partition = partition; -exports.split = split; -exports.mapU = mapU; -exports.map = map; -exports.mapWithKeyU = mapWithKeyU; -exports.mapWithKey = mapWithKey; -/* No side effect */ diff --git a/lib/js/belt_MutableMap.js b/lib/js/belt_MutableMap.js deleted file mode 100644 index fd49cf330d9..00000000000 --- a/lib/js/belt_MutableMap.js +++ /dev/null @@ -1,393 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Caml_option = require("./caml_option.js"); -var Belt_internalAVLtree = require("./belt_internalAVLtree.js"); - -function removeMutateAux(nt, x, cmp) { - var k = nt.k; - var c = cmp(x, k); - if (c === 0) { - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLtree.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLtree.balMutate(nt); - } else { - return l; - } - } else if (r !== undefined) { - return r; - } else { - return l; - } - } - if (c < 0) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = removeMutateAux(l$1, x, cmp); - return Belt_internalAVLtree.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = removeMutateAux(r$1, x, cmp); - return Belt_internalAVLtree.balMutate(nt); - } else { - return nt; - } -} - -function remove(d, k) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var newRoot = removeMutateAux(oldRoot, k, d.cmp); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function removeArrayMutateAux(_t, xs, _i, len, cmp) { - while(true) { - var i = _i; - var t = _t; - if (i >= len) { - return t; - } - var ele = xs[i]; - var u = removeMutateAux(t, ele, cmp); - if (u === undefined) { - return ; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; -} - -function removeMany(d, xs) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var len = xs.length; - var newRoot = removeArrayMutateAux(oldRoot, xs, 0, len, d.cmp); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function updateDone(t, x, f, cmp) { - if (t !== undefined) { - var k = t.k; - var c = cmp(x, k); - if (c === 0) { - var data = f(Caml_option.some(t.v)); - if (data !== undefined) { - t.v = Caml_option.valFromOption(data); - return t; - } - var l = t.l; - var r = t.r; - if (l !== undefined) { - if (r !== undefined) { - t.r = Belt_internalAVLtree.removeMinAuxWithRootMutate(t, r); - return Belt_internalAVLtree.balMutate(t); - } else { - return l; - } - } else if (r !== undefined) { - return r; - } else { - return l; - } - } - if (c < 0) { - t.l = updateDone(t.l, x, f, cmp); - } else { - t.r = updateDone(t.r, x, f, cmp); - } - return Belt_internalAVLtree.balMutate(t); - } - var data$1 = f(undefined); - if (data$1 !== undefined) { - return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); - } else { - return t; - } -} - -function updateU(t, x, f) { - var oldRoot = t.data; - var newRoot = updateDone(oldRoot, x, f, t.cmp); - if (newRoot !== oldRoot) { - t.data = newRoot; - return ; - } - -} - -function update(t, x, f) { - updateU(t, x, Curry.__1(f)); -} - -function make(id) { - return { - cmp: id.cmp, - data: undefined - }; -} - -function clear(m) { - m.data = undefined; -} - -function isEmpty(d) { - var x = d.data; - return x === undefined; -} - -function minKey(m) { - return Belt_internalAVLtree.minKey(m.data); -} - -function minKeyUndefined(m) { - return Belt_internalAVLtree.minKeyUndefined(m.data); -} - -function maxKey(m) { - return Belt_internalAVLtree.maxKey(m.data); -} - -function maxKeyUndefined(m) { - return Belt_internalAVLtree.maxKeyUndefined(m.data); -} - -function minimum(m) { - return Belt_internalAVLtree.minimum(m.data); -} - -function minUndefined(m) { - return Belt_internalAVLtree.minUndefined(m.data); -} - -function maximum(m) { - return Belt_internalAVLtree.maximum(m.data); -} - -function maxUndefined(m) { - return Belt_internalAVLtree.maxUndefined(m.data); -} - -function forEachU(d, f) { - Belt_internalAVLtree.forEachU(d.data, f); -} - -function forEach(d, f) { - Belt_internalAVLtree.forEachU(d.data, Curry.__2(f)); -} - -function reduceU(d, acc, cb) { - return Belt_internalAVLtree.reduceU(d.data, acc, cb); -} - -function reduce(d, acc, cb) { - return reduceU(d, acc, Curry.__3(cb)); -} - -function everyU(d, p) { - return Belt_internalAVLtree.everyU(d.data, p); -} - -function every(d, p) { - return Belt_internalAVLtree.everyU(d.data, Curry.__2(p)); -} - -function someU(d, p) { - return Belt_internalAVLtree.someU(d.data, p); -} - -function some(d, p) { - return Belt_internalAVLtree.someU(d.data, Curry.__2(p)); -} - -function size(d) { - return Belt_internalAVLtree.size(d.data); -} - -function toList(d) { - return Belt_internalAVLtree.toList(d.data); -} - -function toArray(d) { - return Belt_internalAVLtree.toArray(d.data); -} - -function keysToArray(d) { - return Belt_internalAVLtree.keysToArray(d.data); -} - -function valuesToArray(d) { - return Belt_internalAVLtree.valuesToArray(d.data); -} - -function checkInvariantInternal(d) { - Belt_internalAVLtree.checkInvariantInternal(d.data); -} - -function cmpU(m1, m2, cmp) { - return Belt_internalAVLtree.cmpU(m1.data, m2.data, m1.cmp, cmp); -} - -function cmp(m1, m2, cmp$1) { - return cmpU(m1, m2, Curry.__2(cmp$1)); -} - -function eqU(m1, m2, cmp) { - return Belt_internalAVLtree.eqU(m1.data, m2.data, m1.cmp, cmp); -} - -function eq(m1, m2, cmp) { - return eqU(m1, m2, Curry.__2(cmp)); -} - -function mapU(m, f) { - return { - cmp: m.cmp, - data: Belt_internalAVLtree.mapU(m.data, f) - }; -} - -function map(m, f) { - return mapU(m, Curry.__1(f)); -} - -function mapWithKeyU(m, f) { - return { - cmp: m.cmp, - data: Belt_internalAVLtree.mapWithKeyU(m.data, f) - }; -} - -function mapWithKey(m, f) { - return mapWithKeyU(m, Curry.__2(f)); -} - -function get(m, x) { - return Belt_internalAVLtree.get(m.data, x, m.cmp); -} - -function getUndefined(m, x) { - return Belt_internalAVLtree.getUndefined(m.data, x, m.cmp); -} - -function getWithDefault(m, x, def) { - return Belt_internalAVLtree.getWithDefault(m.data, x, def, m.cmp); -} - -function getExn(m, x) { - return Belt_internalAVLtree.getExn(m.data, x, m.cmp); -} - -function has(m, x) { - return Belt_internalAVLtree.has(m.data, x, m.cmp); -} - -function fromArray(data, id) { - var cmp = id.cmp; - return { - cmp: cmp, - data: Belt_internalAVLtree.fromArray(data, cmp) - }; -} - -function set(m, e, v) { - var oldRoot = m.data; - var newRoot = Belt_internalAVLtree.updateMutate(oldRoot, e, v, m.cmp); - if (newRoot !== oldRoot) { - m.data = newRoot; - return ; - } - -} - -function mergeManyAux(t, xs, cmp) { - var v = t; - for(var i = 0 ,i_finish = xs.length; i < i_finish; ++i){ - var match = xs[i]; - v = Belt_internalAVLtree.updateMutate(v, match[0], match[1], cmp); - } - return v; -} - -function mergeMany(d, xs) { - var oldRoot = d.data; - var newRoot = mergeManyAux(oldRoot, xs, d.cmp); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -var Int; - -var $$String; - -exports.Int = Int; -exports.$$String = $$String; -exports.make = make; -exports.clear = clear; -exports.isEmpty = isEmpty; -exports.has = has; -exports.cmpU = cmpU; -exports.cmp = cmp; -exports.eqU = eqU; -exports.eq = eq; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.size = size; -exports.toList = toList; -exports.toArray = toArray; -exports.fromArray = fromArray; -exports.keysToArray = keysToArray; -exports.valuesToArray = valuesToArray; -exports.minKey = minKey; -exports.minKeyUndefined = minKeyUndefined; -exports.maxKey = maxKey; -exports.maxKeyUndefined = maxKeyUndefined; -exports.minimum = minimum; -exports.minUndefined = minUndefined; -exports.maximum = maximum; -exports.maxUndefined = maxUndefined; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getWithDefault = getWithDefault; -exports.getExn = getExn; -exports.checkInvariantInternal = checkInvariantInternal; -exports.remove = remove; -exports.removeMany = removeMany; -exports.set = set; -exports.updateU = updateU; -exports.update = update; -exports.mergeMany = mergeMany; -exports.mapU = mapU; -exports.map = map; -exports.mapWithKeyU = mapWithKeyU; -exports.mapWithKey = mapWithKey; -/* No side effect */ diff --git a/lib/js/belt_MutableMapInt.js b/lib/js/belt_MutableMapInt.js deleted file mode 100644 index b1f05685eef..00000000000 --- a/lib/js/belt_MutableMapInt.js +++ /dev/null @@ -1,360 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Caml_option = require("./caml_option.js"); -var Belt_internalMapInt = require("./belt_internalMapInt.js"); -var Belt_internalAVLtree = require("./belt_internalAVLtree.js"); - -function make(param) { - return { - data: undefined - }; -} - -function isEmpty(m) { - var x = m.data; - return x === undefined; -} - -function clear(m) { - m.data = undefined; -} - -function minKeyUndefined(m) { - return Belt_internalAVLtree.minKeyUndefined(m.data); -} - -function minKey(m) { - return Belt_internalAVLtree.minKey(m.data); -} - -function maxKeyUndefined(m) { - return Belt_internalAVLtree.maxKeyUndefined(m.data); -} - -function maxKey(m) { - return Belt_internalAVLtree.maxKey(m.data); -} - -function minimum(m) { - return Belt_internalAVLtree.minimum(m.data); -} - -function minUndefined(m) { - return Belt_internalAVLtree.minUndefined(m.data); -} - -function maximum(m) { - return Belt_internalAVLtree.maximum(m.data); -} - -function maxUndefined(m) { - return Belt_internalAVLtree.maxUndefined(m.data); -} - -function set(m, k, v) { - var old_data = m.data; - var v$1 = Belt_internalMapInt.addMutate(old_data, k, v); - if (v$1 !== old_data) { - m.data = v$1; - return ; - } - -} - -function forEachU(d, f) { - Belt_internalAVLtree.forEachU(d.data, f); -} - -function forEach(d, f) { - Belt_internalAVLtree.forEachU(d.data, Curry.__2(f)); -} - -function mapU(d, f) { - return { - data: Belt_internalAVLtree.mapU(d.data, f) - }; -} - -function map(d, f) { - return mapU(d, Curry.__1(f)); -} - -function mapWithKeyU(d, f) { - return { - data: Belt_internalAVLtree.mapWithKeyU(d.data, f) - }; -} - -function mapWithKey(d, f) { - return mapWithKeyU(d, Curry.__2(f)); -} - -function reduceU(d, acc, f) { - return Belt_internalAVLtree.reduceU(d.data, acc, f); -} - -function reduce(d, acc, f) { - return reduceU(d, acc, Curry.__3(f)); -} - -function everyU(d, f) { - return Belt_internalAVLtree.everyU(d.data, f); -} - -function every(d, f) { - return Belt_internalAVLtree.everyU(d.data, Curry.__2(f)); -} - -function someU(d, f) { - return Belt_internalAVLtree.someU(d.data, f); -} - -function some(d, f) { - return Belt_internalAVLtree.someU(d.data, Curry.__2(f)); -} - -function size(d) { - return Belt_internalAVLtree.size(d.data); -} - -function toList(d) { - return Belt_internalAVLtree.toList(d.data); -} - -function toArray(d) { - return Belt_internalAVLtree.toArray(d.data); -} - -function keysToArray(d) { - return Belt_internalAVLtree.keysToArray(d.data); -} - -function valuesToArray(d) { - return Belt_internalAVLtree.valuesToArray(d.data); -} - -function checkInvariantInternal(d) { - Belt_internalAVLtree.checkInvariantInternal(d.data); -} - -function has(d, v) { - return Belt_internalMapInt.has(d.data, v); -} - -function removeMutateAux(nt, x) { - var k = nt.k; - if (x === k) { - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLtree.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLtree.balMutate(nt); - } else { - return l; - } - } else { - return r; - } - } - if (x < k) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = removeMutateAux(l$1, x); - return Belt_internalAVLtree.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = removeMutateAux(r$1, x); - return Belt_internalAVLtree.balMutate(nt); - } else { - return nt; - } -} - -function remove(d, v) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var newRoot = removeMutateAux(oldRoot, v); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function updateDone(t, x, f) { - if (t !== undefined) { - var k = t.k; - if (k === x) { - var data = f(Caml_option.some(t.v)); - if (data !== undefined) { - t.v = Caml_option.valFromOption(data); - return t; - } - var l = t.l; - var r = t.r; - if (l !== undefined) { - if (r !== undefined) { - t.r = Belt_internalAVLtree.removeMinAuxWithRootMutate(t, r); - return Belt_internalAVLtree.balMutate(t); - } else { - return l; - } - } else { - return r; - } - } - var l$1 = t.l; - var r$1 = t.r; - if (x < k) { - var ll = updateDone(l$1, x, f); - t.l = ll; - } else { - t.r = updateDone(r$1, x, f); - } - return Belt_internalAVLtree.balMutate(t); - } - var data$1 = f(undefined); - if (data$1 !== undefined) { - return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); - } else { - return t; - } -} - -function updateU(t, x, f) { - var oldRoot = t.data; - var newRoot = updateDone(oldRoot, x, f); - if (newRoot !== oldRoot) { - t.data = newRoot; - return ; - } - -} - -function update(t, x, f) { - updateU(t, x, Curry.__1(f)); -} - -function removeArrayMutateAux(_t, xs, _i, len) { - while(true) { - var i = _i; - var t = _t; - if (i >= len) { - return t; - } - var ele = xs[i]; - var u = removeMutateAux(t, ele); - if (u === undefined) { - return ; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; -} - -function removeMany(d, xs) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var len = xs.length; - var newRoot = removeArrayMutateAux(oldRoot, xs, 0, len); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function fromArray(xs) { - return { - data: Belt_internalMapInt.fromArray(xs) - }; -} - -function cmpU(d0, d1, f) { - return Belt_internalMapInt.cmpU(d0.data, d1.data, f); -} - -function cmp(d0, d1, f) { - return cmpU(d0, d1, Curry.__2(f)); -} - -function eqU(d0, d1, f) { - return Belt_internalMapInt.eqU(d0.data, d1.data, f); -} - -function eq(d0, d1, f) { - return eqU(d0, d1, Curry.__2(f)); -} - -function get(d, x) { - return Belt_internalMapInt.get(d.data, x); -} - -function getUndefined(d, x) { - return Belt_internalMapInt.getUndefined(d.data, x); -} - -function getWithDefault(d, x, def) { - return Belt_internalMapInt.getWithDefault(d.data, x, def); -} - -function getExn(d, x) { - return Belt_internalMapInt.getExn(d.data, x); -} - -exports.make = make; -exports.clear = clear; -exports.isEmpty = isEmpty; -exports.has = has; -exports.cmpU = cmpU; -exports.cmp = cmp; -exports.eqU = eqU; -exports.eq = eq; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.size = size; -exports.toList = toList; -exports.toArray = toArray; -exports.fromArray = fromArray; -exports.keysToArray = keysToArray; -exports.valuesToArray = valuesToArray; -exports.minKey = minKey; -exports.minKeyUndefined = minKeyUndefined; -exports.maxKey = maxKey; -exports.maxKeyUndefined = maxKeyUndefined; -exports.minimum = minimum; -exports.minUndefined = minUndefined; -exports.maximum = maximum; -exports.maxUndefined = maxUndefined; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getWithDefault = getWithDefault; -exports.getExn = getExn; -exports.checkInvariantInternal = checkInvariantInternal; -exports.remove = remove; -exports.removeMany = removeMany; -exports.set = set; -exports.updateU = updateU; -exports.update = update; -exports.mapU = mapU; -exports.map = map; -exports.mapWithKeyU = mapWithKeyU; -exports.mapWithKey = mapWithKey; -/* No side effect */ diff --git a/lib/js/belt_MutableMapString.js b/lib/js/belt_MutableMapString.js deleted file mode 100644 index 372ad595748..00000000000 --- a/lib/js/belt_MutableMapString.js +++ /dev/null @@ -1,360 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Caml_option = require("./caml_option.js"); -var Belt_internalAVLtree = require("./belt_internalAVLtree.js"); -var Belt_internalMapString = require("./belt_internalMapString.js"); - -function make(param) { - return { - data: undefined - }; -} - -function isEmpty(m) { - var x = m.data; - return x === undefined; -} - -function clear(m) { - m.data = undefined; -} - -function minKeyUndefined(m) { - return Belt_internalAVLtree.minKeyUndefined(m.data); -} - -function minKey(m) { - return Belt_internalAVLtree.minKey(m.data); -} - -function maxKeyUndefined(m) { - return Belt_internalAVLtree.maxKeyUndefined(m.data); -} - -function maxKey(m) { - return Belt_internalAVLtree.maxKey(m.data); -} - -function minimum(m) { - return Belt_internalAVLtree.minimum(m.data); -} - -function minUndefined(m) { - return Belt_internalAVLtree.minUndefined(m.data); -} - -function maximum(m) { - return Belt_internalAVLtree.maximum(m.data); -} - -function maxUndefined(m) { - return Belt_internalAVLtree.maxUndefined(m.data); -} - -function set(m, k, v) { - var old_data = m.data; - var v$1 = Belt_internalMapString.addMutate(old_data, k, v); - if (v$1 !== old_data) { - m.data = v$1; - return ; - } - -} - -function forEachU(d, f) { - Belt_internalAVLtree.forEachU(d.data, f); -} - -function forEach(d, f) { - Belt_internalAVLtree.forEachU(d.data, Curry.__2(f)); -} - -function mapU(d, f) { - return { - data: Belt_internalAVLtree.mapU(d.data, f) - }; -} - -function map(d, f) { - return mapU(d, Curry.__1(f)); -} - -function mapWithKeyU(d, f) { - return { - data: Belt_internalAVLtree.mapWithKeyU(d.data, f) - }; -} - -function mapWithKey(d, f) { - return mapWithKeyU(d, Curry.__2(f)); -} - -function reduceU(d, acc, f) { - return Belt_internalAVLtree.reduceU(d.data, acc, f); -} - -function reduce(d, acc, f) { - return reduceU(d, acc, Curry.__3(f)); -} - -function everyU(d, f) { - return Belt_internalAVLtree.everyU(d.data, f); -} - -function every(d, f) { - return Belt_internalAVLtree.everyU(d.data, Curry.__2(f)); -} - -function someU(d, f) { - return Belt_internalAVLtree.someU(d.data, f); -} - -function some(d, f) { - return Belt_internalAVLtree.someU(d.data, Curry.__2(f)); -} - -function size(d) { - return Belt_internalAVLtree.size(d.data); -} - -function toList(d) { - return Belt_internalAVLtree.toList(d.data); -} - -function toArray(d) { - return Belt_internalAVLtree.toArray(d.data); -} - -function keysToArray(d) { - return Belt_internalAVLtree.keysToArray(d.data); -} - -function valuesToArray(d) { - return Belt_internalAVLtree.valuesToArray(d.data); -} - -function checkInvariantInternal(d) { - Belt_internalAVLtree.checkInvariantInternal(d.data); -} - -function has(d, v) { - return Belt_internalMapString.has(d.data, v); -} - -function removeMutateAux(nt, x) { - var k = nt.k; - if (x === k) { - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLtree.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLtree.balMutate(nt); - } else { - return l; - } - } else { - return r; - } - } - if (x < k) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = removeMutateAux(l$1, x); - return Belt_internalAVLtree.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = removeMutateAux(r$1, x); - return Belt_internalAVLtree.balMutate(nt); - } else { - return nt; - } -} - -function remove(d, v) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var newRoot = removeMutateAux(oldRoot, v); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function updateDone(t, x, f) { - if (t !== undefined) { - var k = t.k; - if (k === x) { - var data = f(Caml_option.some(t.v)); - if (data !== undefined) { - t.v = Caml_option.valFromOption(data); - return t; - } - var l = t.l; - var r = t.r; - if (l !== undefined) { - if (r !== undefined) { - t.r = Belt_internalAVLtree.removeMinAuxWithRootMutate(t, r); - return Belt_internalAVLtree.balMutate(t); - } else { - return l; - } - } else { - return r; - } - } - var l$1 = t.l; - var r$1 = t.r; - if (x < k) { - var ll = updateDone(l$1, x, f); - t.l = ll; - } else { - t.r = updateDone(r$1, x, f); - } - return Belt_internalAVLtree.balMutate(t); - } - var data$1 = f(undefined); - if (data$1 !== undefined) { - return Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); - } else { - return t; - } -} - -function updateU(t, x, f) { - var oldRoot = t.data; - var newRoot = updateDone(oldRoot, x, f); - if (newRoot !== oldRoot) { - t.data = newRoot; - return ; - } - -} - -function update(t, x, f) { - updateU(t, x, Curry.__1(f)); -} - -function removeArrayMutateAux(_t, xs, _i, len) { - while(true) { - var i = _i; - var t = _t; - if (i >= len) { - return t; - } - var ele = xs[i]; - var u = removeMutateAux(t, ele); - if (u === undefined) { - return ; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; -} - -function removeMany(d, xs) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var len = xs.length; - var newRoot = removeArrayMutateAux(oldRoot, xs, 0, len); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function fromArray(xs) { - return { - data: Belt_internalMapString.fromArray(xs) - }; -} - -function cmpU(d0, d1, f) { - return Belt_internalMapString.cmpU(d0.data, d1.data, f); -} - -function cmp(d0, d1, f) { - return cmpU(d0, d1, Curry.__2(f)); -} - -function eqU(d0, d1, f) { - return Belt_internalMapString.eqU(d0.data, d1.data, f); -} - -function eq(d0, d1, f) { - return eqU(d0, d1, Curry.__2(f)); -} - -function get(d, x) { - return Belt_internalMapString.get(d.data, x); -} - -function getUndefined(d, x) { - return Belt_internalMapString.getUndefined(d.data, x); -} - -function getWithDefault(d, x, def) { - return Belt_internalMapString.getWithDefault(d.data, x, def); -} - -function getExn(d, x) { - return Belt_internalMapString.getExn(d.data, x); -} - -exports.make = make; -exports.clear = clear; -exports.isEmpty = isEmpty; -exports.has = has; -exports.cmpU = cmpU; -exports.cmp = cmp; -exports.eqU = eqU; -exports.eq = eq; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.size = size; -exports.toList = toList; -exports.toArray = toArray; -exports.fromArray = fromArray; -exports.keysToArray = keysToArray; -exports.valuesToArray = valuesToArray; -exports.minKey = minKey; -exports.minKeyUndefined = minKeyUndefined; -exports.maxKey = maxKey; -exports.maxKeyUndefined = maxKeyUndefined; -exports.minimum = minimum; -exports.minUndefined = minUndefined; -exports.maximum = maximum; -exports.maxUndefined = maxUndefined; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getWithDefault = getWithDefault; -exports.getExn = getExn; -exports.checkInvariantInternal = checkInvariantInternal; -exports.remove = remove; -exports.removeMany = removeMany; -exports.set = set; -exports.updateU = updateU; -exports.update = update; -exports.mapU = mapU; -exports.map = map; -exports.mapWithKeyU = mapWithKeyU; -exports.mapWithKey = mapWithKey; -/* No side effect */ diff --git a/lib/js/belt_MutableQueue.js b/lib/js/belt_MutableQueue.js deleted file mode 100644 index a5b8e2fcf8b..00000000000 --- a/lib/js/belt_MutableQueue.js +++ /dev/null @@ -1,297 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Caml_option = require("./caml_option.js"); - -function make(param) { - return { - length: 0, - first: undefined, - last: undefined - }; -} - -function clear(q) { - q.length = 0; - q.first = undefined; - q.last = undefined; -} - -function add(q, x) { - var cell = { - content: x, - next: undefined - }; - var last = q.last; - if (last !== undefined) { - q.length = q.length + 1 | 0; - last.next = cell; - q.last = cell; - } else { - q.length = 1; - q.first = cell; - q.last = cell; - } -} - -function peek(q) { - var v = q.first; - if (v !== undefined) { - return Caml_option.some(v.content); - } - -} - -function peekUndefined(q) { - var v = q.first; - if (v !== undefined) { - return v.content; - } - -} - -function peekExn(q) { - var v = q.first; - if (v !== undefined) { - return v.content; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -function pop(q) { - var x = q.first; - if (x === undefined) { - return ; - } - var next = x.next; - if (next === undefined) { - clear(q); - return Caml_option.some(x.content); - } else { - q.length = q.length - 1 | 0; - q.first = next; - return Caml_option.some(x.content); - } -} - -function popExn(q) { - var x = q.first; - if (x !== undefined) { - var next = x.next; - if (next === undefined) { - clear(q); - return x.content; - } else { - q.length = q.length - 1 | 0; - q.first = next; - return x.content; - } - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -function popUndefined(q) { - var x = q.first; - if (x === undefined) { - return ; - } - var next = x.next; - if (next === undefined) { - clear(q); - return x.content; - } else { - q.length = q.length - 1 | 0; - q.first = next; - return x.content; - } -} - -function copy(q) { - var qRes = { - length: q.length, - first: undefined, - last: undefined - }; - var _prev; - var _cell = q.first; - while(true) { - var cell = _cell; - var prev = _prev; - if (cell !== undefined) { - var content = cell.content; - var res = { - content: content, - next: undefined - }; - if (prev !== undefined) { - prev.next = res; - } else { - qRes.first = res; - } - _cell = cell.next; - _prev = res; - continue ; - } - qRes.last = prev; - return qRes; - }; -} - -function mapU(q, f) { - var qRes = { - length: q.length, - first: undefined, - last: undefined - }; - var _prev; - var _cell = q.first; - while(true) { - var cell = _cell; - var prev = _prev; - if (cell !== undefined) { - var content = f(cell.content); - var res = { - content: content, - next: undefined - }; - if (prev !== undefined) { - prev.next = res; - } else { - qRes.first = res; - } - _cell = cell.next; - _prev = res; - continue ; - } - qRes.last = prev; - return qRes; - }; -} - -function map(q, f) { - return mapU(q, Curry.__1(f)); -} - -function isEmpty(q) { - return q.length === 0; -} - -function size(q) { - return q.length; -} - -function forEachU(q, f) { - var _cell = q.first; - while(true) { - var cell = _cell; - if (cell === undefined) { - return ; - } - f(cell.content); - _cell = cell.next; - continue ; - }; -} - -function forEach(q, f) { - forEachU(q, Curry.__1(f)); -} - -function reduceU(q, accu, f) { - var _accu = accu; - var _cell = q.first; - while(true) { - var cell = _cell; - var accu$1 = _accu; - if (cell === undefined) { - return accu$1; - } - var accu$2 = f(accu$1, cell.content); - _cell = cell.next; - _accu = accu$2; - continue ; - }; -} - -function reduce(q, accu, f) { - return reduceU(q, accu, Curry.__2(f)); -} - -function transfer(q1, q2) { - if (q1.length <= 0) { - return ; - } - var l = q2.last; - if (l !== undefined) { - q2.length = q2.length + q1.length | 0; - l.next = q1.first; - q2.last = q1.last; - return clear(q1); - } else { - q2.length = q1.length; - q2.first = q1.first; - q2.last = q1.last; - return clear(q1); - } -} - -function fillAux(_i, arr, _cell) { - while(true) { - var cell = _cell; - var i = _i; - if (cell === undefined) { - return ; - } - arr[i] = cell.content; - _cell = cell.next; - _i = i + 1 | 0; - continue ; - }; -} - -function toArray(x) { - var v = new Array(x.length); - fillAux(0, v, x.first); - return v; -} - -function fromArray(arr) { - var q = { - length: 0, - first: undefined, - last: undefined - }; - for(var i = 0 ,i_finish = arr.length; i < i_finish; ++i){ - add(q, arr[i]); - } - return q; -} - -exports.make = make; -exports.clear = clear; -exports.isEmpty = isEmpty; -exports.fromArray = fromArray; -exports.add = add; -exports.peek = peek; -exports.peekUndefined = peekUndefined; -exports.peekExn = peekExn; -exports.pop = pop; -exports.popUndefined = popUndefined; -exports.popExn = popExn; -exports.copy = copy; -exports.size = size; -exports.mapU = mapU; -exports.map = map; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.transfer = transfer; -exports.toArray = toArray; -/* No side effect */ diff --git a/lib/js/belt_MutableSet.js b/lib/js/belt_MutableSet.js deleted file mode 100644 index ef52cc621fd..00000000000 --- a/lib/js/belt_MutableSet.js +++ /dev/null @@ -1,536 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Belt_SortArray = require("./belt_SortArray.js"); -var Belt_internalAVLset = require("./belt_internalAVLset.js"); - -function remove0(nt, x, cmp) { - var k = nt.v; - var c = cmp(x, k); - if (c === 0) { - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLset.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLset.balMutate(nt); - } else { - return l; - } - } else { - return r; - } - } - if (c < 0) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = remove0(l$1, x, cmp); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = remove0(r$1, x, cmp); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } -} - -function remove(d, v) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var newRoot = remove0(oldRoot, v, d.cmp); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function removeMany0(_t, xs, _i, len, cmp) { - while(true) { - var i = _i; - var t = _t; - if (i >= len) { - return t; - } - var ele = xs[i]; - var u = remove0(t, ele, cmp); - if (u === undefined) { - return ; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; -} - -function removeMany(d, xs) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var len = xs.length; - d.data = removeMany0(oldRoot, xs, 0, len, d.cmp); -} - -function removeCheck0(nt, x, removed, cmp) { - var k = nt.v; - var c = cmp(x, k); - if (c === 0) { - removed.contents = true; - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLset.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLset.balMutate(nt); - } else { - return l; - } - } else { - return r; - } - } - if (c < 0) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = removeCheck0(l$1, x, removed, cmp); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = removeCheck0(r$1, x, removed, cmp); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } -} - -function removeCheck(d, v) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return false; - } - var removed = { - contents: false - }; - var newRoot = removeCheck0(oldRoot, v, removed, d.cmp); - if (newRoot !== oldRoot) { - d.data = newRoot; - } - return removed.contents; -} - -function addCheck0(t, x, added, cmp) { - if (t !== undefined) { - var k = t.v; - var c = cmp(x, k); - if (c === 0) { - return t; - } - var l = t.l; - var r = t.r; - if (c < 0) { - var ll = addCheck0(l, x, added, cmp); - t.l = ll; - } else { - t.r = addCheck0(r, x, added, cmp); - } - return Belt_internalAVLset.balMutate(t); - } - added.contents = true; - return Belt_internalAVLset.singleton(x); -} - -function addCheck(m, e) { - var oldRoot = m.data; - var added = { - contents: false - }; - var newRoot = addCheck0(oldRoot, e, added, m.cmp); - if (newRoot !== oldRoot) { - m.data = newRoot; - } - return added.contents; -} - -function add(m, e) { - var oldRoot = m.data; - var newRoot = Belt_internalAVLset.addMutate(m.cmp, oldRoot, e); - if (newRoot !== oldRoot) { - m.data = newRoot; - return ; - } - -} - -function addArrayMutate(t, xs, cmp) { - var v = t; - for(var i = 0 ,i_finish = xs.length; i < i_finish; ++i){ - v = Belt_internalAVLset.addMutate(cmp, v, xs[i]); - } - return v; -} - -function mergeMany(d, xs) { - d.data = addArrayMutate(d.data, xs, d.cmp); -} - -function make(id) { - return { - cmp: id.cmp, - data: undefined - }; -} - -function isEmpty(d) { - var n = d.data; - return n === undefined; -} - -function minimum(d) { - return Belt_internalAVLset.minimum(d.data); -} - -function minUndefined(d) { - return Belt_internalAVLset.minUndefined(d.data); -} - -function maximum(d) { - return Belt_internalAVLset.maximum(d.data); -} - -function maxUndefined(d) { - return Belt_internalAVLset.maxUndefined(d.data); -} - -function forEachU(d, f) { - Belt_internalAVLset.forEachU(d.data, f); -} - -function forEach(d, f) { - Belt_internalAVLset.forEachU(d.data, Curry.__1(f)); -} - -function reduceU(d, acc, cb) { - return Belt_internalAVLset.reduceU(d.data, acc, cb); -} - -function reduce(d, acc, cb) { - return reduceU(d, acc, Curry.__2(cb)); -} - -function everyU(d, p) { - return Belt_internalAVLset.everyU(d.data, p); -} - -function every(d, p) { - return Belt_internalAVLset.everyU(d.data, Curry.__1(p)); -} - -function someU(d, p) { - return Belt_internalAVLset.someU(d.data, p); -} - -function some(d, p) { - return Belt_internalAVLset.someU(d.data, Curry.__1(p)); -} - -function size(d) { - return Belt_internalAVLset.size(d.data); -} - -function toList(d) { - return Belt_internalAVLset.toList(d.data); -} - -function toArray(d) { - return Belt_internalAVLset.toArray(d.data); -} - -function fromSortedArrayUnsafe(xs, id) { - return { - cmp: id.cmp, - data: Belt_internalAVLset.fromSortedArrayUnsafe(xs) - }; -} - -function checkInvariantInternal(d) { - Belt_internalAVLset.checkInvariantInternal(d.data); -} - -function fromArray(data, id) { - var cmp = id.cmp; - return { - cmp: cmp, - data: Belt_internalAVLset.fromArray(data, cmp) - }; -} - -function cmp(d0, d1) { - return Belt_internalAVLset.cmp(d0.data, d1.data, d0.cmp); -} - -function eq(d0, d1) { - return Belt_internalAVLset.eq(d0.data, d1.data, d0.cmp); -} - -function get(d, x) { - return Belt_internalAVLset.get(d.data, x, d.cmp); -} - -function getUndefined(d, x) { - return Belt_internalAVLset.getUndefined(d.data, x, d.cmp); -} - -function getExn(d, x) { - return Belt_internalAVLset.getExn(d.data, x, d.cmp); -} - -function split(d, key) { - var arr = Belt_internalAVLset.toArray(d.data); - var cmp = d.cmp; - var i = Belt_SortArray.binarySearchByU(arr, key, cmp); - var len = arr.length; - if (i >= 0) { - return [ - [ - { - cmp: cmp, - data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, i) - }, - { - cmp: cmp, - data: Belt_internalAVLset.fromSortedArrayAux(arr, i + 1 | 0, (len - i | 0) - 1 | 0) - } - ], - true - ]; - } - var next = (-i | 0) - 1 | 0; - return [ - [ - { - cmp: cmp, - data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, next) - }, - { - cmp: cmp, - data: Belt_internalAVLset.fromSortedArrayAux(arr, next, len - next | 0) - } - ], - false - ]; -} - -function keepU(d, p) { - return { - cmp: d.cmp, - data: Belt_internalAVLset.keepCopyU(d.data, p) - }; -} - -function keep(d, p) { - return keepU(d, Curry.__1(p)); -} - -function partitionU(d, p) { - var cmp = d.cmp; - var match = Belt_internalAVLset.partitionCopyU(d.data, p); - return [ - { - cmp: cmp, - data: match[0] - }, - { - cmp: cmp, - data: match[1] - } - ]; -} - -function partition(d, p) { - return partitionU(d, Curry.__1(p)); -} - -function subset(a, b) { - return Belt_internalAVLset.subset(a.data, b.data, a.cmp); -} - -function intersect(a, b) { - var cmp = a.cmp; - var match = a.data; - var match$1 = b.data; - if (match === undefined) { - return { - cmp: cmp, - data: undefined - }; - } - if (match$1 === undefined) { - return { - cmp: cmp, - data: undefined - }; - } - var sizea = Belt_internalAVLset.lengthNode(match); - var sizeb = Belt_internalAVLset.lengthNode(match$1); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(match, 0, tmp); - Belt_internalAVLset.fillArray(match$1, sizea, tmp); - if (cmp(tmp[sizea - 1 | 0], tmp[sizea]) < 0 || cmp(tmp[totalSize - 1 | 0], tmp[0]) < 0) { - return { - cmp: cmp, - data: undefined - }; - } - var tmp2 = new Array(sizea < sizeb ? sizea : sizeb); - var k = Belt_SortArray.intersectU(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0, cmp); - return { - cmp: cmp, - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function diff(a, b) { - var cmp = a.cmp; - var dataa = a.data; - var match = b.data; - if (dataa === undefined) { - return { - cmp: cmp, - data: undefined - }; - } - if (match === undefined) { - return { - cmp: cmp, - data: Belt_internalAVLset.copy(dataa) - }; - } - var sizea = Belt_internalAVLset.lengthNode(dataa); - var sizeb = Belt_internalAVLset.lengthNode(match); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(dataa, 0, tmp); - Belt_internalAVLset.fillArray(match, sizea, tmp); - if (cmp(tmp[sizea - 1 | 0], tmp[sizea]) < 0 || cmp(tmp[totalSize - 1 | 0], tmp[0]) < 0) { - return { - cmp: cmp, - data: Belt_internalAVLset.copy(dataa) - }; - } - var tmp2 = new Array(sizea); - var k = Belt_SortArray.diffU(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0, cmp); - return { - cmp: cmp, - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function union(a, b) { - var cmp = a.cmp; - var dataa = a.data; - var datab = b.data; - if (dataa === undefined) { - return { - cmp: cmp, - data: Belt_internalAVLset.copy(datab) - }; - } - if (datab === undefined) { - return { - cmp: cmp, - data: Belt_internalAVLset.copy(dataa) - }; - } - var sizea = Belt_internalAVLset.lengthNode(dataa); - var sizeb = Belt_internalAVLset.lengthNode(datab); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(dataa, 0, tmp); - Belt_internalAVLset.fillArray(datab, sizea, tmp); - if (cmp(tmp[sizea - 1 | 0], tmp[sizea]) < 0) { - return { - cmp: cmp, - data: Belt_internalAVLset.fromSortedArrayAux(tmp, 0, totalSize) - }; - } - var tmp2 = new Array(totalSize); - var k = Belt_SortArray.unionU(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0, cmp); - return { - cmp: cmp, - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function has(d, x) { - return Belt_internalAVLset.has(d.data, x, d.cmp); -} - -function copy(d) { - return { - cmp: d.cmp, - data: Belt_internalAVLset.copy(d.data) - }; -} - -var Int; - -var $$String; - -exports.Int = Int; -exports.$$String = $$String; -exports.make = make; -exports.fromArray = fromArray; -exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; -exports.copy = copy; -exports.isEmpty = isEmpty; -exports.has = has; -exports.add = add; -exports.addCheck = addCheck; -exports.mergeMany = mergeMany; -exports.remove = remove; -exports.removeCheck = removeCheck; -exports.removeMany = removeMany; -exports.union = union; -exports.intersect = intersect; -exports.diff = diff; -exports.subset = subset; -exports.cmp = cmp; -exports.eq = eq; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.keepU = keepU; -exports.keep = keep; -exports.partitionU = partitionU; -exports.partition = partition; -exports.size = size; -exports.toList = toList; -exports.toArray = toArray; -exports.minimum = minimum; -exports.minUndefined = minUndefined; -exports.maximum = maximum; -exports.maxUndefined = maxUndefined; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getExn = getExn; -exports.split = split; -exports.checkInvariantInternal = checkInvariantInternal; -/* No side effect */ diff --git a/lib/js/belt_MutableSetInt.js b/lib/js/belt_MutableSetInt.js deleted file mode 100644 index 893ec9dfc07..00000000000 --- a/lib/js/belt_MutableSetInt.js +++ /dev/null @@ -1,499 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Belt_SortArrayInt = require("./belt_SortArrayInt.js"); -var Belt_internalAVLset = require("./belt_internalAVLset.js"); -var Belt_internalSetInt = require("./belt_internalSetInt.js"); - -function remove0(nt, x) { - var k = nt.v; - if (x === k) { - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLset.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLset.balMutate(nt); - } else { - return l; - } - } else { - return r; - } - } - if (x < k) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = remove0(l$1, x); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = remove0(r$1, x); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } -} - -function remove(d, v) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var newRoot = remove0(oldRoot, v); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function removeMany0(_t, xs, _i, len) { - while(true) { - var i = _i; - var t = _t; - if (i >= len) { - return t; - } - var ele = xs[i]; - var u = remove0(t, ele); - if (u === undefined) { - return ; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; -} - -function removeMany(d, xs) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var len = xs.length; - d.data = removeMany0(oldRoot, xs, 0, len); -} - -function removeCheck0(nt, x, removed) { - var k = nt.v; - if (x === k) { - removed.contents = true; - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLset.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLset.balMutate(nt); - } else { - return l; - } - } else { - return r; - } - } - if (x < k) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = removeCheck0(l$1, x, removed); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = removeCheck0(r$1, x, removed); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } -} - -function removeCheck(d, v) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return false; - } - var removed = { - contents: false - }; - var newRoot = removeCheck0(oldRoot, v, removed); - if (newRoot !== oldRoot) { - d.data = newRoot; - } - return removed.contents; -} - -function addCheck0(t, x, added) { - if (t !== undefined) { - var k = t.v; - if (x === k) { - return t; - } - var l = t.l; - var r = t.r; - if (x < k) { - var ll = addCheck0(l, x, added); - t.l = ll; - } else { - t.r = addCheck0(r, x, added); - } - return Belt_internalAVLset.balMutate(t); - } - added.contents = true; - return Belt_internalAVLset.singleton(x); -} - -function addCheck(m, e) { - var oldRoot = m.data; - var added = { - contents: false - }; - var newRoot = addCheck0(oldRoot, e, added); - if (newRoot !== oldRoot) { - m.data = newRoot; - } - return added.contents; -} - -function add(d, k) { - var oldRoot = d.data; - var v = Belt_internalSetInt.addMutate(oldRoot, k); - if (v !== oldRoot) { - d.data = v; - return ; - } - -} - -function addArrayMutate(t, xs) { - var v = t; - for(var i = 0 ,i_finish = xs.length; i < i_finish; ++i){ - v = Belt_internalSetInt.addMutate(v, xs[i]); - } - return v; -} - -function mergeMany(d, arr) { - d.data = addArrayMutate(d.data, arr); -} - -function make(param) { - return { - data: undefined - }; -} - -function isEmpty(d) { - var n = d.data; - return n === undefined; -} - -function minimum(d) { - return Belt_internalAVLset.minimum(d.data); -} - -function minUndefined(d) { - return Belt_internalAVLset.minUndefined(d.data); -} - -function maximum(d) { - return Belt_internalAVLset.maximum(d.data); -} - -function maxUndefined(d) { - return Belt_internalAVLset.maxUndefined(d.data); -} - -function forEachU(d, f) { - Belt_internalAVLset.forEachU(d.data, f); -} - -function forEach(d, f) { - Belt_internalAVLset.forEachU(d.data, Curry.__1(f)); -} - -function reduceU(d, acc, cb) { - return Belt_internalAVLset.reduceU(d.data, acc, cb); -} - -function reduce(d, acc, cb) { - return reduceU(d, acc, Curry.__2(cb)); -} - -function everyU(d, p) { - return Belt_internalAVLset.everyU(d.data, p); -} - -function every(d, p) { - return Belt_internalAVLset.everyU(d.data, Curry.__1(p)); -} - -function someU(d, p) { - return Belt_internalAVLset.someU(d.data, p); -} - -function some(d, p) { - return Belt_internalAVLset.someU(d.data, Curry.__1(p)); -} - -function size(d) { - return Belt_internalAVLset.size(d.data); -} - -function toList(d) { - return Belt_internalAVLset.toList(d.data); -} - -function toArray(d) { - return Belt_internalAVLset.toArray(d.data); -} - -function fromSortedArrayUnsafe(xs) { - return { - data: Belt_internalAVLset.fromSortedArrayUnsafe(xs) - }; -} - -function checkInvariantInternal(d) { - Belt_internalAVLset.checkInvariantInternal(d.data); -} - -function fromArray(xs) { - return { - data: Belt_internalSetInt.fromArray(xs) - }; -} - -function cmp(d0, d1) { - return Belt_internalSetInt.cmp(d0.data, d1.data); -} - -function eq(d0, d1) { - return Belt_internalSetInt.eq(d0.data, d1.data); -} - -function get(d, x) { - return Belt_internalSetInt.get(d.data, x); -} - -function getUndefined(d, x) { - return Belt_internalSetInt.getUndefined(d.data, x); -} - -function getExn(d, x) { - return Belt_internalSetInt.getExn(d.data, x); -} - -function split(d, key) { - var arr = Belt_internalAVLset.toArray(d.data); - var i = Belt_SortArrayInt.binarySearch(arr, key); - var len = arr.length; - if (i >= 0) { - return [ - [ - { - data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, i) - }, - { - data: Belt_internalAVLset.fromSortedArrayAux(arr, i + 1 | 0, (len - i | 0) - 1 | 0) - } - ], - true - ]; - } - var next = (-i | 0) - 1 | 0; - return [ - [ - { - data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, next) - }, - { - data: Belt_internalAVLset.fromSortedArrayAux(arr, next, len - next | 0) - } - ], - false - ]; -} - -function keepU(d, p) { - return { - data: Belt_internalAVLset.keepCopyU(d.data, p) - }; -} - -function keep(d, p) { - return keepU(d, Curry.__1(p)); -} - -function partitionU(d, p) { - var match = Belt_internalAVLset.partitionCopyU(d.data, p); - return [ - { - data: match[0] - }, - { - data: match[1] - } - ]; -} - -function partition(d, p) { - return partitionU(d, Curry.__1(p)); -} - -function subset(a, b) { - return Belt_internalSetInt.subset(a.data, b.data); -} - -function intersect(dataa, datab) { - var dataa$1 = dataa.data; - var datab$1 = datab.data; - if (dataa$1 === undefined) { - return { - data: undefined - }; - } - if (datab$1 === undefined) { - return { - data: undefined - }; - } - var sizea = Belt_internalAVLset.lengthNode(dataa$1); - var sizeb = Belt_internalAVLset.lengthNode(datab$1); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(dataa$1, 0, tmp); - Belt_internalAVLset.fillArray(datab$1, sizea, tmp); - if (tmp[sizea - 1 | 0] < tmp[sizea] || tmp[totalSize - 1 | 0] < tmp[0]) { - return { - data: undefined - }; - } - var tmp2 = new Array(sizea < sizeb ? sizea : sizeb); - var k = Belt_SortArrayInt.intersect(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); - return { - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function diff(dataa, datab) { - var dataa$1 = dataa.data; - var datab$1 = datab.data; - if (dataa$1 === undefined) { - return { - data: undefined - }; - } - if (datab$1 === undefined) { - return { - data: Belt_internalAVLset.copy(dataa$1) - }; - } - var sizea = Belt_internalAVLset.lengthNode(dataa$1); - var sizeb = Belt_internalAVLset.lengthNode(datab$1); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(dataa$1, 0, tmp); - Belt_internalAVLset.fillArray(datab$1, sizea, tmp); - if (tmp[sizea - 1 | 0] < tmp[sizea] || tmp[totalSize - 1 | 0] < tmp[0]) { - return { - data: Belt_internalAVLset.copy(dataa$1) - }; - } - var tmp2 = new Array(sizea); - var k = Belt_SortArrayInt.diff(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); - return { - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function union(dataa, datab) { - var dataa$1 = dataa.data; - var datab$1 = datab.data; - if (dataa$1 === undefined) { - return { - data: Belt_internalAVLset.copy(datab$1) - }; - } - if (datab$1 === undefined) { - return { - data: Belt_internalAVLset.copy(dataa$1) - }; - } - var sizea = Belt_internalAVLset.lengthNode(dataa$1); - var sizeb = Belt_internalAVLset.lengthNode(datab$1); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(dataa$1, 0, tmp); - Belt_internalAVLset.fillArray(datab$1, sizea, tmp); - if (tmp[sizea - 1 | 0] < tmp[sizea]) { - return { - data: Belt_internalAVLset.fromSortedArrayAux(tmp, 0, totalSize) - }; - } - var tmp2 = new Array(totalSize); - var k = Belt_SortArrayInt.union(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); - return { - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function has(d, x) { - return Belt_internalSetInt.has(d.data, x); -} - -function copy(d) { - return { - data: Belt_internalAVLset.copy(d.data) - }; -} - -exports.make = make; -exports.fromArray = fromArray; -exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; -exports.copy = copy; -exports.isEmpty = isEmpty; -exports.has = has; -exports.add = add; -exports.addCheck = addCheck; -exports.mergeMany = mergeMany; -exports.remove = remove; -exports.removeCheck = removeCheck; -exports.removeMany = removeMany; -exports.union = union; -exports.intersect = intersect; -exports.diff = diff; -exports.subset = subset; -exports.cmp = cmp; -exports.eq = eq; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.keepU = keepU; -exports.keep = keep; -exports.partitionU = partitionU; -exports.partition = partition; -exports.size = size; -exports.toList = toList; -exports.toArray = toArray; -exports.minimum = minimum; -exports.minUndefined = minUndefined; -exports.maximum = maximum; -exports.maxUndefined = maxUndefined; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getExn = getExn; -exports.split = split; -exports.checkInvariantInternal = checkInvariantInternal; -/* No side effect */ diff --git a/lib/js/belt_MutableSetString.js b/lib/js/belt_MutableSetString.js deleted file mode 100644 index 6da37904adf..00000000000 --- a/lib/js/belt_MutableSetString.js +++ /dev/null @@ -1,499 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Belt_internalAVLset = require("./belt_internalAVLset.js"); -var Belt_SortArrayString = require("./belt_SortArrayString.js"); -var Belt_internalSetString = require("./belt_internalSetString.js"); - -function remove0(nt, x) { - var k = nt.v; - if (x === k) { - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLset.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLset.balMutate(nt); - } else { - return l; - } - } else { - return r; - } - } - if (x < k) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = remove0(l$1, x); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = remove0(r$1, x); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } -} - -function remove(d, v) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var newRoot = remove0(oldRoot, v); - if (newRoot !== oldRoot) { - d.data = newRoot; - return ; - } - -} - -function removeMany0(_t, xs, _i, len) { - while(true) { - var i = _i; - var t = _t; - if (i >= len) { - return t; - } - var ele = xs[i]; - var u = remove0(t, ele); - if (u === undefined) { - return ; - } - _i = i + 1 | 0; - _t = u; - continue ; - }; -} - -function removeMany(d, xs) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return ; - } - var len = xs.length; - d.data = removeMany0(oldRoot, xs, 0, len); -} - -function removeCheck0(nt, x, removed) { - var k = nt.v; - if (x === k) { - removed.contents = true; - var l = nt.l; - var r = nt.r; - if (l !== undefined) { - if (r !== undefined) { - nt.r = Belt_internalAVLset.removeMinAuxWithRootMutate(nt, r); - return Belt_internalAVLset.balMutate(nt); - } else { - return l; - } - } else { - return r; - } - } - if (x < k) { - var l$1 = nt.l; - if (l$1 !== undefined) { - nt.l = removeCheck0(l$1, x, removed); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } - } - var r$1 = nt.r; - if (r$1 !== undefined) { - nt.r = removeCheck0(r$1, x, removed); - return Belt_internalAVLset.balMutate(nt); - } else { - return nt; - } -} - -function removeCheck(d, v) { - var oldRoot = d.data; - if (oldRoot === undefined) { - return false; - } - var removed = { - contents: false - }; - var newRoot = removeCheck0(oldRoot, v, removed); - if (newRoot !== oldRoot) { - d.data = newRoot; - } - return removed.contents; -} - -function addCheck0(t, x, added) { - if (t !== undefined) { - var k = t.v; - if (x === k) { - return t; - } - var l = t.l; - var r = t.r; - if (x < k) { - var ll = addCheck0(l, x, added); - t.l = ll; - } else { - t.r = addCheck0(r, x, added); - } - return Belt_internalAVLset.balMutate(t); - } - added.contents = true; - return Belt_internalAVLset.singleton(x); -} - -function addCheck(m, e) { - var oldRoot = m.data; - var added = { - contents: false - }; - var newRoot = addCheck0(oldRoot, e, added); - if (newRoot !== oldRoot) { - m.data = newRoot; - } - return added.contents; -} - -function add(d, k) { - var oldRoot = d.data; - var v = Belt_internalSetString.addMutate(oldRoot, k); - if (v !== oldRoot) { - d.data = v; - return ; - } - -} - -function addArrayMutate(t, xs) { - var v = t; - for(var i = 0 ,i_finish = xs.length; i < i_finish; ++i){ - v = Belt_internalSetString.addMutate(v, xs[i]); - } - return v; -} - -function mergeMany(d, arr) { - d.data = addArrayMutate(d.data, arr); -} - -function make(param) { - return { - data: undefined - }; -} - -function isEmpty(d) { - var n = d.data; - return n === undefined; -} - -function minimum(d) { - return Belt_internalAVLset.minimum(d.data); -} - -function minUndefined(d) { - return Belt_internalAVLset.minUndefined(d.data); -} - -function maximum(d) { - return Belt_internalAVLset.maximum(d.data); -} - -function maxUndefined(d) { - return Belt_internalAVLset.maxUndefined(d.data); -} - -function forEachU(d, f) { - Belt_internalAVLset.forEachU(d.data, f); -} - -function forEach(d, f) { - Belt_internalAVLset.forEachU(d.data, Curry.__1(f)); -} - -function reduceU(d, acc, cb) { - return Belt_internalAVLset.reduceU(d.data, acc, cb); -} - -function reduce(d, acc, cb) { - return reduceU(d, acc, Curry.__2(cb)); -} - -function everyU(d, p) { - return Belt_internalAVLset.everyU(d.data, p); -} - -function every(d, p) { - return Belt_internalAVLset.everyU(d.data, Curry.__1(p)); -} - -function someU(d, p) { - return Belt_internalAVLset.someU(d.data, p); -} - -function some(d, p) { - return Belt_internalAVLset.someU(d.data, Curry.__1(p)); -} - -function size(d) { - return Belt_internalAVLset.size(d.data); -} - -function toList(d) { - return Belt_internalAVLset.toList(d.data); -} - -function toArray(d) { - return Belt_internalAVLset.toArray(d.data); -} - -function fromSortedArrayUnsafe(xs) { - return { - data: Belt_internalAVLset.fromSortedArrayUnsafe(xs) - }; -} - -function checkInvariantInternal(d) { - Belt_internalAVLset.checkInvariantInternal(d.data); -} - -function fromArray(xs) { - return { - data: Belt_internalSetString.fromArray(xs) - }; -} - -function cmp(d0, d1) { - return Belt_internalSetString.cmp(d0.data, d1.data); -} - -function eq(d0, d1) { - return Belt_internalSetString.eq(d0.data, d1.data); -} - -function get(d, x) { - return Belt_internalSetString.get(d.data, x); -} - -function getUndefined(d, x) { - return Belt_internalSetString.getUndefined(d.data, x); -} - -function getExn(d, x) { - return Belt_internalSetString.getExn(d.data, x); -} - -function split(d, key) { - var arr = Belt_internalAVLset.toArray(d.data); - var i = Belt_SortArrayString.binarySearch(arr, key); - var len = arr.length; - if (i >= 0) { - return [ - [ - { - data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, i) - }, - { - data: Belt_internalAVLset.fromSortedArrayAux(arr, i + 1 | 0, (len - i | 0) - 1 | 0) - } - ], - true - ]; - } - var next = (-i | 0) - 1 | 0; - return [ - [ - { - data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, next) - }, - { - data: Belt_internalAVLset.fromSortedArrayAux(arr, next, len - next | 0) - } - ], - false - ]; -} - -function keepU(d, p) { - return { - data: Belt_internalAVLset.keepCopyU(d.data, p) - }; -} - -function keep(d, p) { - return keepU(d, Curry.__1(p)); -} - -function partitionU(d, p) { - var match = Belt_internalAVLset.partitionCopyU(d.data, p); - return [ - { - data: match[0] - }, - { - data: match[1] - } - ]; -} - -function partition(d, p) { - return partitionU(d, Curry.__1(p)); -} - -function subset(a, b) { - return Belt_internalSetString.subset(a.data, b.data); -} - -function intersect(dataa, datab) { - var dataa$1 = dataa.data; - var datab$1 = datab.data; - if (dataa$1 === undefined) { - return { - data: undefined - }; - } - if (datab$1 === undefined) { - return { - data: undefined - }; - } - var sizea = Belt_internalAVLset.lengthNode(dataa$1); - var sizeb = Belt_internalAVLset.lengthNode(datab$1); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(dataa$1, 0, tmp); - Belt_internalAVLset.fillArray(datab$1, sizea, tmp); - if (tmp[sizea - 1 | 0] < tmp[sizea] || tmp[totalSize - 1 | 0] < tmp[0]) { - return { - data: undefined - }; - } - var tmp2 = new Array(sizea < sizeb ? sizea : sizeb); - var k = Belt_SortArrayString.intersect(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); - return { - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function diff(dataa, datab) { - var dataa$1 = dataa.data; - var datab$1 = datab.data; - if (dataa$1 === undefined) { - return { - data: undefined - }; - } - if (datab$1 === undefined) { - return { - data: Belt_internalAVLset.copy(dataa$1) - }; - } - var sizea = Belt_internalAVLset.lengthNode(dataa$1); - var sizeb = Belt_internalAVLset.lengthNode(datab$1); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(dataa$1, 0, tmp); - Belt_internalAVLset.fillArray(datab$1, sizea, tmp); - if (tmp[sizea - 1 | 0] < tmp[sizea] || tmp[totalSize - 1 | 0] < tmp[0]) { - return { - data: Belt_internalAVLset.copy(dataa$1) - }; - } - var tmp2 = new Array(sizea); - var k = Belt_SortArrayString.diff(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); - return { - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function union(dataa, datab) { - var dataa$1 = dataa.data; - var datab$1 = datab.data; - if (dataa$1 === undefined) { - return { - data: Belt_internalAVLset.copy(datab$1) - }; - } - if (datab$1 === undefined) { - return { - data: Belt_internalAVLset.copy(dataa$1) - }; - } - var sizea = Belt_internalAVLset.lengthNode(dataa$1); - var sizeb = Belt_internalAVLset.lengthNode(datab$1); - var totalSize = sizea + sizeb | 0; - var tmp = new Array(totalSize); - Belt_internalAVLset.fillArray(dataa$1, 0, tmp); - Belt_internalAVLset.fillArray(datab$1, sizea, tmp); - if (tmp[sizea - 1 | 0] < tmp[sizea]) { - return { - data: Belt_internalAVLset.fromSortedArrayAux(tmp, 0, totalSize) - }; - } - var tmp2 = new Array(totalSize); - var k = Belt_SortArrayString.union(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); - return { - data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) - }; -} - -function has(d, x) { - return Belt_internalSetString.has(d.data, x); -} - -function copy(d) { - return { - data: Belt_internalAVLset.copy(d.data) - }; -} - -exports.make = make; -exports.fromArray = fromArray; -exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; -exports.copy = copy; -exports.isEmpty = isEmpty; -exports.has = has; -exports.add = add; -exports.addCheck = addCheck; -exports.mergeMany = mergeMany; -exports.remove = remove; -exports.removeCheck = removeCheck; -exports.removeMany = removeMany; -exports.union = union; -exports.intersect = intersect; -exports.diff = diff; -exports.subset = subset; -exports.cmp = cmp; -exports.eq = eq; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.keepU = keepU; -exports.keep = keep; -exports.partitionU = partitionU; -exports.partition = partition; -exports.size = size; -exports.toList = toList; -exports.toArray = toArray; -exports.minimum = minimum; -exports.minUndefined = minUndefined; -exports.maximum = maximum; -exports.maxUndefined = maxUndefined; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getExn = getExn; -exports.split = split; -exports.checkInvariantInternal = checkInvariantInternal; -/* No side effect */ diff --git a/lib/js/belt_MutableStack.js b/lib/js/belt_MutableStack.js deleted file mode 100644 index c82ccef3e3e..00000000000 --- a/lib/js/belt_MutableStack.js +++ /dev/null @@ -1,135 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Caml_option = require("./caml_option.js"); - -function make(param) { - return { - root: undefined - }; -} - -function clear(s) { - s.root = undefined; -} - -function copy(s) { - return { - root: s.root - }; -} - -function push(s, x) { - s.root = { - head: x, - tail: s.root - }; -} - -function topUndefined(s) { - var x = s.root; - if (x !== undefined) { - return x.head; - } - -} - -function top(s) { - var x = s.root; - if (x !== undefined) { - return Caml_option.some(x.head); - } - -} - -function isEmpty(s) { - return s.root === undefined; -} - -function popUndefined(s) { - var x = s.root; - if (x !== undefined) { - s.root = x.tail; - return x.head; - } - -} - -function pop(s) { - var x = s.root; - if (x !== undefined) { - s.root = x.tail; - return Caml_option.some(x.head); - } - -} - -function size(s) { - var x = s.root; - if (x !== undefined) { - var _x = x; - var _acc = 0; - while(true) { - var acc = _acc; - var x$1 = _x; - var x$2 = x$1.tail; - if (x$2 === undefined) { - return acc + 1 | 0; - } - _acc = acc + 1 | 0; - _x = x$2; - continue ; - }; - } else { - return 0; - } -} - -function forEachU(s, f) { - var _s = s.root; - while(true) { - var s$1 = _s; - if (s$1 === undefined) { - return ; - } - f(s$1.head); - _s = s$1.tail; - continue ; - }; -} - -function forEach(s, f) { - forEachU(s, Curry.__1(f)); -} - -function dynamicPopIterU(s, f) { - while(true) { - var match = s.root; - if (match === undefined) { - return ; - } - s.root = match.tail; - f(match.head); - continue ; - }; -} - -function dynamicPopIter(s, f) { - dynamicPopIterU(s, Curry.__1(f)); -} - -exports.make = make; -exports.clear = clear; -exports.copy = copy; -exports.push = push; -exports.popUndefined = popUndefined; -exports.pop = pop; -exports.topUndefined = topUndefined; -exports.top = top; -exports.isEmpty = isEmpty; -exports.size = size; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.dynamicPopIterU = dynamicPopIterU; -exports.dynamicPopIter = dynamicPopIter; -/* No side effect */ diff --git a/lib/js/belt_Option.js b/lib/js/belt_Option.js deleted file mode 100644 index 3b1c01c98fc..00000000000 --- a/lib/js/belt_Option.js +++ /dev/null @@ -1,149 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Caml_option = require("./caml_option.js"); - -function keepU(opt, p) { - if (opt !== undefined && p(Caml_option.valFromOption(opt))) { - return opt; - } - -} - -function keep(opt, p) { - return keepU(opt, Curry.__1(p)); -} - -function forEachU(opt, f) { - if (opt !== undefined) { - return f(Caml_option.valFromOption(opt)); - } - -} - -function forEach(opt, f) { - forEachU(opt, Curry.__1(f)); -} - -function getExn(x) { - if (x !== undefined) { - return Caml_option.valFromOption(x); - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -function mapWithDefaultU(opt, $$default, f) { - if (opt !== undefined) { - return f(Caml_option.valFromOption(opt)); - } else { - return $$default; - } -} - -function mapWithDefault(opt, $$default, f) { - return mapWithDefaultU(opt, $$default, Curry.__1(f)); -} - -function mapU(opt, f) { - if (opt !== undefined) { - return Caml_option.some(f(Caml_option.valFromOption(opt))); - } - -} - -function map(opt, f) { - return mapU(opt, Curry.__1(f)); -} - -function flatMapU(opt, f) { - if (opt !== undefined) { - return f(Caml_option.valFromOption(opt)); - } - -} - -function flatMap(opt, f) { - return flatMapU(opt, Curry.__1(f)); -} - -function getWithDefault(opt, $$default) { - if (opt !== undefined) { - return Caml_option.valFromOption(opt); - } else { - return $$default; - } -} - -function orElse(opt, other) { - if (opt !== undefined) { - return opt; - } else { - return other; - } -} - -function isSome(x) { - return x !== undefined; -} - -function isNone(x) { - return x === undefined; -} - -function eqU(a, b, f) { - if (a !== undefined) { - if (b !== undefined) { - return f(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); - } else { - return false; - } - } else { - return b === undefined; - } -} - -function eq(a, b, f) { - return eqU(a, b, Curry.__2(f)); -} - -function cmpU(a, b, f) { - if (a !== undefined) { - if (b !== undefined) { - return f(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); - } else { - return 1; - } - } else if (b !== undefined) { - return -1; - } else { - return 0; - } -} - -function cmp(a, b, f) { - return cmpU(a, b, Curry.__2(f)); -} - -exports.keepU = keepU; -exports.keep = keep; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.getExn = getExn; -exports.mapWithDefaultU = mapWithDefaultU; -exports.mapWithDefault = mapWithDefault; -exports.mapU = mapU; -exports.map = map; -exports.flatMapU = flatMapU; -exports.flatMap = flatMap; -exports.getWithDefault = getWithDefault; -exports.orElse = orElse; -exports.isSome = isSome; -exports.isNone = isNone; -exports.eqU = eqU; -exports.eq = eq; -exports.cmpU = cmpU; -exports.cmp = cmp; -/* No side effect */ diff --git a/lib/js/belt_Range.js b/lib/js/belt_Range.js deleted file mode 100644 index acff5ec0b06..00000000000 --- a/lib/js/belt_Range.js +++ /dev/null @@ -1,107 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); - -function forEachU(s, f, action) { - for(var i = s; i <= f; ++i){ - action(i); - } -} - -function forEach(s, f, action) { - forEachU(s, f, Curry.__1(action)); -} - -function everyU(_s, f, p) { - while(true) { - var s = _s; - if (s > f) { - return true; - } - if (!p(s)) { - return false; - } - _s = s + 1 | 0; - continue ; - }; -} - -function every(s, f, p) { - return everyU(s, f, Curry.__1(p)); -} - -function everyByU(s, f, step, p) { - if (step > 0) { - var _s = s; - while(true) { - var s$1 = _s; - if (s$1 > f) { - return true; - } - if (!p(s$1)) { - return false; - } - _s = s$1 + step | 0; - continue ; - }; - } else { - return true; - } -} - -function everyBy(s, f, step, p) { - return everyByU(s, f, step, Curry.__1(p)); -} - -function someU(_s, f, p) { - while(true) { - var s = _s; - if (s > f) { - return false; - } - if (p(s)) { - return true; - } - _s = s + 1 | 0; - continue ; - }; -} - -function some(s, f, p) { - return someU(s, f, Curry.__1(p)); -} - -function someByU(s, f, step, p) { - if (step > 0) { - var _s = s; - while(true) { - var s$1 = _s; - if (s$1 > f) { - return false; - } - if (p(s$1)) { - return true; - } - _s = s$1 + step | 0; - continue ; - }; - } else { - return false; - } -} - -function someBy(s, f, step, p) { - return someByU(s, f, step, Curry.__1(p)); -} - -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.everyU = everyU; -exports.every = every; -exports.everyByU = everyByU; -exports.everyBy = everyBy; -exports.someU = someU; -exports.some = some; -exports.someByU = someByU; -exports.someBy = someBy; -/* No side effect */ diff --git a/lib/js/belt_Result.js b/lib/js/belt_Result.js deleted file mode 100644 index fbda5c6de2c..00000000000 --- a/lib/js/belt_Result.js +++ /dev/null @@ -1,134 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); - -function getExn(x) { - if (x.TAG === "Ok") { - return x._0; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; -} - -function mapWithDefaultU(opt, $$default, f) { - if (opt.TAG === "Ok") { - return f(opt._0); - } else { - return $$default; - } -} - -function mapWithDefault(opt, $$default, f) { - return mapWithDefaultU(opt, $$default, Curry.__1(f)); -} - -function mapU(opt, f) { - if (opt.TAG === "Ok") { - return { - TAG: "Ok", - _0: f(opt._0) - }; - } else { - return { - TAG: "Error", - _0: opt._0 - }; - } -} - -function map(opt, f) { - return mapU(opt, Curry.__1(f)); -} - -function flatMapU(opt, f) { - if (opt.TAG === "Ok") { - return f(opt._0); - } else { - return { - TAG: "Error", - _0: opt._0 - }; - } -} - -function flatMap(opt, f) { - return flatMapU(opt, Curry.__1(f)); -} - -function getWithDefault(opt, $$default) { - if (opt.TAG === "Ok") { - return opt._0; - } else { - return $$default; - } -} - -function isOk(x) { - if (x.TAG === "Ok") { - return true; - } else { - return false; - } -} - -function isError(x) { - if (x.TAG === "Ok") { - return false; - } else { - return true; - } -} - -function eqU(a, b, f) { - if (a.TAG === "Ok") { - if (b.TAG === "Ok") { - return f(a._0, b._0); - } else { - return false; - } - } else if (b.TAG === "Ok") { - return false; - } else { - return true; - } -} - -function eq(a, b, f) { - return eqU(a, b, Curry.__2(f)); -} - -function cmpU(a, b, f) { - if (a.TAG === "Ok") { - if (b.TAG === "Ok") { - return f(a._0, b._0); - } else { - return 1; - } - } else if (b.TAG === "Ok") { - return -1; - } else { - return 0; - } -} - -function cmp(a, b, f) { - return cmpU(a, b, Curry.__2(f)); -} - -exports.getExn = getExn; -exports.mapWithDefaultU = mapWithDefaultU; -exports.mapWithDefault = mapWithDefault; -exports.mapU = mapU; -exports.map = map; -exports.flatMapU = flatMapU; -exports.flatMap = flatMap; -exports.getWithDefault = getWithDefault; -exports.isOk = isOk; -exports.isError = isError; -exports.eqU = eqU; -exports.eq = eq; -exports.cmpU = cmpU; -exports.cmp = cmp; -/* No side effect */ diff --git a/lib/js/belt_Set.js b/lib/js/belt_Set.js deleted file mode 100644 index 50d6fdac0c3..00000000000 --- a/lib/js/belt_Set.js +++ /dev/null @@ -1,312 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Belt_SetDict = require("./belt_SetDict.js"); - -function fromArray(data, id) { - var cmp = id.cmp; - return { - cmp: cmp, - data: Belt_SetDict.fromArray(data, cmp) - }; -} - -function remove(m, e) { - var data = m.data; - var cmp = m.cmp; - var newData = Belt_SetDict.remove(data, e, cmp); - if (newData === data) { - return m; - } else { - return { - cmp: cmp, - data: newData - }; - } -} - -function add(m, e) { - var data = m.data; - var cmp = m.cmp; - var newData = Belt_SetDict.add(data, e, cmp); - if (newData === data) { - return m; - } else { - return { - cmp: cmp, - data: newData - }; - } -} - -function mergeMany(m, e) { - var cmp = m.cmp; - return { - cmp: cmp, - data: Belt_SetDict.mergeMany(m.data, e, cmp) - }; -} - -function removeMany(m, e) { - var cmp = m.cmp; - return { - cmp: cmp, - data: Belt_SetDict.removeMany(m.data, e, cmp) - }; -} - -function union(m, n) { - var cmp = m.cmp; - return { - cmp: cmp, - data: Belt_SetDict.union(m.data, n.data, cmp) - }; -} - -function intersect(m, n) { - var cmp = m.cmp; - return { - cmp: cmp, - data: Belt_SetDict.intersect(m.data, n.data, cmp) - }; -} - -function diff(m, n) { - var cmp = m.cmp; - return { - cmp: cmp, - data: Belt_SetDict.diff(m.data, n.data, cmp) - }; -} - -function subset(m, n) { - var cmp = m.cmp; - return Belt_SetDict.subset(m.data, n.data, cmp); -} - -function split(m, e) { - var cmp = m.cmp; - var match = Belt_SetDict.split(m.data, e, cmp); - var match$1 = match[0]; - return [ - [ - { - cmp: cmp, - data: match$1[0] - }, - { - cmp: cmp, - data: match$1[1] - } - ], - match[1] - ]; -} - -function make(id) { - return { - cmp: id.cmp, - data: undefined - }; -} - -function isEmpty(m) { - return Belt_SetDict.isEmpty(m.data); -} - -function cmp(m, n) { - var cmp$1 = m.cmp; - return Belt_SetDict.cmp(m.data, n.data, cmp$1); -} - -function eq(m, n) { - return Belt_SetDict.eq(m.data, n.data, m.cmp); -} - -function forEachU(m, f) { - Belt_SetDict.forEachU(m.data, f); -} - -function forEach(m, f) { - Belt_SetDict.forEachU(m.data, Curry.__1(f)); -} - -function reduceU(m, acc, f) { - return Belt_SetDict.reduceU(m.data, acc, f); -} - -function reduce(m, acc, f) { - return reduceU(m, acc, Curry.__2(f)); -} - -function everyU(m, f) { - return Belt_SetDict.everyU(m.data, f); -} - -function every(m, f) { - return Belt_SetDict.everyU(m.data, Curry.__1(f)); -} - -function someU(m, f) { - return Belt_SetDict.someU(m.data, f); -} - -function some(m, f) { - return Belt_SetDict.someU(m.data, Curry.__1(f)); -} - -function keepU(m, f) { - return { - cmp: m.cmp, - data: Belt_SetDict.keepU(m.data, f) - }; -} - -function keep(m, f) { - return keepU(m, Curry.__1(f)); -} - -function partitionU(m, f) { - var match = Belt_SetDict.partitionU(m.data, f); - var cmp = m.cmp; - return [ - { - cmp: cmp, - data: match[0] - }, - { - cmp: cmp, - data: match[1] - } - ]; -} - -function partition(m, f) { - return partitionU(m, Curry.__1(f)); -} - -function size(m) { - return Belt_SetDict.size(m.data); -} - -function toList(m) { - return Belt_SetDict.toList(m.data); -} - -function toArray(m) { - return Belt_SetDict.toArray(m.data); -} - -function minimum(m) { - return Belt_SetDict.minimum(m.data); -} - -function minUndefined(m) { - return Belt_SetDict.minUndefined(m.data); -} - -function maximum(m) { - return Belt_SetDict.maximum(m.data); -} - -function maxUndefined(m) { - return Belt_SetDict.maxUndefined(m.data); -} - -function get(m, e) { - return Belt_SetDict.get(m.data, e, m.cmp); -} - -function getUndefined(m, e) { - return Belt_SetDict.getUndefined(m.data, e, m.cmp); -} - -function getExn(m, e) { - return Belt_SetDict.getExn(m.data, e, m.cmp); -} - -function has(m, e) { - return Belt_SetDict.has(m.data, e, m.cmp); -} - -function fromSortedArrayUnsafe(xs, id) { - return { - cmp: id.cmp, - data: Belt_SetDict.fromSortedArrayUnsafe(xs) - }; -} - -function getData(m) { - return m.data; -} - -function getId(m) { - var cmp = m.cmp; - return { - cmp: cmp - }; -} - -function packIdData(id, data) { - return { - cmp: id.cmp, - data: data - }; -} - -function checkInvariantInternal(d) { - Belt_SetDict.checkInvariantInternal(d.data); -} - -var Int; - -var $$String; - -var Dict; - -exports.Int = Int; -exports.$$String = $$String; -exports.Dict = Dict; -exports.make = make; -exports.fromArray = fromArray; -exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; -exports.isEmpty = isEmpty; -exports.has = has; -exports.add = add; -exports.mergeMany = mergeMany; -exports.remove = remove; -exports.removeMany = removeMany; -exports.union = union; -exports.intersect = intersect; -exports.diff = diff; -exports.subset = subset; -exports.cmp = cmp; -exports.eq = eq; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.keepU = keepU; -exports.keep = keep; -exports.partitionU = partitionU; -exports.partition = partition; -exports.size = size; -exports.toArray = toArray; -exports.toList = toList; -exports.minimum = minimum; -exports.minUndefined = minUndefined; -exports.maximum = maximum; -exports.maxUndefined = maxUndefined; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getExn = getExn; -exports.split = split; -exports.checkInvariantInternal = checkInvariantInternal; -exports.getData = getData; -exports.getId = getId; -exports.packIdData = packIdData; -/* No side effect */ diff --git a/lib/js/belt_SetDict.js b/lib/js/belt_SetDict.js deleted file mode 100644 index 410c492659f..00000000000 --- a/lib/js/belt_SetDict.js +++ /dev/null @@ -1,360 +0,0 @@ -'use strict'; - -var Belt_internalAVLset = require("./belt_internalAVLset.js"); - -function add(t, x, cmp) { - if (t === undefined) { - return Belt_internalAVLset.singleton(x); - } - var k = t.v; - var c = cmp(x, k); - if (c === 0) { - return t; - } - var l = t.l; - var r = t.r; - if (c < 0) { - var ll = add(l, x, cmp); - if (ll === l) { - return t; - } else { - return Belt_internalAVLset.bal(ll, k, r); - } - } - var rr = add(r, x, cmp); - if (rr === r) { - return t; - } else { - return Belt_internalAVLset.bal(l, k, rr); - } -} - -function remove(t, x, cmp) { - if (t === undefined) { - return t; - } - var v = t.v; - var l = t.l; - var r = t.r; - var c = cmp(x, v); - if (c === 0) { - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var v$1 = { - contents: r.v - }; - var r$1 = Belt_internalAVLset.removeMinAuxWithRef(r, v$1); - return Belt_internalAVLset.bal(l, v$1.contents, r$1); - } - if (c < 0) { - var ll = remove(l, x, cmp); - if (ll === l) { - return t; - } else { - return Belt_internalAVLset.bal(ll, v, r); - } - } - var rr = remove(r, x, cmp); - if (rr === r) { - return t; - } else { - return Belt_internalAVLset.bal(l, v, rr); - } -} - -function mergeMany(h, arr, cmp) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var key = arr[i]; - v = add(v, key, cmp); - } - return v; -} - -function removeMany(h, arr, cmp) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var key = arr[i]; - v = remove(v, key, cmp); - } - return v; -} - -function splitAuxNoPivot(cmp, n, x) { - var v = n.v; - var l = n.l; - var r = n.r; - var c = cmp(x, v); - if (c === 0) { - return [ - l, - r - ]; - } - if (c < 0) { - if (l === undefined) { - return [ - undefined, - n - ]; - } - var match = splitAuxNoPivot(cmp, l, x); - return [ - match[0], - Belt_internalAVLset.joinShared(match[1], v, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined - ]; - } - var match$1 = splitAuxNoPivot(cmp, r, x); - return [ - Belt_internalAVLset.joinShared(l, v, match$1[0]), - match$1[1] - ]; -} - -function splitAuxPivot(cmp, n, x, pres) { - var v = n.v; - var l = n.l; - var r = n.r; - var c = cmp(x, v); - if (c === 0) { - pres.contents = true; - return [ - l, - r - ]; - } - if (c < 0) { - if (l === undefined) { - return [ - undefined, - n - ]; - } - var match = splitAuxPivot(cmp, l, x, pres); - return [ - match[0], - Belt_internalAVLset.joinShared(match[1], v, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined - ]; - } - var match$1 = splitAuxPivot(cmp, r, x, pres); - return [ - Belt_internalAVLset.joinShared(l, v, match$1[0]), - match$1[1] - ]; -} - -function split(t, x, cmp) { - if (t === undefined) { - return [ - [ - undefined, - undefined - ], - false - ]; - } - var pres = { - contents: false - }; - var v = splitAuxPivot(cmp, t, x, pres); - return [ - v, - pres.contents - ]; -} - -function union(s1, s2, cmp) { - if (s1 === undefined) { - return s2; - } - if (s2 === undefined) { - return s1; - } - var h1 = s1.h; - var h2 = s2.h; - if (h1 >= h2) { - if (h2 === 1) { - return add(s1, s2.v, cmp); - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var match = splitAuxNoPivot(cmp, s2, v1); - return Belt_internalAVLset.joinShared(union(l1, match[0], cmp), v1, union(r1, match[1], cmp)); - } - if (h1 === 1) { - return add(s2, s1.v, cmp); - } - var v2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - var match$1 = splitAuxNoPivot(cmp, s1, v2); - return Belt_internalAVLset.joinShared(union(match$1[0], l2, cmp), v2, union(match$1[1], r2, cmp)); -} - -function intersect(s1, s2, cmp) { - if (s1 === undefined) { - return ; - } - if (s2 === undefined) { - return ; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var pres = { - contents: false - }; - var match = splitAuxPivot(cmp, s2, v1, pres); - var ll = intersect(l1, match[0], cmp); - var rr = intersect(r1, match[1], cmp); - if (pres.contents) { - return Belt_internalAVLset.joinShared(ll, v1, rr); - } else { - return Belt_internalAVLset.concatShared(ll, rr); - } -} - -function diff(s1, s2, cmp) { - if (s1 === undefined) { - return s1; - } - if (s2 === undefined) { - return s1; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var pres = { - contents: false - }; - var match = splitAuxPivot(cmp, s2, v1, pres); - var ll = diff(l1, match[0], cmp); - var rr = diff(r1, match[1], cmp); - if (pres.contents) { - return Belt_internalAVLset.concatShared(ll, rr); - } else { - return Belt_internalAVLset.joinShared(ll, v1, rr); - } -} - -var empty; - -var fromArray = Belt_internalAVLset.fromArray; - -var fromSortedArrayUnsafe = Belt_internalAVLset.fromSortedArrayUnsafe; - -var isEmpty = Belt_internalAVLset.isEmpty; - -var has = Belt_internalAVLset.has; - -var subset = Belt_internalAVLset.subset; - -var cmp = Belt_internalAVLset.cmp; - -var eq = Belt_internalAVLset.eq; - -var forEachU = Belt_internalAVLset.forEachU; - -var forEach = Belt_internalAVLset.forEach; - -var reduceU = Belt_internalAVLset.reduceU; - -var reduce = Belt_internalAVLset.reduce; - -var everyU = Belt_internalAVLset.everyU; - -var every = Belt_internalAVLset.every; - -var someU = Belt_internalAVLset.someU; - -var some = Belt_internalAVLset.some; - -var keepU = Belt_internalAVLset.keepSharedU; - -var keep = Belt_internalAVLset.keepShared; - -var partitionU = Belt_internalAVLset.partitionSharedU; - -var partition = Belt_internalAVLset.partitionShared; - -var size = Belt_internalAVLset.size; - -var toList = Belt_internalAVLset.toList; - -var toArray = Belt_internalAVLset.toArray; - -var minimum = Belt_internalAVLset.minimum; - -var minUndefined = Belt_internalAVLset.minUndefined; - -var maximum = Belt_internalAVLset.maximum; - -var maxUndefined = Belt_internalAVLset.maxUndefined; - -var get = Belt_internalAVLset.get; - -var getUndefined = Belt_internalAVLset.getUndefined; - -var getExn = Belt_internalAVLset.getExn; - -var checkInvariantInternal = Belt_internalAVLset.checkInvariantInternal; - -exports.empty = empty; -exports.fromArray = fromArray; -exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; -exports.isEmpty = isEmpty; -exports.has = has; -exports.add = add; -exports.mergeMany = mergeMany; -exports.remove = remove; -exports.removeMany = removeMany; -exports.union = union; -exports.intersect = intersect; -exports.diff = diff; -exports.subset = subset; -exports.cmp = cmp; -exports.eq = eq; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.keepU = keepU; -exports.keep = keep; -exports.partitionU = partitionU; -exports.partition = partition; -exports.size = size; -exports.toList = toList; -exports.toArray = toArray; -exports.minimum = minimum; -exports.minUndefined = minUndefined; -exports.maximum = maximum; -exports.maxUndefined = maxUndefined; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getExn = getExn; -exports.split = split; -exports.checkInvariantInternal = checkInvariantInternal; -/* No side effect */ diff --git a/lib/js/belt_SetInt.js b/lib/js/belt_SetInt.js deleted file mode 100644 index c99b75349c8..00000000000 --- a/lib/js/belt_SetInt.js +++ /dev/null @@ -1,357 +0,0 @@ -'use strict'; - -var Belt_internalAVLset = require("./belt_internalAVLset.js"); -var Belt_internalSetInt = require("./belt_internalSetInt.js"); - -function add(t, x) { - if (t === undefined) { - return Belt_internalAVLset.singleton(x); - } - var v = t.v; - if (x === v) { - return t; - } - var l = t.l; - var r = t.r; - if (x < v) { - var ll = add(l, x); - if (ll === l) { - return t; - } else { - return Belt_internalAVLset.bal(ll, v, r); - } - } - var rr = add(r, x); - if (rr === r) { - return t; - } else { - return Belt_internalAVLset.bal(l, v, rr); - } -} - -function mergeMany(h, arr) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var key = arr[i]; - v = add(v, key); - } - return v; -} - -function remove(t, x) { - if (t === undefined) { - return t; - } - var v = t.v; - var l = t.l; - var r = t.r; - if (x === v) { - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var v$1 = { - contents: r.v - }; - var r$1 = Belt_internalAVLset.removeMinAuxWithRef(r, v$1); - return Belt_internalAVLset.bal(l, v$1.contents, r$1); - } - if (x < v) { - var ll = remove(l, x); - if (ll === l) { - return t; - } else { - return Belt_internalAVLset.bal(ll, v, r); - } - } - var rr = remove(r, x); - if (rr === r) { - return t; - } else { - return Belt_internalAVLset.bal(l, v, rr); - } -} - -function removeMany(h, arr) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var key = arr[i]; - v = remove(v, key); - } - return v; -} - -function splitAuxNoPivot(n, x) { - var v = n.v; - var l = n.l; - var r = n.r; - if (x === v) { - return [ - l, - r - ]; - } - if (x < v) { - if (l === undefined) { - return [ - undefined, - n - ]; - } - var match = splitAuxNoPivot(l, x); - return [ - match[0], - Belt_internalAVLset.joinShared(match[1], v, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined - ]; - } - var match$1 = splitAuxNoPivot(r, x); - return [ - Belt_internalAVLset.joinShared(l, v, match$1[0]), - match$1[1] - ]; -} - -function splitAuxPivot(n, x, pres) { - var v = n.v; - var l = n.l; - var r = n.r; - if (x === v) { - pres.contents = true; - return [ - l, - r - ]; - } - if (x < v) { - if (l === undefined) { - return [ - undefined, - n - ]; - } - var match = splitAuxPivot(l, x, pres); - return [ - match[0], - Belt_internalAVLset.joinShared(match[1], v, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined - ]; - } - var match$1 = splitAuxPivot(r, x, pres); - return [ - Belt_internalAVLset.joinShared(l, v, match$1[0]), - match$1[1] - ]; -} - -function split(t, x) { - if (t === undefined) { - return [ - [ - undefined, - undefined - ], - false - ]; - } - var pres = { - contents: false - }; - var v = splitAuxPivot(t, x, pres); - return [ - v, - pres.contents - ]; -} - -function union(s1, s2) { - if (s1 === undefined) { - return s2; - } - if (s2 === undefined) { - return s1; - } - var h1 = s1.h; - var h2 = s2.h; - if (h1 >= h2) { - if (h2 === 1) { - return add(s1, s2.v); - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var match = splitAuxNoPivot(s2, v1); - return Belt_internalAVLset.joinShared(union(l1, match[0]), v1, union(r1, match[1])); - } - if (h1 === 1) { - return add(s2, s1.v); - } - var v2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - var match$1 = splitAuxNoPivot(s1, v2); - return Belt_internalAVLset.joinShared(union(match$1[0], l2), v2, union(match$1[1], r2)); -} - -function intersect(s1, s2) { - if (s1 === undefined) { - return ; - } - if (s2 === undefined) { - return ; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var pres = { - contents: false - }; - var match = splitAuxPivot(s2, v1, pres); - var ll = intersect(l1, match[0]); - var rr = intersect(r1, match[1]); - if (pres.contents) { - return Belt_internalAVLset.joinShared(ll, v1, rr); - } else { - return Belt_internalAVLset.concatShared(ll, rr); - } -} - -function diff(s1, s2) { - if (s1 === undefined) { - return s1; - } - if (s2 === undefined) { - return s1; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var pres = { - contents: false - }; - var match = splitAuxPivot(s2, v1, pres); - var ll = diff(l1, match[0]); - var rr = diff(r1, match[1]); - if (pres.contents) { - return Belt_internalAVLset.concatShared(ll, rr); - } else { - return Belt_internalAVLset.joinShared(ll, v1, rr); - } -} - -var empty; - -var fromArray = Belt_internalSetInt.fromArray; - -var fromSortedArrayUnsafe = Belt_internalAVLset.fromSortedArrayUnsafe; - -var isEmpty = Belt_internalAVLset.isEmpty; - -var has = Belt_internalSetInt.has; - -var subset = Belt_internalSetInt.subset; - -var cmp = Belt_internalSetInt.cmp; - -var eq = Belt_internalSetInt.eq; - -var forEachU = Belt_internalAVLset.forEachU; - -var forEach = Belt_internalAVLset.forEach; - -var reduceU = Belt_internalAVLset.reduceU; - -var reduce = Belt_internalAVLset.reduce; - -var everyU = Belt_internalAVLset.everyU; - -var every = Belt_internalAVLset.every; - -var someU = Belt_internalAVLset.someU; - -var some = Belt_internalAVLset.some; - -var keepU = Belt_internalAVLset.keepSharedU; - -var keep = Belt_internalAVLset.keepShared; - -var partitionU = Belt_internalAVLset.partitionSharedU; - -var partition = Belt_internalAVLset.partitionShared; - -var size = Belt_internalAVLset.size; - -var toList = Belt_internalAVLset.toList; - -var toArray = Belt_internalAVLset.toArray; - -var minimum = Belt_internalAVLset.minimum; - -var minUndefined = Belt_internalAVLset.minUndefined; - -var maximum = Belt_internalAVLset.maximum; - -var maxUndefined = Belt_internalAVLset.maxUndefined; - -var get = Belt_internalSetInt.get; - -var getUndefined = Belt_internalSetInt.getUndefined; - -var getExn = Belt_internalSetInt.getExn; - -var checkInvariantInternal = Belt_internalAVLset.checkInvariantInternal; - -exports.empty = empty; -exports.fromArray = fromArray; -exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; -exports.isEmpty = isEmpty; -exports.has = has; -exports.add = add; -exports.mergeMany = mergeMany; -exports.remove = remove; -exports.removeMany = removeMany; -exports.union = union; -exports.intersect = intersect; -exports.diff = diff; -exports.subset = subset; -exports.cmp = cmp; -exports.eq = eq; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.keepU = keepU; -exports.keep = keep; -exports.partitionU = partitionU; -exports.partition = partition; -exports.size = size; -exports.toList = toList; -exports.toArray = toArray; -exports.minimum = minimum; -exports.minUndefined = minUndefined; -exports.maximum = maximum; -exports.maxUndefined = maxUndefined; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getExn = getExn; -exports.split = split; -exports.checkInvariantInternal = checkInvariantInternal; -/* No side effect */ diff --git a/lib/js/belt_SetString.js b/lib/js/belt_SetString.js deleted file mode 100644 index 26d69750227..00000000000 --- a/lib/js/belt_SetString.js +++ /dev/null @@ -1,357 +0,0 @@ -'use strict'; - -var Belt_internalAVLset = require("./belt_internalAVLset.js"); -var Belt_internalSetString = require("./belt_internalSetString.js"); - -function add(t, x) { - if (t === undefined) { - return Belt_internalAVLset.singleton(x); - } - var v = t.v; - if (x === v) { - return t; - } - var l = t.l; - var r = t.r; - if (x < v) { - var ll = add(l, x); - if (ll === l) { - return t; - } else { - return Belt_internalAVLset.bal(ll, v, r); - } - } - var rr = add(r, x); - if (rr === r) { - return t; - } else { - return Belt_internalAVLset.bal(l, v, rr); - } -} - -function mergeMany(h, arr) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var key = arr[i]; - v = add(v, key); - } - return v; -} - -function remove(t, x) { - if (t === undefined) { - return t; - } - var v = t.v; - var l = t.l; - var r = t.r; - if (x === v) { - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var v$1 = { - contents: r.v - }; - var r$1 = Belt_internalAVLset.removeMinAuxWithRef(r, v$1); - return Belt_internalAVLset.bal(l, v$1.contents, r$1); - } - if (x < v) { - var ll = remove(l, x); - if (ll === l) { - return t; - } else { - return Belt_internalAVLset.bal(ll, v, r); - } - } - var rr = remove(r, x); - if (rr === r) { - return t; - } else { - return Belt_internalAVLset.bal(l, v, rr); - } -} - -function removeMany(h, arr) { - var len = arr.length; - var v = h; - for(var i = 0; i < len; ++i){ - var key = arr[i]; - v = remove(v, key); - } - return v; -} - -function splitAuxNoPivot(n, x) { - var v = n.v; - var l = n.l; - var r = n.r; - if (x === v) { - return [ - l, - r - ]; - } - if (x < v) { - if (l === undefined) { - return [ - undefined, - n - ]; - } - var match = splitAuxNoPivot(l, x); - return [ - match[0], - Belt_internalAVLset.joinShared(match[1], v, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined - ]; - } - var match$1 = splitAuxNoPivot(r, x); - return [ - Belt_internalAVLset.joinShared(l, v, match$1[0]), - match$1[1] - ]; -} - -function splitAuxPivot(n, x, pres) { - var v = n.v; - var l = n.l; - var r = n.r; - if (x === v) { - pres.contents = true; - return [ - l, - r - ]; - } - if (x < v) { - if (l === undefined) { - return [ - undefined, - n - ]; - } - var match = splitAuxPivot(l, x, pres); - return [ - match[0], - Belt_internalAVLset.joinShared(match[1], v, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined - ]; - } - var match$1 = splitAuxPivot(r, x, pres); - return [ - Belt_internalAVLset.joinShared(l, v, match$1[0]), - match$1[1] - ]; -} - -function split(t, x) { - if (t === undefined) { - return [ - [ - undefined, - undefined - ], - false - ]; - } - var pres = { - contents: false - }; - var v = splitAuxPivot(t, x, pres); - return [ - v, - pres.contents - ]; -} - -function union(s1, s2) { - if (s1 === undefined) { - return s2; - } - if (s2 === undefined) { - return s1; - } - var h1 = s1.h; - var h2 = s2.h; - if (h1 >= h2) { - if (h2 === 1) { - return add(s1, s2.v); - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var match = splitAuxNoPivot(s2, v1); - return Belt_internalAVLset.joinShared(union(l1, match[0]), v1, union(r1, match[1])); - } - if (h1 === 1) { - return add(s2, s1.v); - } - var v2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - var match$1 = splitAuxNoPivot(s1, v2); - return Belt_internalAVLset.joinShared(union(match$1[0], l2), v2, union(match$1[1], r2)); -} - -function intersect(s1, s2) { - if (s1 === undefined) { - return ; - } - if (s2 === undefined) { - return ; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var pres = { - contents: false - }; - var match = splitAuxPivot(s2, v1, pres); - var ll = intersect(l1, match[0]); - var rr = intersect(r1, match[1]); - if (pres.contents) { - return Belt_internalAVLset.joinShared(ll, v1, rr); - } else { - return Belt_internalAVLset.concatShared(ll, rr); - } -} - -function diff(s1, s2) { - if (s1 === undefined) { - return s1; - } - if (s2 === undefined) { - return s1; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var pres = { - contents: false - }; - var match = splitAuxPivot(s2, v1, pres); - var ll = diff(l1, match[0]); - var rr = diff(r1, match[1]); - if (pres.contents) { - return Belt_internalAVLset.concatShared(ll, rr); - } else { - return Belt_internalAVLset.joinShared(ll, v1, rr); - } -} - -var empty; - -var fromArray = Belt_internalSetString.fromArray; - -var fromSortedArrayUnsafe = Belt_internalAVLset.fromSortedArrayUnsafe; - -var isEmpty = Belt_internalAVLset.isEmpty; - -var has = Belt_internalSetString.has; - -var subset = Belt_internalSetString.subset; - -var cmp = Belt_internalSetString.cmp; - -var eq = Belt_internalSetString.eq; - -var forEachU = Belt_internalAVLset.forEachU; - -var forEach = Belt_internalAVLset.forEach; - -var reduceU = Belt_internalAVLset.reduceU; - -var reduce = Belt_internalAVLset.reduce; - -var everyU = Belt_internalAVLset.everyU; - -var every = Belt_internalAVLset.every; - -var someU = Belt_internalAVLset.someU; - -var some = Belt_internalAVLset.some; - -var keepU = Belt_internalAVLset.keepSharedU; - -var keep = Belt_internalAVLset.keepShared; - -var partitionU = Belt_internalAVLset.partitionSharedU; - -var partition = Belt_internalAVLset.partitionShared; - -var size = Belt_internalAVLset.size; - -var toList = Belt_internalAVLset.toList; - -var toArray = Belt_internalAVLset.toArray; - -var minimum = Belt_internalAVLset.minimum; - -var minUndefined = Belt_internalAVLset.minUndefined; - -var maximum = Belt_internalAVLset.maximum; - -var maxUndefined = Belt_internalAVLset.maxUndefined; - -var get = Belt_internalSetString.get; - -var getUndefined = Belt_internalSetString.getUndefined; - -var getExn = Belt_internalSetString.getExn; - -var checkInvariantInternal = Belt_internalAVLset.checkInvariantInternal; - -exports.empty = empty; -exports.fromArray = fromArray; -exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; -exports.isEmpty = isEmpty; -exports.has = has; -exports.add = add; -exports.mergeMany = mergeMany; -exports.remove = remove; -exports.removeMany = removeMany; -exports.union = union; -exports.intersect = intersect; -exports.diff = diff; -exports.subset = subset; -exports.cmp = cmp; -exports.eq = eq; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.keepU = keepU; -exports.keep = keep; -exports.partitionU = partitionU; -exports.partition = partition; -exports.size = size; -exports.toList = toList; -exports.toArray = toArray; -exports.minimum = minimum; -exports.minUndefined = minUndefined; -exports.maximum = maximum; -exports.maxUndefined = maxUndefined; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getExn = getExn; -exports.split = split; -exports.checkInvariantInternal = checkInvariantInternal; -/* No side effect */ diff --git a/lib/js/belt_SortArray.js b/lib/js/belt_SortArray.js deleted file mode 100644 index a09c0f2f117..00000000000 --- a/lib/js/belt_SortArray.js +++ /dev/null @@ -1,425 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Belt_Array = require("./belt_Array.js"); - -function sortedLengthAuxMore(xs, _prec, _acc, len, lt) { - while(true) { - var acc = _acc; - var prec = _prec; - if (acc >= len) { - return acc; - } - var v = xs[acc]; - if (!lt(v, prec)) { - return acc; - } - _acc = acc + 1 | 0; - _prec = v; - continue ; - }; -} - -function strictlySortedLengthU(xs, lt) { - var len = xs.length; - if (len === 0 || len === 1) { - return len; - } - var x0 = xs[0]; - var x1 = xs[1]; - if (lt(x0, x1)) { - var _prec = x1; - var _acc = 2; - while(true) { - var acc = _acc; - var prec = _prec; - if (acc >= len) { - return acc; - } - var v = xs[acc]; - if (!lt(prec, v)) { - return acc; - } - _acc = acc + 1 | 0; - _prec = v; - continue ; - }; - } else if (lt(x1, x0)) { - return -sortedLengthAuxMore(xs, x1, 2, len, lt) | 0; - } else { - return 1; - } -} - -function strictlySortedLength(xs, lt) { - return strictlySortedLengthU(xs, Curry.__2(lt)); -} - -function isSortedU(a, cmp) { - var len = a.length; - if (len === 0) { - return true; - } else { - var _i = 0; - var last_bound = len - 1 | 0; - while(true) { - var i = _i; - if (i === last_bound) { - return true; - } - if (cmp(a[i], a[i + 1 | 0]) > 0) { - return false; - } - _i = i + 1 | 0; - continue ; - }; - } -} - -function isSorted(a, cmp) { - return isSortedU(a, Curry.__2(cmp)); -} - -function merge(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (cmp(s1, s2) <= 0) { - dst[d] = s1; - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return Belt_Array.blitUnsafe(src2, i2, dst, d + 1 | 0, src2r - i2 | 0); - } - _d = d + 1 | 0; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - dst[d] = s2; - var i2$1 = i2 + 1 | 0; - if (i2$1 >= src2r) { - return Belt_Array.blitUnsafe(src, i1, dst, d + 1 | 0, src1r - i1 | 0); - } - _d = d + 1 | 0; - _s2 = src2[i2$1]; - _i2 = i2$1; - continue ; - }; -} - -function unionU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - var c = cmp(s1, s2); - if (c < 0) { - dst[d] = s1; - var i1$1 = i1 + 1 | 0; - var d$1 = d + 1 | 0; - if (i1$1 < src1r) { - _d = d$1; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - Belt_Array.blitUnsafe(src2, i2, dst, d$1, src2r - i2 | 0); - return (d$1 + src2r | 0) - i2 | 0; - } - if (c === 0) { - dst[d] = s1; - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - var d$2 = d + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - if (i1$2 === src1r) { - Belt_Array.blitUnsafe(src2, i2$1, dst, d$2, src2r - i2$1 | 0); - return (d$2 + src2r | 0) - i2$1 | 0; - } else { - Belt_Array.blitUnsafe(src, i1$2, dst, d$2, src1r - i1$2 | 0); - return (d$2 + src1r | 0) - i1$2 | 0; - } - } - _d = d$2; - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - dst[d] = s2; - var i2$2 = i2 + 1 | 0; - var d$3 = d + 1 | 0; - if (i2$2 < src2r) { - _d = d$3; - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - } - Belt_Array.blitUnsafe(src, i1, dst, d$3, src1r - i1 | 0); - return (d$3 + src1r | 0) - i1 | 0; - }; -} - -function union(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - return unionU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, Curry.__2(cmp)); -} - -function intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - var c = cmp(s1, s2); - if (c < 0) { - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return d; - } - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - if (c === 0) { - dst[d] = s1; - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - var d$1 = d + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - return d$1; - } - _d = d$1; - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - var i2$2 = i2 + 1 | 0; - if (i2$2 >= src2r) { - return d; - } - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - }; -} - -function intersect(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - return intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, Curry.__2(cmp)); -} - -function diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - var c = cmp(s1, s2); - if (c < 0) { - dst[d] = s1; - var d$1 = d + 1 | 0; - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return d$1; - } - _d = d$1; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - if (c === 0) { - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - if (i1$2 === src1r) { - return d; - } else { - Belt_Array.blitUnsafe(src, i1$2, dst, d, src1r - i1$2 | 0); - return (d + src1r | 0) - i1$2 | 0; - } - } - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - var i2$2 = i2 + 1 | 0; - if (i2$2 < src2r) { - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - } - Belt_Array.blitUnsafe(src, i1, dst, d, src1r - i1 | 0); - return (d + src1r | 0) - i1 | 0; - }; -} - -function diff(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { - return diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, Curry.__2(cmp)); -} - -function insertionSort(src, srcofs, dst, dstofs, len, cmp) { - for(var i = 0; i < len; ++i){ - var e = src[srcofs + i | 0]; - var j = (dstofs + i | 0) - 1 | 0; - while(j >= dstofs && cmp(dst[j], e) > 0) { - dst[j + 1 | 0] = dst[j]; - j = j - 1 | 0; - }; - dst[j + 1 | 0] = e; - } -} - -function sortTo(src, srcofs, dst, dstofs, len, cmp) { - if (len <= 5) { - return insertionSort(src, srcofs, dst, dstofs, len, cmp); - } - var l1 = len / 2 | 0; - var l2 = len - l1 | 0; - sortTo(src, srcofs + l1 | 0, dst, dstofs + l1 | 0, l2, cmp); - sortTo(src, srcofs, src, srcofs + l2 | 0, l1, cmp); - merge(src, srcofs + l2 | 0, l1, dst, dstofs + l1 | 0, l2, dst, dstofs, cmp); -} - -function stableSortInPlaceByU(a, cmp) { - var l = a.length; - if (l <= 5) { - return insertionSort(a, 0, a, 0, l, cmp); - } - var l1 = l / 2 | 0; - var l2 = l - l1 | 0; - var t = new Array(l2); - sortTo(a, l1, t, 0, l2, cmp); - sortTo(a, 0, a, l2, l1, cmp); - merge(a, l2, l1, t, 0, l2, a, 0, cmp); -} - -function stableSortInPlaceBy(a, cmp) { - stableSortInPlaceByU(a, Curry.__2(cmp)); -} - -function stableSortByU(a, cmp) { - var b = a.slice(0); - stableSortInPlaceByU(b, cmp); - return b; -} - -function stableSortBy(a, cmp) { - return stableSortByU(a, Curry.__2(cmp)); -} - -function binarySearchByU(sorted, key, cmp) { - var len = sorted.length; - if (len === 0) { - return -1; - } - var lo = sorted[0]; - var c = cmp(key, lo); - if (c < 0) { - return -1; - } - var hi = sorted[len - 1 | 0]; - var c2 = cmp(key, hi); - if (c2 > 0) { - return -(len + 1 | 0) | 0; - } else { - var _lo = 0; - var _hi = len - 1 | 0; - while(true) { - var hi$1 = _hi; - var lo$1 = _lo; - var mid = (lo$1 + hi$1 | 0) / 2 | 0; - var midVal = sorted[mid]; - var c$1 = cmp(key, midVal); - if (c$1 === 0) { - return mid; - } - if (c$1 < 0) { - if (hi$1 === mid) { - if (cmp(sorted[lo$1], key) === 0) { - return lo$1; - } else { - return -(hi$1 + 1 | 0) | 0; - } - } - _hi = mid; - continue ; - } - if (lo$1 === mid) { - if (cmp(sorted[hi$1], key) === 0) { - return hi$1; - } else { - return -(hi$1 + 1 | 0) | 0; - } - } - _lo = mid; - continue ; - }; - } -} - -function binarySearchBy(sorted, key, cmp) { - return binarySearchByU(sorted, key, Curry.__2(cmp)); -} - -var Int; - -var $$String; - -exports.Int = Int; -exports.$$String = $$String; -exports.strictlySortedLengthU = strictlySortedLengthU; -exports.strictlySortedLength = strictlySortedLength; -exports.isSortedU = isSortedU; -exports.isSorted = isSorted; -exports.stableSortInPlaceByU = stableSortInPlaceByU; -exports.stableSortInPlaceBy = stableSortInPlaceBy; -exports.stableSortByU = stableSortByU; -exports.stableSortBy = stableSortBy; -exports.binarySearchByU = binarySearchByU; -exports.binarySearchBy = binarySearchBy; -exports.unionU = unionU; -exports.union = union; -exports.intersectU = intersectU; -exports.intersect = intersect; -exports.diffU = diffU; -exports.diff = diff; -/* No side effect */ diff --git a/lib/js/belt_SortArrayInt.js b/lib/js/belt_SortArrayInt.js deleted file mode 100644 index d1e69bb1958..00000000000 --- a/lib/js/belt_SortArrayInt.js +++ /dev/null @@ -1,372 +0,0 @@ -'use strict'; - -var Belt_Array = require("./belt_Array.js"); - -function sortedLengthAuxMore(xs, _prec, _acc, len) { - while(true) { - var acc = _acc; - var prec = _prec; - if (acc >= len) { - return acc; - } - var v = xs[acc]; - if (prec <= v) { - return acc; - } - _acc = acc + 1 | 0; - _prec = v; - continue ; - }; -} - -function strictlySortedLength(xs) { - var len = xs.length; - if (len === 0 || len === 1) { - return len; - } - var x0 = xs[0]; - var x1 = xs[1]; - if (x0 < x1) { - var _prec = x1; - var _acc = 2; - while(true) { - var acc = _acc; - var prec = _prec; - if (acc >= len) { - return acc; - } - var v = xs[acc]; - if (prec >= v) { - return acc; - } - _acc = acc + 1 | 0; - _prec = v; - continue ; - }; - } else if (x0 > x1) { - return -sortedLengthAuxMore(xs, x1, 2, len) | 0; - } else { - return 1; - } -} - -function isSorted(a) { - var len = a.length; - if (len === 0) { - return true; - } else { - var _i = 0; - var last_bound = len - 1 | 0; - while(true) { - var i = _i; - if (i === last_bound) { - return true; - } - if (a[i] > a[i + 1 | 0]) { - return false; - } - _i = i + 1 | 0; - continue ; - }; - } -} - -function merge(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (s1 <= s2) { - dst[d] = s1; - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return Belt_Array.blitUnsafe(src2, i2, dst, d + 1 | 0, src2r - i2 | 0); - } - _d = d + 1 | 0; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - dst[d] = s2; - var i2$1 = i2 + 1 | 0; - if (i2$1 >= src2r) { - return Belt_Array.blitUnsafe(src, i1, dst, d + 1 | 0, src1r - i1 | 0); - } - _d = d + 1 | 0; - _s2 = src2[i2$1]; - _i2 = i2$1; - continue ; - }; -} - -function union(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (s1 < s2) { - dst[d] = s1; - var i1$1 = i1 + 1 | 0; - var d$1 = d + 1 | 0; - if (i1$1 < src1r) { - _d = d$1; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - Belt_Array.blitUnsafe(src2, i2, dst, d$1, src2r - i2 | 0); - return (d$1 + src2r | 0) - i2 | 0; - } - if (s1 === s2) { - dst[d] = s1; - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - var d$2 = d + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - if (i1$2 === src1r) { - Belt_Array.blitUnsafe(src2, i2$1, dst, d$2, src2r - i2$1 | 0); - return (d$2 + src2r | 0) - i2$1 | 0; - } else { - Belt_Array.blitUnsafe(src, i1$2, dst, d$2, src1r - i1$2 | 0); - return (d$2 + src1r | 0) - i1$2 | 0; - } - } - _d = d$2; - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - dst[d] = s2; - var i2$2 = i2 + 1 | 0; - var d$3 = d + 1 | 0; - if (i2$2 < src2r) { - _d = d$3; - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - } - Belt_Array.blitUnsafe(src, i1, dst, d$3, src1r - i1 | 0); - return (d$3 + src1r | 0) - i1 | 0; - }; -} - -function intersect(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (s1 < s2) { - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return d; - } - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - if (s1 === s2) { - dst[d] = s1; - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - var d$1 = d + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - return d$1; - } - _d = d$1; - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - var i2$2 = i2 + 1 | 0; - if (i2$2 >= src2r) { - return d; - } - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - }; -} - -function diff(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (s1 < s2) { - dst[d] = s1; - var d$1 = d + 1 | 0; - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return d$1; - } - _d = d$1; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - if (s1 === s2) { - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - if (i1$2 === src1r) { - return d; - } else { - Belt_Array.blitUnsafe(src, i1$2, dst, d, src1r - i1$2 | 0); - return (d + src1r | 0) - i1$2 | 0; - } - } - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - var i2$2 = i2 + 1 | 0; - if (i2$2 < src2r) { - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - } - Belt_Array.blitUnsafe(src, i1, dst, d, src1r - i1 | 0); - return (d + src1r | 0) - i1 | 0; - }; -} - -function insertionSort(src, srcofs, dst, dstofs, len) { - for(var i = 0; i < len; ++i){ - var e = src[srcofs + i | 0]; - var j = (dstofs + i | 0) - 1 | 0; - while(j >= dstofs && dst[j] > e) { - dst[j + 1 | 0] = dst[j]; - j = j - 1 | 0; - }; - dst[j + 1 | 0] = e; - } -} - -function sortTo(src, srcofs, dst, dstofs, len) { - if (len <= 5) { - return insertionSort(src, srcofs, dst, dstofs, len); - } - var l1 = len / 2 | 0; - var l2 = len - l1 | 0; - sortTo(src, srcofs + l1 | 0, dst, dstofs + l1 | 0, l2); - sortTo(src, srcofs, src, srcofs + l2 | 0, l1); - merge(src, srcofs + l2 | 0, l1, dst, dstofs + l1 | 0, l2, dst, dstofs); -} - -function stableSortInPlace(a) { - var l = a.length; - if (l <= 5) { - return insertionSort(a, 0, a, 0, l); - } - var l1 = l / 2 | 0; - var l2 = l - l1 | 0; - var t = new Array(l2); - sortTo(a, l1, t, 0, l2); - sortTo(a, 0, a, l2, l1); - merge(a, l2, l1, t, 0, l2, a, 0); -} - -function stableSort(a) { - var b = a.slice(0); - stableSortInPlace(b); - return b; -} - -function binarySearch(sorted, key) { - var len = sorted.length; - if (len === 0) { - return -1; - } - var lo = sorted[0]; - if (key < lo) { - return -1; - } - var hi = sorted[len - 1 | 0]; - if (key > hi) { - return -(len + 1 | 0) | 0; - } else { - var _lo = 0; - var _hi = len - 1 | 0; - while(true) { - var hi$1 = _hi; - var lo$1 = _lo; - var mid = (lo$1 + hi$1 | 0) / 2 | 0; - var midVal = sorted[mid]; - if (key === midVal) { - return mid; - } - if (key < midVal) { - if (hi$1 === mid) { - if (sorted[lo$1] === key) { - return lo$1; - } else { - return -(hi$1 + 1 | 0) | 0; - } - } - _hi = mid; - continue ; - } - if (lo$1 === mid) { - if (sorted[hi$1] === key) { - return hi$1; - } else { - return -(hi$1 + 1 | 0) | 0; - } - } - _lo = mid; - continue ; - }; - } -} - -exports.strictlySortedLength = strictlySortedLength; -exports.isSorted = isSorted; -exports.stableSortInPlace = stableSortInPlace; -exports.stableSort = stableSort; -exports.binarySearch = binarySearch; -exports.union = union; -exports.intersect = intersect; -exports.diff = diff; -/* No side effect */ diff --git a/lib/js/belt_SortArrayString.js b/lib/js/belt_SortArrayString.js deleted file mode 100644 index d1e69bb1958..00000000000 --- a/lib/js/belt_SortArrayString.js +++ /dev/null @@ -1,372 +0,0 @@ -'use strict'; - -var Belt_Array = require("./belt_Array.js"); - -function sortedLengthAuxMore(xs, _prec, _acc, len) { - while(true) { - var acc = _acc; - var prec = _prec; - if (acc >= len) { - return acc; - } - var v = xs[acc]; - if (prec <= v) { - return acc; - } - _acc = acc + 1 | 0; - _prec = v; - continue ; - }; -} - -function strictlySortedLength(xs) { - var len = xs.length; - if (len === 0 || len === 1) { - return len; - } - var x0 = xs[0]; - var x1 = xs[1]; - if (x0 < x1) { - var _prec = x1; - var _acc = 2; - while(true) { - var acc = _acc; - var prec = _prec; - if (acc >= len) { - return acc; - } - var v = xs[acc]; - if (prec >= v) { - return acc; - } - _acc = acc + 1 | 0; - _prec = v; - continue ; - }; - } else if (x0 > x1) { - return -sortedLengthAuxMore(xs, x1, 2, len) | 0; - } else { - return 1; - } -} - -function isSorted(a) { - var len = a.length; - if (len === 0) { - return true; - } else { - var _i = 0; - var last_bound = len - 1 | 0; - while(true) { - var i = _i; - if (i === last_bound) { - return true; - } - if (a[i] > a[i + 1 | 0]) { - return false; - } - _i = i + 1 | 0; - continue ; - }; - } -} - -function merge(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (s1 <= s2) { - dst[d] = s1; - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return Belt_Array.blitUnsafe(src2, i2, dst, d + 1 | 0, src2r - i2 | 0); - } - _d = d + 1 | 0; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - dst[d] = s2; - var i2$1 = i2 + 1 | 0; - if (i2$1 >= src2r) { - return Belt_Array.blitUnsafe(src, i1, dst, d + 1 | 0, src1r - i1 | 0); - } - _d = d + 1 | 0; - _s2 = src2[i2$1]; - _i2 = i2$1; - continue ; - }; -} - -function union(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (s1 < s2) { - dst[d] = s1; - var i1$1 = i1 + 1 | 0; - var d$1 = d + 1 | 0; - if (i1$1 < src1r) { - _d = d$1; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - Belt_Array.blitUnsafe(src2, i2, dst, d$1, src2r - i2 | 0); - return (d$1 + src2r | 0) - i2 | 0; - } - if (s1 === s2) { - dst[d] = s1; - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - var d$2 = d + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - if (i1$2 === src1r) { - Belt_Array.blitUnsafe(src2, i2$1, dst, d$2, src2r - i2$1 | 0); - return (d$2 + src2r | 0) - i2$1 | 0; - } else { - Belt_Array.blitUnsafe(src, i1$2, dst, d$2, src1r - i1$2 | 0); - return (d$2 + src1r | 0) - i1$2 | 0; - } - } - _d = d$2; - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - dst[d] = s2; - var i2$2 = i2 + 1 | 0; - var d$3 = d + 1 | 0; - if (i2$2 < src2r) { - _d = d$3; - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - } - Belt_Array.blitUnsafe(src, i1, dst, d$3, src1r - i1 | 0); - return (d$3 + src1r | 0) - i1 | 0; - }; -} - -function intersect(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (s1 < s2) { - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return d; - } - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - if (s1 === s2) { - dst[d] = s1; - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - var d$1 = d + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - return d$1; - } - _d = d$1; - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - var i2$2 = i2 + 1 | 0; - if (i2$2 >= src2r) { - return d; - } - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - }; -} - -function diff(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = src[src1ofs]; - var _i2 = src2ofs; - var _s2 = src2[src2ofs]; - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (s1 < s2) { - dst[d] = s1; - var d$1 = d + 1 | 0; - var i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return d$1; - } - _d = d$1; - _s1 = src[i1$1]; - _i1 = i1$1; - continue ; - } - if (s1 === s2) { - var i1$2 = i1 + 1 | 0; - var i2$1 = i2 + 1 | 0; - if (!(i1$2 < src1r && i2$1 < src2r)) { - if (i1$2 === src1r) { - return d; - } else { - Belt_Array.blitUnsafe(src, i1$2, dst, d, src1r - i1$2 | 0); - return (d + src1r | 0) - i1$2 | 0; - } - } - _s2 = src2[i2$1]; - _i2 = i2$1; - _s1 = src[i1$2]; - _i1 = i1$2; - continue ; - } - var i2$2 = i2 + 1 | 0; - if (i2$2 < src2r) { - _s2 = src2[i2$2]; - _i2 = i2$2; - continue ; - } - Belt_Array.blitUnsafe(src, i1, dst, d, src1r - i1 | 0); - return (d + src1r | 0) - i1 | 0; - }; -} - -function insertionSort(src, srcofs, dst, dstofs, len) { - for(var i = 0; i < len; ++i){ - var e = src[srcofs + i | 0]; - var j = (dstofs + i | 0) - 1 | 0; - while(j >= dstofs && dst[j] > e) { - dst[j + 1 | 0] = dst[j]; - j = j - 1 | 0; - }; - dst[j + 1 | 0] = e; - } -} - -function sortTo(src, srcofs, dst, dstofs, len) { - if (len <= 5) { - return insertionSort(src, srcofs, dst, dstofs, len); - } - var l1 = len / 2 | 0; - var l2 = len - l1 | 0; - sortTo(src, srcofs + l1 | 0, dst, dstofs + l1 | 0, l2); - sortTo(src, srcofs, src, srcofs + l2 | 0, l1); - merge(src, srcofs + l2 | 0, l1, dst, dstofs + l1 | 0, l2, dst, dstofs); -} - -function stableSortInPlace(a) { - var l = a.length; - if (l <= 5) { - return insertionSort(a, 0, a, 0, l); - } - var l1 = l / 2 | 0; - var l2 = l - l1 | 0; - var t = new Array(l2); - sortTo(a, l1, t, 0, l2); - sortTo(a, 0, a, l2, l1); - merge(a, l2, l1, t, 0, l2, a, 0); -} - -function stableSort(a) { - var b = a.slice(0); - stableSortInPlace(b); - return b; -} - -function binarySearch(sorted, key) { - var len = sorted.length; - if (len === 0) { - return -1; - } - var lo = sorted[0]; - if (key < lo) { - return -1; - } - var hi = sorted[len - 1 | 0]; - if (key > hi) { - return -(len + 1 | 0) | 0; - } else { - var _lo = 0; - var _hi = len - 1 | 0; - while(true) { - var hi$1 = _hi; - var lo$1 = _lo; - var mid = (lo$1 + hi$1 | 0) / 2 | 0; - var midVal = sorted[mid]; - if (key === midVal) { - return mid; - } - if (key < midVal) { - if (hi$1 === mid) { - if (sorted[lo$1] === key) { - return lo$1; - } else { - return -(hi$1 + 1 | 0) | 0; - } - } - _hi = mid; - continue ; - } - if (lo$1 === mid) { - if (sorted[hi$1] === key) { - return hi$1; - } else { - return -(hi$1 + 1 | 0) | 0; - } - } - _lo = mid; - continue ; - }; - } -} - -exports.strictlySortedLength = strictlySortedLength; -exports.isSorted = isSorted; -exports.stableSortInPlace = stableSortInPlace; -exports.stableSort = stableSort; -exports.binarySearch = binarySearch; -exports.union = union; -exports.intersect = intersect; -exports.diff = diff; -/* No side effect */ diff --git a/lib/js/belt_internalAVLset.js b/lib/js/belt_internalAVLset.js deleted file mode 100644 index 8140346f0cc..00000000000 --- a/lib/js/belt_internalAVLset.js +++ /dev/null @@ -1,938 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Caml_option = require("./caml_option.js"); -var Belt_SortArray = require("./belt_SortArray.js"); - -function copy(n) { - if (n !== undefined) { - return { - v: n.v, - h: n.h, - l: copy(n.l), - r: copy(n.r) - }; - } else { - return n; - } -} - -function create(l, v, r) { - var hl = l !== undefined ? l.h : 0; - var hr = r !== undefined ? r.h : 0; - return { - v: v, - h: ( - hl >= hr ? hl : hr - ) + 1 | 0, - l: l, - r: r - }; -} - -function singleton(x) { - return { - v: x, - h: 1, - l: undefined, - r: undefined - }; -} - -function heightGe(l, r) { - if (r !== undefined) { - if (l !== undefined) { - return l.h >= r.h; - } else { - return false; - } - } else { - return true; - } -} - -function bal(l, v, r) { - var hl = l !== undefined ? l.h : 0; - var hr = r !== undefined ? r.h : 0; - if (hl > (hr + 2 | 0)) { - var ll = l.l; - var 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)); - } - } - if (hr <= (hl + 2 | 0)) { - return { - v: v, - h: ( - hl >= hr ? hl : hr - ) + 1 | 0, - l: l, - r: r - }; - } - var rl = r.l; - var 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)); - } -} - -function min0Aux(_n) { - while(true) { - var n = _n; - var n$1 = n.l; - if (n$1 === undefined) { - return n.v; - } - _n = n$1; - continue ; - }; -} - -function minimum(n) { - if (n !== undefined) { - return Caml_option.some(min0Aux(n)); - } - -} - -function minUndefined(n) { - if (n !== undefined) { - return min0Aux(n); - } - -} - -function max0Aux(_n) { - while(true) { - var n = _n; - var n$1 = n.r; - if (n$1 === undefined) { - return n.v; - } - _n = n$1; - continue ; - }; -} - -function maximum(n) { - if (n !== undefined) { - return Caml_option.some(max0Aux(n)); - } - -} - -function maxUndefined(n) { - if (n !== undefined) { - return max0Aux(n); - } - -} - -function removeMinAuxWithRef(n, v) { - var ln = n.l; - if (ln !== undefined) { - return bal(removeMinAuxWithRef(ln, v), n.v, n.r); - } else { - v.contents = n.v; - return n.r; - } -} - -function isEmpty(n) { - return n === undefined; -} - -function stackAllLeft(_v, _s) { - while(true) { - var s = _s; - var v = _v; - if (v === undefined) { - return s; - } - _s = { - hd: v, - tl: s - }; - _v = v.l; - continue ; - }; -} - -function forEachU(_n, f) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - forEachU(n.l, f); - f(n.v); - _n = n.r; - continue ; - }; -} - -function forEach(n, f) { - forEachU(n, Curry.__1(f)); -} - -function reduceU(_s, _accu, f) { - while(true) { - var accu = _accu; - var s = _s; - if (s === undefined) { - return accu; - } - _accu = f(reduceU(s.l, accu, f), s.v); - _s = s.r; - continue ; - }; -} - -function reduce(s, accu, f) { - return reduceU(s, accu, Curry.__2(f)); -} - -function everyU(_n, p) { - while(true) { - var n = _n; - if (n === undefined) { - return true; - } - if (!p(n.v)) { - return false; - } - if (!everyU(n.l, p)) { - return false; - } - _n = n.r; - continue ; - }; -} - -function every(n, p) { - return everyU(n, Curry.__1(p)); -} - -function someU(_n, p) { - while(true) { - var n = _n; - if (n === undefined) { - return false; - } - if (p(n.v)) { - return true; - } - if (someU(n.l, p)) { - return true; - } - _n = n.r; - continue ; - }; -} - -function some(n, p) { - return someU(n, Curry.__1(p)); -} - -function addMinElement(n, v) { - if (n !== undefined) { - return bal(addMinElement(n.l, v), n.v, n.r); - } else { - return singleton(v); - } -} - -function addMaxElement(n, v) { - if (n !== undefined) { - return bal(n.l, n.v, addMaxElement(n.r, v)); - } else { - return singleton(v); - } -} - -function joinShared(ln, v, rn) { - if (ln === undefined) { - return addMinElement(rn, v); - } - if (rn === undefined) { - return addMaxElement(ln, v); - } - var lh = ln.h; - var rh = rn.h; - if (lh > (rh + 2 | 0)) { - return bal(ln.l, ln.v, joinShared(ln.r, v, rn)); - } else if (rh > (lh + 2 | 0)) { - return bal(joinShared(ln, v, rn.l), rn.v, rn.r); - } else { - return create(ln, v, rn); - } -} - -function concatShared(t1, t2) { - if (t1 === undefined) { - return t2; - } - if (t2 === undefined) { - return t1; - } - var v = { - contents: t2.v - }; - var t2r = removeMinAuxWithRef(t2, v); - return joinShared(t1, v.contents, t2r); -} - -function partitionSharedU(n, p) { - if (n === undefined) { - return [ - undefined, - undefined - ]; - } - var value = n.v; - var match = partitionSharedU(n.l, p); - var lf = match[1]; - var lt = match[0]; - var pv = p(value); - var match$1 = partitionSharedU(n.r, p); - var rf = match$1[1]; - var rt = match$1[0]; - if (pv) { - return [ - joinShared(lt, value, rt), - concatShared(lf, rf) - ]; - } else { - return [ - concatShared(lt, rt), - joinShared(lf, value, rf) - ]; - } -} - -function partitionShared(n, p) { - return partitionSharedU(n, Curry.__1(p)); -} - -function lengthNode(n) { - var l = n.l; - var r = n.r; - var sizeL = l !== undefined ? lengthNode(l) : 0; - var sizeR = r !== undefined ? lengthNode(r) : 0; - return (1 + sizeL | 0) + sizeR | 0; -} - -function size(n) { - if (n !== undefined) { - return lengthNode(n); - } else { - return 0; - } -} - -function toListAux(_n, _accu) { - while(true) { - var accu = _accu; - var n = _n; - if (n === undefined) { - return accu; - } - _accu = { - hd: n.v, - tl: toListAux(n.r, accu) - }; - _n = n.l; - continue ; - }; -} - -function toList(s) { - return toListAux(s, /* [] */0); -} - -function checkInvariantInternal(_v) { - while(true) { - var v = _v; - if (v === undefined) { - return ; - } - var l = v.l; - var r = v.r; - var diff = ( - l !== undefined ? l.h : 0 - ) - ( - r !== undefined ? r.h : 0 - ) | 0; - if (!(diff <= 2 && diff >= -2)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLset.res", - 319, - 4 - ], - Error: new Error() - }; - } - checkInvariantInternal(l); - _v = r; - continue ; - }; -} - -function fillArray(_n, _i, arr) { - while(true) { - var i = _i; - var n = _n; - var v = n.v; - var l = n.l; - var r = n.r; - var next = l !== undefined ? fillArray(l, i, arr) : i; - arr[next] = v; - var rnext = next + 1 | 0; - if (r === undefined) { - return rnext; - } - _i = rnext; - _n = r; - continue ; - }; -} - -function fillArrayWithPartition(_n, cursor, arr, p) { - while(true) { - var n = _n; - var v = n.v; - var l = n.l; - var r = n.r; - if (l !== undefined) { - fillArrayWithPartition(l, cursor, arr, p); - } - if (p(v)) { - var c = cursor.forward; - arr[c] = v; - cursor.forward = c + 1 | 0; - } else { - var c$1 = cursor.backward; - arr[c$1] = v; - cursor.backward = c$1 - 1 | 0; - } - if (r === undefined) { - return ; - } - _n = r; - continue ; - }; -} - -function fillArrayWithFilter(_n, _i, arr, p) { - while(true) { - var i = _i; - var n = _n; - var v = n.v; - var l = n.l; - var r = n.r; - var next = l !== undefined ? fillArrayWithFilter(l, i, arr, p) : i; - var rnext = p(v) ? (arr[next] = v, next + 1 | 0) : next; - if (r === undefined) { - return rnext; - } - _i = rnext; - _n = r; - continue ; - }; -} - -function toArray(n) { - if (n === undefined) { - return []; - } - var size = lengthNode(n); - var v = new Array(size); - fillArray(n, 0, v); - return v; -} - -function fromSortedArrayRevAux(arr, off, len) { - switch (len) { - case 0 : - return ; - case 1 : - return singleton(arr[off]); - case 2 : - var x0 = arr[off]; - var x1 = arr[off - 1 | 0]; - return { - v: x1, - h: 2, - l: singleton(x0), - r: undefined - }; - case 3 : - var x0$1 = arr[off]; - var x1$1 = arr[off - 1 | 0]; - var x2 = arr[off - 2 | 0]; - return { - v: x1$1, - h: 2, - l: singleton(x0$1), - r: singleton(x2) - }; - default: - var nl = len / 2 | 0; - var left = fromSortedArrayRevAux(arr, off, nl); - var mid = arr[off - nl | 0]; - var right = fromSortedArrayRevAux(arr, (off - nl | 0) - 1 | 0, (len - nl | 0) - 1 | 0); - return create(left, mid, right); - } -} - -function fromSortedArrayAux(arr, off, len) { - switch (len) { - case 0 : - return ; - case 1 : - return singleton(arr[off]); - case 2 : - var x0 = arr[off]; - var x1 = arr[off + 1 | 0]; - return { - v: x1, - h: 2, - l: singleton(x0), - r: undefined - }; - case 3 : - var x0$1 = arr[off]; - var x1$1 = arr[off + 1 | 0]; - var x2 = arr[off + 2 | 0]; - return { - v: x1$1, - h: 2, - l: singleton(x0$1), - r: singleton(x2) - }; - default: - var nl = len / 2 | 0; - var left = fromSortedArrayAux(arr, off, nl); - var mid = arr[off + nl | 0]; - var right = fromSortedArrayAux(arr, (off + nl | 0) + 1 | 0, (len - nl | 0) - 1 | 0); - return create(left, mid, right); - } -} - -function fromSortedArrayUnsafe(arr) { - return fromSortedArrayAux(arr, 0, arr.length); -} - -function keepSharedU(n, p) { - if (n === undefined) { - return ; - } - var v = n.v; - var l = n.l; - var r = n.r; - var newL = keepSharedU(l, p); - var pv = p(v); - var newR = keepSharedU(r, p); - if (pv) { - if (l === newL && r === newR) { - return n; - } else { - return joinShared(newL, v, newR); - } - } else { - return concatShared(newL, newR); - } -} - -function keepShared(n, p) { - return keepSharedU(n, Curry.__1(p)); -} - -function keepCopyU(n, p) { - if (n === undefined) { - return ; - } - var size = lengthNode(n); - var v = new Array(size); - var last = fillArrayWithFilter(n, 0, v, p); - return fromSortedArrayAux(v, 0, last); -} - -function keepCopy(n, p) { - return keepCopyU(n, Curry.__1(p)); -} - -function partitionCopyU(n, p) { - if (n === undefined) { - return [ - undefined, - undefined - ]; - } - var size = lengthNode(n); - var v = new Array(size); - var backward = size - 1 | 0; - var cursor = { - forward: 0, - backward: backward - }; - fillArrayWithPartition(n, cursor, v, p); - var forwardLen = cursor.forward; - return [ - fromSortedArrayAux(v, 0, forwardLen), - fromSortedArrayRevAux(v, backward, size - forwardLen | 0) - ]; -} - -function partitionCopy(n, p) { - return partitionCopyU(n, Curry.__1(p)); -} - -function has(_t, x, cmp) { - while(true) { - var t = _t; - if (t === undefined) { - return false; - } - var v = t.v; - var c = cmp(x, v); - if (c === 0) { - return true; - } - _t = c < 0 ? t.l : t.r; - continue ; - }; -} - -function cmp(s1, s2, cmp$1) { - var len1 = size(s1); - var len2 = size(s2); - if (len1 === len2) { - var _e1 = stackAllLeft(s1, /* [] */0); - var _e2 = stackAllLeft(s2, /* [] */0); - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return 0; - } - if (!e2) { - return 0; - } - var h2 = e2.hd; - var h1 = e1.hd; - var c = cmp$1(h1.v, h2.v); - if (c !== 0) { - return c; - } - _e2 = stackAllLeft(h2.r, e2.tl); - _e1 = stackAllLeft(h1.r, e1.tl); - continue ; - }; - } else if (len1 < len2) { - return -1; - } else { - return 1; - } -} - -function eq(s1, s2, c) { - return cmp(s1, s2, c) === 0; -} - -function subset(_s1, _s2, cmp) { - while(true) { - var s2 = _s2; - var s1 = _s1; - if (s1 === undefined) { - return true; - } - if (s2 === undefined) { - return false; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var v2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - var c = cmp(v1, v2); - if (c === 0) { - if (!subset(l1, l2, cmp)) { - return false; - } - _s2 = r2; - _s1 = r1; - continue ; - } - if (c < 0) { - if (!subset(create(l1, v1, undefined), l2, cmp)) { - return false; - } - _s1 = r1; - continue ; - } - if (!subset(create(undefined, v1, r1), r2, cmp)) { - return false; - } - _s1 = l1; - continue ; - }; -} - -function get(_n, x, cmp) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.v; - var c = cmp(x, v); - if (c === 0) { - return Caml_option.some(v); - } - _n = c < 0 ? n.l : n.r; - continue ; - }; -} - -function getUndefined(_n, x, cmp) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.v; - var c = cmp(x, v); - if (c === 0) { - return v; - } - _n = c < 0 ? n.l : n.r; - continue ; - }; -} - -function getExn(_n, x, cmp) { - while(true) { - var n = _n; - if (n !== undefined) { - var v = n.v; - var c = cmp(x, v); - if (c === 0) { - return v; - } - _n = c < 0 ? n.l : n.r; - continue ; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function rotateWithLeftChild(k2) { - var k1 = k2.l; - k2.l = k1.r; - k1.r = k2; - var n = k2.l; - var hlk2 = n !== undefined ? n.h : 0; - var n$1 = k2.r; - var hrk2 = n$1 !== undefined ? n$1.h : 0; - k2.h = ( - hlk2 > hrk2 ? hlk2 : hrk2 - ) + 1 | 0; - var n$2 = k1.l; - var hlk1 = n$2 !== undefined ? n$2.h : 0; - var hk2 = k2.h; - k1.h = ( - hlk1 > hk2 ? hlk1 : hk2 - ) + 1 | 0; - return k1; -} - -function rotateWithRightChild(k1) { - var k2 = k1.r; - k1.r = k2.l; - k2.l = k1; - var n = k1.l; - var hlk1 = n !== undefined ? n.h : 0; - var n$1 = k1.r; - var hrk1 = n$1 !== undefined ? n$1.h : 0; - k1.h = ( - hlk1 > hrk1 ? hlk1 : hrk1 - ) + 1 | 0; - var n$2 = k2.r; - var hrk2 = n$2 !== undefined ? n$2.h : 0; - var hk1 = k1.h; - k2.h = ( - hrk2 > hk1 ? hrk2 : hk1 - ) + 1 | 0; - return k2; -} - -function doubleWithLeftChild(k3) { - var k3l = k3.l; - var v = rotateWithRightChild(k3l); - k3.l = v; - return rotateWithLeftChild(k3); -} - -function doubleWithRightChild(k2) { - var k2r = k2.r; - var v = rotateWithLeftChild(k2r); - k2.r = v; - return rotateWithRightChild(k2); -} - -function heightUpdateMutate(t) { - var n = t.l; - var hlt = n !== undefined ? n.h : 0; - var n$1 = t.r; - var hrt = n$1 !== undefined ? n$1.h : 0; - t.h = ( - hlt > hrt ? hlt : hrt - ) + 1 | 0; - return t; -} - -function balMutate(nt) { - var l = nt.l; - var r = nt.r; - var hl = l !== undefined ? l.h : 0; - var hr = r !== undefined ? r.h : 0; - if (hl > (2 + hr | 0)) { - var ll = l.l; - var lr = l.r; - if (heightGe(ll, lr)) { - return heightUpdateMutate(rotateWithLeftChild(nt)); - } else { - return heightUpdateMutate(doubleWithLeftChild(nt)); - } - } - if (hr > (2 + hl | 0)) { - var rl = r.l; - var rr = r.r; - if (heightGe(rr, rl)) { - return heightUpdateMutate(rotateWithRightChild(nt)); - } else { - return heightUpdateMutate(doubleWithRightChild(nt)); - } - } - nt.h = ( - hl > hr ? hl : hr - ) + 1 | 0; - return nt; -} - -function addMutate(cmp, t, x) { - if (t === undefined) { - return singleton(x); - } - var k = t.v; - var c = cmp(x, k); - if (c === 0) { - return t; - } - var l = t.l; - var r = t.r; - if (c < 0) { - var ll = addMutate(cmp, l, x); - t.l = ll; - } else { - t.r = addMutate(cmp, r, x); - } - return balMutate(t); -} - -function fromArray(xs, cmp) { - var len = xs.length; - if (len === 0) { - return ; - } - var next = Belt_SortArray.strictlySortedLengthU(xs, (function (x, y) { - return cmp(x, y) < 0; - })); - var result; - if (next >= 0) { - result = fromSortedArrayAux(xs, 0, next); - } else { - next = -next | 0; - result = fromSortedArrayRevAux(xs, next - 1 | 0, next); - } - for(var i = next; i < len; ++i){ - result = addMutate(cmp, result, xs[i]); - } - return result; -} - -function removeMinAuxWithRootMutate(nt, n) { - var ln = n.l; - var rn = n.r; - if (ln !== undefined) { - n.l = removeMinAuxWithRootMutate(nt, ln); - return balMutate(n); - } else { - nt.v = n.v; - return rn; - } -} - -exports.copy = copy; -exports.create = create; -exports.bal = bal; -exports.singleton = singleton; -exports.minimum = minimum; -exports.minUndefined = minUndefined; -exports.maximum = maximum; -exports.maxUndefined = maxUndefined; -exports.removeMinAuxWithRef = removeMinAuxWithRef; -exports.isEmpty = isEmpty; -exports.stackAllLeft = stackAllLeft; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.joinShared = joinShared; -exports.concatShared = concatShared; -exports.keepSharedU = keepSharedU; -exports.keepShared = keepShared; -exports.keepCopyU = keepCopyU; -exports.keepCopy = keepCopy; -exports.partitionSharedU = partitionSharedU; -exports.partitionShared = partitionShared; -exports.partitionCopyU = partitionCopyU; -exports.partitionCopy = partitionCopy; -exports.lengthNode = lengthNode; -exports.size = size; -exports.toList = toList; -exports.checkInvariantInternal = checkInvariantInternal; -exports.fillArray = fillArray; -exports.toArray = toArray; -exports.fromSortedArrayAux = fromSortedArrayAux; -exports.fromSortedArrayRevAux = fromSortedArrayRevAux; -exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; -exports.has = has; -exports.cmp = cmp; -exports.eq = eq; -exports.subset = subset; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getExn = getExn; -exports.fromArray = fromArray; -exports.addMutate = addMutate; -exports.balMutate = balMutate; -exports.removeMinAuxWithRootMutate = removeMinAuxWithRootMutate; -/* No side effect */ diff --git a/lib/js/belt_internalAVLtree.js b/lib/js/belt_internalAVLtree.js deleted file mode 100644 index f9f85077b4b..00000000000 --- a/lib/js/belt_internalAVLtree.js +++ /dev/null @@ -1,1144 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Caml_option = require("./caml_option.js"); -var Belt_SortArray = require("./belt_SortArray.js"); - -function treeHeight(n) { - if (n !== undefined) { - return n.h; - } else { - return 0; - } -} - -function copy(n) { - if (n !== undefined) { - return { - k: n.k, - v: n.v, - h: n.h, - l: copy(n.l), - r: copy(n.r) - }; - } else { - return n; - } -} - -function create(l, x, d, r) { - var hl = treeHeight(l); - var hr = treeHeight(r); - return { - k: x, - v: d, - h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0, - l: l, - r: r - }; -} - -function singleton(x, d) { - return { - k: x, - v: d, - h: 1, - l: undefined, - r: undefined - }; -} - -function heightGe(l, r) { - if (r !== undefined) { - if (l !== undefined) { - return l.h >= r.h; - } else { - return false; - } - } else { - return true; - } -} - -function updateValue(n, newValue) { - if (n.v === newValue) { - return n; - } else { - return { - k: n.k, - v: newValue, - h: n.h, - l: n.l, - r: n.r - }; - } -} - -function bal(l, x, d, r) { - var hl = l !== undefined ? l.h : 0; - var hr = r !== undefined ? r.h : 0; - if (hl > (hr + 2 | 0)) { - var ll = l.l; - var 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)); - } - } - if (hr <= (hl + 2 | 0)) { - return { - k: x, - v: d, - h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0, - l: l, - r: r - }; - } - var rl = r.l; - var 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)); - } -} - -function minKey0Aux(_n) { - while(true) { - var n = _n; - var n$1 = n.l; - if (n$1 === undefined) { - return n.k; - } - _n = n$1; - continue ; - }; -} - -function minKey(n) { - if (n !== undefined) { - return Caml_option.some(minKey0Aux(n)); - } - -} - -function minKeyUndefined(n) { - if (n !== undefined) { - return minKey0Aux(n); - } - -} - -function maxKey0Aux(_n) { - while(true) { - var n = _n; - var n$1 = n.r; - if (n$1 === undefined) { - return n.k; - } - _n = n$1; - continue ; - }; -} - -function maxKey(n) { - if (n !== undefined) { - return Caml_option.some(maxKey0Aux(n)); - } - -} - -function maxKeyUndefined(n) { - if (n !== undefined) { - return maxKey0Aux(n); - } - -} - -function minKV0Aux(_n) { - while(true) { - var n = _n; - var n$1 = n.l; - if (n$1 === undefined) { - return [ - n.k, - n.v - ]; - } - _n = n$1; - continue ; - }; -} - -function minimum(n) { - if (n !== undefined) { - return minKV0Aux(n); - } - -} - -function minUndefined(n) { - if (n !== undefined) { - return minKV0Aux(n); - } - -} - -function maxKV0Aux(_n) { - while(true) { - var n = _n; - var n$1 = n.r; - if (n$1 === undefined) { - return [ - n.k, - n.v - ]; - } - _n = n$1; - continue ; - }; -} - -function maximum(n) { - if (n !== undefined) { - return maxKV0Aux(n); - } - -} - -function maxUndefined(n) { - if (n !== undefined) { - return maxKV0Aux(n); - } - -} - -function removeMinAuxWithRef(n, kr, vr) { - var ln = n.l; - if (ln !== undefined) { - return bal(removeMinAuxWithRef(ln, kr, vr), n.k, n.v, n.r); - } else { - kr.contents = n.k; - vr.contents = n.v; - return n.r; - } -} - -function isEmpty(x) { - return x === undefined; -} - -function stackAllLeft(_v, _s) { - while(true) { - var s = _s; - var v = _v; - if (v === undefined) { - return s; - } - _s = { - hd: v, - tl: s - }; - _v = v.l; - continue ; - }; -} - -function findFirstByU(n, p) { - if (n === undefined) { - return ; - } - var left = findFirstByU(n.l, p); - if (left !== undefined) { - return left; - } - var v = n.k; - var d = n.v; - var pvd = p(v, d); - if (pvd) { - return [ - v, - d - ]; - } - var right = findFirstByU(n.r, p); - if (right !== undefined) { - return right; - } - -} - -function findFirstBy(n, p) { - return findFirstByU(n, Curry.__2(p)); -} - -function forEachU(_n, f) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - forEachU(n.l, f); - f(n.k, n.v); - _n = n.r; - continue ; - }; -} - -function forEach(n, f) { - forEachU(n, Curry.__2(f)); -} - -function mapU(n, f) { - if (n === undefined) { - return ; - } - var newLeft = mapU(n.l, f); - var newD = f(n.v); - var newRight = mapU(n.r, f); - return { - k: n.k, - v: newD, - h: n.h, - l: newLeft, - r: newRight - }; -} - -function map(n, f) { - return mapU(n, Curry.__1(f)); -} - -function mapWithKeyU(n, f) { - if (n === undefined) { - return ; - } - var key = n.k; - var newLeft = mapWithKeyU(n.l, f); - var newD = f(key, n.v); - var newRight = mapWithKeyU(n.r, f); - return { - k: key, - v: newD, - h: n.h, - l: newLeft, - r: newRight - }; -} - -function mapWithKey(n, f) { - return mapWithKeyU(n, Curry.__2(f)); -} - -function reduceU(_m, _accu, f) { - while(true) { - var accu = _accu; - var m = _m; - if (m === undefined) { - return accu; - } - var v = m.k; - var d = m.v; - var l = m.l; - var r = m.r; - _accu = f(reduceU(l, accu, f), v, d); - _m = r; - continue ; - }; -} - -function reduce(m, accu, f) { - return reduceU(m, accu, Curry.__3(f)); -} - -function everyU(_n, p) { - while(true) { - var n = _n; - if (n === undefined) { - return true; - } - if (!p(n.k, n.v)) { - return false; - } - if (!everyU(n.l, p)) { - return false; - } - _n = n.r; - continue ; - }; -} - -function every(n, p) { - return everyU(n, Curry.__2(p)); -} - -function someU(_n, p) { - while(true) { - var n = _n; - if (n === undefined) { - return false; - } - if (p(n.k, n.v)) { - return true; - } - if (someU(n.l, p)) { - return true; - } - _n = n.r; - continue ; - }; -} - -function some(n, p) { - return someU(n, Curry.__2(p)); -} - -function addMinElement(n, k, v) { - if (n !== undefined) { - return bal(addMinElement(n.l, k, v), n.k, n.v, n.r); - } else { - return singleton(k, v); - } -} - -function addMaxElement(n, k, v) { - if (n !== undefined) { - return bal(n.l, n.k, n.v, addMaxElement(n.r, k, v)); - } else { - return singleton(k, v); - } -} - -function join(ln, v, d, rn) { - if (ln === undefined) { - return addMinElement(rn, v, d); - } - if (rn === undefined) { - return addMaxElement(ln, v, d); - } - var lv = ln.k; - var ld = ln.v; - var lh = ln.h; - var ll = ln.l; - var lr = ln.r; - var rv = rn.k; - var rd = rn.v; - var rh = rn.h; - var rl = rn.l; - var rr = rn.r; - if (lh > (rh + 2 | 0)) { - return bal(ll, lv, ld, join(lr, v, d, rn)); - } else if (rh > (lh + 2 | 0)) { - return bal(join(ln, v, d, rl), rv, rd, rr); - } else { - return create(ln, v, d, rn); - } -} - -function concat(t1, t2) { - if (t1 === undefined) { - return t2; - } - if (t2 === undefined) { - return t1; - } - var kr = { - contents: t2.k - }; - var vr = { - contents: t2.v - }; - var t2r = removeMinAuxWithRef(t2, kr, vr); - return join(t1, kr.contents, vr.contents, t2r); -} - -function concatOrJoin(t1, v, d, t2) { - if (d !== undefined) { - return join(t1, v, Caml_option.valFromOption(d), t2); - } else { - return concat(t1, t2); - } -} - -function keepSharedU(n, p) { - if (n === undefined) { - return ; - } - var v = n.k; - var d = n.v; - var newLeft = keepSharedU(n.l, p); - var pvd = p(v, d); - var newRight = keepSharedU(n.r, p); - if (pvd) { - return join(newLeft, v, d, newRight); - } else { - return concat(newLeft, newRight); - } -} - -function keepShared(n, p) { - return keepSharedU(n, Curry.__2(p)); -} - -function keepMapU(n, p) { - if (n === undefined) { - return ; - } - var v = n.k; - var d = n.v; - var newLeft = keepMapU(n.l, p); - var pvd = p(v, d); - var newRight = keepMapU(n.r, p); - if (pvd !== undefined) { - return join(newLeft, v, Caml_option.valFromOption(pvd), newRight); - } else { - return concat(newLeft, newRight); - } -} - -function keepMap(n, p) { - return keepMapU(n, Curry.__2(p)); -} - -function partitionSharedU(n, p) { - if (n === undefined) { - return [ - undefined, - undefined - ]; - } - var key = n.k; - var value = n.v; - var match = partitionSharedU(n.l, p); - var lf = match[1]; - var lt = match[0]; - var pvd = p(key, value); - var match$1 = partitionSharedU(n.r, p); - var rf = match$1[1]; - var rt = match$1[0]; - if (pvd) { - return [ - join(lt, key, value, rt), - concat(lf, rf) - ]; - } else { - return [ - concat(lt, rt), - join(lf, key, value, rf) - ]; - } -} - -function partitionShared(n, p) { - return partitionSharedU(n, Curry.__2(p)); -} - -function lengthNode(n) { - var l = n.l; - var r = n.r; - var sizeL = l !== undefined ? lengthNode(l) : 0; - var sizeR = r !== undefined ? lengthNode(r) : 0; - return (1 + sizeL | 0) + sizeR | 0; -} - -function size(n) { - if (n !== undefined) { - return lengthNode(n); - } else { - return 0; - } -} - -function toListAux(_n, _accu) { - while(true) { - var accu = _accu; - var n = _n; - if (n === undefined) { - return accu; - } - var k = n.k; - var v = n.v; - var l = n.l; - var r = n.r; - _accu = { - hd: [ - k, - v - ], - tl: toListAux(r, accu) - }; - _n = l; - continue ; - }; -} - -function toList(s) { - return toListAux(s, /* [] */0); -} - -function checkInvariantInternal(_v) { - while(true) { - var v = _v; - if (v === undefined) { - return ; - } - var l = v.l; - var r = v.r; - var diff = treeHeight(l) - treeHeight(r) | 0; - if (!(diff <= 2 && diff >= -2)) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "belt_internalAVLtree.res", - 457, - 4 - ], - Error: new Error() - }; - } - checkInvariantInternal(l); - _v = r; - continue ; - }; -} - -function fillArrayKey(_n, _i, arr) { - while(true) { - var i = _i; - var n = _n; - var v = n.k; - var l = n.l; - var r = n.r; - var next = l !== undefined ? fillArrayKey(l, i, arr) : i; - arr[next] = v; - var rnext = next + 1 | 0; - if (r === undefined) { - return rnext; - } - _i = rnext; - _n = r; - continue ; - }; -} - -function fillArrayValue(_n, _i, arr) { - while(true) { - var i = _i; - var n = _n; - var l = n.l; - var r = n.r; - var next = l !== undefined ? fillArrayValue(l, i, arr) : i; - arr[next] = n.v; - var rnext = next + 1 | 0; - if (r === undefined) { - return rnext; - } - _i = rnext; - _n = r; - continue ; - }; -} - -function fillArray(_n, _i, arr) { - while(true) { - var i = _i; - var n = _n; - var l = n.l; - var v = n.k; - var r = n.r; - var next = l !== undefined ? fillArray(l, i, arr) : i; - arr[next] = [ - v, - n.v - ]; - var rnext = next + 1 | 0; - if (r === undefined) { - return rnext; - } - _i = rnext; - _n = r; - continue ; - }; -} - -function toArray(n) { - if (n === undefined) { - return []; - } - var size = lengthNode(n); - var v = new Array(size); - fillArray(n, 0, v); - return v; -} - -function keysToArray(n) { - if (n === undefined) { - return []; - } - var size = lengthNode(n); - var v = new Array(size); - fillArrayKey(n, 0, v); - return v; -} - -function valuesToArray(n) { - if (n === undefined) { - return []; - } - var size = lengthNode(n); - var v = new Array(size); - fillArrayValue(n, 0, v); - return v; -} - -function fromSortedArrayRevAux(arr, off, len) { - switch (len) { - case 0 : - return ; - case 1 : - var match = arr[off]; - return singleton(match[0], match[1]); - case 2 : - var match_0 = arr[off]; - var match_1 = arr[off - 1 | 0]; - var match$1 = match_1; - var match$2 = match_0; - return { - k: match$1[0], - v: match$1[1], - h: 2, - l: singleton(match$2[0], match$2[1]), - r: undefined - }; - case 3 : - var match_0$1 = arr[off]; - var match_1$1 = arr[off - 1 | 0]; - var match_2 = arr[off - 2 | 0]; - var match$3 = match_2; - var match$4 = match_1$1; - var match$5 = match_0$1; - return { - k: match$4[0], - v: match$4[1], - h: 2, - l: singleton(match$5[0], match$5[1]), - r: singleton(match$3[0], match$3[1]) - }; - default: - var nl = len / 2 | 0; - var left = fromSortedArrayRevAux(arr, off, nl); - var match$6 = arr[off - nl | 0]; - var right = fromSortedArrayRevAux(arr, (off - nl | 0) - 1 | 0, (len - nl | 0) - 1 | 0); - return create(left, match$6[0], match$6[1], right); - } -} - -function fromSortedArrayAux(arr, off, len) { - switch (len) { - case 0 : - return ; - case 1 : - var match = arr[off]; - return singleton(match[0], match[1]); - case 2 : - var match_0 = arr[off]; - var match_1 = arr[off + 1 | 0]; - var match$1 = match_1; - var match$2 = match_0; - return { - k: match$1[0], - v: match$1[1], - h: 2, - l: singleton(match$2[0], match$2[1]), - r: undefined - }; - case 3 : - var match_0$1 = arr[off]; - var match_1$1 = arr[off + 1 | 0]; - var match_2 = arr[off + 2 | 0]; - var match$3 = match_2; - var match$4 = match_1$1; - var match$5 = match_0$1; - return { - k: match$4[0], - v: match$4[1], - h: 2, - l: singleton(match$5[0], match$5[1]), - r: singleton(match$3[0], match$3[1]) - }; - default: - var nl = len / 2 | 0; - var left = fromSortedArrayAux(arr, off, nl); - var match$6 = arr[off + nl | 0]; - var right = fromSortedArrayAux(arr, (off + nl | 0) + 1 | 0, (len - nl | 0) - 1 | 0); - return create(left, match$6[0], match$6[1], right); - } -} - -function fromSortedArrayUnsafe(arr) { - return fromSortedArrayAux(arr, 0, arr.length); -} - -function cmpU(s1, s2, kcmp, vcmp) { - var len1 = size(s1); - var len2 = size(s2); - if (len1 === len2) { - var _e1 = stackAllLeft(s1, /* [] */0); - var _e2 = stackAllLeft(s2, /* [] */0); - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return 0; - } - if (!e2) { - return 0; - } - var h2 = e2.hd; - var h1 = e1.hd; - var c = kcmp(h1.k, h2.k); - if (c !== 0) { - return c; - } - var cx = vcmp(h1.v, h2.v); - if (cx !== 0) { - return cx; - } - _e2 = stackAllLeft(h2.r, e2.tl); - _e1 = stackAllLeft(h1.r, e1.tl); - continue ; - }; - } else if (len1 < len2) { - return -1; - } else { - return 1; - } -} - -function cmp(s1, s2, kcmp, vcmp) { - return cmpU(s1, s2, kcmp, Curry.__2(vcmp)); -} - -function eqU(s1, s2, kcmp, veq) { - var len1 = size(s1); - var len2 = size(s2); - if (len1 === len2) { - var _e1 = stackAllLeft(s1, /* [] */0); - var _e2 = stackAllLeft(s2, /* [] */0); - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return true; - } - if (!e2) { - return true; - } - var h2 = e2.hd; - var h1 = e1.hd; - if (!(kcmp(h1.k, h2.k) === 0 && veq(h1.v, h2.v))) { - return false; - } - _e2 = stackAllLeft(h2.r, e2.tl); - _e1 = stackAllLeft(h1.r, e1.tl); - continue ; - }; - } else { - return false; - } -} - -function eq(s1, s2, kcmp, veq) { - return eqU(s1, s2, kcmp, Curry.__2(veq)); -} - -function get(_n, x, cmp) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.k; - var c = cmp(x, v); - if (c === 0) { - return Caml_option.some(n.v); - } - _n = c < 0 ? n.l : n.r; - continue ; - }; -} - -function getUndefined(_n, x, cmp) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.k; - var c = cmp(x, v); - if (c === 0) { - return n.v; - } - _n = c < 0 ? n.l : n.r; - continue ; - }; -} - -function getExn(_n, x, cmp) { - while(true) { - var n = _n; - if (n !== undefined) { - var v = n.k; - var c = cmp(x, v); - if (c === 0) { - return n.v; - } - _n = c < 0 ? n.l : n.r; - continue ; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function getWithDefault(_n, x, def, cmp) { - while(true) { - var n = _n; - if (n === undefined) { - return def; - } - var v = n.k; - var c = cmp(x, v); - if (c === 0) { - return n.v; - } - _n = c < 0 ? n.l : n.r; - continue ; - }; -} - -function has(_n, x, cmp) { - while(true) { - var n = _n; - if (n === undefined) { - return false; - } - var v = n.k; - var c = cmp(x, v); - if (c === 0) { - return true; - } - _n = c < 0 ? n.l : n.r; - continue ; - }; -} - -function rotateWithLeftChild(k2) { - var k1 = k2.l; - k2.l = k1.r; - k1.r = k2; - var hlk2 = treeHeight(k2.l); - var hrk2 = treeHeight(k2.r); - k2.h = ( - hlk2 > hrk2 ? hlk2 : hrk2 - ) + 1 | 0; - var hlk1 = treeHeight(k1.l); - var hk2 = k2.h; - k1.h = ( - hlk1 > hk2 ? hlk1 : hk2 - ) + 1 | 0; - return k1; -} - -function rotateWithRightChild(k1) { - var k2 = k1.r; - k1.r = k2.l; - k2.l = k1; - var hlk1 = treeHeight(k1.l); - var hrk1 = treeHeight(k1.r); - k1.h = ( - hlk1 > hrk1 ? hlk1 : hrk1 - ) + 1 | 0; - var hrk2 = treeHeight(k2.r); - var hk1 = k1.h; - k2.h = ( - hrk2 > hk1 ? hrk2 : hk1 - ) + 1 | 0; - return k2; -} - -function doubleWithLeftChild(k3) { - var x = k3.l; - var v = rotateWithRightChild(x); - k3.l = v; - return rotateWithLeftChild(k3); -} - -function doubleWithRightChild(k2) { - var x = k2.r; - var v = rotateWithLeftChild(x); - k2.r = v; - return rotateWithRightChild(k2); -} - -function heightUpdateMutate(t) { - var hlt = treeHeight(t.l); - var hrt = treeHeight(t.r); - t.h = ( - hlt > hrt ? hlt : hrt - ) + 1 | 0; - return t; -} - -function balMutate(nt) { - var l = nt.l; - var r = nt.r; - var hl = treeHeight(l); - var hr = treeHeight(r); - if (hl > (2 + hr | 0)) { - var ll = l.l; - var lr = l.r; - if (heightGe(ll, lr)) { - return heightUpdateMutate(rotateWithLeftChild(nt)); - } else { - return heightUpdateMutate(doubleWithLeftChild(nt)); - } - } - if (hr > (2 + hl | 0)) { - var rl = r.l; - var rr = r.r; - if (heightGe(rr, rl)) { - return heightUpdateMutate(rotateWithRightChild(nt)); - } else { - return heightUpdateMutate(doubleWithRightChild(nt)); - } - } - nt.h = ( - hl > hr ? hl : hr - ) + 1 | 0; - return nt; -} - -function updateMutate(t, x, data, cmp) { - if (t === undefined) { - return singleton(x, data); - } - var k = t.k; - var c = cmp(x, k); - if (c === 0) { - t.v = data; - return t; - } - var l = t.l; - var r = t.r; - if (c < 0) { - var ll = updateMutate(l, x, data, cmp); - t.l = ll; - } else { - t.r = updateMutate(r, x, data, cmp); - } - return balMutate(t); -} - -function fromArray(xs, cmp) { - var len = xs.length; - if (len === 0) { - return ; - } - var next = Belt_SortArray.strictlySortedLengthU(xs, (function (param, param$1) { - return cmp(param[0], param$1[0]) < 0; - })); - var result; - if (next >= 0) { - result = fromSortedArrayAux(xs, 0, next); - } else { - next = -next | 0; - result = fromSortedArrayRevAux(xs, next - 1 | 0, next); - } - for(var i = next; i < len; ++i){ - var match = xs[i]; - result = updateMutate(result, match[0], match[1], cmp); - } - return result; -} - -function removeMinAuxWithRootMutate(nt, n) { - var rn = n.r; - var ln = n.l; - if (ln !== undefined) { - n.l = removeMinAuxWithRootMutate(nt, ln); - return balMutate(n); - } else { - nt.k = n.k; - nt.v = n.v; - return rn; - } -} - -exports.copy = copy; -exports.create = create; -exports.bal = bal; -exports.singleton = singleton; -exports.updateValue = updateValue; -exports.minKey = minKey; -exports.minKeyUndefined = minKeyUndefined; -exports.maxKey = maxKey; -exports.maxKeyUndefined = maxKeyUndefined; -exports.minimum = minimum; -exports.minUndefined = minUndefined; -exports.maximum = maximum; -exports.maxUndefined = maxUndefined; -exports.removeMinAuxWithRef = removeMinAuxWithRef; -exports.isEmpty = isEmpty; -exports.stackAllLeft = stackAllLeft; -exports.findFirstByU = findFirstByU; -exports.findFirstBy = findFirstBy; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.mapU = mapU; -exports.map = map; -exports.mapWithKeyU = mapWithKeyU; -exports.mapWithKey = mapWithKey; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.everyU = everyU; -exports.every = every; -exports.someU = someU; -exports.some = some; -exports.join = join; -exports.concat = concat; -exports.concatOrJoin = concatOrJoin; -exports.keepSharedU = keepSharedU; -exports.keepShared = keepShared; -exports.keepMapU = keepMapU; -exports.keepMap = keepMap; -exports.partitionSharedU = partitionSharedU; -exports.partitionShared = partitionShared; -exports.lengthNode = lengthNode; -exports.size = size; -exports.toList = toList; -exports.checkInvariantInternal = checkInvariantInternal; -exports.fillArray = fillArray; -exports.toArray = toArray; -exports.keysToArray = keysToArray; -exports.valuesToArray = valuesToArray; -exports.fromSortedArrayAux = fromSortedArrayAux; -exports.fromSortedArrayRevAux = fromSortedArrayRevAux; -exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; -exports.cmpU = cmpU; -exports.cmp = cmp; -exports.eqU = eqU; -exports.eq = eq; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getWithDefault = getWithDefault; -exports.getExn = getExn; -exports.has = has; -exports.fromArray = fromArray; -exports.updateMutate = updateMutate; -exports.balMutate = balMutate; -exports.removeMinAuxWithRootMutate = removeMinAuxWithRootMutate; -/* No side effect */ diff --git a/lib/js/belt_internalBuckets.js b/lib/js/belt_internalBuckets.js deleted file mode 100644 index eabd14bcbcd..00000000000 --- a/lib/js/belt_internalBuckets.js +++ /dev/null @@ -1,285 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Belt_Array = require("./belt_Array.js"); -var Caml_option = require("./caml_option.js"); - -function copyBucket(c) { - if (c === undefined) { - return c; - } - var head = { - key: c.key, - value: c.value, - next: undefined - }; - copyAuxCont(c.next, head); - return head; -} - -function copyAuxCont(_c, _prec) { - while(true) { - var prec = _prec; - var c = _c; - if (c === undefined) { - return ; - } - var ncopy = { - key: c.key, - value: c.value, - next: undefined - }; - prec.next = ncopy; - _prec = ncopy; - _c = c.next; - continue ; - }; -} - -function copyBuckets(buckets) { - var len = buckets.length; - var newBuckets = new Array(len); - for(var i = 0; i < len; ++i){ - newBuckets[i] = copyBucket(buckets[i]); - } - return newBuckets; -} - -function copy(x) { - return { - size: x.size, - buckets: copyBuckets(x.buckets), - hash: x.hash, - eq: x.eq - }; -} - -function bucketLength(_accu, _buckets) { - while(true) { - var buckets = _buckets; - var accu = _accu; - if (buckets === undefined) { - return accu; - } - _buckets = buckets.next; - _accu = accu + 1 | 0; - continue ; - }; -} - -function do_bucket_iter(f, _buckets) { - while(true) { - var buckets = _buckets; - if (buckets === undefined) { - return ; - } - f(buckets.key, buckets.value); - _buckets = buckets.next; - continue ; - }; -} - -function forEachU(h, f) { - var d = h.buckets; - for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ - do_bucket_iter(f, d[i]); - } -} - -function forEach(h, f) { - forEachU(h, Curry.__2(f)); -} - -function do_bucket_fold(f, _b, _accu) { - while(true) { - var accu = _accu; - var b = _b; - if (b === undefined) { - return accu; - } - _accu = f(accu, b.key, b.value); - _b = b.next; - continue ; - }; -} - -function reduceU(h, init, f) { - var d = h.buckets; - var accu = init; - for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ - accu = do_bucket_fold(f, d[i], accu); - } - return accu; -} - -function reduce(h, init, f) { - return reduceU(h, init, Curry.__3(f)); -} - -function getMaxBucketLength(h) { - return Belt_Array.reduceU(h.buckets, 0, (function (m, b) { - var len = bucketLength(0, b); - if (m > len) { - return m; - } else { - return len; - } - })); -} - -function getBucketHistogram(h) { - var mbl = getMaxBucketLength(h); - var histo = Belt_Array.makeByU(mbl + 1 | 0, (function (param) { - return 0; - })); - Belt_Array.forEachU(h.buckets, (function (b) { - var l = bucketLength(0, b); - histo[l] = histo[l] + 1 | 0; - })); - return histo; -} - -function logStats(h) { - var histogram = getBucketHistogram(h); - console.log({ - bindings: h.size, - buckets: h.buckets.length, - histogram: histogram - }); -} - -function filterMapInplaceBucket(f, h, i, _prec, _cell) { - while(true) { - var cell = _cell; - var prec = _prec; - var n = cell.next; - var data = f(cell.key, cell.value); - if (data !== undefined) { - if (prec !== undefined) { - cell.next = cell; - } else { - h.buckets[i] = cell; - } - cell.value = Caml_option.valFromOption(data); - if (n === undefined) { - cell.next = n; - return ; - } - _cell = n; - _prec = cell; - continue ; - } - h.size = h.size - 1 | 0; - if (n === undefined) { - if (prec !== undefined) { - prec.next = n; - } else { - h.buckets[i] = prec; - } - return ; - } - _cell = n; - continue ; - }; -} - -function keepMapInPlaceU(h, f) { - var h_buckets = h.buckets; - for(var i = 0 ,i_finish = h_buckets.length; i < i_finish; ++i){ - var v = h_buckets[i]; - if (v !== undefined) { - filterMapInplaceBucket(f, h, i, undefined, v); - } - - } -} - -function keepMapInPlace(h, f) { - keepMapInPlaceU(h, Curry.__2(f)); -} - -function fillArray(_i, arr, _cell) { - while(true) { - var cell = _cell; - var i = _i; - arr[i] = [ - cell.key, - cell.value - ]; - var v = cell.next; - if (v === undefined) { - return i + 1 | 0; - } - _cell = v; - _i = i + 1 | 0; - continue ; - }; -} - -function fillArrayMap(_i, arr, _cell, f) { - while(true) { - var cell = _cell; - var i = _i; - arr[i] = f(cell); - var v = cell.next; - if (v === undefined) { - return i + 1 | 0; - } - _cell = v; - _i = i + 1 | 0; - continue ; - }; -} - -function linear(h, f) { - var d = h.buckets; - var current = 0; - var arr = new Array(h.size); - for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ - var cell = d[i]; - if (cell !== undefined) { - current = fillArrayMap(current, arr, cell, f); - } - - } - return arr; -} - -function keysToArray(h) { - return linear(h, (function (x) { - return x.key; - })); -} - -function valuesToArray(h) { - return linear(h, (function (x) { - return x.value; - })); -} - -function toArray(h) { - return linear(h, (function (x) { - return [ - x.key, - x.value - ]; - })); -} - -var C; - -exports.C = C; -exports.copy = copy; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.logStats = logStats; -exports.keepMapInPlaceU = keepMapInPlaceU; -exports.keepMapInPlace = keepMapInPlace; -exports.fillArray = fillArray; -exports.keysToArray = keysToArray; -exports.valuesToArray = valuesToArray; -exports.toArray = toArray; -exports.getBucketHistogram = getBucketHistogram; -/* No side effect */ diff --git a/lib/js/belt_internalBucketsType.js b/lib/js/belt_internalBucketsType.js deleted file mode 100644 index b1c9b5aa8ce..00000000000 --- a/lib/js/belt_internalBucketsType.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; - - -function power_2_above(_x, n) { - while(true) { - var x = _x; - if (x >= n) { - return x; - } - if ((x << 1) < x) { - return x; - } - _x = (x << 1); - continue ; - }; -} - -function make(hash, eq, hintSize) { - var s = power_2_above(16, hintSize); - return { - size: 0, - buckets: new Array(s), - hash: hash, - eq: eq - }; -} - -function clear(h) { - h.size = 0; - var h_buckets = h.buckets; - var len = h_buckets.length; - for(var i = 0; i < len; ++i){ - h_buckets[i] = undefined; - } -} - -function isEmpty(h) { - return h.size === 0; -} - -var emptyOpt; - -exports.emptyOpt = emptyOpt; -exports.make = make; -exports.clear = clear; -exports.isEmpty = isEmpty; -/* No side effect */ diff --git a/lib/js/belt_internalMapInt.js b/lib/js/belt_internalMapInt.js deleted file mode 100644 index 2887d9e5889..00000000000 --- a/lib/js/belt_internalMapInt.js +++ /dev/null @@ -1,363 +0,0 @@ -'use strict'; - -var Caml = require("./caml.js"); -var Curry = require("./curry.js"); -var Caml_option = require("./caml_option.js"); -var Belt_SortArray = require("./belt_SortArray.js"); -var Belt_internalAVLtree = require("./belt_internalAVLtree.js"); - -function add(t, x, data) { - if (t === undefined) { - return Belt_internalAVLtree.singleton(x, data); - } - var k = t.k; - if (x === k) { - return Belt_internalAVLtree.updateValue(t, data); - } - var v = t.v; - if (x < k) { - return Belt_internalAVLtree.bal(add(t.l, x, data), k, v, t.r); - } else { - return Belt_internalAVLtree.bal(t.l, k, v, add(t.r, x, data)); - } -} - -function get(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.k; - if (x === v) { - return Caml_option.some(n.v); - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function getUndefined(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.k; - if (x === v) { - return n.v; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function getExn(_n, x) { - while(true) { - var n = _n; - if (n !== undefined) { - var v = n.k; - if (x === v) { - return n.v; - } - _n = x < v ? n.l : n.r; - continue ; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function getWithDefault(_n, x, def) { - while(true) { - var n = _n; - if (n === undefined) { - return def; - } - var v = n.k; - if (x === v) { - return n.v; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function has(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return false; - } - var v = n.k; - if (x === v) { - return true; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function remove(n, x) { - if (n === undefined) { - return n; - } - var v = n.k; - var l = n.l; - var r = n.r; - if (x !== v) { - if (x < v) { - return Belt_internalAVLtree.bal(remove(l, x), v, n.v, r); - } else { - return Belt_internalAVLtree.bal(l, v, n.v, remove(r, x)); - } - } - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var kr = { - contents: r.k - }; - var vr = { - contents: r.v - }; - var r$1 = Belt_internalAVLtree.removeMinAuxWithRef(r, kr, vr); - return Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); -} - -function splitAux(x, n) { - var v = n.k; - var d = n.v; - var l = n.l; - var r = n.r; - if (x === v) { - return [ - l, - Caml_option.some(d), - r - ]; - } - if (x < v) { - if (l === undefined) { - return [ - undefined, - undefined, - n - ]; - } - var match = splitAux(x, l); - return [ - match[0], - match[1], - Belt_internalAVLtree.join(match[2], v, d, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined, - undefined - ]; - } - var match$1 = splitAux(x, r); - return [ - Belt_internalAVLtree.join(l, v, d, match$1[0]), - match$1[1], - match$1[2] - ]; -} - -function split(x, n) { - if (n !== undefined) { - return splitAux(x, n); - } else { - return [ - undefined, - undefined, - undefined - ]; - } -} - -function mergeU(s1, s2, f) { - if (s1 !== undefined) { - if (s1.h >= ( - s2 !== undefined ? s2.h : 0 - )) { - var v1 = s1.k; - var d1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var match = split(v1, s2); - return Belt_internalAVLtree.concatOrJoin(mergeU(l1, match[0], f), v1, f(v1, Caml_option.some(d1), match[1]), mergeU(r1, match[2], f)); - } - - } else if (s2 === undefined) { - return ; - } - var v2 = s2.k; - var d2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - var 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) { - return mergeU(s1, s2, Curry.__3(f)); -} - -function compareAux(_e1, _e2, vcmp) { - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return 0; - } - if (!e2) { - return 0; - } - var h2 = e2.hd; - var h1 = e1.hd; - var c = Caml.int_compare(h1.k, h2.k); - if (c !== 0) { - return c; - } - var cx = vcmp(h1.v, h2.v); - if (cx !== 0) { - return cx; - } - _e2 = Belt_internalAVLtree.stackAllLeft(h2.r, e2.tl); - _e1 = Belt_internalAVLtree.stackAllLeft(h1.r, e1.tl); - continue ; - }; -} - -function cmpU(s1, s2, cmp) { - var len1 = Belt_internalAVLtree.size(s1); - var len2 = Belt_internalAVLtree.size(s2); - if (len1 === len2) { - return compareAux(Belt_internalAVLtree.stackAllLeft(s1, /* [] */0), Belt_internalAVLtree.stackAllLeft(s2, /* [] */0), cmp); - } else if (len1 < len2) { - return -1; - } else { - return 1; - } -} - -function cmp(s1, s2, f) { - return cmpU(s1, s2, Curry.__2(f)); -} - -function eqAux(_e1, _e2, eq) { - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return true; - } - if (!e2) { - return true; - } - var h2 = e2.hd; - var h1 = e1.hd; - if (!(h1.k === h2.k && eq(h1.v, h2.v))) { - return false; - } - _e2 = Belt_internalAVLtree.stackAllLeft(h2.r, e2.tl); - _e1 = Belt_internalAVLtree.stackAllLeft(h1.r, e1.tl); - continue ; - }; -} - -function eqU(s1, s2, eq) { - var len1 = Belt_internalAVLtree.size(s1); - var len2 = Belt_internalAVLtree.size(s2); - if (len1 === len2) { - return eqAux(Belt_internalAVLtree.stackAllLeft(s1, /* [] */0), Belt_internalAVLtree.stackAllLeft(s2, /* [] */0), eq); - } else { - return false; - } -} - -function eq(s1, s2, f) { - return eqU(s1, s2, Curry.__2(f)); -} - -function addMutate(t, x, data) { - if (t === undefined) { - return Belt_internalAVLtree.singleton(x, data); - } - var k = t.k; - if (x === k) { - t.k = x; - t.v = data; - return t; - } - var l = t.l; - var r = t.r; - if (x < k) { - var ll = addMutate(l, x, data); - t.l = ll; - } else { - t.r = addMutate(r, x, data); - } - return Belt_internalAVLtree.balMutate(t); -} - -function fromArray(xs) { - var len = xs.length; - if (len === 0) { - return ; - } - var next = Belt_SortArray.strictlySortedLengthU(xs, (function (param, param$1) { - return param[0] < param$1[0]; - })); - var result; - if (next >= 0) { - result = Belt_internalAVLtree.fromSortedArrayAux(xs, 0, next); - } else { - next = -next | 0; - result = Belt_internalAVLtree.fromSortedArrayRevAux(xs, next - 1 | 0, next); - } - for(var i = next; i < len; ++i){ - var match = xs[i]; - result = addMutate(result, match[0], match[1]); - } - return result; -} - -var N; - -var A; - -var S; - -exports.N = N; -exports.A = A; -exports.S = S; -exports.add = add; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getExn = getExn; -exports.getWithDefault = getWithDefault; -exports.has = has; -exports.remove = remove; -exports.splitAux = splitAux; -exports.split = split; -exports.mergeU = mergeU; -exports.merge = merge; -exports.compareAux = compareAux; -exports.cmpU = cmpU; -exports.cmp = cmp; -exports.eqAux = eqAux; -exports.eqU = eqU; -exports.eq = eq; -exports.addMutate = addMutate; -exports.fromArray = fromArray; -/* No side effect */ diff --git a/lib/js/belt_internalMapString.js b/lib/js/belt_internalMapString.js deleted file mode 100644 index 97b43e85049..00000000000 --- a/lib/js/belt_internalMapString.js +++ /dev/null @@ -1,363 +0,0 @@ -'use strict'; - -var Caml = require("./caml.js"); -var Curry = require("./curry.js"); -var Caml_option = require("./caml_option.js"); -var Belt_SortArray = require("./belt_SortArray.js"); -var Belt_internalAVLtree = require("./belt_internalAVLtree.js"); - -function add(t, x, data) { - if (t === undefined) { - return Belt_internalAVLtree.singleton(x, data); - } - var k = t.k; - if (x === k) { - return Belt_internalAVLtree.updateValue(t, data); - } - var v = t.v; - if (x < k) { - return Belt_internalAVLtree.bal(add(t.l, x, data), k, v, t.r); - } else { - return Belt_internalAVLtree.bal(t.l, k, v, add(t.r, x, data)); - } -} - -function get(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.k; - if (x === v) { - return Caml_option.some(n.v); - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function getUndefined(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.k; - if (x === v) { - return n.v; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function getExn(_n, x) { - while(true) { - var n = _n; - if (n !== undefined) { - var v = n.k; - if (x === v) { - return n.v; - } - _n = x < v ? n.l : n.r; - continue ; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function getWithDefault(_n, x, def) { - while(true) { - var n = _n; - if (n === undefined) { - return def; - } - var v = n.k; - if (x === v) { - return n.v; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function has(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return false; - } - var v = n.k; - if (x === v) { - return true; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function remove(n, x) { - if (n === undefined) { - return n; - } - var v = n.k; - var l = n.l; - var r = n.r; - if (x !== v) { - if (x < v) { - return Belt_internalAVLtree.bal(remove(l, x), v, n.v, r); - } else { - return Belt_internalAVLtree.bal(l, v, n.v, remove(r, x)); - } - } - if (l === undefined) { - return r; - } - if (r === undefined) { - return l; - } - var kr = { - contents: r.k - }; - var vr = { - contents: r.v - }; - var r$1 = Belt_internalAVLtree.removeMinAuxWithRef(r, kr, vr); - return Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); -} - -function splitAux(x, n) { - var v = n.k; - var d = n.v; - var l = n.l; - var r = n.r; - if (x === v) { - return [ - l, - Caml_option.some(d), - r - ]; - } - if (x < v) { - if (l === undefined) { - return [ - undefined, - undefined, - n - ]; - } - var match = splitAux(x, l); - return [ - match[0], - match[1], - Belt_internalAVLtree.join(match[2], v, d, r) - ]; - } - if (r === undefined) { - return [ - n, - undefined, - undefined - ]; - } - var match$1 = splitAux(x, r); - return [ - Belt_internalAVLtree.join(l, v, d, match$1[0]), - match$1[1], - match$1[2] - ]; -} - -function split(x, n) { - if (n !== undefined) { - return splitAux(x, n); - } else { - return [ - undefined, - undefined, - undefined - ]; - } -} - -function mergeU(s1, s2, f) { - if (s1 !== undefined) { - if (s1.h >= ( - s2 !== undefined ? s2.h : 0 - )) { - var v1 = s1.k; - var d1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var match = split(v1, s2); - return Belt_internalAVLtree.concatOrJoin(mergeU(l1, match[0], f), v1, f(v1, Caml_option.some(d1), match[1]), mergeU(r1, match[2], f)); - } - - } else if (s2 === undefined) { - return ; - } - var v2 = s2.k; - var d2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - var 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) { - return mergeU(s1, s2, Curry.__3(f)); -} - -function compareAux(_e1, _e2, vcmp) { - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return 0; - } - if (!e2) { - return 0; - } - var h2 = e2.hd; - var h1 = e1.hd; - var c = Caml.string_compare(h1.k, h2.k); - if (c !== 0) { - return c; - } - var cx = vcmp(h1.v, h2.v); - if (cx !== 0) { - return cx; - } - _e2 = Belt_internalAVLtree.stackAllLeft(h2.r, e2.tl); - _e1 = Belt_internalAVLtree.stackAllLeft(h1.r, e1.tl); - continue ; - }; -} - -function cmpU(s1, s2, cmp) { - var len1 = Belt_internalAVLtree.size(s1); - var len2 = Belt_internalAVLtree.size(s2); - if (len1 === len2) { - return compareAux(Belt_internalAVLtree.stackAllLeft(s1, /* [] */0), Belt_internalAVLtree.stackAllLeft(s2, /* [] */0), cmp); - } else if (len1 < len2) { - return -1; - } else { - return 1; - } -} - -function cmp(s1, s2, f) { - return cmpU(s1, s2, Curry.__2(f)); -} - -function eqAux(_e1, _e2, eq) { - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return true; - } - if (!e2) { - return true; - } - var h2 = e2.hd; - var h1 = e1.hd; - if (!(h1.k === h2.k && eq(h1.v, h2.v))) { - return false; - } - _e2 = Belt_internalAVLtree.stackAllLeft(h2.r, e2.tl); - _e1 = Belt_internalAVLtree.stackAllLeft(h1.r, e1.tl); - continue ; - }; -} - -function eqU(s1, s2, eq) { - var len1 = Belt_internalAVLtree.size(s1); - var len2 = Belt_internalAVLtree.size(s2); - if (len1 === len2) { - return eqAux(Belt_internalAVLtree.stackAllLeft(s1, /* [] */0), Belt_internalAVLtree.stackAllLeft(s2, /* [] */0), eq); - } else { - return false; - } -} - -function eq(s1, s2, f) { - return eqU(s1, s2, Curry.__2(f)); -} - -function addMutate(t, x, data) { - if (t === undefined) { - return Belt_internalAVLtree.singleton(x, data); - } - var k = t.k; - if (x === k) { - t.k = x; - t.v = data; - return t; - } - var l = t.l; - var r = t.r; - if (x < k) { - var ll = addMutate(l, x, data); - t.l = ll; - } else { - t.r = addMutate(r, x, data); - } - return Belt_internalAVLtree.balMutate(t); -} - -function fromArray(xs) { - var len = xs.length; - if (len === 0) { - return ; - } - var next = Belt_SortArray.strictlySortedLengthU(xs, (function (param, param$1) { - return param[0] < param$1[0]; - })); - var result; - if (next >= 0) { - result = Belt_internalAVLtree.fromSortedArrayAux(xs, 0, next); - } else { - next = -next | 0; - result = Belt_internalAVLtree.fromSortedArrayRevAux(xs, next - 1 | 0, next); - } - for(var i = next; i < len; ++i){ - var match = xs[i]; - result = addMutate(result, match[0], match[1]); - } - return result; -} - -var N; - -var A; - -var S; - -exports.N = N; -exports.A = A; -exports.S = S; -exports.add = add; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getExn = getExn; -exports.getWithDefault = getWithDefault; -exports.has = has; -exports.remove = remove; -exports.splitAux = splitAux; -exports.split = split; -exports.mergeU = mergeU; -exports.merge = merge; -exports.compareAux = compareAux; -exports.cmpU = cmpU; -exports.cmp = cmp; -exports.eqAux = eqAux; -exports.eqU = eqU; -exports.eq = eq; -exports.addMutate = addMutate; -exports.fromArray = fromArray; -/* No side effect */ diff --git a/lib/js/belt_internalSetBuckets.js b/lib/js/belt_internalSetBuckets.js deleted file mode 100644 index 00b7d16e779..00000000000 --- a/lib/js/belt_internalSetBuckets.js +++ /dev/null @@ -1,189 +0,0 @@ -'use strict'; - -var Curry = require("./curry.js"); -var Belt_Array = require("./belt_Array.js"); - -function copyAuxCont(_c, _prec) { - while(true) { - var prec = _prec; - var c = _c; - if (c === undefined) { - return ; - } - var ncopy = { - key: c.key, - next: undefined - }; - prec.next = ncopy; - _prec = ncopy; - _c = c.next; - continue ; - }; -} - -function copyBucket(c) { - if (c === undefined) { - return c; - } - var head = { - key: c.key, - next: undefined - }; - copyAuxCont(c.next, head); - return head; -} - -function copyBuckets(buckets) { - var len = buckets.length; - var newBuckets = new Array(len); - for(var i = 0; i < len; ++i){ - newBuckets[i] = copyBucket(buckets[i]); - } - return newBuckets; -} - -function copy(x) { - return { - size: x.size, - buckets: copyBuckets(x.buckets), - hash: x.hash, - eq: x.eq - }; -} - -function bucketLength(_accu, _buckets) { - while(true) { - var buckets = _buckets; - var accu = _accu; - if (buckets === undefined) { - return accu; - } - _buckets = buckets.next; - _accu = accu + 1 | 0; - continue ; - }; -} - -function doBucketIter(f, _buckets) { - while(true) { - var buckets = _buckets; - if (buckets === undefined) { - return ; - } - f(buckets.key); - _buckets = buckets.next; - continue ; - }; -} - -function forEachU(h, f) { - var d = h.buckets; - for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ - doBucketIter(f, d[i]); - } -} - -function forEach(h, f) { - forEachU(h, Curry.__1(f)); -} - -function fillArray(_i, arr, _cell) { - while(true) { - var cell = _cell; - var i = _i; - arr[i] = cell.key; - var v = cell.next; - if (v === undefined) { - return i + 1 | 0; - } - _cell = v; - _i = i + 1 | 0; - continue ; - }; -} - -function toArray(h) { - var d = h.buckets; - var current = 0; - var arr = new Array(h.size); - for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ - var cell = d[i]; - if (cell !== undefined) { - current = fillArray(current, arr, cell); - } - - } - return arr; -} - -function doBucketFold(f, _b, _accu) { - while(true) { - var accu = _accu; - var b = _b; - if (b === undefined) { - return accu; - } - _accu = f(accu, b.key); - _b = b.next; - continue ; - }; -} - -function reduceU(h, init, f) { - var d = h.buckets; - var accu = init; - for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ - accu = doBucketFold(f, d[i], accu); - } - return accu; -} - -function reduce(h, init, f) { - return reduceU(h, init, Curry.__2(f)); -} - -function getMaxBucketLength(h) { - return Belt_Array.reduceU(h.buckets, 0, (function (m, b) { - var len = bucketLength(0, b); - if (m > len) { - return m; - } else { - return len; - } - })); -} - -function getBucketHistogram(h) { - var mbl = getMaxBucketLength(h); - var histo = Belt_Array.makeByU(mbl + 1 | 0, (function (param) { - return 0; - })); - Belt_Array.forEachU(h.buckets, (function (b) { - var l = bucketLength(0, b); - histo[l] = histo[l] + 1 | 0; - })); - return histo; -} - -function logStats(h) { - var histogram = getBucketHistogram(h); - console.log({ - bindings: h.size, - buckets: h.buckets.length, - histogram: histogram - }); -} - -var C; - -exports.C = C; -exports.copy = copy; -exports.forEachU = forEachU; -exports.forEach = forEach; -exports.fillArray = fillArray; -exports.toArray = toArray; -exports.reduceU = reduceU; -exports.reduce = reduce; -exports.logStats = logStats; -exports.getBucketHistogram = getBucketHistogram; -/* No side effect */ diff --git a/lib/js/belt_internalSetInt.js b/lib/js/belt_internalSetInt.js deleted file mode 100644 index 32d5a313de8..00000000000 --- a/lib/js/belt_internalSetInt.js +++ /dev/null @@ -1,207 +0,0 @@ -'use strict'; - -var Belt_SortArrayInt = require("./belt_SortArrayInt.js"); -var Belt_internalAVLset = require("./belt_internalAVLset.js"); - -function has(_t, x) { - while(true) { - var t = _t; - if (t === undefined) { - return false; - } - var v = t.v; - if (x === v) { - return true; - } - _t = x < v ? t.l : t.r; - continue ; - }; -} - -function compareAux(_e1, _e2) { - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return 0; - } - if (!e2) { - return 0; - } - var h2 = e2.hd; - var h1 = e1.hd; - var k1 = h1.v; - var k2 = h2.v; - if (k1 !== k2) { - if (k1 < k2) { - return -1; - } else { - return 1; - } - } - _e2 = Belt_internalAVLset.stackAllLeft(h2.r, e2.tl); - _e1 = Belt_internalAVLset.stackAllLeft(h1.r, e1.tl); - continue ; - }; -} - -function cmp(s1, s2) { - var len1 = Belt_internalAVLset.size(s1); - var len2 = Belt_internalAVLset.size(s2); - if (len1 === len2) { - return compareAux(Belt_internalAVLset.stackAllLeft(s1, /* [] */0), Belt_internalAVLset.stackAllLeft(s2, /* [] */0)); - } else if (len1 < len2) { - return -1; - } else { - return 1; - } -} - -function eq(s1, s2) { - return cmp(s1, s2) === 0; -} - -function subset(_s1, _s2) { - while(true) { - var s2 = _s2; - var s1 = _s1; - if (s1 === undefined) { - return true; - } - if (s2 === undefined) { - return false; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var v2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - if (v1 === v2) { - if (!subset(l1, l2)) { - return false; - } - _s2 = r2; - _s1 = r1; - continue ; - } - if (v1 < v2) { - if (!subset(Belt_internalAVLset.create(l1, v1, undefined), l2)) { - return false; - } - _s1 = r1; - continue ; - } - if (!subset(Belt_internalAVLset.create(undefined, v1, r1), r2)) { - return false; - } - _s1 = l1; - continue ; - }; -} - -function get(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.v; - if (x === v) { - return v; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function getUndefined(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.v; - if (x === v) { - return v; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function getExn(_n, x) { - while(true) { - var n = _n; - if (n !== undefined) { - var v = n.v; - if (x === v) { - return v; - } - _n = x < v ? n.l : n.r; - continue ; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function addMutate(t, x) { - if (t === undefined) { - return Belt_internalAVLset.singleton(x); - } - var k = t.v; - if (x === k) { - return t; - } - var l = t.l; - var r = t.r; - if (x < k) { - t.l = addMutate(l, x); - } else { - t.r = addMutate(r, x); - } - return Belt_internalAVLset.balMutate(t); -} - -function fromArray(xs) { - var len = xs.length; - if (len === 0) { - return ; - } - var next = Belt_SortArrayInt.strictlySortedLength(xs); - var result; - if (next >= 0) { - result = Belt_internalAVLset.fromSortedArrayAux(xs, 0, next); - } else { - next = -next | 0; - result = Belt_internalAVLset.fromSortedArrayRevAux(xs, next - 1 | 0, next); - } - for(var i = next; i < len; ++i){ - result = addMutate(result, xs[i]); - } - return result; -} - -var S; - -var N; - -var A; - -exports.S = S; -exports.N = N; -exports.A = A; -exports.has = has; -exports.compareAux = compareAux; -exports.cmp = cmp; -exports.eq = eq; -exports.subset = subset; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getExn = getExn; -exports.addMutate = addMutate; -exports.fromArray = fromArray; -/* No side effect */ diff --git a/lib/js/belt_internalSetString.js b/lib/js/belt_internalSetString.js deleted file mode 100644 index e29bec23638..00000000000 --- a/lib/js/belt_internalSetString.js +++ /dev/null @@ -1,207 +0,0 @@ -'use strict'; - -var Belt_internalAVLset = require("./belt_internalAVLset.js"); -var Belt_SortArrayString = require("./belt_SortArrayString.js"); - -function has(_t, x) { - while(true) { - var t = _t; - if (t === undefined) { - return false; - } - var v = t.v; - if (x === v) { - return true; - } - _t = x < v ? t.l : t.r; - continue ; - }; -} - -function compareAux(_e1, _e2) { - while(true) { - var e2 = _e2; - var e1 = _e1; - if (!e1) { - return 0; - } - if (!e2) { - return 0; - } - var h2 = e2.hd; - var h1 = e1.hd; - var k1 = h1.v; - var k2 = h2.v; - if (k1 !== k2) { - if (k1 < k2) { - return -1; - } else { - return 1; - } - } - _e2 = Belt_internalAVLset.stackAllLeft(h2.r, e2.tl); - _e1 = Belt_internalAVLset.stackAllLeft(h1.r, e1.tl); - continue ; - }; -} - -function cmp(s1, s2) { - var len1 = Belt_internalAVLset.size(s1); - var len2 = Belt_internalAVLset.size(s2); - if (len1 === len2) { - return compareAux(Belt_internalAVLset.stackAllLeft(s1, /* [] */0), Belt_internalAVLset.stackAllLeft(s2, /* [] */0)); - } else if (len1 < len2) { - return -1; - } else { - return 1; - } -} - -function eq(s1, s2) { - return cmp(s1, s2) === 0; -} - -function subset(_s1, _s2) { - while(true) { - var s2 = _s2; - var s1 = _s1; - if (s1 === undefined) { - return true; - } - if (s2 === undefined) { - return false; - } - var v1 = s1.v; - var l1 = s1.l; - var r1 = s1.r; - var v2 = s2.v; - var l2 = s2.l; - var r2 = s2.r; - if (v1 === v2) { - if (!subset(l1, l2)) { - return false; - } - _s2 = r2; - _s1 = r1; - continue ; - } - if (v1 < v2) { - if (!subset(Belt_internalAVLset.create(l1, v1, undefined), l2)) { - return false; - } - _s1 = r1; - continue ; - } - if (!subset(Belt_internalAVLset.create(undefined, v1, r1), r2)) { - return false; - } - _s1 = l1; - continue ; - }; -} - -function get(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.v; - if (x === v) { - return v; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function getUndefined(_n, x) { - while(true) { - var n = _n; - if (n === undefined) { - return ; - } - var v = n.v; - if (x === v) { - return v; - } - _n = x < v ? n.l : n.r; - continue ; - }; -} - -function getExn(_n, x) { - while(true) { - var n = _n; - if (n !== undefined) { - var v = n.v; - if (x === v) { - return v; - } - _n = x < v ? n.l : n.r; - continue ; - } - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }; -} - -function addMutate(t, x) { - if (t === undefined) { - return Belt_internalAVLset.singleton(x); - } - var k = t.v; - if (x === k) { - return t; - } - var l = t.l; - var r = t.r; - if (x < k) { - t.l = addMutate(l, x); - } else { - t.r = addMutate(r, x); - } - return Belt_internalAVLset.balMutate(t); -} - -function fromArray(xs) { - var len = xs.length; - if (len === 0) { - return ; - } - var next = Belt_SortArrayString.strictlySortedLength(xs); - var result; - if (next >= 0) { - result = Belt_internalAVLset.fromSortedArrayAux(xs, 0, next); - } else { - next = -next | 0; - result = Belt_internalAVLset.fromSortedArrayRevAux(xs, next - 1 | 0, next); - } - for(var i = next; i < len; ++i){ - result = addMutate(result, xs[i]); - } - return result; -} - -var S; - -var N; - -var A; - -exports.S = S; -exports.N = N; -exports.A = A; -exports.has = has; -exports.compareAux = compareAux; -exports.cmp = cmp; -exports.eq = eq; -exports.subset = subset; -exports.get = get; -exports.getUndefined = getUndefined; -exports.getExn = getExn; -exports.addMutate = addMutate; -exports.fromArray = fromArray; -/* No side effect */ diff --git a/packages/artifacts.txt b/packages/artifacts.txt index 0fbc2e76768..52650deb2f7 100644 --- a/packages/artifacts.txt +++ b/packages/artifacts.txt @@ -18,49 +18,6 @@ lib/bstracing lib/es6/arg.js lib/es6/array.js lib/es6/arrayLabels.js -lib/es6/belt.js -lib/es6/belt_Array.js -lib/es6/belt_Float.js -lib/es6/belt_HashMap.js -lib/es6/belt_HashMapInt.js -lib/es6/belt_HashMapString.js -lib/es6/belt_HashSet.js -lib/es6/belt_HashSetInt.js -lib/es6/belt_HashSetString.js -lib/es6/belt_Id.js -lib/es6/belt_Int.js -lib/es6/belt_List.js -lib/es6/belt_Map.js -lib/es6/belt_MapDict.js -lib/es6/belt_MapInt.js -lib/es6/belt_MapString.js -lib/es6/belt_MutableMap.js -lib/es6/belt_MutableMapInt.js -lib/es6/belt_MutableMapString.js -lib/es6/belt_MutableQueue.js -lib/es6/belt_MutableSet.js -lib/es6/belt_MutableSetInt.js -lib/es6/belt_MutableSetString.js -lib/es6/belt_MutableStack.js -lib/es6/belt_Option.js -lib/es6/belt_Range.js -lib/es6/belt_Result.js -lib/es6/belt_Set.js -lib/es6/belt_SetDict.js -lib/es6/belt_SetInt.js -lib/es6/belt_SetString.js -lib/es6/belt_SortArray.js -lib/es6/belt_SortArrayInt.js -lib/es6/belt_SortArrayString.js -lib/es6/belt_internalAVLset.js -lib/es6/belt_internalAVLtree.js -lib/es6/belt_internalBuckets.js -lib/es6/belt_internalBucketsType.js -lib/es6/belt_internalMapInt.js -lib/es6/belt_internalMapString.js -lib/es6/belt_internalSetBuckets.js -lib/es6/belt_internalSetInt.js -lib/es6/belt_internalSetString.js lib/es6/buffer.js lib/es6/bytes.js lib/es6/bytesLabels.js @@ -181,49 +138,6 @@ lib/es6/uchar.js lib/js/arg.js lib/js/array.js lib/js/arrayLabels.js -lib/js/belt.js -lib/js/belt_Array.js -lib/js/belt_Float.js -lib/js/belt_HashMap.js -lib/js/belt_HashMapInt.js -lib/js/belt_HashMapString.js -lib/js/belt_HashSet.js -lib/js/belt_HashSetInt.js -lib/js/belt_HashSetString.js -lib/js/belt_Id.js -lib/js/belt_Int.js -lib/js/belt_List.js -lib/js/belt_Map.js -lib/js/belt_MapDict.js -lib/js/belt_MapInt.js -lib/js/belt_MapString.js -lib/js/belt_MutableMap.js -lib/js/belt_MutableMapInt.js -lib/js/belt_MutableMapString.js -lib/js/belt_MutableQueue.js -lib/js/belt_MutableSet.js -lib/js/belt_MutableSetInt.js -lib/js/belt_MutableSetString.js -lib/js/belt_MutableStack.js -lib/js/belt_Option.js -lib/js/belt_Range.js -lib/js/belt_Result.js -lib/js/belt_Set.js -lib/js/belt_SetDict.js -lib/js/belt_SetInt.js -lib/js/belt_SetString.js -lib/js/belt_SortArray.js -lib/js/belt_SortArrayInt.js -lib/js/belt_SortArrayString.js -lib/js/belt_internalAVLset.js -lib/js/belt_internalAVLtree.js -lib/js/belt_internalBuckets.js -lib/js/belt_internalBucketsType.js -lib/js/belt_internalMapInt.js -lib/js/belt_internalMapString.js -lib/js/belt_internalSetBuckets.js -lib/js/belt_internalSetInt.js -lib/js/belt_internalSetString.js lib/js/buffer.js lib/js/bytes.js lib/js/bytesLabels.js @@ -359,245 +273,6 @@ lib/ocaml/arrayLabels.cmt lib/ocaml/arrayLabels.cmti lib/ocaml/arrayLabels.res lib/ocaml/arrayLabels.resi -lib/ocaml/belt.cmi -lib/ocaml/belt.cmj -lib/ocaml/belt.cmt -lib/ocaml/belt.res -lib/ocaml/belt_Array.cmi -lib/ocaml/belt_Array.cmj -lib/ocaml/belt_Array.cmt -lib/ocaml/belt_Array.cmti -lib/ocaml/belt_Array.res -lib/ocaml/belt_Array.resi -lib/ocaml/belt_Float.cmi -lib/ocaml/belt_Float.cmj -lib/ocaml/belt_Float.cmt -lib/ocaml/belt_Float.cmti -lib/ocaml/belt_Float.res -lib/ocaml/belt_Float.resi -lib/ocaml/belt_HashMap.cmi -lib/ocaml/belt_HashMap.cmj -lib/ocaml/belt_HashMap.cmt -lib/ocaml/belt_HashMap.cmti -lib/ocaml/belt_HashMap.res -lib/ocaml/belt_HashMap.resi -lib/ocaml/belt_HashMapInt.cmi -lib/ocaml/belt_HashMapInt.cmj -lib/ocaml/belt_HashMapInt.cmt -lib/ocaml/belt_HashMapInt.cmti -lib/ocaml/belt_HashMapInt.res -lib/ocaml/belt_HashMapInt.resi -lib/ocaml/belt_HashMapString.cmi -lib/ocaml/belt_HashMapString.cmj -lib/ocaml/belt_HashMapString.cmt -lib/ocaml/belt_HashMapString.cmti -lib/ocaml/belt_HashMapString.res -lib/ocaml/belt_HashMapString.resi -lib/ocaml/belt_HashSet.cmi -lib/ocaml/belt_HashSet.cmj -lib/ocaml/belt_HashSet.cmt -lib/ocaml/belt_HashSet.cmti -lib/ocaml/belt_HashSet.res -lib/ocaml/belt_HashSet.resi -lib/ocaml/belt_HashSetInt.cmi -lib/ocaml/belt_HashSetInt.cmj -lib/ocaml/belt_HashSetInt.cmt -lib/ocaml/belt_HashSetInt.cmti -lib/ocaml/belt_HashSetInt.res -lib/ocaml/belt_HashSetInt.resi -lib/ocaml/belt_HashSetString.cmi -lib/ocaml/belt_HashSetString.cmj -lib/ocaml/belt_HashSetString.cmt -lib/ocaml/belt_HashSetString.cmti -lib/ocaml/belt_HashSetString.res -lib/ocaml/belt_HashSetString.resi -lib/ocaml/belt_Id.cmi -lib/ocaml/belt_Id.cmj -lib/ocaml/belt_Id.cmt -lib/ocaml/belt_Id.cmti -lib/ocaml/belt_Id.res -lib/ocaml/belt_Id.resi -lib/ocaml/belt_Int.cmi -lib/ocaml/belt_Int.cmj -lib/ocaml/belt_Int.cmt -lib/ocaml/belt_Int.cmti -lib/ocaml/belt_Int.res -lib/ocaml/belt_Int.resi -lib/ocaml/belt_List.cmi -lib/ocaml/belt_List.cmj -lib/ocaml/belt_List.cmt -lib/ocaml/belt_List.cmti -lib/ocaml/belt_List.res -lib/ocaml/belt_List.resi -lib/ocaml/belt_Map.cmi -lib/ocaml/belt_Map.cmj -lib/ocaml/belt_Map.cmt -lib/ocaml/belt_Map.cmti -lib/ocaml/belt_Map.res -lib/ocaml/belt_Map.resi -lib/ocaml/belt_MapDict.cmi -lib/ocaml/belt_MapDict.cmj -lib/ocaml/belt_MapDict.cmt -lib/ocaml/belt_MapDict.cmti -lib/ocaml/belt_MapDict.res -lib/ocaml/belt_MapDict.resi -lib/ocaml/belt_MapInt.cmi -lib/ocaml/belt_MapInt.cmj -lib/ocaml/belt_MapInt.cmt -lib/ocaml/belt_MapInt.cmti -lib/ocaml/belt_MapInt.res -lib/ocaml/belt_MapInt.resi -lib/ocaml/belt_MapString.cmi -lib/ocaml/belt_MapString.cmj -lib/ocaml/belt_MapString.cmt -lib/ocaml/belt_MapString.cmti -lib/ocaml/belt_MapString.res -lib/ocaml/belt_MapString.resi -lib/ocaml/belt_MutableMap.cmi -lib/ocaml/belt_MutableMap.cmj -lib/ocaml/belt_MutableMap.cmt -lib/ocaml/belt_MutableMap.cmti -lib/ocaml/belt_MutableMap.res -lib/ocaml/belt_MutableMap.resi -lib/ocaml/belt_MutableMapInt.cmi -lib/ocaml/belt_MutableMapInt.cmj -lib/ocaml/belt_MutableMapInt.cmt -lib/ocaml/belt_MutableMapInt.cmti -lib/ocaml/belt_MutableMapInt.res -lib/ocaml/belt_MutableMapInt.resi -lib/ocaml/belt_MutableMapString.cmi -lib/ocaml/belt_MutableMapString.cmj -lib/ocaml/belt_MutableMapString.cmt -lib/ocaml/belt_MutableMapString.cmti -lib/ocaml/belt_MutableMapString.res -lib/ocaml/belt_MutableMapString.resi -lib/ocaml/belt_MutableQueue.cmi -lib/ocaml/belt_MutableQueue.cmj -lib/ocaml/belt_MutableQueue.cmt -lib/ocaml/belt_MutableQueue.cmti -lib/ocaml/belt_MutableQueue.res -lib/ocaml/belt_MutableQueue.resi -lib/ocaml/belt_MutableSet.cmi -lib/ocaml/belt_MutableSet.cmj -lib/ocaml/belt_MutableSet.cmt -lib/ocaml/belt_MutableSet.cmti -lib/ocaml/belt_MutableSet.res -lib/ocaml/belt_MutableSet.resi -lib/ocaml/belt_MutableSetInt.cmi -lib/ocaml/belt_MutableSetInt.cmj -lib/ocaml/belt_MutableSetInt.cmt -lib/ocaml/belt_MutableSetInt.cmti -lib/ocaml/belt_MutableSetInt.res -lib/ocaml/belt_MutableSetInt.resi -lib/ocaml/belt_MutableSetString.cmi -lib/ocaml/belt_MutableSetString.cmj -lib/ocaml/belt_MutableSetString.cmt -lib/ocaml/belt_MutableSetString.cmti -lib/ocaml/belt_MutableSetString.res -lib/ocaml/belt_MutableSetString.resi -lib/ocaml/belt_MutableStack.cmi -lib/ocaml/belt_MutableStack.cmj -lib/ocaml/belt_MutableStack.cmt -lib/ocaml/belt_MutableStack.cmti -lib/ocaml/belt_MutableStack.res -lib/ocaml/belt_MutableStack.resi -lib/ocaml/belt_Option.cmi -lib/ocaml/belt_Option.cmj -lib/ocaml/belt_Option.cmt -lib/ocaml/belt_Option.cmti -lib/ocaml/belt_Option.res -lib/ocaml/belt_Option.resi -lib/ocaml/belt_Range.cmi -lib/ocaml/belt_Range.cmj -lib/ocaml/belt_Range.cmt -lib/ocaml/belt_Range.cmti -lib/ocaml/belt_Range.res -lib/ocaml/belt_Range.resi -lib/ocaml/belt_Result.cmi -lib/ocaml/belt_Result.cmj -lib/ocaml/belt_Result.cmt -lib/ocaml/belt_Result.cmti -lib/ocaml/belt_Result.res -lib/ocaml/belt_Result.resi -lib/ocaml/belt_Set.cmi -lib/ocaml/belt_Set.cmj -lib/ocaml/belt_Set.cmt -lib/ocaml/belt_Set.cmti -lib/ocaml/belt_Set.res -lib/ocaml/belt_Set.resi -lib/ocaml/belt_SetDict.cmi -lib/ocaml/belt_SetDict.cmj -lib/ocaml/belt_SetDict.cmt -lib/ocaml/belt_SetDict.cmti -lib/ocaml/belt_SetDict.res -lib/ocaml/belt_SetDict.resi -lib/ocaml/belt_SetInt.cmi -lib/ocaml/belt_SetInt.cmj -lib/ocaml/belt_SetInt.cmt -lib/ocaml/belt_SetInt.cmti -lib/ocaml/belt_SetInt.res -lib/ocaml/belt_SetInt.resi -lib/ocaml/belt_SetString.cmi -lib/ocaml/belt_SetString.cmj -lib/ocaml/belt_SetString.cmt -lib/ocaml/belt_SetString.cmti -lib/ocaml/belt_SetString.res -lib/ocaml/belt_SetString.resi -lib/ocaml/belt_SortArray.cmi -lib/ocaml/belt_SortArray.cmj -lib/ocaml/belt_SortArray.cmt -lib/ocaml/belt_SortArray.cmti -lib/ocaml/belt_SortArray.res -lib/ocaml/belt_SortArray.resi -lib/ocaml/belt_SortArrayInt.cmi -lib/ocaml/belt_SortArrayInt.cmj -lib/ocaml/belt_SortArrayInt.cmt -lib/ocaml/belt_SortArrayInt.cmti -lib/ocaml/belt_SortArrayInt.res -lib/ocaml/belt_SortArrayInt.resi -lib/ocaml/belt_SortArrayString.cmi -lib/ocaml/belt_SortArrayString.cmj -lib/ocaml/belt_SortArrayString.cmt -lib/ocaml/belt_SortArrayString.cmti -lib/ocaml/belt_SortArrayString.res -lib/ocaml/belt_SortArrayString.resi -lib/ocaml/belt_internalAVLset.cmj -lib/ocaml/belt_internalAVLset.cmt -lib/ocaml/belt_internalAVLset.cmti -lib/ocaml/belt_internalAVLset.res -lib/ocaml/belt_internalAVLset.resi -lib/ocaml/belt_internalAVLtree.cmj -lib/ocaml/belt_internalAVLtree.cmt -lib/ocaml/belt_internalAVLtree.cmti -lib/ocaml/belt_internalAVLtree.res -lib/ocaml/belt_internalAVLtree.resi -lib/ocaml/belt_internalBuckets.cmj -lib/ocaml/belt_internalBuckets.cmt -lib/ocaml/belt_internalBuckets.cmti -lib/ocaml/belt_internalBuckets.res -lib/ocaml/belt_internalBuckets.resi -lib/ocaml/belt_internalBucketsType.cmj -lib/ocaml/belt_internalBucketsType.cmt -lib/ocaml/belt_internalBucketsType.cmti -lib/ocaml/belt_internalBucketsType.res -lib/ocaml/belt_internalBucketsType.resi -lib/ocaml/belt_internalMapInt.cmj -lib/ocaml/belt_internalMapInt.cmt -lib/ocaml/belt_internalMapInt.res -lib/ocaml/belt_internalMapString.cmj -lib/ocaml/belt_internalMapString.cmt -lib/ocaml/belt_internalMapString.res -lib/ocaml/belt_internalSetBuckets.cmj -lib/ocaml/belt_internalSetBuckets.cmt -lib/ocaml/belt_internalSetBuckets.cmti -lib/ocaml/belt_internalSetBuckets.res -lib/ocaml/belt_internalSetBuckets.resi -lib/ocaml/belt_internalSetInt.cmj -lib/ocaml/belt_internalSetInt.cmt -lib/ocaml/belt_internalSetInt.res -lib/ocaml/belt_internalSetString.cmj -lib/ocaml/belt_internalSetString.cmt -lib/ocaml/belt_internalSetString.res lib/ocaml/belt_internals.cmti lib/ocaml/belt_internals.resi lib/ocaml/buffer.cmi diff --git a/scripts/ninja.js b/scripts/ninja.js index bce31a4465b..03f0aeef4e6 100755 --- a/scripts/ninja.js +++ b/scripts/ninja.js @@ -1305,7 +1305,7 @@ include body.ninja ` ); - preprocessorNinjaSync(); // This is needed so that ocamldep makes sense + // preprocessorNinjaSync(); // This is needed so that ocamldep makes sense runtimeNinja(); stdlibNinja(true); if (fs.existsSync(bsc_exe)) {