From 904f3fffbd0c83dea1f9a45f0e28114c904bc488 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Mon, 9 Sep 2024 01:07:35 +0900 Subject: [PATCH] Drop OCaml Array module --- jscomp/core/lam_analysis.ml | 2 +- jscomp/core/lam_dispatch_primitive.ml | 6 - jscomp/ext/js_runtime_modules.ml | 4 +- jscomp/runtime/caml_array.res | 99 ---- jscomp/runtime/caml_array.resi | 37 -- jscomp/runtime/caml_array_extern.res | 11 - jscomp/runtime/caml_module.res | 18 +- jscomp/runtime/caml_obj.res | 11 +- jscomp/runtime/curry.res | 12 +- jscomp/runtime/primitive_array.res | 19 + jscomp/runtime/release.ninja | 12 +- jscomp/stdlib-406/array.res | 399 -------------- jscomp/stdlib-406/array.resi | 246 --------- jscomp/stdlib-406/arrayLabels.res | 399 -------------- jscomp/stdlib-406/arrayLabels.resi | 245 --------- jscomp/stdlib-406/release.ninja | 10 +- jscomp/stdlib-406/sort.res | 134 ----- jscomp/stdlib-406/sort.resi | 44 -- jscomp/stdlib-406/stdLabels.res | 20 - jscomp/stdlib-406/stdLabels.resi | 25 - jscomp/syntax/src/res_comments_table.ml | 10 +- jscomp/syntax/src/res_core.ml | 15 +- jscomp/syntax/src/res_parsetree_viewer.ml | 5 +- jscomp/syntax/src/res_printer.ml | 10 +- .../errors/expressions/expected/array.res.txt | 4 +- .../expressions/expected/async.res.txt | 2 +- .../expressions/expected/await.res.txt | 5 +- .../expected/binaryNoEs6Arrow.res.txt | 2 +- .../expected/bracedOrRecord.res.txt | 4 +- .../expressions/expected/bsObject.res.txt | 6 +- .../expected/firstClassModule.res.txt | 15 +- .../expressions/expected/primary.res.txt | 10 +- .../structure/expected/valueBinding.res.txt | 5 +- .../tests/printer/structure/valueBinding.res | 5 +- jscomp/test/UntaggedVariants.js | 8 +- jscomp/test/array_safe_get.js | 4 +- jscomp/test/array_subtle_test.js | 28 +- jscomp/test/array_subtle_test.res | 2 + jscomp/test/array_test.js | 336 ------------ jscomp/test/array_test.res | 183 ------- jscomp/test/array_test.resi | 1 - jscomp/test/async_await.js | 4 +- jscomp/test/bdd.js | 81 +-- jscomp/test/bdd.res | 8 +- jscomp/test/bench.js | 6 +- jscomp/test/bench.res | 14 +- jscomp/test/bs_mutable_set_test.js | 6 +- jscomp/test/bs_poly_map_test.js | 30 +- jscomp/test/bs_poly_map_test.res | 7 +- jscomp/test/bs_set_int_test.js | 120 ++-- jscomp/test/bs_set_int_test.res | 9 +- jscomp/test/build.ninja | 5 +- jscomp/test/chn_test.js | 36 +- jscomp/test/chn_test.res | 4 +- jscomp/test/const_block_test.js | 14 +- jscomp/test/cps_test.js | 20 +- jscomp/test/cps_test.res | 6 +- jscomp/test/earger_curry_test.js | 22 +- jscomp/test/earger_curry_test.res | 19 +- jscomp/test/ext_array_test.js | 27 +- jscomp/test/ext_array_test.res | 42 +- jscomp/test/ffi_js_test.res | 4 +- jscomp/test/ffi_test.res | 4 +- jscomp/test/flexible_array_test.js | 10 +- jscomp/test/flexible_array_test.res | 6 +- jscomp/test/float_test.js | 139 ++--- jscomp/test/float_test.res | 18 +- jscomp/test/for_loop_test.js | 64 +-- jscomp/test/for_loop_test.res | 28 +- jscomp/test/gpr_1409_test.js | 14 +- jscomp/test/gpr_1409_test.res | 4 +- jscomp/test/gpr_3931_test.js | 4 +- jscomp/test/gpr_3931_test.res | 2 +- jscomp/test/hash_test.js | 12 +- jscomp/test/hash_test.res | 4 +- jscomp/test/js_json_test.js | 31 +- jscomp/test/js_json_test.res | 4 +- jscomp/test/js_obj_test.res | 2 +- jscomp/test/js_re_test.js | 10 +- jscomp/test/list_test.js | 35 +- jscomp/test/list_test.res | 13 +- jscomp/test/module_missing_conversion.js | 105 +++- jscomp/test/module_missing_conversion.res | 2 +- jscomp/test/mt.js | 35 +- jscomp/test/mt.res | 34 +- jscomp/test/obj_literal_ppx.res | 2 +- jscomp/test/queue_test.js | 26 +- jscomp/test/queue_test.res | 4 +- jscomp/test/reactDOMRe.res | 6 +- jscomp/test/reasonReactRouter.res | 3 +- jscomp/test/set_gen.res | 16 +- jscomp/test/splice_test.js | 51 +- jscomp/test/splice_test.res | 8 +- jscomp/test/string_set.js | 4 +- jscomp/test/string_set.res | 2 +- jscomp/test/tagged_template_test.js | 6 +- jscomp/test/tagged_template_test.res | 2 +- jscomp/test/tailcall_inline_test.js | 35 +- jscomp/test/tailcall_inline_test.res | 7 +- jscomp/test/test_array.js | 40 +- jscomp/test/test_array.res | 9 +- jscomp/test/test_array_append.js | 4 +- jscomp/test/test_array_append.res | 2 +- jscomp/test/test_array_primitive.js | 50 -- jscomp/test/test_array_primitive.res | 40 -- jscomp/test/test_closure.js | 10 +- jscomp/test/test_closure.res | 4 +- jscomp/test/test_cps.js | 7 +- jscomp/test/test_cps.res | 2 +- jscomp/test/test_for_loop.js | 32 +- jscomp/test/test_for_loop.res | 18 +- jscomp/test/test_google_closure.js | 8 +- jscomp/test/test_google_closure.res | 2 +- jscomp/test/test_primitive.js | 4 +- jscomp/test/test_runtime_encoding.js | 8 +- jscomp/test/test_simple_include.js | 236 ++++++-- jscomp/test/test_simple_include.res | 2 +- jscomp/test/test_while_closure.js | 12 +- jscomp/test/test_while_closure.res | 4 +- lib/es6/array.js | 513 ------------------ lib/es6/arrayLabels.js | 513 ------------------ lib/es6/caml_array.js | 115 ---- lib/es6/caml_array_extern.js | 1 - lib/es6/caml_bigint_extern.js | 1 - lib/es6/curry.js | 5 +- lib/es6/primitive_array.js | 32 ++ lib/es6/sort.js | 168 ------ lib/es6/stdLabels.js | 12 - lib/js/array.js | 511 ----------------- lib/js/arrayLabels.js | 511 ----------------- lib/js/caml_array.js | 113 ---- lib/js/caml_array_extern.js | 1 - lib/js/caml_bigint_extern.js | 1 - lib/js/curry.js | 5 +- lib/js/primitive_array.js | 30 + lib/js/sort.js | 166 ------ lib/js/stdLabels.js | 10 - 137 files changed, 1117 insertions(+), 5734 deletions(-) delete mode 100644 jscomp/runtime/caml_array.res delete mode 100644 jscomp/runtime/caml_array.resi delete mode 100644 jscomp/runtime/caml_array_extern.res create mode 100644 jscomp/runtime/primitive_array.res delete mode 100644 jscomp/stdlib-406/array.res delete mode 100644 jscomp/stdlib-406/array.resi delete mode 100644 jscomp/stdlib-406/arrayLabels.res delete mode 100644 jscomp/stdlib-406/arrayLabels.resi delete mode 100644 jscomp/stdlib-406/sort.res delete mode 100644 jscomp/stdlib-406/sort.resi delete mode 100644 jscomp/stdlib-406/stdLabels.res delete mode 100644 jscomp/stdlib-406/stdLabels.resi delete mode 100644 jscomp/test/array_test.js delete mode 100644 jscomp/test/array_test.res delete mode 100644 jscomp/test/array_test.resi delete mode 100644 jscomp/test/test_array_primitive.js delete mode 100644 jscomp/test/test_array_primitive.res delete mode 100644 lib/es6/array.js delete mode 100644 lib/es6/arrayLabels.js delete mode 100644 lib/es6/caml_array.js delete mode 100644 lib/es6/caml_array_extern.js delete mode 100644 lib/es6/caml_bigint_extern.js create mode 100644 lib/es6/primitive_array.js delete mode 100644 lib/es6/sort.js delete mode 100644 lib/es6/stdLabels.js delete mode 100644 lib/js/array.js delete mode 100644 lib/js/arrayLabels.js delete mode 100644 lib/js/caml_array.js delete mode 100644 lib/js/caml_array_extern.js delete mode 100644 lib/js/caml_bigint_extern.js create mode 100644 lib/js/primitive_array.js delete mode 100644 lib/js/sort.js delete mode 100644 lib/js/stdLabels.js diff --git a/jscomp/core/lam_analysis.ml b/jscomp/core/lam_analysis.ml index b677345df9c..69422455792 100644 --- a/jscomp/core/lam_analysis.ml +++ b/jscomp/core/lam_analysis.ml @@ -46,7 +46,7 @@ let rec no_side_effects (lam : Lam.t) : bool = ( (* more safe to check if arguments are constant *) (* non-observable side effect *) - "?make_vect" | "?obj_dup" | "caml_array_dup" ), + "?obj_dup" ), _ ) -> true | _, _ -> false) diff --git a/jscomp/core/lam_dispatch_primitive.ml b/jscomp/core/lam_dispatch_primitive.ml index 75d8d77ef57..5deb6235dc9 100644 --- a/jscomp/core/lam_dispatch_primitive.ml +++ b/jscomp/core/lam_dispatch_primitive.ml @@ -136,12 +136,6 @@ let translate loc (prim_name : string) (args : J.expression list) : J.expression like normal one to set the identifier *) | "?exn_slot_name" | "?is_extension" -> call Js_runtime_modules.exceptions | "?as_js_exn" -> call Js_runtime_modules.caml_js_exceptions - | "?array_sub" -> E.runtime_call Js_runtime_modules.array "sub" args - | "?array_concat" -> E.runtime_call Js_runtime_modules.array "concat" args - (*external concat: 'a array list -> 'a array - Not good for inline *) - | "?array_blit" -> E.runtime_call Js_runtime_modules.array "blit" args - | "?make_vect" -> E.runtime_call Js_runtime_modules.array "make" args | "?obj_dup" -> call Js_runtime_modules.obj_runtime | "?obj_tag" -> ( (* Note that in ocaml, [int] has tag [1000] and [string] has tag [252] diff --git a/jscomp/ext/js_runtime_modules.ml b/jscomp/ext/js_runtime_modules.ml index a74c6301006..63c1977a15b 100644 --- a/jscomp/ext/js_runtime_modules.ml +++ b/jscomp/ext/js_runtime_modules.ml @@ -32,6 +32,8 @@ let bigint = "Primitive_bigint" let string = "Primitive_string" +let array = "Primitive_array" + let deriving = "Runtime_deriving" let promise = "Runtime_promise" @@ -42,8 +44,6 @@ let exceptions = "Caml_exceptions" let obj_runtime = "Caml_obj" -let array = "Caml_array" - let hash_primitive = "Caml_hash_primitive" let hash = "Caml_hash" diff --git a/jscomp/runtime/caml_array.res b/jscomp/runtime/caml_array.res deleted file mode 100644 index 094b94975fe..00000000000 --- a/jscomp/runtime/caml_array.res +++ /dev/null @@ -1,99 +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. */ - -@send external dup: (array<'a>, @as(0) _) => array<'a> = "slice" - -%%private(let {unsafe_get, unsafe_set} = module(Caml_array_extern)) - -let sub = (x: array<'a>, offset: int, len: int) => { - let result = Caml_array_extern.new_uninitialized(len) - let j = {contents: 0} and i = {contents: offset} - while j.contents < len { - result->unsafe_set(j.contents, x->unsafe_get(i.contents)) - j.contents = j.contents + 1 - i.contents = i.contents + 1 - } - result -} - -let rec len = (acc, l) => - switch l { - | list{} => acc - | list{x, ...xs} => len(Caml_array_extern.length(x) + acc, xs) - } - -let rec fill = (arr, i, l) => - switch l { - | list{} => () - | list{x, ...xs} => - let l = Caml_array_extern.length(x) - let k = {contents: i} - let j = {contents: 0} - while j.contents < l { - arr->unsafe_set(k.contents, x->unsafe_get(j.contents)) - k.contents = k.contents + 1 - j.contents = j.contents + 1 - } - fill(arr, k.contents, xs) - } - -let concat = (l: list>): array<'a> => { - let v = len(0, l) - let result = Caml_array_extern.new_uninitialized(v) - fill(result, 0, l) - result -} - -let set = (xs, index, newval) => - if index < 0 || index >= Caml_array_extern.length(xs) { - raise(Invalid_argument("index out of bounds")) - } else { - xs->unsafe_set(index, newval) - } - -let get = (xs, index) => - if index < 0 || index >= Caml_array_extern.length(xs) { - raise(Invalid_argument("index out of bounds")) - } else { - xs->unsafe_get(index) - } - -let make = (len, init) => { - let b = Caml_array_extern.new_uninitialized(len) - for i in 0 to len - 1 { - b->unsafe_set(i, init) - } - b -} - -let blit = (a1, i1, a2, i2, len) => - if i2 <= i1 { - for j in 0 to len - 1 { - a2->unsafe_set(j + i2, a1->unsafe_get(j + i1)) - } - } else { - for j in len - 1 downto 0 { - a2->unsafe_set(j + i2, a1->unsafe_get(j + i1)) - } - } diff --git a/jscomp/runtime/caml_array.resi b/jscomp/runtime/caml_array.resi deleted file mode 100644 index c75528816f9..00000000000 --- a/jscomp/runtime/caml_array.resi +++ /dev/null @@ -1,37 +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. */ - -let dup: array<'a> => array<'a> - -let sub: (array<'a>, int, int) => array<'a> - -let concat: list> => array<'a> - -let make: (int, 'a) => array<'a> - -let blit: (array<'a>, int, array<'a>, int, int) => unit - -let get: (array<'a>, int) => 'a - -let set: (array<'a>, int, 'a) => unit diff --git a/jscomp/runtime/caml_array_extern.res b/jscomp/runtime/caml_array_extern.res deleted file mode 100644 index 84b2ac34061..00000000000 --- a/jscomp/runtime/caml_array_extern.res +++ /dev/null @@ -1,11 +0,0 @@ -@new external new_uninitialized: int => array<'a> = "Array" -@send external append: (array<'a>, array<'a>) => array<'a> = "concat" -external unsafe_get: (array<'a>, int) => 'a = "%array_unsafe_get" -external unsafe_set: (array<'a>, int, 'a) => unit = "%array_unsafe_set" -external length: array<'a> => int = "%array_length" - -/* - Could be replaced by {!Caml_array.caml_make_vect} - Leave here temporarily since we have marked it side effect free internally -*/ -external make: (int, 'a) => array<'a> = "?make_vect" diff --git a/jscomp/runtime/caml_module.res b/jscomp/runtime/caml_module.res index 8b645038c3f..fc21ba028f1 100644 --- a/jscomp/runtime/caml_module.res +++ b/jscomp/runtime/caml_module.res @@ -35,11 +35,11 @@ type rec shape = | Class | Module(array<(shape, string)>) | Value(Obj.t) -/* ATTENTION: check across versions */ -module Array = Caml_array_extern -@set_index external set_field: (Obj.t, string, Obj.t) => unit = "" +@get external array_length: array<'a> => int = "length" +@get_index external array_unsafe_get: (array<'a>, int) => 'a = "" +@set_index external set_field: (Obj.t, string, Obj.t) => unit = "" @get_index external get_field: (Obj.t, string) => Obj.t = "" module type Empty = {} @@ -69,9 +69,9 @@ let init_mod = (loc: (string, int, int), shape: shape) => { | Module(comps) => let v = Obj.repr(module({}: Empty)) set_field(struct_, idx, v) - let len = Array.length(comps) + let len = array_length(comps) for i in 0 to len - 1 { - let (shape, name) = Caml_array_extern.unsafe_get(comps, i) + let (shape, name) = array_unsafe_get(comps, i) loop(shape, v, name) } | Value(v) => set_field(struct_, idx, v) @@ -94,16 +94,16 @@ let update_mod = (shape: shape, o: Obj.t, n: Obj.t): unit => { | Class => Caml_obj.update_dummy(o, n) | Module(comps) => - for i in 0 to Array.length(comps) - 1 { - let (shape, name) = Caml_array_extern.unsafe_get(comps, i) + for i in 0 to array_length(comps) - 1 { + let (shape, name) = array_unsafe_get(comps, i) aux(shape, get_field(o, name), get_field(n, name), o, name) } | Value(_) => () } switch shape { | Module(comps) => - for i in 0 to Array.length(comps) - 1 { - let (shape, name) = Caml_array_extern.unsafe_get(comps, i) + for i in 0 to array_length(comps) - 1 { + let (shape, name) = array_unsafe_get(comps, i) aux(shape, get_field(o, name), get_field(n, name), o, name) } | _ => assert(false) diff --git a/jscomp/runtime/caml_obj.res b/jscomp/runtime/caml_obj.res index f9fcff04f02..4607d4f3c25 100644 --- a/jscomp/runtime/caml_obj.res +++ b/jscomp/runtime/caml_obj.res @@ -22,6 +22,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +external array_unsafe_get: (array<'a>, int) => 'a = "%array_unsafe_get" + type t = Obj.t module O = { @@ -69,7 +71,6 @@ module O = { var new_record = u.slice () ]} - `obj_dup` is a superset of `array_dup` */ let obj_dup: Obj.t => Obj.t = %raw(`function(x){ if(Array.isArray(x)){ @@ -234,7 +235,7 @@ and aux_same_length = (a: array, b: array, i, same_length) => if i == same_length { 0 } else { - let res = compare(Caml_array_extern.unsafe_get(a, i), Caml_array_extern.unsafe_get(b, i)) + let res = compare(array_unsafe_get(a, i), array_unsafe_get(b, i)) if res != 0 { res @@ -247,7 +248,7 @@ and aux_length_a_short = (a: array, b: array, i, short_length) => if i == short_length { -1 } else { - let res = compare(Caml_array_extern.unsafe_get(a, i), Caml_array_extern.unsafe_get(b, i)) + let res = compare(array_unsafe_get(a, i), array_unsafe_get(b, i)) if res != 0 { res @@ -260,7 +261,7 @@ and aux_length_b_short = (a: array, b: array, i, short_length) => if i == short_length { 1 } else { - let res = compare(Caml_array_extern.unsafe_get(a, i), Caml_array_extern.unsafe_get(b, i)) + let res = compare(array_unsafe_get(a, i), array_unsafe_get(b, i)) if res != 0 { res @@ -359,7 +360,7 @@ and aux_equal_length = (a: array, b: array, i, same_length) => if i == same_length { true } else { - equal(Caml_array_extern.unsafe_get(a, i), Caml_array_extern.unsafe_get(b, i)) && + equal(array_unsafe_get(a, i), array_unsafe_get(b, i)) && aux_equal_length(a, b, i + 1, same_length) } diff --git a/jscomp/runtime/curry.res b/jscomp/runtime/curry.res index 97147be5083..6ae20041578 100644 --- a/jscomp/runtime/curry.res +++ b/jscomp/runtime/curry.res @@ -24,12 +24,14 @@ @@uncurried +@get external array_length: array<'a> => int = "length" +@send external array_slice: (array<'a>, int, int) => array<'a> = "slice" +@send external array_concat: (array<'a>, array<'a>) => array<'a> = "concat" + /* Generated by scripts/curry_gen.ml */ external function_length: 'a => int = "#function_length" external apply_args: ('a => 'b, array<_>) => 'b = "#apply" -let _ = Caml_array.sub /* make the build dependency on Caml_array explicit */ -%%private(let sub = Caml_array.sub) /* Public */ let rec app = (f, args) => { let init_arity = function_length(f) @@ -38,15 +40,15 @@ let rec app = (f, args) => { } else { init_arity } /* arity fixing */ - let len = Caml_array_extern.length(args) + let len = array_length(args) let d = arity - len if d == 0 { apply_args(f, args) /* f.apply (null,args) */ } else if d < 0 { /* TODO: could avoid copy by tracking the index */ - app(Obj.magic(apply_args(f, sub(args, 0, arity))), sub(args, arity, -d)) + app(Obj.magic(apply_args(f, array_slice(args, 0, arity))), array_slice(args, arity, len)) } else { - Obj.magic(x => app(f, Caml_array_extern.append(args, [x]))) + Obj.magic(x => app(f, array_concat(args, [x]))) } } diff --git a/jscomp/runtime/primitive_array.res b/jscomp/runtime/primitive_array.res new file mode 100644 index 00000000000..cbf9d49ff7c --- /dev/null +++ b/jscomp/runtime/primitive_array.res @@ -0,0 +1,19 @@ +@get external length: array<'a> => int = "length" + +@get_index external get: (array<'a>, int) => 'a = "" + +let get = (xs, index) => + if index < 0 || index >= length(xs) { + raise(Invalid_argument("index out of bounds")) + } else { + xs->get(index) + } + +@set_index external set: (array<'a>, int, 'a) => unit = "" + +let set = (xs, index, newval) => + if index < 0 || index >= length(xs) { + raise(Invalid_argument("index out of bounds")) + } else { + xs->set(index, newval) + } diff --git a/jscomp/runtime/release.ninja b/jscomp/runtime/release.ninja index 880f94f1dc5..f7bee9c600f 100644 --- a/jscomp/runtime/release.ninja +++ b/jscomp/runtime/release.ninja @@ -13,8 +13,6 @@ o runtime/bs_stdlib_mini.cmi : cc runtime/bs_stdlib_mini.resi bsc_flags = -nostdlib -nopervasives o runtime/js.cmj runtime/js.cmi : cc runtime/js.res bsc_flags = $bsc_no_open_flags -o runtime/caml_array.cmj : cc_cmi runtime/caml_array.res | runtime/caml_array.cmi runtime/caml_array_extern.cmj -o runtime/caml_array.cmi : cc runtime/caml_array.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_dict.cmj : cc_cmi runtime/caml_dict.res | runtime/caml_dict.cmi o runtime/caml_dict.cmi : cc runtime/caml_dict.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_exceptions.cmj : cc_cmi runtime/caml_exceptions.res | runtime/caml_exceptions.cmi @@ -23,18 +21,18 @@ o runtime/caml_hash.cmj : cc_cmi runtime/caml_hash.res | runtime/caml_hash.cmi r o runtime/caml_hash.cmi : cc runtime/caml_hash.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_hash_primitive.cmj : cc_cmi runtime/caml_hash_primitive.res | runtime/caml_hash_primitive.cmi o runtime/caml_hash_primitive.cmi : cc runtime/caml_hash_primitive.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj -o runtime/caml_module.cmj : cc_cmi runtime/caml_module.res | runtime/caml_array_extern.cmj runtime/caml_module.cmi runtime/caml_obj.cmj +o runtime/caml_module.cmj : cc_cmi runtime/caml_module.res | runtime/caml_module.cmi runtime/caml_obj.cmj o runtime/caml_module.cmi : cc runtime/caml_module.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj -o runtime/caml_obj.cmj : cc_cmi runtime/caml_obj.res | runtime/caml_array_extern.cmj runtime/caml_obj.cmi runtime/caml_option.cmj runtime/primitive_bool.cmj runtime/primitive_float.cmj runtime/primitive_int.cmj runtime/primitive_string.cmj +o runtime/caml_obj.cmj : cc_cmi runtime/caml_obj.res | runtime/caml_obj.cmi runtime/caml_option.cmj runtime/primitive_bool.cmj runtime/primitive_float.cmj runtime/primitive_int.cmj runtime/primitive_string.cmj o runtime/caml_obj.cmi : cc runtime/caml_obj.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_option.cmj : cc_cmi runtime/caml_option.res | runtime/caml_option.cmi runtime/caml_undefined_extern.cmj o runtime/caml_option.cmi : cc runtime/caml_option.resi | runtime/bs_stdlib_mini.cmi runtime/caml_undefined_extern.cmj runtime/js.cmi runtime/js.cmj o runtime/caml_splice_call.cmj : cc_cmi runtime/caml_splice_call.res | runtime/caml_splice_call.cmi o runtime/caml_splice_call.cmi : cc runtime/caml_splice_call.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj -o runtime/caml_array_extern.cmi runtime/caml_array_extern.cmj : cc runtime/caml_array_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/caml_js_exceptions.cmi runtime/caml_js_exceptions.cmj : cc runtime/caml_js_exceptions.res | runtime/bs_stdlib_mini.cmi runtime/caml_exceptions.cmj runtime/caml_option.cmj runtime/js.cmi runtime/js.cmj o runtime/caml_undefined_extern.cmi runtime/caml_undefined_extern.cmj : cc runtime/caml_undefined_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj -o runtime/curry.cmi runtime/curry.cmj : cc runtime/curry.res | runtime/bs_stdlib_mini.cmi runtime/caml_array.cmj runtime/caml_array_extern.cmj runtime/js.cmi runtime/js.cmj +o runtime/curry.cmi runtime/curry.cmj : cc runtime/curry.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj +o runtime/primitive_array.cmi runtime/primitive_array.cmj : cc runtime/primitive_array.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/primitive_bigint.cmi runtime/primitive_bigint.cmj : cc runtime/primitive_bigint.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/primitive_bool.cmi runtime/primitive_bool.cmj : cc runtime/primitive_bool.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/primitive_float.cmi runtime/primitive_float.cmj : cc runtime/primitive_float.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj runtime/primitive_float_extern.cmj @@ -42,4 +40,4 @@ o runtime/primitive_float_extern.cmi runtime/primitive_float_extern.cmj : cc run o runtime/primitive_int.cmi runtime/primitive_int.cmj : cc runtime/primitive_int.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj o runtime/primitive_string.cmi runtime/primitive_string.cmj : cc runtime/primitive_string.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj runtime/primitive_string_extern.cmj o runtime/primitive_string_extern.cmi runtime/primitive_string_extern.cmj : cc runtime/primitive_string_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj -o runtime : phony runtime/bs_stdlib_mini.cmi runtime/js.cmj runtime/js.cmi runtime/caml_array.cmi runtime/caml_array.cmj runtime/caml_dict.cmi runtime/caml_dict.cmj runtime/caml_exceptions.cmi runtime/caml_exceptions.cmj runtime/caml_hash.cmi runtime/caml_hash.cmj runtime/caml_hash_primitive.cmi runtime/caml_hash_primitive.cmj runtime/caml_module.cmi runtime/caml_module.cmj runtime/caml_obj.cmi runtime/caml_obj.cmj runtime/caml_option.cmi runtime/caml_option.cmj runtime/caml_splice_call.cmi runtime/caml_splice_call.cmj runtime/caml_array_extern.cmi runtime/caml_array_extern.cmj runtime/caml_js_exceptions.cmi runtime/caml_js_exceptions.cmj runtime/caml_undefined_extern.cmi runtime/caml_undefined_extern.cmj runtime/curry.cmi runtime/curry.cmj runtime/primitive_bigint.cmi runtime/primitive_bigint.cmj runtime/primitive_bool.cmi runtime/primitive_bool.cmj runtime/primitive_float.cmi runtime/primitive_float.cmj runtime/primitive_float_extern.cmi runtime/primitive_float_extern.cmj runtime/primitive_int.cmi runtime/primitive_int.cmj runtime/primitive_string.cmi runtime/primitive_string.cmj runtime/primitive_string_extern.cmi runtime/primitive_string_extern.cmj +o runtime : phony runtime/bs_stdlib_mini.cmi runtime/js.cmj runtime/js.cmi runtime/caml_dict.cmi runtime/caml_dict.cmj runtime/caml_exceptions.cmi runtime/caml_exceptions.cmj runtime/caml_hash.cmi runtime/caml_hash.cmj runtime/caml_hash_primitive.cmi runtime/caml_hash_primitive.cmj runtime/caml_module.cmi runtime/caml_module.cmj runtime/caml_obj.cmi runtime/caml_obj.cmj runtime/caml_option.cmi runtime/caml_option.cmj runtime/caml_splice_call.cmi runtime/caml_splice_call.cmj runtime/caml_js_exceptions.cmi runtime/caml_js_exceptions.cmj runtime/caml_undefined_extern.cmi runtime/caml_undefined_extern.cmj runtime/curry.cmi runtime/curry.cmj runtime/primitive_array.cmi runtime/primitive_array.cmj runtime/primitive_bigint.cmi runtime/primitive_bigint.cmj runtime/primitive_bool.cmi runtime/primitive_bool.cmj runtime/primitive_float.cmi runtime/primitive_float.cmj runtime/primitive_float_extern.cmi runtime/primitive_float_extern.cmj runtime/primitive_int.cmi runtime/primitive_int.cmj runtime/primitive_string.cmi runtime/primitive_string.cmj runtime/primitive_string_extern.cmi runtime/primitive_string_extern.cmj diff --git a/jscomp/stdlib-406/array.res b/jscomp/stdlib-406/array.res deleted file mode 100644 index 5044e6ebc50..00000000000 --- a/jscomp/stdlib-406/array.res +++ /dev/null @@ -1,399 +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. */ -/* */ -/* ************************************************************************ */ - -/* Array operations */ - -external length: array<'a> => int = "%array_length" -external get: (array<'a>, int) => 'a = "%array_safe_get" -external set: (array<'a>, int, 'a) => unit = "%array_safe_set" -external unsafe_get: (array<'a>, int) => 'a = "%array_unsafe_get" -external unsafe_set: (array<'a>, int, 'a) => unit = "%array_unsafe_set" -external make: (int, 'a) => array<'a> = "?make_vect" -external create: (int, 'a) => array<'a> = "?make_vect" -external unsafe_sub: (array<'a>, int, int) => array<'a> = "?array_sub" - -@send external append_prim: (array<'a>, array<'a>) => array<'a> = "concat" - -external concat: list> => array<'a> = "?array_concat" -external unsafe_blit: (array<'a>, int, array<'a>, int, int) => unit = "?array_blit" - -let init = (l, f) => - if l == 0 { - [] - } else if l < 0 { - invalid_arg("Array.init") - } else { - /* 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 res = create(l, f(0)) - for i in 1 to pred(l) { - unsafe_set(res, i, f(i)) - } - res - } - -let make_matrix = (sx, sy, init) => { - let res = create(sx, []) - for x in 0 to pred(sx) { - unsafe_set(res, x, create(sy, init)) - } - res -} - -let create_matrix = make_matrix - -let copy = a => { - let l = length(a) - if l == 0 { - [] - } else { - unsafe_sub(a, 0, l) - } -} - -let append = (a1, a2) => { - let l1 = length(a1) - if l1 == 0 { - copy(a2) - } else if length(a2) == 0 { - unsafe_sub(a1, 0, l1) - } else { - append_prim(a1, a2) - } -} - -let sub = (a, ofs, len) => - if ofs < 0 || (len < 0 || ofs > length(a) - len) { - invalid_arg("Array.sub") - } else { - unsafe_sub(a, ofs, len) - } - -let fill = (a, ofs, len, v) => - if ofs < 0 || (len < 0 || ofs > length(a) - len) { - invalid_arg("Array.fill") - } else { - for i in ofs to ofs + len - 1 { - unsafe_set(a, i, v) - } - } - -let blit = (a1, ofs1, a2, ofs2, len) => - if len < 0 || (ofs1 < 0 || (ofs1 > length(a1) - len || (ofs2 < 0 || ofs2 > length(a2) - len))) { - invalid_arg("Array.blit") - } else { - unsafe_blit(a1, ofs1, a2, ofs2, len) - } - -let iter = (f, a) => - for i in 0 to length(a) - 1 { - f(unsafe_get(a, i)) - } - -let iter2 = (f, a, b) => - if length(a) != length(b) { - invalid_arg("Array.iter2: arrays must have the same length") - } else { - for i in 0 to length(a) - 1 { - f(unsafe_get(a, i), unsafe_get(b, i)) - } - } - -let map = (f, a) => { - let l = length(a) - if l == 0 { - [] - } else { - let r = create(l, f(unsafe_get(a, 0))) - for i in 1 to l - 1 { - unsafe_set(r, i, f(unsafe_get(a, i))) - } - r - } -} - -let map2 = (f, a, b) => { - let la = length(a) - let lb = length(b) - if la != lb { - invalid_arg("Array.map2: arrays must have the same length") - } else if la == 0 { - [] - } else { - let r = create(la, f(unsafe_get(a, 0), unsafe_get(b, 0))) - for i in 1 to la - 1 { - unsafe_set(r, i, f(unsafe_get(a, i), unsafe_get(b, i))) - } - r - } -} - -let iteri = (f, a) => - for i in 0 to length(a) - 1 { - f(i, unsafe_get(a, i)) - } - -let mapi = (f, a) => { - let l = length(a) - if l == 0 { - [] - } else { - let r = create(l, f(0, unsafe_get(a, 0))) - for i in 1 to l - 1 { - unsafe_set(r, i, f(i, unsafe_get(a, i))) - } - r - } -} - -let to_list = a => { - let rec tolist = (i, res) => - if i < 0 { - res - } else { - tolist(i - 1, list{unsafe_get(a, i), ...res}) - } - tolist(length(a) - 1, list{}) -} - -/* Cannot use List.length here because the List module depends on Array. */ -let rec list_length = (accu, param) => - switch param { - | list{} => accu - | list{_, ...t} => list_length(succ(accu), t) - } - -let of_list = param => - switch param { - | list{} => [] - | list{hd, ...tl} as l => - let a = create(list_length(0, l), hd) - let rec fill = (i, param) => - switch param { - | list{} => a - | list{hd, ...tl} => - unsafe_set(a, i, hd) - fill(i + 1, tl) - } - fill(1, tl) - } - -let fold_left = (f, x, a) => { - let r = ref(x) - for i in 0 to length(a) - 1 { - r := f(r.contents, unsafe_get(a, i)) - } - r.contents -} - -let fold_right = (f, a, x) => { - let r = ref(x) - for i in length(a) - 1 downto 0 { - r := f(unsafe_get(a, i), r.contents) - } - r.contents -} - -let exists = (p, a) => { - let n = length(a) - let rec loop = i => - if i == n { - false - } else if p(unsafe_get(a, i)) { - true - } else { - loop(succ(i)) - } - loop(0) -} - -let for_all = (p, a) => { - let n = length(a) - let rec loop = i => - if i == n { - true - } else if p(unsafe_get(a, i)) { - loop(succ(i)) - } else { - false - } - loop(0) -} - -let mem = (x, a) => { - let n = length(a) - let rec loop = i => - if i == n { - false - } else if compare(unsafe_get(a, i), x) == 0 { - true - } else { - loop(succ(i)) - } - loop(0) -} - -let memq = (x, a) => { - let n = length(a) - let rec loop = i => - if i == n { - false - } else if x === unsafe_get(a, i) { - true - } else { - loop(succ(i)) - } - loop(0) -} - -exception Bottom(int) -let sort = (cmp, a) => { - let maxson = (l, i) => { - let i31 = i + i + i + 1 - let x = ref(i31) - if i31 + 2 < l { - if cmp(get(a, i31), get(a, i31 + 1)) < 0 { - x := i31 + 1 - } - if cmp(get(a, x.contents), get(a, i31 + 2)) < 0 { - x := i31 + 2 - } - x.contents - } else if i31 + 1 < l && cmp(get(a, i31), get(a, i31 + 1)) < 0 { - i31 + 1 - } else if i31 < l { - i31 - } else { - raise(Bottom(i)) - } - } - - let rec trickledown = (l, i, e) => { - let j = maxson(l, i) - if cmp(get(a, j), e) > 0 { - set(a, i, get(a, j)) - trickledown(l, j, e) - } else { - set(a, i, e) - } - } - - let trickle = (l, i, e) => - try trickledown(l, i, e) catch { - | Bottom(i) => set(a, i, e) - } - let rec bubbledown = (l, i) => { - let j = maxson(l, i) - set(a, i, get(a, j)) - bubbledown(l, j) - } - - let bubble = (l, i) => - try bubbledown(l, i) catch { - | Bottom(i) => i - } - let rec trickleup = (i, e) => { - let father = (i - 1) / 3 - assert(i != father) - if cmp(get(a, father), e) < 0 { - set(a, i, get(a, father)) - if father > 0 { - trickleup(father, e) - } else { - set(a, 0, e) - } - } else { - set(a, i, e) - } - } - - let l = length(a) - for i in (l + 1) / 3 - 1 downto 0 { - trickle(l, i, get(a, i)) - } - for i in l - 1 downto 2 { - let e = get(a, i) - set(a, i, get(a, 0)) - trickleup(bubble(i, 0), e) - } - if l > 1 { - let e = get(a, 1) - set(a, 1, get(a, 0)) - set(a, 0, e) - } -} - -let cutoff = 5 -let stable_sort = (cmp, a) => { - let merge = (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { - let src1r = src1ofs + src1len and src2r = src2ofs + src2len - let rec loop = (i1, s1, i2, s2, d) => - if cmp(s1, s2) <= 0 { - set(dst, d, s1) - let i1 = i1 + 1 - if i1 < src1r { - loop(i1, get(a, i1), i2, s2, d + 1) - } else { - blit(src2, i2, dst, d + 1, src2r - i2) - } - } else { - set(dst, d, s2) - let i2 = i2 + 1 - if i2 < src2r { - loop(i1, s1, i2, get(src2, i2), d + 1) - } else { - blit(a, i1, dst, d + 1, src1r - i1) - } - } - loop(src1ofs, get(a, src1ofs), src2ofs, get(src2, src2ofs), dstofs) - } - - let isortto = (srcofs, dst, dstofs, len) => - for i in 0 to len - 1 { - let e = get(a, srcofs + i) - let j = ref(dstofs + i - 1) - while j.contents >= dstofs && cmp(get(dst, j.contents), e) > 0 { - set(dst, j.contents + 1, get(dst, j.contents)) - decr(j) - } - set(dst, j.contents + 1, e) - } - - let rec sortto = (srcofs, dst, dstofs, len) => - if len <= cutoff { - isortto(srcofs, dst, dstofs, len) - } else { - let l1 = len / 2 - let l2 = len - l1 - sortto(srcofs + l1, dst, dstofs + l1, l2) - sortto(srcofs, a, srcofs + l2, l1) - merge(srcofs + l2, l1, dst, dstofs + l1, l2, dst, dstofs) - } - - let l = length(a) - if l <= cutoff { - isortto(0, a, 0, l) - } else { - let l1 = l / 2 - let l2 = l - l1 - let t = make(l2, get(a, 0)) - sortto(l1, t, 0, l2) - sortto(0, a, l2, l1) - merge(l2, l1, t, 0, l2, a, 0) - } -} - -let fast_sort = stable_sort diff --git a/jscomp/stdlib-406/array.resi b/jscomp/stdlib-406/array.resi deleted file mode 100644 index d4f8fff58be..00000000000 --- a/jscomp/stdlib-406/array.resi +++ /dev/null @@ -1,246 +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. */ -/* */ -/* ************************************************************************ */ - -/* Array operations. */ - -/** Return the length (number of elements) of the given array. */ -external length: array<'a> => int = "%array_length" - -/** [Array.get a n] returns the element number [n] of array [a]. - The first element has number 0. - The last element has number [Array.length a - 1]. - You can also write [a.(n)] instead of [Array.get a n]. - - Raise [Invalid_argument "index out of bounds"] - if [n] is outside the range 0 to [(Array.length a - 1)]. */ -external get: (array<'a>, int) => 'a = "%array_safe_get" - -/** [Array.set a n x] modifies array [a] in place, replacing - element number [n] with [x]. - You can also write [a.(n) <- x] instead of [Array.set a n x]. - - Raise [Invalid_argument "index out of bounds"] - if [n] is outside the range 0 to [Array.length a - 1]. */ -external set: (array<'a>, int, 'a) => unit = "%array_safe_set" - -/** [Array.make n x] returns a fresh array of length [n], - initialized with [x]. - All the elements of this new array are initially - physically equal to [x] (in the sense of the [==] predicate). - Consequently, if [x] is mutable, it is shared among all elements - of the array, and modifying [x] through one of the array entries - will modify all other entries at the same time. - - Raise [Invalid_argument] if [n < 0] or [n > Sys.max_array_length]. - If the value of [x] is a floating-point number, then the maximum - size is only [Sys.max_array_length / 2].*/ -external make: (int, 'a) => array<'a> = "?make_vect" - -@deprecated("Use Array.make instead.") -/** @deprecated [Array.create] is an alias for {!Array.make}. */ -external create: (int, 'a) => array<'a> = "?make_vect" - -/** [Array.init n f] returns a fresh array of length [n], - with element number [i] initialized to the result of [f i]. - In other terms, [Array.init n f] tabulates the results of [f] - applied to the integers [0] to [n-1]. - - Raise [Invalid_argument] if [n < 0] or [n > Sys.max_array_length]. - If the return type of [f] is [float], then the maximum - size is only [Sys.max_array_length / 2].*/ -let init: (int, int => 'a) => array<'a> - -/** [Array.make_matrix dimx dimy e] returns a two-dimensional array - (an array of arrays) with first dimension [dimx] and - second dimension [dimy]. All the elements of this new matrix - are initially physically equal to [e]. - The element ([x,y]) of a matrix [m] is accessed - with the notation [m.(x).(y)]. - - Raise [Invalid_argument] if [dimx] or [dimy] is negative or - greater than {!Sys.max_array_length}. - If the value of [e] is a floating-point number, then the maximum - size is only [Sys.max_array_length / 2]. */ -let make_matrix: (int, int, 'a) => array> - -@deprecated("Use Array.make_matrix instead.") -/** @deprecated [Array.create_matrix] is an alias for {!Array.make_matrix}. */ -let create_matrix: (int, int, 'a) => array> - -/** [Array.append v1 v2] returns a fresh array containing the - concatenation of the arrays [v1] and [v2]. */ -let append: (array<'a>, array<'a>) => array<'a> - -/** Same as {!Array.append}, but concatenates a list of arrays. */ -let concat: list> => array<'a> - -/** [Array.sub a start len] returns a fresh array of length [len], - containing the elements number [start] to [start + len - 1] - of array [a]. - - Raise [Invalid_argument "Array.sub"] if [start] and [len] do not - designate a valid subarray of [a]; that is, if - [start < 0], or [len < 0], or [start + len > Array.length a]. */ -let sub: (array<'a>, int, int) => array<'a> - -/** [Array.copy a] returns a copy of [a], that is, a fresh array - containing the same elements as [a]. */ -let copy: array<'a> => array<'a> - -/** [Array.fill a ofs len x] modifies the array [a] in place, - storing [x] in elements number [ofs] to [ofs + len - 1]. - - Raise [Invalid_argument "Array.fill"] if [ofs] and [len] do not - designate a valid subarray of [a]. */ -let fill: (array<'a>, int, int, 'a) => unit - -/** [Array.blit v1 o1 v2 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. - - Raise [Invalid_argument "Array.blit"] if [o1] and [len] do not - designate a valid subarray of [v1], or if [o2] and [len] do not - designate a valid subarray of [v2]. */ -let blit: (array<'a>, int, array<'a>, int, int) => unit - -/** [Array.to_list a] returns the list of all the elements of [a]. */ -let to_list: array<'a> => list<'a> - -/** [Array.of_list l] returns a fresh array containing the elements - of [l]. */ -let of_list: list<'a> => array<'a> - -/* {1 Iterators} */ - -/** [Array.iter f a] applies function [f] in turn to all - the elements of [a]. It is equivalent to - [f a.(0); f a.(1); ...; f a.(Array.length a - 1); ()]. */ -let iter: ('a => unit, array<'a>) => unit - -/** Same as {!Array.iter}, but the - function is applied with the index of the element as first argument, - and the element itself as second argument. */ -let iteri: ((int, 'a) => unit, array<'a>) => unit - -/** [Array.map f a] applies function [f] to all the elements of [a], - and builds an array with the results returned by [f]: - [[| f a.(0); f a.(1); ...; f a.(Array.length a - 1) |]]. */ -let map: ('a => 'b, array<'a>) => array<'b> - -/** Same as {!Array.map}, but the - function is applied to the index of the element as first argument, - and the element itself as second argument. */ -let mapi: ((int, 'a) => 'b, array<'a>) => array<'b> - -/** [Array.fold_left f x a] computes - [f (... (f (f x a.(0)) a.(1)) ...) a.(n-1)], - where [n] is the length of the array [a]. */ -let fold_left: (('a, 'b) => 'a, 'a, array<'b>) => 'a - -/** [Array.fold_right f a x] computes - [f a.(0) (f a.(1) ( ... (f a.(n-1) x) ...))], - where [n] is the length of the array [a]. */ -let fold_right: (('b, 'a) => 'a, array<'b>, 'a) => 'a - -/* {1 Iterators on two arrays} */ - -/** [Array.iter2 f a b] applies function [f] to all the elements of [a] - and [b]. - Raise [Invalid_argument] if the arrays are not the same size. - @since 4.03.0 */ -let iter2: (('a, 'b) => unit, array<'a>, array<'b>) => unit - -/** [Array.map2 f a b] applies function [f] to all the elements of [a] - and [b], and builds an array with the results returned by [f]: - [[| f a.(0) b.(0); ...; f a.(Array.length a - 1) b.(Array.length b - 1)|]]. - Raise [Invalid_argument] if the arrays are not the same size. - @since 4.03.0 */ -let map2: (('a, 'b) => 'c, array<'a>, array<'b>) => array<'c> - -/* {1 Array scanning} */ - -/** [Array.for_all p [|a1; ...; an|]] checks if all elements of the array - satisfy the predicate [p]. That is, it returns - [(p a1) && (p a2) && ... && (p an)]. - @since 4.03.0 */ -let for_all: ('a => bool, array<'a>) => bool - -/** [Array.exists p [|a1; ...; an|]] checks if at least one element of - the array satisfies the predicate [p]. That is, it returns - [(p a1) || (p a2) || ... || (p an)]. - @since 4.03.0 */ -let exists: ('a => bool, array<'a>) => bool - -/** [mem a l] is true if and only if [a] is equal - to an element of [l]. - @since 4.03.0 */ -let mem: ('a, array<'a>) => bool - -/** Same as {!Array.mem}, but uses physical equality instead of structural - equality to compare array elements. - @since 4.03.0 */ -let memq: ('a, array<'a>) => bool - -/* {1 Sorting} */ - -/** Sort an array in increasing order according to a comparison - function. The comparison function must return 0 if its arguments - compare as equal, a positive integer if the first is greater, - and a negative integer if the first is smaller (see below for a - complete specification). For example, {!Pervasives.compare} is - a suitable comparison function, provided there are no floating-point - NaN values in the data. After calling [Array.sort], the - array is sorted in place in increasing order. - [Array.sort] is guaranteed to run in constant heap space - and (at most) logarithmic stack space. - - The current implementation uses Heap Sort. It runs in constant - stack space. - - Specification of the comparison function: - Let [a] be the array and [cmp] the comparison function. The following - must be true for all x, y, z in a : -- [cmp x y] > 0 if and only if [cmp y x] < 0 -- if [cmp x y] >= 0 and [cmp y z] >= 0 then [cmp x z] >= 0 - - When [Array.sort] returns, [a] contains the same elements as before, - reordered in such a way that for all i and j valid indices of [a] : -- [cmp a.(i) a.(j)] >= 0 if and only if i >= j -*/ -let sort: (('a, 'a) => int, array<'a>) => unit - -/** Same as {!Array.sort}, but the sorting algorithm is stable (i.e. - elements that compare equal are kept in their original order) and - not guaranteed to run in constant heap space. - - The current implementation uses Merge Sort. It uses [n/2] - words of heap space, where [n] is the length of the array. - It is usually faster than the current implementation of {!Array.sort}. -*/ -let stable_sort: (('a, 'a) => int, array<'a>) => unit - -/** Same as {!Array.sort} or {!Array.stable_sort}, whichever is faster - on typical input. -*/ -let fast_sort: (('a, 'a) => int, array<'a>) => unit - -/* {1 Undocumented functions} */ - -/* The following is for system use only. Do not call directly. */ - -external unsafe_get: (array<'a>, int) => 'a = "%array_unsafe_get" -external unsafe_set: (array<'a>, int, 'a) => unit = "%array_unsafe_set" diff --git a/jscomp/stdlib-406/arrayLabels.res b/jscomp/stdlib-406/arrayLabels.res deleted file mode 100644 index d6ca3af65a0..00000000000 --- a/jscomp/stdlib-406/arrayLabels.res +++ /dev/null @@ -1,399 +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. */ -/* */ -/* ************************************************************************ */ - -/* Array operations */ - -external length: array<'a> => int = "%array_length" -external get: (array<'a>, int) => 'a = "%array_safe_get" -external set: (array<'a>, int, 'a) => unit = "%array_safe_set" -external unsafe_get: (array<'a>, int) => 'a = "%array_unsafe_get" -external unsafe_set: (array<'a>, int, 'a) => unit = "%array_unsafe_set" -external make: (int, 'a) => array<'a> = "?make_vect" -external create: (int, 'a) => array<'a> = "?make_vect" -external unsafe_sub: (array<'a>, int, int) => array<'a> = "?array_sub" - -@send external append_prim: (array<'a>, array<'a>) => array<'a> = "concat" - -external concat: list> => array<'a> = "?array_concat" -external unsafe_blit: (array<'a>, int, array<'a>, int, int) => unit = "?array_blit" - -let init = (l, ~f) => - if l == 0 { - [] - } else if l < 0 { - invalid_arg("Array.init") - } else { - /* 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 res = create(l, f(0)) - for i in 1 to pred(l) { - unsafe_set(res, i, f(i)) - } - res - } - -let make_matrix = (~dimx as sx, ~dimy as sy, init) => { - let res = create(sx, []) - for x in 0 to pred(sx) { - unsafe_set(res, x, create(sy, init)) - } - res -} - -let create_matrix = make_matrix - -let copy = a => { - let l = length(a) - if l == 0 { - [] - } else { - unsafe_sub(a, 0, l) - } -} - -let append = (a1, a2) => { - let l1 = length(a1) - if l1 == 0 { - copy(a2) - } else if length(a2) == 0 { - unsafe_sub(a1, 0, l1) - } else { - append_prim(a1, a2) - } -} - -let sub = (a, ~pos as ofs, ~len) => - if ofs < 0 || (len < 0 || ofs > length(a) - len) { - invalid_arg("Array.sub") - } else { - unsafe_sub(a, ofs, len) - } - -let fill = (a, ~pos as ofs, ~len, v) => - if ofs < 0 || (len < 0 || ofs > length(a) - len) { - invalid_arg("Array.fill") - } else { - for i in ofs to ofs + len - 1 { - unsafe_set(a, i, v) - } - } - -let blit = (~src as a1, ~src_pos as ofs1, ~dst as a2, ~dst_pos as ofs2, ~len) => - if len < 0 || (ofs1 < 0 || (ofs1 > length(a1) - len || (ofs2 < 0 || ofs2 > length(a2) - len))) { - invalid_arg("Array.blit") - } else { - unsafe_blit(a1, ofs1, a2, ofs2, len) - } - -let iter = (~f, a) => - for i in 0 to length(a) - 1 { - f(unsafe_get(a, i)) - } - -let iter2 = (~f, a, b) => - if length(a) != length(b) { - invalid_arg("Array.iter2: arrays must have the same length") - } else { - for i in 0 to length(a) - 1 { - f(unsafe_get(a, i), unsafe_get(b, i)) - } - } - -let map = (~f, a) => { - let l = length(a) - if l == 0 { - [] - } else { - let r = create(l, f(unsafe_get(a, 0))) - for i in 1 to l - 1 { - unsafe_set(r, i, f(unsafe_get(a, i))) - } - r - } -} - -let map2 = (~f, a, b) => { - let la = length(a) - let lb = length(b) - if la != lb { - invalid_arg("Array.map2: arrays must have the same length") - } else if la == 0 { - [] - } else { - let r = create(la, f(unsafe_get(a, 0), unsafe_get(b, 0))) - for i in 1 to la - 1 { - unsafe_set(r, i, f(unsafe_get(a, i), unsafe_get(b, i))) - } - r - } -} - -let iteri = (~f, a) => - for i in 0 to length(a) - 1 { - f(i, unsafe_get(a, i)) - } - -let mapi = (~f, a) => { - let l = length(a) - if l == 0 { - [] - } else { - let r = create(l, f(0, unsafe_get(a, 0))) - for i in 1 to l - 1 { - unsafe_set(r, i, f(i, unsafe_get(a, i))) - } - r - } -} - -let to_list = a => { - let rec tolist = (i, res) => - if i < 0 { - res - } else { - tolist(i - 1, list{unsafe_get(a, i), ...res}) - } - tolist(length(a) - 1, list{}) -} - -/* Cannot use List.length here because the List module depends on Array. */ -let rec list_length = (accu, param) => - switch param { - | list{} => accu - | list{_, ...t} => list_length(succ(accu), t) - } - -let of_list = param => - switch param { - | list{} => [] - | list{hd, ...tl} as l => - let a = create(list_length(0, l), hd) - let rec fill = (i, param) => - switch param { - | list{} => a - | list{hd, ...tl} => - unsafe_set(a, i, hd) - fill(i + 1, tl) - } - fill(1, tl) - } - -let fold_left = (~f, ~init as x, a) => { - let r = ref(x) - for i in 0 to length(a) - 1 { - r := f(r.contents, unsafe_get(a, i)) - } - r.contents -} - -let fold_right = (~f, a, ~init as x) => { - let r = ref(x) - for i in length(a) - 1 downto 0 { - r := f(unsafe_get(a, i), r.contents) - } - r.contents -} - -let exists = (~f as p, a) => { - let n = length(a) - let rec loop = i => - if i == n { - false - } else if p(unsafe_get(a, i)) { - true - } else { - loop(succ(i)) - } - loop(0) -} - -let for_all = (~f as p, a) => { - let n = length(a) - let rec loop = i => - if i == n { - true - } else if p(unsafe_get(a, i)) { - loop(succ(i)) - } else { - false - } - loop(0) -} - -let mem = (x, ~set as a) => { - let n = length(a) - let rec loop = i => - if i == n { - false - } else if compare(unsafe_get(a, i), x) == 0 { - true - } else { - loop(succ(i)) - } - loop(0) -} - -let memq = (x, ~set as a) => { - let n = length(a) - let rec loop = i => - if i == n { - false - } else if x === unsafe_get(a, i) { - true - } else { - loop(succ(i)) - } - loop(0) -} - -exception Bottom(int) -let sort = (~cmp, a) => { - let maxson = (l, i) => { - let i31 = i + i + i + 1 - let x = ref(i31) - if i31 + 2 < l { - if cmp(get(a, i31), get(a, i31 + 1)) < 0 { - x := i31 + 1 - } - if cmp(get(a, x.contents), get(a, i31 + 2)) < 0 { - x := i31 + 2 - } - x.contents - } else if i31 + 1 < l && cmp(get(a, i31), get(a, i31 + 1)) < 0 { - i31 + 1 - } else if i31 < l { - i31 - } else { - raise(Bottom(i)) - } - } - - let rec trickledown = (l, i, e) => { - let j = maxson(l, i) - if cmp(get(a, j), e) > 0 { - set(a, i, get(a, j)) - trickledown(l, j, e) - } else { - set(a, i, e) - } - } - - let trickle = (l, i, e) => - try trickledown(l, i, e) catch { - | Bottom(i) => set(a, i, e) - } - let rec bubbledown = (l, i) => { - let j = maxson(l, i) - set(a, i, get(a, j)) - bubbledown(l, j) - } - - let bubble = (l, i) => - try bubbledown(l, i) catch { - | Bottom(i) => i - } - let rec trickleup = (i, e) => { - let father = (i - 1) / 3 - assert(i != father) - if cmp(get(a, father), e) < 0 { - set(a, i, get(a, father)) - if father > 0 { - trickleup(father, e) - } else { - set(a, 0, e) - } - } else { - set(a, i, e) - } - } - - let l = length(a) - for i in (l + 1) / 3 - 1 downto 0 { - trickle(l, i, get(a, i)) - } - for i in l - 1 downto 2 { - let e = get(a, i) - set(a, i, get(a, 0)) - trickleup(bubble(i, 0), e) - } - if l > 1 { - let e = get(a, 1) - set(a, 1, get(a, 0)) - set(a, 0, e) - } -} - -let cutoff = 5 -let stable_sort = (~cmp, a) => { - let merge = (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { - let src1r = src1ofs + src1len and src2r = src2ofs + src2len - let rec loop = (i1, s1, i2, s2, d) => - if cmp(s1, s2) <= 0 { - set(dst, d, s1) - let i1 = i1 + 1 - if i1 < src1r { - loop(i1, get(a, i1), i2, s2, d + 1) - } else { - blit(~src=src2, ~src_pos=i2, ~dst, ~dst_pos=d + 1, ~len=src2r - i2) - } - } else { - set(dst, d, s2) - let i2 = i2 + 1 - if i2 < src2r { - loop(i1, s1, i2, get(src2, i2), d + 1) - } else { - blit(~src=a, ~src_pos=i1, ~dst, ~dst_pos=d + 1, ~len=src1r - i1) - } - } - loop(src1ofs, get(a, src1ofs), src2ofs, get(src2, src2ofs), dstofs) - } - - let isortto = (srcofs, dst, dstofs, len) => - for i in 0 to len - 1 { - let e = get(a, srcofs + i) - let j = ref(dstofs + i - 1) - while j.contents >= dstofs && cmp(get(dst, j.contents), e) > 0 { - set(dst, j.contents + 1, get(dst, j.contents)) - decr(j) - } - set(dst, j.contents + 1, e) - } - - let rec sortto = (srcofs, dst, dstofs, len) => - if len <= cutoff { - isortto(srcofs, dst, dstofs, len) - } else { - let l1 = len / 2 - let l2 = len - l1 - sortto(srcofs + l1, dst, dstofs + l1, l2) - sortto(srcofs, a, srcofs + l2, l1) - merge(srcofs + l2, l1, dst, dstofs + l1, l2, dst, dstofs) - } - - let l = length(a) - if l <= cutoff { - isortto(0, a, 0, l) - } else { - let l1 = l / 2 - let l2 = l - l1 - let t = make(l2, get(a, 0)) - sortto(l1, t, 0, l2) - sortto(0, a, l2, l1) - merge(l2, l1, t, 0, l2, a, 0) - } -} - -let fast_sort = stable_sort diff --git a/jscomp/stdlib-406/arrayLabels.resi b/jscomp/stdlib-406/arrayLabels.resi deleted file mode 100644 index 0b38eab0581..00000000000 --- a/jscomp/stdlib-406/arrayLabels.resi +++ /dev/null @@ -1,245 +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. */ -/* */ -/* ************************************************************************ */ - -/*** Array operations. */ - -/** Return the length (number of elements) of the given array. */ -external length: array<'a> => int = "%array_length" - -/** [Array.get a n] returns the element number [n] of array [a]. - The first element has number 0. - The last element has number [Array.length a - 1]. - You can also write [a.(n)] instead of [Array.get a n]. - - Raise [Invalid_argument "index out of bounds"] - if [n] is outside the range 0 to [(Array.length a - 1)]. */ -external get: (array<'a>, int) => 'a = "%array_safe_get" - -/** [Array.set a n x] modifies array [a] in place, replacing - element number [n] with [x]. - You can also write [a.(n) <- x] instead of [Array.set a n x]. - - Raise [Invalid_argument "index out of bounds"] - if [n] is outside the range 0 to [Array.length a - 1]. */ -external set: (array<'a>, int, 'a) => unit = "%array_safe_set" - -/** [Array.make n x] returns a fresh array of length [n], - initialized with [x]. - All the elements of this new array are initially - physically equal to [x] (in the sense of the [==] predicate). - Consequently, if [x] is mutable, it is shared among all elements - of the array, and modifying [x] through one of the array entries - will modify all other entries at the same time. - - Raise [Invalid_argument] if [n < 0] or [n > Sys.max_array_length]. - If the value of [x] is a floating-point number, then the maximum - size is only [Sys.max_array_length / 2].*/ -external make: (int, 'a) => array<'a> = "?make_vect" - -@deprecated("Use Array.make instead.") -/** @deprecated [Array.create] is an alias for {!Array.make}. */ -external create: (int, 'a) => array<'a> = "?make_vect" - -/** [Array.init n f] returns a fresh array of length [n], - with element number [i] initialized to the result of [f i]. - In other terms, [Array.init n f] tabulates the results of [f] - applied to the integers [0] to [n-1]. - - Raise [Invalid_argument] if [n < 0] or [n > Sys.max_array_length]. - If the return type of [f] is [float], then the maximum - size is only [Sys.max_array_length / 2].*/ -let init: (int, ~f: int => 'a) => array<'a> - -/** [Array.make_matrix dimx dimy e] returns a two-dimensional array - (an array of arrays) with first dimension [dimx] and - second dimension [dimy]. All the elements of this new matrix - are initially physically equal to [e]. - The element ([x,y]) of a matrix [m] is accessed - with the notation [m.(x).(y)]. - - Raise [Invalid_argument] if [dimx] or [dimy] is negative or - greater than {!Sys.max_array_length}. - If the value of [e] is a floating-point number, then the maximum - size is only [Sys.max_array_length / 2]. */ -let make_matrix: (~dimx: int, ~dimy: int, 'a) => array> - -@deprecated("Use Array.make_matrix instead.") -/** @deprecated [Array.create_matrix] is an alias for - {!Array.make_matrix}. */ -let create_matrix: (~dimx: int, ~dimy: int, 'a) => array> - -/** [Array.append v1 v2] returns a fresh array containing the - concatenation of the arrays [v1] and [v2]. */ -let append: (array<'a>, array<'a>) => array<'a> - -/** Same as {!Array.append}, but concatenates a list of arrays. */ -let concat: list> => array<'a> - -/** [Array.sub a start len] returns a fresh array of length [len], - containing the elements number [start] to [start + len - 1] - of array [a]. - - Raise [Invalid_argument "Array.sub"] if [start] and [len] do not - designate a valid subarray of [a]; that is, if - [start < 0], or [len < 0], or [start + len > Array.length a]. */ -let sub: (array<'a>, ~pos: int, ~len: int) => array<'a> - -/** [Array.copy a] returns a copy of [a], that is, a fresh array - containing the same elements as [a]. */ -let copy: array<'a> => array<'a> - -/** [Array.fill a ofs len x] modifies the array [a] in place, - storing [x] in elements number [ofs] to [ofs + len - 1]. - - Raise [Invalid_argument "Array.fill"] if [ofs] and [len] do not - designate a valid subarray of [a]. */ -let fill: (array<'a>, ~pos: int, ~len: int, 'a) => unit - -/** [Array.blit v1 o1 v2 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. - - Raise [Invalid_argument "Array.blit"] if [o1] and [len] do not - designate a valid subarray of [v1], or if [o2] and [len] do not - designate a valid subarray of [v2]. */ -let blit: (~src: array<'a>, ~src_pos: int, ~dst: array<'a>, ~dst_pos: int, ~len: int) => unit - -/** [Array.to_list a] returns the list of all the elements of [a]. */ -let to_list: array<'a> => list<'a> - -/** [Array.of_list l] returns a fresh array containing the elements - of [l]. */ -let of_list: list<'a> => array<'a> - -/** [Array.iter f a] applies function [f] in turn to all - the elements of [a]. It is equivalent to - [f a.(0); f a.(1); ...; f a.(Array.length a - 1); ()]. */ -let iter: (~f: 'a => unit, array<'a>) => unit - -/** [Array.map f a] applies function [f] to all the elements of [a], - and builds an array with the results returned by [f]: - [[| f a.(0); f a.(1); ...; f a.(Array.length a - 1) |]]. */ -let map: (~f: 'a => 'b, array<'a>) => array<'b> - -/** Same as {!Array.iter}, but the - function is applied to the index of the element as first argument, - and the element itself as second argument. */ -let iteri: (~f: (int, 'a) => unit, array<'a>) => unit - -/** Same as {!Array.map}, but the - function is applied to the index of the element as first argument, - and the element itself as second argument. */ -let mapi: (~f: (int, 'a) => 'b, array<'a>) => array<'b> - -/** [Array.fold_left f x a] computes - [f (... (f (f x a.(0)) a.(1)) ...) a.(n-1)], - where [n] is the length of the array [a]. */ -let fold_left: (~f: ('a, 'b) => 'a, ~init: 'a, array<'b>) => 'a - -/** [Array.fold_right f a x] computes - [f a.(0) (f a.(1) ( ... (f a.(n-1) x) ...))], - where [n] is the length of the array [a]. */ -let fold_right: (~f: ('b, 'a) => 'a, array<'b>, ~init: 'a) => 'a - -/* {6 Iterators on two arrays} */ - -/** [Array.iter2 f a b] applies function [f] to all the elements of [a] - and [b]. - Raise [Invalid_argument] if the arrays are not the same size. - @since 4.05.0 */ -let iter2: (~f: ('a, 'b) => unit, array<'a>, array<'b>) => unit - -/** [Array.map2 f a b] applies function [f] to all the elements of [a] - and [b], and builds an array with the results returned by [f]: - [[| f a.(0) b.(0); ...; f a.(Array.length a - 1) b.(Array.length b - 1)|]]. - Raise [Invalid_argument] if the arrays are not the same size. - @since 4.05.0 */ -let map2: (~f: ('a, 'b) => 'c, array<'a>, array<'b>) => array<'c> - -/* {6 Array scanning} */ - -/** [Array.exists p [|a1; ...; an|]] checks if at least one element of - the array satisfies the predicate [p]. That is, it returns - [(p a1) || (p a2) || ... || (p an)]. - @since 4.03.0 */ -let exists: (~f: 'a => bool, array<'a>) => bool - -/** [Array.for_all p [|a1; ...; an|]] checks if all elements of the array - satisfy the predicate [p]. That is, it returns - [(p a1) && (p a2) && ... && (p an)]. - @since 4.03.0 */ -let for_all: (~f: 'a => bool, array<'a>) => bool - -/** [mem x a] is true if and only if [x] is equal - to an element of [a]. - @since 4.03.0 */ -let mem: ('a, ~set: array<'a>) => bool - -/** Same as {!Array.mem}, but uses physical equality instead of structural - equality to compare list elements. - @since 4.03.0 */ -let memq: ('a, ~set: array<'a>) => bool - -/* {1 Sorting} */ - -/** Sort an array in increasing order according to a comparison - function. The comparison function must return 0 if its arguments - compare as equal, a positive integer if the first is greater, - and a negative integer if the first is smaller (see below for a - complete specification). For example, {!Pervasives.compare} is - a suitable comparison function, provided there are no floating-point - NaN values in the data. After calling [Array.sort], the - array is sorted in place in increasing order. - [Array.sort] is guaranteed to run in constant heap space - and (at most) logarithmic stack space. - - The current implementation uses Heap Sort. It runs in constant - stack space. - - Specification of the comparison function: - Let [a] be the array and [cmp] the comparison function. The following - must be true for all x, y, z in a : -- [cmp x y] > 0 if and only if [cmp y x] < 0 -- if [cmp x y] >= 0 and [cmp y z] >= 0 then [cmp x z] >= 0 - - When [Array.sort] returns, [a] contains the same elements as before, - reordered in such a way that for all i and j valid indices of [a] : -- [cmp a.(i) a.(j)] >= 0 if and only if i >= j -*/ -let sort: (~cmp: ('a, 'a) => int, array<'a>) => unit - -/** Same as {!Array.sort}, but the sorting algorithm is stable (i.e. - elements that compare equal are kept in their original order) and - not guaranteed to run in constant heap space. - - The current implementation uses Merge Sort. It uses [n/2] - words of heap space, where [n] is the length of the array. - It is usually faster than the current implementation of {!Array.sort}. -*/ -let stable_sort: (~cmp: ('a, 'a) => int, array<'a>) => unit - -/** Same as {!Array.sort} or {!Array.stable_sort}, whichever is - faster on typical input. -*/ -let fast_sort: (~cmp: ('a, 'a) => int, array<'a>) => unit - -/* {1 Undocumented functions} */ - -/* The following is for system use only. Do not call directly. */ - -external unsafe_get: (array<'a>, int) => 'a = "%array_unsafe_get" -external unsafe_set: (array<'a>, int, 'a) => unit = "%array_unsafe_set" diff --git a/jscomp/stdlib-406/release.ninja b/jscomp/stdlib-406/release.ninja index 119fd3eda2d..ea73a61756b 100644 --- a/jscomp/stdlib-406/release.ninja +++ b/jscomp/stdlib-406/release.ninja @@ -12,10 +12,6 @@ o stdlib-406/pervasives.cmj : cc_cmi stdlib-406/pervasives.res | stdlib-406/perv bsc_flags = $bsc_flags -nopervasives o stdlib-406/pervasives.cmi : cc stdlib-406/pervasives.resi | $bsc others bsc_flags = $bsc_flags -nopervasives -o stdlib-406/array.cmj : cc_cmi stdlib-406/array.res | stdlib-406/array.cmi $bsc others -o stdlib-406/array.cmi : cc stdlib-406/array.resi | stdlib-406/pervasives.cmj $bsc others -o stdlib-406/arrayLabels.cmj : cc_cmi stdlib-406/arrayLabels.res | stdlib-406/arrayLabels.cmi $bsc others -o stdlib-406/arrayLabels.cmi : cc stdlib-406/arrayLabels.resi | stdlib-406/pervasives.cmj $bsc others o stdlib-406/callback.cmj : cc_cmi stdlib-406/callback.res | stdlib-406/callback.cmi $bsc others o stdlib-406/callback.cmi : cc stdlib-406/callback.resi | stdlib-406/pervasives.cmj $bsc others o stdlib-406/camlinternalLazy.cmj : cc_cmi stdlib-406/camlinternalLazy.res | stdlib-406/camlinternalLazy.cmi $bsc others @@ -44,12 +40,8 @@ o stdlib-406/queue.cmi : cc stdlib-406/queue.resi | stdlib-406/pervasives.cmj $b o stdlib-406/set.cmj : cc_cmi stdlib-406/set.res | stdlib-406/list.cmj stdlib-406/set.cmi $bsc others o stdlib-406/set.cmi : cc stdlib-406/set.resi | stdlib-406/pervasives.cmj $bsc others o stdlib-406/setLabels.cmi stdlib-406/setLabels.cmj : cc stdlib-406/setLabels.res | stdlib-406/list.cmj stdlib-406/pervasives.cmj $bsc others -o stdlib-406/sort.cmj : cc_cmi stdlib-406/sort.res | stdlib-406/array.cmj stdlib-406/sort.cmi $bsc others -o stdlib-406/sort.cmi : cc stdlib-406/sort.resi | stdlib-406/pervasives.cmj $bsc others o stdlib-406/stack.cmj : cc_cmi stdlib-406/stack.res | stdlib-406/list.cmj stdlib-406/stack.cmi $bsc others o stdlib-406/stack.cmi : cc stdlib-406/stack.resi | stdlib-406/pervasives.cmj $bsc others -o stdlib-406/stdLabels.cmj : cc_cmi stdlib-406/stdLabels.res | stdlib-406/arrayLabels.cmj stdlib-406/listLabels.cmj stdlib-406/stdLabels.cmi $bsc others -o stdlib-406/stdLabels.cmi : cc stdlib-406/stdLabels.resi | stdlib-406/arrayLabels.cmi stdlib-406/listLabels.cmi stdlib-406/pervasives.cmj $bsc others o stdlib-406/string.cmj : cc_cmi stdlib-406/string.res | stdlib-406/string.cmi $bsc others o stdlib-406/string.cmi : cc stdlib-406/string.resi | stdlib-406/pervasives.cmj $bsc others -o $stdlib : phony stdlib-406/array.cmi stdlib-406/array.cmj stdlib-406/arrayLabels.cmi stdlib-406/arrayLabels.cmj stdlib-406/callback.cmi stdlib-406/callback.cmj stdlib-406/camlinternalLazy.cmi stdlib-406/camlinternalLazy.cmj stdlib-406/camlinternalMod.cmi stdlib-406/camlinternalMod.cmj stdlib-406/char.cmi stdlib-406/char.cmj stdlib-406/complex.cmi stdlib-406/complex.cmj stdlib-406/hashtbl.cmi stdlib-406/hashtbl.cmj stdlib-406/lazy.cmi stdlib-406/lazy.cmj stdlib-406/list.cmi stdlib-406/list.cmj stdlib-406/listLabels.cmi stdlib-406/listLabels.cmj stdlib-406/map.cmi stdlib-406/map.cmj stdlib-406/mapLabels.cmi stdlib-406/mapLabels.cmj stdlib-406/obj.cmi stdlib-406/obj.cmj stdlib-406/queue.cmi stdlib-406/queue.cmj stdlib-406/set.cmi stdlib-406/set.cmj stdlib-406/setLabels.cmi stdlib-406/setLabels.cmj stdlib-406/sort.cmi stdlib-406/sort.cmj stdlib-406/stack.cmi stdlib-406/stack.cmj stdlib-406/stdLabels.cmi stdlib-406/stdLabels.cmj stdlib-406/string.cmi stdlib-406/string.cmj +o $stdlib : phony stdlib-406/callback.cmi stdlib-406/callback.cmj stdlib-406/camlinternalLazy.cmi stdlib-406/camlinternalLazy.cmj stdlib-406/camlinternalMod.cmi stdlib-406/camlinternalMod.cmj stdlib-406/char.cmi stdlib-406/char.cmj stdlib-406/complex.cmi stdlib-406/complex.cmj stdlib-406/hashtbl.cmi stdlib-406/hashtbl.cmj stdlib-406/lazy.cmi stdlib-406/lazy.cmj stdlib-406/list.cmi stdlib-406/list.cmj stdlib-406/listLabels.cmi stdlib-406/listLabels.cmj stdlib-406/map.cmi stdlib-406/map.cmj stdlib-406/mapLabels.cmi stdlib-406/mapLabels.cmj stdlib-406/obj.cmi stdlib-406/obj.cmj stdlib-406/queue.cmi stdlib-406/queue.cmj stdlib-406/set.cmi stdlib-406/set.cmj stdlib-406/setLabels.cmi stdlib-406/setLabels.cmj stdlib-406/stack.cmi stdlib-406/stack.cmj stdlib-406/string.cmi stdlib-406/string.cmj diff --git a/jscomp/stdlib-406/sort.res b/jscomp/stdlib-406/sort.res deleted file mode 100644 index ab1713a6ee1..00000000000 --- a/jscomp/stdlib-406/sort.res +++ /dev/null @@ -1,134 +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. */ -/* */ -/* ************************************************************************ */ - -/* Merging and sorting */ - -open Array - -let rec merge = (order, l1, l2) => - switch l1 { - | list{} => l2 - | list{h1, ...t1} => - switch l2 { - | list{} => l1 - | list{h2, ...t2} => - if order(h1, h2) { - list{h1, ...merge(order, t1, l2)} - } else { - list{h2, ...merge(order, l1, t2)} - } - } - } - -let list = (order, l) => { - let rec initlist = param => - switch param { - | list{} => list{} - | list{e} => list{list{e}} - | list{e1, e2, ...rest} => - list{ - if order(e1, e2) { - list{e1, e2} - } else { - list{e2, e1} - }, - ...initlist(rest), - } - } - let rec merge2 = param => - switch param { - | list{l1, l2, ...rest} => list{merge(order, l1, l2), ...merge2(rest)} - | x => x - } - let rec mergeall = param => - switch param { - | list{} => list{} - | list{l} => l - | llist => mergeall(merge2(llist)) - } - mergeall(initlist(l)) -} - -let swap = (arr, i, j) => { - let tmp = unsafe_get(arr, i) - unsafe_set(arr, i, unsafe_get(arr, j)) - unsafe_set(arr, j, tmp) -} - -/* There is a known performance bug in the code below. If you find - it, don't bother reporting it. You're not supposed to use this - module anyway. */ -let array = (cmp, arr) => { - let rec qsort = (lo, hi) => - if hi - lo >= 6 { - let mid = lsr(lo + hi, 1) - - /* Select median value from among LO, MID, and HI. Rearrange - LO and HI so the three values are sorted. This lowers the - probability of picking a pathological pivot. It also - avoids extra comparisons on i and j in the two tight "while" - loops below. */ - if cmp(unsafe_get(arr, mid), unsafe_get(arr, lo)) { - swap(arr, mid, lo) - } - if cmp(unsafe_get(arr, hi), unsafe_get(arr, mid)) { - swap(arr, mid, hi) - if cmp(unsafe_get(arr, mid), unsafe_get(arr, lo)) { - swap(arr, mid, lo) - } - } - let pivot = unsafe_get(arr, mid) - let i = ref(lo + 1) and j = ref(hi - 1) - if !cmp(pivot, unsafe_get(arr, hi)) || !cmp(unsafe_get(arr, lo), pivot) { - raise(Invalid_argument("Sort.array")) - } - while i.contents < j.contents { - while !cmp(pivot, unsafe_get(arr, i.contents)) { - incr(i) - } - while !cmp(unsafe_get(arr, j.contents), pivot) { - decr(j) - } - if i.contents < j.contents { - swap(arr, i.contents, j.contents) - } - incr(i) - decr(j) - } - - /* Recursion on smaller half, tail-call on larger half */ - if j.contents - lo <= hi - i.contents { - qsort(lo, j.contents) - qsort(i.contents, hi) - } else { - qsort(i.contents, hi) - qsort(lo, j.contents) - } - } - qsort(0, Array.length(arr) - 1) - /* Finish sorting by insertion sort */ - for i in 1 to Array.length(arr) - 1 { - let val_i = unsafe_get(arr, i) - if !cmp(unsafe_get(arr, i - 1), val_i) { - unsafe_set(arr, i, unsafe_get(arr, i - 1)) - let j = ref(i - 1) - while j.contents >= 1 && !cmp(unsafe_get(arr, j.contents - 1), val_i) { - unsafe_set(arr, j.contents, unsafe_get(arr, j.contents - 1)) - decr(j) - } - unsafe_set(arr, j.contents, val_i) - } - } -} diff --git a/jscomp/stdlib-406/sort.resi b/jscomp/stdlib-406/sort.resi deleted file mode 100644 index b4de4f98f0f..00000000000 --- a/jscomp/stdlib-406/sort.resi +++ /dev/null @@ -1,44 +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. */ -/* */ -/* ************************************************************************ */ - -/*** Sorting and merging lists. - - @deprecated This module is obsolete and exists only for backward - compatibility. - The sorting functions in {!Array} and {!List} should be used instead. - The new functions are faster and use less memory. -*/ - -@deprecated("Use List.sort instead.") -/** Sort a list in increasing order according to an ordering predicate. - The predicate should return [true] if its first argument is - less than or equal to its second argument. */ -let list: (('a, 'a) => bool, list<'a>) => list<'a> - -@deprecated("Use Array.sort instead.") -/** Sort an array in increasing order according to an - ordering predicate. - The predicate should return [true] if its first argument is - less than or equal to its second argument. - The array is sorted in place. */ -let array: (('a, 'a) => bool, array<'a>) => unit - -@deprecated("Use List.merge instead.") -/** Merge two lists according to the given predicate. - Assuming the two argument lists are sorted according to the - predicate, [merge] returns a sorted list containing the elements - from the two lists. The behavior is undefined if the two - argument lists were not sorted. */ -let merge: (('a, 'a) => bool, list<'a>, list<'a>) => list<'a> diff --git a/jscomp/stdlib-406/stdLabels.res b/jscomp/stdlib-406/stdLabels.res deleted file mode 100644 index e82101734fb..00000000000 --- a/jscomp/stdlib-406/stdLabels.res +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************ */ -/* */ -/* OCaml */ -/* */ -/* Jacques Garrigue, Kyoto University RIMS */ -/* */ -/* Copyright 2001 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. */ -/* */ -/* ************************************************************************ */ - -/* Module [StdLabels]: meta-module for labelled libraries */ - -module Array = ArrayLabels - -module List = ListLabels diff --git a/jscomp/stdlib-406/stdLabels.resi b/jscomp/stdlib-406/stdLabels.resi deleted file mode 100644 index 832b9dd3362..00000000000 --- a/jscomp/stdlib-406/stdLabels.resi +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************ */ -/* */ -/* OCaml */ -/* */ -/* Jacques Garrigue, Kyoto University RIMS */ -/* */ -/* Copyright 2001 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. */ -/* */ -/* ************************************************************************ */ - -/*** Standard labeled libraries. - - This meta-module provides labelized version of the {!Array} and {!List} modules. - - They only differ by their labels. Detailed interfaces can be found - in [arrayLabels.mli] and [listLabels.mli]. -*/ - -module Array = ArrayLabels -module List = ListLabels diff --git a/jscomp/syntax/src/res_comments_table.ml b/jscomp/syntax/src/res_comments_table.ml index c1b9435548b..e6be72a19dc 100644 --- a/jscomp/syntax/src/res_comments_table.ml +++ b/jscomp/syntax/src/res_comments_table.ml @@ -1335,11 +1335,17 @@ and walk_expression expr t comments = (* (List.concat [inside; after]); *) attach t.trailing operand2.pexp_loc after | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Ldot (Lident "Array", "get")}}, + ( { + pexp_desc = + Pexp_ident {txt = Longident.Ldot (Lident "Primitive_array", "get")}; + }, [(Nolabel, parent_expr); (Nolabel, member_expr)] ) -> walk_list [Expression parent_expr; Expression member_expr] t comments | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Ldot (Lident "Array", "set")}}, + ( { + pexp_desc = + Pexp_ident {txt = Longident.Ldot (Lident "Primitive_array", "set")}; + }, [(Nolabel, parent_expr); (Nolabel, member_expr); (Nolabel, target_expr)] ) -> walk_list diff --git a/jscomp/syntax/src/res_core.ml b/jscomp/syntax/src/res_core.ml index 4560b04bcfa..7aec91c62aa 100644 --- a/jscomp/syntax/src/res_core.ml +++ b/jscomp/syntax/src/res_core.ml @@ -2010,8 +2010,17 @@ and parse_bracket_access p expr start_pos = Parser.leave_breadcrumb p ExprArrayMutation; Parser.next p; let rhs_expr = parse_expr p in + (* FIXME: Do not implicitly rely on specific module name, even primitive one + + This can be abused like + module Primitive_array = MyModule + + Find better mechanism to support it + *) let array_set = - Location.mkloc (Longident.Ldot (Lident "Array", "set")) array_loc + Location.mkloc + (Longident.Ldot (Lident "Primitive_array", "set")) + array_loc in let end_pos = p.prev_end_pos in let array_set = @@ -2026,7 +2035,9 @@ and parse_bracket_access p expr start_pos = let e = Ast_helper.Exp.apply ~loc:(mk_loc start_pos end_pos) (Ast_helper.Exp.ident ~loc:array_loc - (Location.mkloc (Longident.Ldot (Lident "Array", "get")) array_loc)) + (Location.mkloc + (Longident.Ldot (Lident "Primitive_array", "get")) + array_loc)) [(Nolabel, expr); (Nolabel, access_expr)] in parse_primary_expr ~operand:e p) diff --git a/jscomp/syntax/src/res_parsetree_viewer.ml b/jscomp/syntax/src/res_parsetree_viewer.ml index cc415f5fd16..4fe5fb4fb37 100644 --- a/jscomp/syntax/src/res_parsetree_viewer.ml +++ b/jscomp/syntax/src/res_parsetree_viewer.ml @@ -395,7 +395,10 @@ let has_attributes attrs = let is_array_access expr = match expr.pexp_desc with | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Ldot (Lident "Array", "get")}}, + ( { + pexp_desc = + Pexp_ident {txt = Longident.Ldot (Lident "Primitive_array", "get")}; + }, [(Nolabel, _parentExpr); (Nolabel, _memberExpr)] ) -> true | _ -> false diff --git a/jscomp/syntax/src/res_printer.ml b/jscomp/syntax/src/res_printer.ml index c6c386e25a4..086b8244e13 100644 --- a/jscomp/syntax/src/res_printer.ml +++ b/jscomp/syntax/src/res_printer.ml @@ -4089,7 +4089,10 @@ and print_pexp_apply ~state expr cmt_tbl = Doc.rbrace; ] | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Ldot (Lident "Array", "get")}}, + ( { + pexp_desc = + Pexp_ident {txt = Longident.Ldot (Lident "Primitive_array", "get")}; + }, [(Nolabel, parent_expr); (Nolabel, member_expr)] ) when not (ParsetreeViewer.is_rewritten_underscore_apply_sugar parent_expr) -> @@ -4129,7 +4132,10 @@ and print_pexp_apply ~state expr cmt_tbl = Doc.rbracket; ]) | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Ldot (Lident "Array", "set")}}, + ( { + pexp_desc = + Pexp_ident {txt = Longident.Ldot (Lident "Primitive_array", "set")}; + }, [(Nolabel, parent_expr); (Nolabel, member_expr); (Nolabel, target_expr)] ) -> let member = diff --git a/jscomp/syntax/tests/parsing/errors/expressions/expected/array.res.txt b/jscomp/syntax/tests/parsing/errors/expressions/expected/array.res.txt index 994def86cf0..09d5f9a824f 100644 --- a/jscomp/syntax/tests/parsing/errors/expressions/expected/array.res.txt +++ b/jscomp/syntax/tests/parsing/errors/expressions/expected/array.res.txt @@ -9,4 +9,6 @@ Did you forget a `]` here? let xs = - x.map ((Function$ (fun key -> [|key;(predicates.(key))|]))[@res.arity 1]) \ No newline at end of file + x.map + ((Function$ (fun key -> [|key;(Primitive_array.get predicates key)|])) + [@res.arity 1]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/async.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/async.res.txt index 5bc16662035..34c9029b4d2 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/async.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/async.res.txt @@ -20,7 +20,7 @@ let async = () |.u async; async (); async.async; - { async = (async.(async)) }; + { async = (Primitive_array.get async async) }; (result |.u async) |.u (mapAsync ((Function$ (fun a -> doStuff a))[@res.arity 1]))) [@res.braces ]) diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/await.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/await.res.txt index 3ccb4c9d5e2..a552bf16315 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/await.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/await.res.txt @@ -9,8 +9,9 @@ let () = ((let response = ((fetch {js|/users.json|js})[@res.await ]) in let users = ((response.json ())[@res.await ]) in let comments = - ((((fetch {js|comment.json|js})[@res.await ]).json ()) - [@res.await ]).(0) in + Primitive_array.get + ((((fetch {js|comment.json|js})[@res.await ]).json ())[@res.await ]) + 0 in Js.log2 users comments) [@res.braces ]) let () = ((delay 10)[@res.braces ][@res.await ]) diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/binaryNoEs6Arrow.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/binaryNoEs6Arrow.res.txt index 77cf1dcb5fb..ceb4b28f93c 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/binaryNoEs6Arrow.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/binaryNoEs6Arrow.res.txt @@ -34,4 +34,4 @@ [@res.braces ]))) [@res.namedArgLoc ][@res.braces ][@res.arity 1]) ~children:[] ()) [@JSX ]) -;;if inclusions.(index) <- (uid, url) then onChange inclusions \ No newline at end of file +;;if Primitive_array.set inclusions index (uid, url) then onChange inclusions \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/bracedOrRecord.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/bracedOrRecord.res.txt index 1503dc741cc..a1b5ccf49e7 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/bracedOrRecord.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/bracedOrRecord.res.txt @@ -12,10 +12,10 @@ let e = ((a + b)[@res.braces ]) let e = ((if a then true else false)[@res.braces ][@res.ternary ]) let e = ((if computation a then true else false) [@res.braces ][@res.ternary ]) -let e = ((a.(0))[@res.braces ]) +let e = ((Primitive_array.get a 0)[@res.braces ]) let e = ((f b)[@res.braces ]) let e = (((a.b).c)[@res.braces ]) -let e = ((arr.(x) <- 20)[@res.braces ]) +let e = ((Primitive_array.set arr x 20)[@res.braces ]) let e = ((Function$ (fun x -> doStuff config (x + 1))) [@res.braces ][@res.arity 1]) let e = ((doStuff config ((Function$ (fun x -> x + 1))[@res.arity 1])) diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/bsObject.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/bsObject.res.txt index 190921ce0ad..7050466b428 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/bsObject.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/bsObject.res.txt @@ -6,7 +6,7 @@ let y = [%obj { age = 30; name = {js|steve|js} }] let z = [%obj { \xff = 1; \u2212 = {js|two|js}; \0 = zero; \o123 = {js|o123|js} }] let x = (({js|age|js})[@res.braces ]) -let x = (({js|age|js}.(0))[@res.braces ]) +let x = ((Primitive_array.get {js|age|js} 0)[@res.braces ]) let x = (({js|age|js} |.u Js.log)[@res.braces ]) let x = ((if {js|age|js} then true else false)[@res.braces ][@res.ternary ]) let x = (({js|age|js} |.u Js.log; (let foo = 1 in let bar = 2 in foo + bar)) @@ -16,5 +16,7 @@ let x = [@res.ternary ]); (let foo = 1 in let bar = 2 in foo + bar)) [@res.braces ]) -let x = (({js|age|js}.(0); (let foo = 1 in let bar = 2 in foo + bar)) +let x = + ((Primitive_array.get {js|age|js} 0; + (let foo = 1 in let bar = 2 in foo + bar)) [@res.braces ]) \ No newline at end of file diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/firstClassModule.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/firstClassModule.res.txt index e1f798dc53b..20d6210f13f 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/firstClassModule.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/firstClassModule.res.txt @@ -66,37 +66,38 @@ let build_dispatch_table = [@res.arity 1]) ;;(module Three) ;;((module Three) : (module X_int)) -;;(module Teenager).(0) +;;Primitive_array.get (module Teenager) 0 ;;((module Teenager) |.u age) |.u Js.log -;;((module Teenager).(0)) |.u Js.log +;;(Primitive_array.get (module Teenager) 0) |.u Js.log ;;((if ((module Teenager) |.u age) |.u isAdult then Js.log {js|has responsibilities|js} else Js.log {js|can play in the playground|js})[@res.ternary ]) -;;((if ((module Streets).(0)) |.u isExpensive +;;((if (Primitive_array.get (module Streets) 0) |.u isExpensive then Js.log {js|big money|js} else Js.log {js|affordable|js})[@res.ternary ]) let () = ((((module Teenager) |.u age) |.u Js.log)[@res.braces ]) -let () = (((module Teenager).(0))[@res.braces ]) +let () = ((Primitive_array.get (module Teenager) 0)[@res.braces ]) let () = ((if ((module Teenager) |.u age) |.u isAdult then Js.log {js|has responsibilities|js} else Js.log {js|can play in the playground|js}) [@res.braces ][@res.ternary ]) let () = - ((if ((module Streets).(0)) |.u isExpensive + ((if (Primitive_array.get (module Streets) 0) |.u isExpensive then Js.log {js|big money|js} else Js.log {js|affordable|js}) [@res.braces ][@res.ternary ]) let () = ((let a = 1 in let b = 2 in - (module Teenager).(0); ((module Teenager) |.u age) |.u Js.log) + Primitive_array.get (module Teenager) 0; + ((module Teenager) |.u age) |.u Js.log) [@res.braces ]) let () = ((let a = 1 in let b = 2 in ((module Teenager) |.u age) |.u Js.log; - ((if (((module Teenager).(0)) |.u age) |.u isAdult + ((if ((Primitive_array.get (module Teenager) 0) |.u age) |.u isAdult then Js.log {js|has responsibilities|js} else Js.log {js|can play in the playground|js}) [@res.ternary ])) diff --git a/jscomp/syntax/tests/parsing/grammar/expressions/expected/primary.res.txt b/jscomp/syntax/tests/parsing/grammar/expressions/expected/primary.res.txt index f7aabdd0018..3a88b96236a 100644 --- a/jscomp/syntax/tests/parsing/grammar/expressions/expected/primary.res.txt +++ b/jscomp/syntax/tests/parsing/grammar/expressions/expected/primary.res.txt @@ -5,11 +5,11 @@ let x = p.Parser.token let x = (p.Lang.Parser.token).pos ;;lexbuf.lnum <- (lexbuf.lnum + 1) ;;(parser.lexbuf).lnum <- ((parser.lexbuf).lnum + 1) -let x = arr.(0) -let x = arr.((x : int)) -let x = (arr.(0)).(1) -let x = (arr.((x : int))).((y : int)) -;;arr.(0) <- (a + b) +let x = Primitive_array.get arr 0 +let x = Primitive_array.get arr (x : int) +let x = Primitive_array.get (Primitive_array.get arr 0) 1 +let x = Primitive_array.get (Primitive_array.get arr (x : int)) (y : int) +;;Primitive_array.set arr 0 (a + b) ;;f () ;;(f ()) () ;;f a diff --git a/jscomp/syntax/tests/printer/structure/expected/valueBinding.res.txt b/jscomp/syntax/tests/printer/structure/expected/valueBinding.res.txt index 642afd5e9f7..ea6d8bd1491 100644 --- a/jscomp/syntax/tests/printer/structure/expected/valueBinding.res.txt +++ b/jscomp/syntax/tests/printer/structure/expected/valueBinding.res.txt @@ -22,7 +22,6 @@ let make = () =>
@react.recursiveComponent and otherMake = () =>
-@ocaml.doc(" {b See} {!length} ") -external size: array<'a> => int = "%array_length" +@ocaml.doc(" {b See} {!length} ") @get external size: array<'a> => int = "length" -@ocaml.doc(" {b See} {!length} ") external size: array<'a> => int = "%array_length" +@ocaml.doc(" {b See} {!length} ") @get external size: array<'a> => int = "length" diff --git a/jscomp/syntax/tests/printer/structure/valueBinding.res b/jscomp/syntax/tests/printer/structure/valueBinding.res index eab76aca582..cdda3d1328a 100644 --- a/jscomp/syntax/tests/printer/structure/valueBinding.res +++ b/jscomp/syntax/tests/printer/structure/valueBinding.res @@ -24,6 +24,7 @@ let make = () =>
and otherMake = () =>
@ocaml.doc(" {b See} {!length} ") -external size: array<'a> => int = "%array_length" +@get external size: array<'a> => int = "length" -@ocaml.doc(" {b See} {!length} ") external size: array<'a> => int = "%array_length" +@ocaml.doc(" {b See} {!length} ") +@get external size: array<'a> => int = "length" diff --git a/jscomp/test/UntaggedVariants.js b/jscomp/test/UntaggedVariants.js index 6dab75df61c..40e02fe9bf4 100644 --- a/jscomp/test/UntaggedVariants.js +++ b/jscomp/test/UntaggedVariants.js @@ -3,8 +3,8 @@ let Js_dict = require("../../lib/js/js_dict.js"); let Belt_Array = require("../../lib/js/belt_Array.js"); -let Caml_array = require("../../lib/js/caml_array.js"); let Caml_option = require("../../lib/js/caml_option.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); function classify(x) { if (x === "A" && typeof x !== "number") { @@ -290,7 +290,7 @@ let OverlapObject = { function classify$7(v) { if (Array.isArray(v)) { - return Caml_array.get(v, 0); + return Primitive_array.get(v, 0); } else { return v.x; } @@ -304,7 +304,7 @@ function classify$8(v) { if (typeof v === "object" && !Array.isArray(v)) { return v.x; } else { - return Caml_array.get(v, 0); + return Primitive_array.get(v, 0); } } @@ -357,7 +357,7 @@ let OptionUnboxingHeuristic = { function classify$9(v) { if (Array.isArray(v)) { - return Caml_array.get(v, 0); + return Primitive_array.get(v, 0); } switch (typeof v) { case "object" : diff --git a/jscomp/test/array_safe_get.js b/jscomp/test/array_safe_get.js index ce8a0437bf6..0426bda8b01 100644 --- a/jscomp/test/array_safe_get.js +++ b/jscomp/test/array_safe_get.js @@ -1,7 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let Caml_array = require("../../lib/js/caml_array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); let x = [ @@ -12,7 +12,7 @@ let x = [ let y; try { - y = Caml_array.get(x, 3); + y = Primitive_array.get(x, 3); } catch (raw_msg) { let msg = Caml_js_exceptions.internalToOCamlException(raw_msg); if (msg.RE_EXN_ID === "Invalid_argument") { diff --git a/jscomp/test/array_subtle_test.js b/jscomp/test/array_subtle_test.js index 822662d6ea1..7133d5f3251 100644 --- a/jscomp/test/array_subtle_test.js +++ b/jscomp/test/array_subtle_test.js @@ -2,7 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); -let Caml_array = require("../../lib/js/caml_array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); let suites = { contents: /* [] */0 @@ -36,43 +36,43 @@ let v = [ 3 ]; -eq("File \"array_subtle_test.res\", line 14, characters 12-19", [ +eq("File \"array_subtle_test.res\", line 16, characters 12-19", [ 4, v.length ]); -eq("File \"array_subtle_test.res\", line 17, characters 5-12", [ +eq("File \"array_subtle_test.res\", line 19, characters 5-12", [ 5, v.push(3) ]); -eq("File \"array_subtle_test.res\", line 18, characters 5-12", [ +eq("File \"array_subtle_test.res\", line 20, characters 5-12", [ 5, v.length ]); -eq("File \"array_subtle_test.res\", line 19, characters 5-12", [ +eq("File \"array_subtle_test.res\", line 21, characters 5-12", [ 5, v.length ]); -eq("File \"array_subtle_test.res\", line 23, characters 5-12", [ +eq("File \"array_subtle_test.res\", line 25, characters 5-12", [ 3, - Caml_array.get(v, 2) + Primitive_array.get(v, 2) ]); -Caml_array.set(v, 2, 4); +Primitive_array.set(v, 2, 4); -eq("File \"array_subtle_test.res\", line 25, characters 5-12", [ +eq("File \"array_subtle_test.res\", line 27, characters 5-12", [ 4, - Caml_array.get(v, 2) + Primitive_array.get(v, 2) ]); while (v.length > 0) { v.pop(); }; -eq("File \"array_subtle_test.res\", line 32, characters 5-12", [ +eq("File \"array_subtle_test.res\", line 34, characters 5-12", [ 0, v.length ]); @@ -111,17 +111,17 @@ function fff4(x) { } } -eq("File \"array_subtle_test.res\", line 64, characters 3-10", [ +eq("File \"array_subtle_test.res\", line 66, characters 3-10", [ fff3([]), 1 ]); -eq("File \"array_subtle_test.res\", line 65, characters 3-10", [ +eq("File \"array_subtle_test.res\", line 67, characters 3-10", [ fff4([]), 2 ]); -eq("File \"array_subtle_test.res\", line 66, characters 3-10", [ +eq("File \"array_subtle_test.res\", line 68, characters 3-10", [ fff4([1]), 1 ]); diff --git a/jscomp/test/array_subtle_test.res b/jscomp/test/array_subtle_test.res index a24b8a460e4..0af8da9d682 100644 --- a/jscomp/test/array_subtle_test.res +++ b/jscomp/test/array_subtle_test.res @@ -1,3 +1,5 @@ +open Belt + let suites: ref = ref(list{}) let test_id = ref(0) let eq = (loc, (x, y)) => { diff --git a/jscomp/test/array_test.js b/jscomp/test/array_test.js deleted file mode 100644 index 72f85c2e20c..00000000000 --- a/jscomp/test/array_test.js +++ /dev/null @@ -1,336 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Mt = require("./mt.js"); -let List = require("../../lib/js/list.js"); -let $$Array = require("../../lib/js/array.js"); -let Caml_obj = require("../../lib/js/caml_obj.js"); -let Caml_array = require("../../lib/js/caml_array.js"); -let Primitive_int = require("../../lib/js/primitive_int.js"); -let Caml_exceptions = require("../../lib/js/caml_exceptions.js"); -let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); - -function starts_with(xs, prefix, p) { - let H = /* @__PURE__ */Caml_exceptions.create("H"); - let len1 = xs.length; - let len2 = prefix.length; - if (len2 > len1) { - return false; - } - try { - for (let i = 0; i < len2; ++i) { - if (!p(Caml_array.get(xs, i), Caml_array.get(prefix, i))) { - throw new Error(H, { - cause: { - RE_EXN_ID: H - } - }); - } - - } - return true; - } catch (raw_exn) { - let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === H) { - return false; - } - throw new Error(exn.RE_EXN_ID, { - cause: exn - }); - } -} - -function is_sorted(x) { - let len = x.length; - let _i = 0; - while (true) { - let i = _i; - if (i >= (len - 1 | 0)) { - return true; - } - if (!Caml_obj.lessthan(Caml_array.get(x, i), Caml_array.get(x, i + 1 | 0))) { - return false; - } - _i = i + 1 | 0; - continue; - }; -} - -let array_suites_0 = [ - "init", - param => ({ - TAG: "Eq", - _0: $$Array.init(5, x => x), - _1: [ - 0, - 1, - 2, - 3, - 4 - ] - }) -]; - -let array_suites_1 = { - hd: [ - "toList", - param => { - let aux = xs => List.fold_left((acc, param) => ({ - hd: [ - $$Array.to_list(param[0]), - param[1] - ], - tl: acc - }), /* [] */0, xs); - let match = List.split(aux({ - hd: [ - [], - /* [] */0 - ], - tl: /* [] */0 - })); - return { - TAG: "Eq", - _0: match[0], - _1: match[1] - }; - } - ], - tl: { - hd: [ - "concat", - param => ({ - TAG: "Eq", - _0: [ - 0, - 1, - 2, - 3, - 4, - 5 - ], - _1: Caml_array.concat({ - hd: [ - 0, - 1, - 2 - ], - tl: { - hd: [ - 3, - 4 - ], - tl: { - hd: [], - tl: { - hd: [5], - tl: /* [] */0 - } - } - } - }) - }) - ], - tl: { - hd: [ - "make", - param => ({ - TAG: "Eq", - _0: Caml_array.make(100, /* 'a' */97), - _1: $$Array.init(100, param => /* 'a' */97) - }) - ], - tl: { - hd: [ - "sub", - param => ({ - TAG: "Eq", - _0: $$Array.sub([ - 0, - 1, - 2, - 3, - 4 - ], 2, 2), - _1: [ - 2, - 3 - ] - }) - ], - tl: { - hd: [ - "blit", - param => { - let u = [ - 100, - 0, - 0 - ]; - let v = $$Array.init(3, x => (x << 1)); - $$Array.blit(v, 1, u, 1, 2); - return { - TAG: "Eq", - _0: [ - [ - 0, - 2, - 4 - ], - [ - 100, - 2, - 4 - ] - ], - _1: [ - v, - u - ] - }; - } - ], - tl: { - hd: [ - "File \"array_test.res\", line 69, characters 8-15", - param => { - let a0 = $$Array.init(100, i => (i << 0)); - $$Array.blit(a0, 10, a0, 5, 20); - return { - TAG: "Eq", - _0: true, - _1: starts_with(a0, [ - 0, - 1, - 2, - 3, - 4, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28 - ], (prim0, prim1) => prim0 === prim1) - }; - } - ], - tl: { - hd: [ - "File \"array_test.res\", line 112, characters 8-15", - param => { - let a0 = $$Array.init(100, i => (i << 0)); - $$Array.blit(a0, 5, a0, 10, 20); - return { - TAG: "Eq", - _0: true, - _1: starts_with(a0, [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20 - ], (prim0, prim1) => prim0 === prim1) - }; - } - ], - tl: { - hd: [ - "make", - param => ({ - TAG: "Eq", - _0: Caml_array.make(2, 1), - _1: [ - 1, - 1 - ] - }) - ], - tl: { - hd: [ - "sort", - param => { - let u = [ - 3, - 0, - 1 - ]; - $$Array.sort(Primitive_int.compare, u); - return { - TAG: "Eq", - _0: Caml_obj.equal([ - 0, - 1, - 3 - ], u), - _1: true - }; - } - ], - tl: { - hd: [ - "sort_large", - param => { - let v = $$Array.init(4, i => i % 17); - $$Array.sort(Primitive_int.compare, v); - return { - TAG: "Eq", - _0: true, - _1: is_sorted(v) - }; - } - ], - tl: /* [] */0 - } - } - } - } - } - } - } - } - } -}; - -let array_suites = { - hd: array_suites_0, - tl: array_suites_1 -}; - -Mt.from_pair_suites("Array_test", array_suites); - -/* Not a pure module */ diff --git a/jscomp/test/array_test.res b/jscomp/test/array_test.res deleted file mode 100644 index 3bca391f4a7..00000000000 --- a/jscomp/test/array_test.res +++ /dev/null @@ -1,183 +0,0 @@ -open Mt - -module type ARRAY = module type of Array -module Make = (Array: ARRAY) => { - let starts_with = (xs, prefix, p) => { - module X = { - exception H - } - let (len1, len2) = { - open Array - (length(xs), length(prefix)) - } - if len2 > len1 { - false - } else { - try { - for i in 0 to len2 - 1 { - if \"@@"(not, p(xs[i], prefix[i])) { - raise(X.H) - } - } - true - } catch { - | X.H => false - } - } - } - - let is_sorted = x => { - let len = Array.length(x) - let rec aux = i => - if i >= len - 1 { - true - } else if x[i] < x[i + 1] { - aux(i + 1) - } else { - false - } - aux(0) - } - - let array_suites = { - open Mt - list{ - ("init", _ => Eq(Array.init(5, x => x), [0, 1, 2, 3, 4])), - ( - "toList", - _ => { - let aux = (xs: list<(array, list)>) => - List.fold_left((acc, (x, y)) => list{(Array.to_list(x), y), ...acc}, list{}, xs) - - let (a, b) = \"@@"(List.split, aux(list{([], list{})})) - Eq(a, b) - }, - ), - ("concat", _ => Eq([0, 1, 2, 3, 4, 5], Array.concat(list{[0, 1, 2], [3, 4], [], [5]}))), - ("make", _ => Eq(Array.make(100, 'a'), Array.init(100, _ => 'a'))), - ("sub", _ => Eq(Array.sub([0, 1, 2, 3, 4], 2, 2), [2, 3])), - ( - "blit", - _ => { - let u = [100, 0, 0] - let v = Array.init(3, x => x * 2) - let () = Array.blit(v, 1, u, 1, 2) - Eq(([0, 2, 4], [100, 2, 4]), (v, u)) - }, - ), - ( - __LOC__, - { - open Array - _ => { - let a0 = init(100, i => i * 1) - blit(a0, 10, a0, 5, 20) - Eq( - true, - starts_with( - a0, - [ - 0, - 1, - 2, - 3, - 4, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - ], - \"=", - ), - ) - } - }, - ), - ( - __LOC__, - { - open Array - _ => { - let a0 = init(100, i => i * 1) - blit(a0, 5, a0, 10, 20) - Eq( - true, - starts_with( - a0, - [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - ], - \"=", - ), - ) - } - }, - ), - ("make", _ => Eq(Array.make(2, 1), [1, 1])), - ( - "sort", - _ => { - let u = [3, 0, 1] - Array.sort((x: int, y) => Pervasives.compare(x, y), u) - Eq([0, 1, 3] == u, true) /* seems [assert.deepEqual] does not do the right job.. */ - }, - ), - ( - "sort_large", - _ => { - let v = Array.init(4, i => mod(i, 17)) - Array.sort((x: int, y) => compare(x, y), v) - Eq(true, is_sorted(v)) - }, - ), - } - } -} - -from_pair_suites( - __MODULE__, - { - module Array_test = Make(Array) - Array_test.array_suites - }, -) diff --git a/jscomp/test/array_test.resi b/jscomp/test/array_test.resi deleted file mode 100644 index 8b137891791..00000000000 --- a/jscomp/test/array_test.resi +++ /dev/null @@ -1 +0,0 @@ - diff --git a/jscomp/test/async_await.js b/jscomp/test/async_await.js index 3bdca2ae5dc..7b2eb2411c3 100644 --- a/jscomp/test/async_await.js +++ b/jscomp/test/async_await.js @@ -1,7 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let Caml_array = require("../../lib/js/caml_array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); function next(n) { return n + 1 | 0; @@ -30,7 +30,7 @@ let arr = [ let toplevelAwait = await topFoo(); -let toplevelAwait2 = Caml_array.get(arr, await topFoo()); +let toplevelAwait2 = Primitive_array.get(arr, await topFoo()); async function f(value) { return await Promise.resolve(1); diff --git a/jscomp/test/bdd.js b/jscomp/test/bdd.js index a7b4f929b54..7d8172f1169 100644 --- a/jscomp/test/bdd.js +++ b/jscomp/test/bdd.js @@ -1,7 +1,8 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let Caml_array = require("../../lib/js/caml_array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); function $$eval(_bdd, vars) { while (true) { @@ -13,7 +14,7 @@ function $$eval(_bdd, vars) { return false; } } - if (Caml_array.get(vars, bdd._1)) { + if (Primitive_array.get(vars, bdd._1)) { _bdd = bdd._3; continue; } @@ -43,7 +44,7 @@ let sz_1 = { }; let htab = { - contents: Caml_array.make(sz_1.contents + 1 | 0, /* [] */0) + contents: Belt_Array.make(sz_1.contents + 1 | 0, /* [] */0) }; let n_items = { @@ -57,7 +58,7 @@ function hashVal(x, y, v) { function resize(newSize) { let arr = htab.contents; let newSz_1 = newSize - 1 | 0; - let newArr = Caml_array.make(newSize, /* [] */0); + let newArr = Belt_Array.make(newSize, /* [] */0); let copyBucket = _bucket => { while (true) { let bucket = _bucket; @@ -90,9 +91,9 @@ function resize(newSize) { }); } else { let ind = hashVal(getId(n._0), getId(n._3), n._1) & newSz_1; - Caml_array.set(newArr, ind, { + Primitive_array.set(newArr, ind, { hd: n, - tl: Caml_array.get(newArr, ind) + tl: Primitive_array.get(newArr, ind) }); _bucket = bucket.tl; continue; @@ -100,7 +101,7 @@ function resize(newSize) { }; }; for (let n = 0, n_finish = sz_1.contents; n <= n_finish; ++n) { - copyBucket(Caml_array.get(arr, n)); + copyBucket(Primitive_array.get(arr, n)); } htab.contents = newArr; sz_1.contents = newSz_1; @@ -108,7 +109,7 @@ function resize(newSize) { function insert(idl, idh, v, ind, bucket, newNode) { if (n_items.contents <= sz_1.contents) { - Caml_array.set(htab.contents, ind, { + Primitive_array.set(htab.contents, ind, { hd: newNode, tl: bucket }); @@ -117,15 +118,15 @@ function insert(idl, idh, v, ind, bucket, newNode) { } resize((sz_1.contents + sz_1.contents | 0) + 2 | 0); let ind$1 = hashVal(idl, idh, v) & sz_1.contents; - Caml_array.set(htab.contents, ind$1, { + Primitive_array.set(htab.contents, ind$1, { hd: newNode, - tl: Caml_array.get(htab.contents, ind$1) + tl: Primitive_array.get(htab.contents, ind$1) }); } function resetUnique() { sz_1.contents = 8191; - htab.contents = Caml_array.make(sz_1.contents + 1 | 0, /* [] */0); + htab.contents = Belt_Array.make(sz_1.contents + 1 | 0, /* [] */0); n_items.contents = 0; nodeC.contents = 1; } @@ -137,7 +138,7 @@ function mkNode(low, v, high) { return low; } let ind = hashVal(idl, idh, v) & sz_1.contents; - let bucket = Caml_array.get(htab.contents, ind); + let bucket = Primitive_array.get(htab.contents, ind); let _b = bucket; while (true) { let b = _b; @@ -202,21 +203,21 @@ function mkVar(x) { return mkNode("Zero", x, "One"); } -let andslot1 = Caml_array.make(1999, 0); +let andslot1 = Belt_Array.make(1999, 0); -let andslot2 = Caml_array.make(1999, 0); +let andslot2 = Belt_Array.make(1999, 0); -let andslot3 = Caml_array.make(1999, "Zero"); +let andslot3 = Belt_Array.make(1999, "Zero"); -let xorslot1 = Caml_array.make(1999, 0); +let xorslot1 = Belt_Array.make(1999, 0); -let xorslot2 = Caml_array.make(1999, 0); +let xorslot2 = Belt_Array.make(1999, 0); -let xorslot3 = Caml_array.make(1999, "Zero"); +let xorslot3 = Belt_Array.make(1999, "Zero"); -let notslot1 = Caml_array.make(1999, 0); +let notslot1 = Belt_Array.make(1999, 0); -let notslot2 = Caml_array.make(1999, "One"); +let notslot2 = Belt_Array.make(1999, "One"); function hash(x, y) { return ((x << 1) + y | 0) % 1999; @@ -232,12 +233,12 @@ function not(n) { } let id = n._2; let h = id % 1999; - if (id === Caml_array.get(notslot1, h)) { - return Caml_array.get(notslot2, h); + if (id === Primitive_array.get(notslot1, h)) { + return Primitive_array.get(notslot2, h); } let f = mkNode(not(n._0), n._1, not(n._3)); - Caml_array.set(notslot1, h, id); - Caml_array.set(notslot2, h, f); + Primitive_array.set(notslot1, h, id); + Primitive_array.set(notslot2, h, f); return f; } @@ -265,8 +266,8 @@ function and2(n1, n2) { let v2 = n2._1; let l2 = n2._0; let h = hash(i1, i2); - if (i1 === Caml_array.get(andslot1, h) && i2 === Caml_array.get(andslot2, h)) { - return Caml_array.get(andslot3, h); + if (i1 === Primitive_array.get(andslot1, h) && i2 === Primitive_array.get(andslot2, h)) { + return Primitive_array.get(andslot3, h); } let match = cmpVar(v1, v2); let f; @@ -281,9 +282,9 @@ function and2(n1, n2) { f = mkNode(and2(n1, l2), v2, and2(n1, r2)); break; } - Caml_array.set(andslot1, h, i1); - Caml_array.set(andslot2, h, i2); - Caml_array.set(andslot3, h, f); + Primitive_array.set(andslot1, h, i1); + Primitive_array.set(andslot2, h, i2); + Primitive_array.set(andslot3, h, f); return f; } @@ -311,8 +312,8 @@ function xor(n1, n2) { let v2 = n2._1; let l2 = n2._0; let h = hash(i1, i2); - if (i1 === Caml_array.get(andslot1, h) && i2 === Caml_array.get(andslot2, h)) { - return Caml_array.get(andslot3, h); + if (i1 === Primitive_array.get(andslot1, h) && i2 === Primitive_array.get(andslot2, h)) { + return Primitive_array.get(andslot3, h); } let match = cmpVar(v1, v2); let f; @@ -327,9 +328,9 @@ function xor(n1, n2) { f = mkNode(xor(n1, l2), v2, xor(n1, r2)); break; } - Caml_array.set(andslot1, h, i1); - Caml_array.set(andslot2, h, i2); - Caml_array.set(andslot3, h, f); + Primitive_array.set(andslot1, h, i1); + Primitive_array.set(andslot2, h, i2); + Primitive_array.set(andslot3, h, f); return f; } @@ -361,9 +362,9 @@ function random() { } function random_vars(n) { - let vars = Caml_array.make(n, false); + let vars = Belt_Array.make(n, false); for (let i = 0; i < n; ++i) { - Caml_array.set(vars, i, random()); + Primitive_array.set(vars, i, random()); } return vars; } @@ -385,12 +386,12 @@ function bool_equal(a, b) { function test_hwb(bdd, vars) { let ntrue = 0; for (let i = 0, i_finish = vars.length; i < i_finish; ++i) { - if (Caml_array.get(vars, i)) { + if (Primitive_array.get(vars, i)) { ntrue = ntrue + 1 | 0; } } - return bool_equal($$eval(bdd, vars), ntrue > 0 ? Caml_array.get(vars, ntrue - 1 | 0) : false); + return bool_equal($$eval(bdd, vars), ntrue > 0 ? Primitive_array.get(vars, ntrue - 1 | 0) : false); } function main() { @@ -407,7 +408,7 @@ function main() { RE_EXN_ID: "Assert_failure", _1: [ "bdd.res", - 301, + 303, 2 ] } @@ -460,4 +461,4 @@ exports.random_vars = random_vars; exports.bool_equal = bool_equal; exports.test_hwb = test_hwb; exports.main = main; -/* Not a pure module */ +/* htab Not a pure module */ diff --git a/jscomp/test/bdd.res b/jscomp/test/bdd.res index 109d61da03c..cd918be5787 100644 --- a/jscomp/test/bdd.res +++ b/jscomp/test/bdd.res @@ -39,14 +39,14 @@ let getId = bdd => let initSize_1 = 8 * 1024 - 1 let nodeC = ref(1) let sz_1 = ref(initSize_1) -let htab = ref(Array.make(sz_1.contents + 1, list{})) +let htab = ref(Belt.Array.make(sz_1.contents + 1, list{})) let n_items = ref(0) let hashVal = (x, y, v) => lsl(x, 1) + y + lsl(v, 2) let resize = newSize => { let arr = htab.contents let newSz_1 = newSize - 1 - let newArr = Array.make(newSize, list{}) + let newArr = Belt.Array.make(newSize, list{}) let rec copyBucket = bucket => switch bucket { | list{} => () @@ -81,7 +81,7 @@ let rec insert = (idl, idh, v, ind, bucket, newNode) => let resetUnique = () => { sz_1 := initSize_1 - htab := Array.make(sz_1.contents + 1, list{}) + htab := Belt.Array.make(sz_1.contents + 1, list{}) n_items := 0 nodeC := 1 } @@ -143,6 +143,8 @@ let one = One let mkVar = x => mkNode(zero, x, one) let cacheSize = 1999 + +open Belt let andslot1 = Array.make(cacheSize, 0) let andslot2 = Array.make(cacheSize, 0) let andslot3 = Array.make(cacheSize, zero) diff --git a/jscomp/test/bench.js b/jscomp/test/bench.js index 114e60a8f08..b84d8a48cad 100644 --- a/jscomp/test/bench.js +++ b/jscomp/test/bench.js @@ -1,7 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let Caml_array = require("../../lib/js/caml_array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); function map(f, a) { let f$1 = x => f(x); @@ -9,7 +9,7 @@ function map(f, a) { if (l === 0) { return []; } - let r = Caml_array.make(l, f$1(a[0])); + let r = Belt_Array.make(l, f$1(a[0])); for (let i = 1; i < l; ++i) { r[i] = f$1(a[i]); } @@ -29,7 +29,7 @@ function init(l, f) { } }); } - let res = Caml_array.make(l, f$1(0)); + let res = Belt_Array.make(l, f$1(0)); for (let i = 1; i < l; ++i) { res[i] = f$1(i); } diff --git a/jscomp/test/bench.res b/jscomp/test/bench.res index d245ed54331..0be1bd44f00 100644 --- a/jscomp/test/bench.res +++ b/jscomp/test/bench.res @@ -1,11 +1,13 @@ +open Belt + let map = (f, a) => { let l = Array.length(a) if l == 0 { [] } else { - let r = Array.make(l, f(Array.unsafe_get(a, 0))) + let r = Array.make(l, f(Array.getUnsafe(a, 0))) for i in 1 to l - 1 { - Array.unsafe_set(r, i, f(Array.unsafe_get(a, i))) + Array.setUnsafe(r, i, f(Array.getUnsafe(a, i))) } r } @@ -24,7 +26,7 @@ let init = (l, f) => let res = Array.make(l, f(0)) for i in 1 to pred(l) { - Array.unsafe_set(res, i, f(i)) + Array.setUnsafe(res, i, f(i)) } res } @@ -34,7 +36,7 @@ let init = (l, f) => init(l, x => f(x)) let fold_left = (f, x, a) => { let r = ref(x) for i in 0 to Array.length(a) - 1 { - r := f(r.contents, Array.unsafe_get(a, i)) + r := f(r.contents, Array.getUnsafe(a, i)) } r.contents } @@ -49,7 +51,3 @@ let f2 = () => { } f2() - -/* local variables: */ -/* compile-command: "ocamlc bench.ml -o bench.byte && js_of_ocaml --opt 3 bench.byte -o bench.1.js " */ -/* end: */ diff --git a/jscomp/test/bs_mutable_set_test.js b/jscomp/test/bs_mutable_set_test.js index 8c17ab5ba92..c4e90e55681 100644 --- a/jscomp/test/bs_mutable_set_test.js +++ b/jscomp/test/bs_mutable_set_test.js @@ -5,8 +5,8 @@ let Mt = require("./mt.js"); let Belt_List = require("../../lib/js/belt_List.js"); let Belt_Array = require("../../lib/js/belt_Array.js"); let Belt_Range = require("../../lib/js/belt_Range.js"); -let Caml_array = require("../../lib/js/caml_array.js"); let Array_data_util = require("./array_data_util.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); let Belt_MutableSetInt = require("../../lib/js/belt_MutableSetInt.js"); let Belt_internalAVLset = require("../../lib/js/belt_internalAVLset.js"); let Belt_internalSetInt = require("../../lib/js/belt_internalSetInt.js"); @@ -436,7 +436,7 @@ eq("File \"bs_mutable_set_test.res\", line 210, characters 5-12", Belt_internalA let vv = Array_data_util.randomRange(0, 100000); for (let 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)); + Belt_MutableSetInt.remove(v$3, Primitive_array.get(vv, i$4)); } eq("File \"bs_mutable_set_test.res\", line 216, characters 5-12", Belt_internalAVLset.size(v$3.data), 0); @@ -464,7 +464,7 @@ eq("File \"bs_mutable_set_test.res\", line 227, characters 5-12", Belt_internalA let vv$1 = Array_data_util.randomRange(1, 28); for (let 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)); + Belt_MutableSetInt.remove(v$4, Primitive_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); diff --git a/jscomp/test/bs_poly_map_test.js b/jscomp/test/bs_poly_map_test.js index 5101068024d..2a76a7b7cac 100644 --- a/jscomp/test/bs_poly_map_test.js +++ b/jscomp/test/bs_poly_map_test.js @@ -162,9 +162,9 @@ let u0$1 = Belt_Map.fromArray(randomRange(0, 100), Icmp); let 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 107, 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); +eq("File \"bs_poly_map_test.res\", line 108, characters 5-12", Belt_Map.get(u0$1, 3), 3); function acc(m, is) { return Belt_Array.reduce(is, m, (a, i) => Belt_Map.update(a, i, n => { @@ -185,7 +185,7 @@ let m = { let 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, i => [ +b("File \"bs_poly_map_test.res\", line 125, characters 4-11", Belt_Map.eq(m1, Belt_Map.fromArray(Belt_Array.makeBy(31, i => [ i, i >= 10 && i <= 20 ? 2 : 1 ]), Icmp), (x, y) => x === y)); @@ -207,7 +207,7 @@ let v2 = Belt_Map.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 10000) x ]), Icmp); -b("File \"bs_poly_map_test.res\", line 150, characters 4-11", Belt_Map.eq(v1, v2, (x, y) => x === y)); +b("File \"bs_poly_map_test.res\", line 149, characters 4-11", Belt_Map.eq(v1, v2, (x, y) => x === y)); function inc(x) { if (x !== undefined) { @@ -229,35 +229,35 @@ let match$1 = match[0]; let 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); +b("File \"bs_poly_map_test.res\", line 160, characters 4-11", match$2 !== undefined ? match$2 === 11 : false); let match$3 = Belt_Map.get(v3, -10); -b("File \"bs_poly_map_test.res\", line 168, characters 4-11", match$3 === undefined); +b("File \"bs_poly_map_test.res\", line 167, characters 4-11", match$3 === undefined); let 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); +b("File \"bs_poly_map_test.res\", line 174, characters 4-11", match$4 !== undefined ? match$4 === 0 : false); let 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)); +b("File \"bs_poly_map_test.res\", line 180, characters 4-11", Belt_MapDict.isEmpty(map.data)); let 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 181, 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 183, 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, i => i), (prim0, prim1) => prim0 === prim1)); +b("File \"bs_poly_map_test.res\", line 189, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$1[0].data), Belt_Array.makeBy(5000, i => i), (prim0, prim1) => 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, i => 5001 + i | 0), (prim0, prim1) => prim0 === prim1)); +b("File \"bs_poly_map_test.res\", line 190, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$1[1].data), Belt_Array.makeBy(5000, i => 5001 + i | 0), (prim0, prim1) => prim0 === prim1)); let v7 = Belt_Map.remove(v3, 5000); @@ -265,11 +265,11 @@ let match$5 = Belt_Map.split(v7, 5000); let 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 195, 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, i => i), (prim0, prim1) => prim0 === prim1)); +b("File \"bs_poly_map_test.res\", line 201, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$6[0].data), Belt_Array.makeBy(5000, i => i), (prim0, prim1) => 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, i => 5001 + i | 0), (prim0, prim1) => prim0 === prim1)); +b("File \"bs_poly_map_test.res\", line 202, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$6[1].data), Belt_Array.makeBy(5000, i => 5001 + i | 0), (prim0, prim1) => prim0 === prim1)); Mt.from_pair_suites("Bs_poly_map_test", suites.contents); diff --git a/jscomp/test/bs_poly_map_test.res b/jscomp/test/bs_poly_map_test.res index d3084fa4878..76d2bbce35e 100644 --- a/jscomp/test/bs_poly_map_test.res +++ b/jscomp/test/bs_poly_map_test.res @@ -102,11 +102,10 @@ let () = { } 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 u1 = M.set(u0, 3, 32) + eq(__LOC__, M.get(u1, 3), Some(32)) + eq(__LOC__, M.get(u0, 3), Some(3)) } let acc = (m, i) => diff --git a/jscomp/test/bs_set_int_test.js b/jscomp/test/bs_set_int_test.js index e2eeb5971fc..b6dfe0be994 100644 --- a/jscomp/test/bs_set_int_test.js +++ b/jscomp/test/bs_set_int_test.js @@ -2,8 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); -let List = require("../../lib/js/list.js"); -let $$Array = require("../../lib/js/array.js"); +let Belt_List = require("../../lib/js/belt_List.js"); let Belt_Array = require("../../lib/js/belt_Array.js"); let Belt_SetInt = require("../../lib/js/belt_SetInt.js"); let Array_data_util = require("./array_data_util.js"); @@ -32,7 +31,7 @@ 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([ +b("File \"bs_set_int_test.res\", line 22, characters 11-18", $eq$star([ 1, 2, 3 @@ -52,21 +51,21 @@ let u = Belt_SetInt.intersect(Belt_SetInt.fromArray([ 5 ])); -b("File \"bs_set_int_test.res\", line 27, characters 11-18", Belt_SetInt.eq(Belt_SetInt.fromArray([3]), u)); +b("File \"bs_set_int_test.res\", line 28, characters 11-18", Belt_SetInt.eq(Belt_SetInt.fromArray([3]), u)); function range(i, j) { - return $$Array.init((j - i | 0) + 1 | 0, k => k + i | 0); + return Belt_Array.init((j - i | 0) + 1 | 0, k => k + i | 0); } function revRange(i, j) { - return $$Array.of_list(List.rev($$Array.to_list($$Array.init((j - i | 0) + 1 | 0, k => k + i | 0)))); + return Belt_List.toArray(Belt_List.reverse(Belt_List.fromArray(Belt_Array.init((j - i | 0) + 1 | 0, k => k + i | 0)))); } -let v = Belt_SetInt.fromArray($$Array.append(range(100, 1000), revRange(400, 1500))); +let v = Belt_SetInt.fromArray(Belt_Array.concat(range(100, 1000), revRange(400, 1500))); let i = range(100, 1500); -b("File \"bs_set_int_test.res\", line 36, characters 4-11", Belt_SetInt.eq(Belt_SetInt.fromArray(i), v)); +b("File \"bs_set_int_test.res\", line 37, characters 4-11", Belt_SetInt.eq(Belt_SetInt.fromArray(i), v)); let match = Belt_SetInt.partition(v, x => x % 3 === 0); @@ -86,45 +85,45 @@ let nl = l; let nr = r; -b("File \"bs_set_int_test.res\", line 49, characters 4-11", Belt_SetInt.eq(match[0], nl)); +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 50, characters 4-11", Belt_SetInt.eq(match[1], nr)); +b("File \"bs_set_int_test.res\", line 51, characters 4-11", Belt_SetInt.eq(match[1], nr)); let i$2 = range(50, 100); let s = Belt_SetInt.intersect(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))); -b("File \"bs_set_int_test.res\", line 54, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$2), s)); +b("File \"bs_set_int_test.res\", line 55, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$2), s)); let i$3 = range(1, 200); let 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 65, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$3), s$1)); +b("File \"bs_set_int_test.res\", line 66, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$3), s$1)); let i$4 = range(1, 49); let 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 76, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$4), s$2)); +b("File \"bs_set_int_test.res\", line 77, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$4), s$2)); let i$5 = revRange(50, 100); let 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 87, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$5), s$3)); +b("File \"bs_set_int_test.res\", line 88, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$5), s$3)); let i$6 = revRange(1, 200); let 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 98, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$6), s$4)); +b("File \"bs_set_int_test.res\", line 99, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$6), s$4)); let i$7 = revRange(1, 49); let 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 109, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$7), s$5)); +b("File \"bs_set_int_test.res\", line 110, characters 2-9", Belt_SetInt.eq(Belt_SetInt.fromArray(i$7), s$5)); let ss = [ 1, @@ -156,11 +155,11 @@ function approx(loc, x, y) { b(loc, x === y); } -eq("File \"bs_set_int_test.res\", line 124, characters 5-12", Belt_SetInt.reduce(v$1, 0, (x, y) => x + y | 0), Belt_Array.reduce(ss, 0, (prim0, prim1) => prim0 + prim1 | 0)); +eq("File \"bs_set_int_test.res\", line 125, characters 5-12", Belt_SetInt.reduce(v$1, 0, (x, y) => x + y | 0), Belt_Array.reduce(ss, 0, (prim0, prim1) => prim0 + prim1 | 0)); -approx("File \"bs_set_int_test.res\", line 125, characters 9-16", -1, minv); +approx("File \"bs_set_int_test.res\", line 126, characters 9-16", -1, minv); -approx("File \"bs_set_int_test.res\", line 126, characters 9-16", 222, maxv); +approx("File \"bs_set_int_test.res\", line 127, characters 9-16", 222, maxv); let v$2 = Belt_SetInt.remove(v$1, 3); @@ -168,9 +167,9 @@ let minv$1 = Belt_SetInt.minimum(v$2); let maxv$1 = Belt_SetInt.maximum(v$2); -eq("File \"bs_set_int_test.res\", line 129, characters 5-12", minv$1, -1); +eq("File \"bs_set_int_test.res\", line 130, characters 5-12", minv$1, -1); -eq("File \"bs_set_int_test.res\", line 130, characters 5-12", maxv$1, 222); +eq("File \"bs_set_int_test.res\", line 131, characters 5-12", maxv$1, 222); let v$3 = Belt_SetInt.remove(v$2, 222); @@ -178,9 +177,9 @@ let minv$2 = Belt_SetInt.minimum(v$3); let maxv$2 = Belt_SetInt.maximum(v$3); -eq("File \"bs_set_int_test.res\", line 133, characters 5-12", minv$2, -1); +eq("File \"bs_set_int_test.res\", line 134, characters 5-12", minv$2, -1); -eq("File \"bs_set_int_test.res\", line 134, characters 5-12", maxv$2, 33); +eq("File \"bs_set_int_test.res\", line 135, characters 5-12", maxv$2, 33); let v$4 = Belt_SetInt.remove(v$3, -1); @@ -188,9 +187,9 @@ let minv$3 = Belt_SetInt.minimum(v$4); let maxv$3 = Belt_SetInt.maximum(v$4); -eq("File \"bs_set_int_test.res\", line 137, characters 5-12", minv$3, 0); +eq("File \"bs_set_int_test.res\", line 138, characters 5-12", minv$3, 0); -eq("File \"bs_set_int_test.res\", line 138, characters 5-12", maxv$3, 33); +eq("File \"bs_set_int_test.res\", line 139, characters 5-12", maxv$3, 33); let v$5 = Belt_SetInt.remove(v$4, 0); @@ -204,7 +203,7 @@ let v$9 = Belt_SetInt.remove(v$8, 4); let v$10 = Belt_SetInt.remove(v$9, 1); -b("File \"bs_set_int_test.res\", line 145, characters 4-11", Belt_SetInt.isEmpty(v$10)); +b("File \"bs_set_int_test.res\", line 146, characters 4-11", Belt_SetInt.isEmpty(v$10)); let v$11 = Belt_Array.makeByAndShuffle(1000000, i => i); @@ -218,7 +217,7 @@ let xx = Belt_Array.reduce(firstHalf, u$1, Belt_SetInt.remove); Belt_SetInt.checkInvariantInternal(u$1); -b("File \"bs_set_int_test.res\", line 157, characters 4-11", Belt_SetInt.eq(Belt_SetInt.union(Belt_SetInt.fromArray(firstHalf), xx), 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)); let aa = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)); @@ -228,17 +227,17 @@ let cc = Belt_SetInt.fromArray(Array_data_util.randomRange(120, 200)); let dd = Belt_SetInt.union(aa, cc); -b("File \"bs_set_int_test.res\", line 170, characters 4-11", Belt_SetInt.subset(aa, bb)); +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 171, characters 4-11", Belt_SetInt.subset(dd, 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 172, characters 4-11", Belt_SetInt.subset(Belt_SetInt.add(dd, 200), 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 173, characters 4-11", Belt_SetInt.add(dd, 200) === dd); +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 174, characters 4-11", Belt_SetInt.add(dd, 0) === 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 175, characters 4-11", !Belt_SetInt.subset(Belt_SetInt.add(dd, 201), bb)); +b("File \"bs_set_int_test.res\", line 176, characters 4-11", !Belt_SetInt.subset(Belt_SetInt.add(dd, 201), bb)); let aa$1 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)); @@ -250,13 +249,13 @@ let dd$1 = Belt_SetInt.remove(bb$1, 99); let ee = Belt_SetInt.add(dd$1, 101); -b("File \"bs_set_int_test.res\", line 184, characters 4-11", Belt_SetInt.eq(aa$1, bb$1)); +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 185, characters 4-11", !Belt_SetInt.eq(aa$1, cc$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 186, characters 4-11", !Belt_SetInt.eq(dd$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 187, characters 4-11", !Belt_SetInt.eq(bb$1, ee)); +b("File \"bs_set_int_test.res\", line 188, characters 4-11", !Belt_SetInt.eq(bb$1, ee)); let a1 = Belt_SetInt.mergeMany(undefined, Array_data_util.randomRange(0, 100)); @@ -272,17 +271,17 @@ let a5 = match$2[1]; let a4 = match$2[0]; -b("File \"bs_set_int_test.res\", line 196, characters 4-11", Belt_SetInt.eq(a1, Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)))); +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 197, characters 4-11", Belt_SetInt.eq(a2, a3)); +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 198, characters 4-11", match$1[1]); +b("File \"bs_set_int_test.res\", line 199, characters 4-11", match$1[1]); -b("File \"bs_set_int_test.res\", line 199, characters 4-11", Belt_SetInt.eq(a3, a4)); +b("File \"bs_set_int_test.res\", line 200, characters 4-11", Belt_SetInt.eq(a3, a4)); let a6 = Belt_SetInt.remove(Belt_SetInt.removeMany(a1, Array_data_util.randomRange(0, 39)), 40); -b("File \"bs_set_int_test.res\", line 201, characters 4-11", Belt_SetInt.eq(a5, a6)); +b("File \"bs_set_int_test.res\", line 202, characters 4-11", Belt_SetInt.eq(a5, a6)); let a7 = Belt_SetInt.remove(a1, 40); @@ -292,29 +291,29 @@ let match$4 = match$3[0]; let a9 = match$4[1]; -b("File \"bs_set_int_test.res\", line 204, characters 4-11", !match$3[1]); +b("File \"bs_set_int_test.res\", line 205, characters 4-11", !match$3[1]); -b("File \"bs_set_int_test.res\", line 205, characters 4-11", Belt_SetInt.eq(a4, match$4[0])); +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 206, characters 4-11", Belt_SetInt.eq(a5, a9)); +b("File \"bs_set_int_test.res\", line 207, characters 4-11", Belt_SetInt.eq(a5, a9)); let a10 = Belt_SetInt.removeMany(a9, Array_data_util.randomRange(42, 2000)); -eq("File \"bs_set_int_test.res\", line 208, characters 5-12", Belt_SetInt.size(a10), 1); +eq("File \"bs_set_int_test.res\", line 209, characters 5-12", Belt_SetInt.size(a10), 1); let a11 = Belt_SetInt.removeMany(a9, Array_data_util.randomRange(0, 2000)); -b("File \"bs_set_int_test.res\", line 210, characters 4-11", Belt_SetInt.isEmpty(a11)); +b("File \"bs_set_int_test.res\", line 211, characters 4-11", Belt_SetInt.isEmpty(a11)); let match$5 = Belt_SetInt.split(undefined, 0); let match$6 = match$5[0]; -b("File \"bs_set_int_test.res\", line 215, characters 4-11", Belt_SetInt.isEmpty(match$6[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 216, characters 4-11", Belt_SetInt.isEmpty(match$6[1])); +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 217, characters 4-11", !match$5[1]); +b("File \"bs_set_int_test.res\", line 218, characters 4-11", !match$5[1]); let v$12 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 2000)); @@ -339,23 +338,23 @@ let counted = Belt_Array.reduce(us, 0, (acc, x) => { } }); -eq("File \"bs_set_int_test.res\", line 234, characters 5-12", counted, 1001); +eq("File \"bs_set_int_test.res\", line 235, characters 5-12", counted, 1001); -b("File \"bs_set_int_test.res\", line 235, characters 4-11", Belt_SetInt.eq(v$12, v0)); +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 236, characters 4-11", Belt_SetInt.cmp(v$12, v0) === 0); +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 237, characters 4-11", Belt_SetInt.cmp(v$12, v1) < 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 238, characters 4-11", Belt_SetInt.cmp(v$12, v2) > 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 239, characters 4-11", Belt_SetInt.subset(v3, v0)); +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 240, characters 4-11", !Belt_SetInt.subset(v1, 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 241, characters 5-12", Belt_SetInt.get(v$12, 30), 30); +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 242, characters 5-12", Belt_SetInt.get(v$12, 3000), undefined); +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); @@ -363,6 +362,8 @@ let N; let I; +let L; + let A; let ofA = Belt_SetInt.fromArray; @@ -373,6 +374,7 @@ exports.eq = eq; exports.b = b; exports.N = N; exports.I = I; +exports.L = L; exports.A = A; exports.$eq$tilde = $eq$tilde; exports.$eq$star = $eq$star; diff --git a/jscomp/test/bs_set_int_test.res b/jscomp/test/bs_set_int_test.res index 9b5223c511d..44b6dd8c374 100644 --- a/jscomp/test/bs_set_int_test.res +++ b/jscomp/test/bs_set_int_test.res @@ -7,6 +7,7 @@ let b = (loc, v) => Mt.bool_suites(~suites, ~test_id, loc, v) module N = Belt.Set.Int module I = Array_data_util +module L = Belt.List module A = Belt.Array let \"=~" = (s, i) => { open N @@ -27,12 +28,12 @@ let u = { let () = b(__LOC__, \"=~"(u, [3])) /* inclusive */ -let range = (i, j) => Array.init(j - i + 1, k => k + i) +let range = (i, j) => A.init(j - i + 1, k => k + i) -let revRange = (i, j) => Array.of_list(List.rev(Array.to_list(Array.init(j - i + 1, k => k + i)))) +let revRange = (i, j) => L.toArray(L.reverse(L.fromArray(A.init(j - i + 1, k => k + i)))) let () = { - let v = ofA(Array.append(range(100, 1000), revRange(400, 1500))) + let v = ofA(A.concat(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) = { @@ -151,7 +152,7 @@ let () = { 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) + let xx = A.reduce(firstHalf, u, N.remove) N.checkInvariantInternal(u) b( __LOC__, diff --git a/jscomp/test/build.ninja b/jscomp/test/build.ninja index 396037255b0..c32bf9c2c13 100644 --- a/jscomp/test/build.ninja +++ b/jscomp/test/build.ninja @@ -51,8 +51,6 @@ o test/arity_infer.cmi test/arity_infer.cmj : cc test/arity_infer.res | $bsc $st 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 -o test/array_test.cmi : cc test/array_test.resi | $bsc $stdlib runtime o test/as_inline_record_test.cmi test/as_inline_record_test.cmj : cc test/as_inline_record_test.res | $bsc $stdlib runtime o test/ast_abstract_test.cmi test/ast_abstract_test.cmj : cc test/ast_abstract_test.res | test/mt.cmj $bsc $stdlib runtime o test/ast_mapper_unused_warning_test.cmi test/ast_mapper_unused_warning_test.cmj : cc test/ast_mapper_unused_warning_test.res | $bsc $stdlib runtime @@ -522,7 +520,6 @@ o test/test_alias.cmi test/test_alias.cmj : cc test/test_alias.res | test/test_g o test/test_ari.cmi test/test_ari.cmj : cc test/test_ari.res | $bsc $stdlib runtime o test/test_array.cmi test/test_array.cmj : cc test/test_array.res | $bsc $stdlib runtime o test/test_array_append.cmi test/test_array_append.cmj : cc test/test_array_append.res | $bsc $stdlib runtime -o test/test_array_primitive.cmi test/test_array_primitive.cmj : cc test/test_array_primitive.res | $bsc $stdlib runtime o test/test_bool_equal.cmi test/test_bool_equal.cmj : cc test/test_bool_equal.res | $bsc $stdlib runtime o test/test_bs_this.cmi test/test_bs_this.cmj : cc test/test_bs_this.res | $bsc $stdlib runtime o test/test_case_opt_collision.cmi test/test_case_opt_collision.cmj : cc test/test_case_opt_collision.res | test/mt.cmj $bsc $stdlib runtime @@ -641,4 +638,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/AsInUncurriedExternals.cmi test/AsInUncurriedExternals.cmj test/Coercion.cmi test/Coercion.cmj test/DerivingAccessorsCurried.cmi test/DerivingAccessorsCurried.cmj test/DerivingAccessorsUncurried.cmi test/DerivingAccessorsUncurried.cmj test/DictInference.cmi test/DictInference.cmj test/DictTests.cmi test/DictTests.cmj test/DisambiguateOptionalFields.cmi test/DisambiguateOptionalFields.cmj test/DotDotDot.cmi test/DotDotDot.cmj test/EmptyRecord.cmi test/EmptyRecord.cmj test/ExternalArity.cmi test/ExternalArity.cmj test/FFI.cmi test/FFI.cmj test/Import.cmi test/Import.cmj test/ImportAttributes.cmi test/ImportAttributes.cmj test/PartialApplicationNoRuntimeCurry.cmi test/PartialApplicationNoRuntimeCurry.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_recursive_type.cmi test/a_recursive_type.cmj test/a_scope_bug.cmi test/a_scope_bug.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/ari_regress_test.cmi test/ari_regress_test.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_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_float_ntest.cmi test/belt_float_ntest.cmj test/belt_hashmap_ntest.cmi test/belt_hashmap_ntest.cmj test/belt_hashset_int_ntest.cmi test/belt_hashset_int_ntest.cmj test/belt_int_ntest.cmi test/belt_int_ntest.cmj test/belt_internal_test.cmi test/belt_internal_test.cmj test/belt_list_ntest.cmi test/belt_list_ntest.cmj test/belt_mapint_ntest.cmi test/belt_mapint_ntest.cmj test/belt_result_alias_test.cmi test/belt_result_alias_test.cmj test/belt_sortarray_ntest.cmi test/belt_sortarray_ntest.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/bigint_test.cmi test/bigint_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_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_ignore_effect.cmi test/bs_ignore_effect.cmj test/bs_ignore_test.cmi test/bs_ignore_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_rest_test.cmi test/bs_rest_test.cmj test/bs_set_int_test.cmi test/bs_set_int_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/caml_compare_bigint_test.cmi test/caml_compare_bigint_test.cmj test/caml_compare_test.cmi test/caml_compare_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_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_projector_test.cmi test/derive_projector_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/exotic_labels_test.cmi test/exotic_labels_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_pervasives_test.cmi test/ext_pervasives_test.cmj test/extensible_variant_test.cmi test/extensible_variant_test.cmj test/external_ppx.cmi test/external_ppx.cmj test/external_ppx2.cmi test/external_ppx2.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_record.cmi test/float_record.cmj test/float_test.cmi test/float_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/fun_pattern_match.cmi test/fun_pattern_match.cmj test/function_directives.cmi test/function_directives.cmj test/function_directives_no_inline.cmi test/function_directives_no_inline.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/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_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_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_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_5557.cmi test/gpr_5557.cmj test/gpr_5753.cmi test/gpr_5753.cmj test/gpr_658.cmi test/gpr_658.cmj test/gpr_7012_test.cmi test/gpr_7012_test.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/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/hello.foo.cmi test/hello.foo.cmj test/hello_res.cmi test/hello_res.cmj test/ignore_test.cmi test/ignore_test.cmj test/ignore_uncurry_attribute.cmi test/ignore_uncurry_attribute.cmj test/import2.cmi test/import2.cmj test/import_external.cmi test/import_external.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/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/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_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_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/keep_uncurry_attribute.cmi test/keep_uncurry_attribute.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/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/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/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_assert.cmi test/node_assert.cmj test/node_path_test.cmi test/node_path_test.cmj test/node_test.cmi test/node_test.cmj test/node_test_util.cmi test/node_test_util.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/offset.cmi test/offset.cmj test/omit_trailing_undefined_in_external_calls.cmi test/omit_trailing_undefined_in_external_calls.cmj test/option_encoding_test.cmi test/option_encoding_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/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/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/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/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/string_bound_get_test.cmi test/string_bound_get_test.cmj test/string_constant_compare.cmi test/string_constant_compare.cmj test/string_set.cmi test/string_set.cmj test/string_set_test.cmi test/string_set_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/tagged_template_test.cmi test/tagged_template_test.cmj test/tailcall_inline_test.cmi test/tailcall_inline_test.cmj test/template.cmi test/template.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_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_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_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_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_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_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_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_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-coercion-free-vars.cmi test/type-coercion-free-vars.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_regression_test.cmi test/undef_regression_test.cmj test/unit_undefined_test.cmi test/unit_undefined_test.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/AsInUncurriedExternals.cmi test/AsInUncurriedExternals.cmj test/Coercion.cmi test/Coercion.cmj test/DerivingAccessorsCurried.cmi test/DerivingAccessorsCurried.cmj test/DerivingAccessorsUncurried.cmi test/DerivingAccessorsUncurried.cmj test/DictInference.cmi test/DictInference.cmj test/DictTests.cmi test/DictTests.cmj test/DisambiguateOptionalFields.cmi test/DisambiguateOptionalFields.cmj test/DotDotDot.cmi test/DotDotDot.cmj test/EmptyRecord.cmi test/EmptyRecord.cmj test/ExternalArity.cmi test/ExternalArity.cmj test/FFI.cmi test/FFI.cmj test/Import.cmi test/Import.cmj test/ImportAttributes.cmi test/ImportAttributes.cmj test/PartialApplicationNoRuntimeCurry.cmi test/PartialApplicationNoRuntimeCurry.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_recursive_type.cmi test/a_recursive_type.cmj test/a_scope_bug.cmi test/a_scope_bug.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/ari_regress_test.cmi test/ari_regress_test.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/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_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_float_ntest.cmi test/belt_float_ntest.cmj test/belt_hashmap_ntest.cmi test/belt_hashmap_ntest.cmj test/belt_hashset_int_ntest.cmi test/belt_hashset_int_ntest.cmj test/belt_int_ntest.cmi test/belt_int_ntest.cmj test/belt_internal_test.cmi test/belt_internal_test.cmj test/belt_list_ntest.cmi test/belt_list_ntest.cmj test/belt_mapint_ntest.cmi test/belt_mapint_ntest.cmj test/belt_result_alias_test.cmi test/belt_result_alias_test.cmj test/belt_sortarray_ntest.cmi test/belt_sortarray_ntest.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/bigint_test.cmi test/bigint_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_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_ignore_effect.cmi test/bs_ignore_effect.cmj test/bs_ignore_test.cmi test/bs_ignore_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_rest_test.cmi test/bs_rest_test.cmj test/bs_set_int_test.cmi test/bs_set_int_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/caml_compare_bigint_test.cmi test/caml_compare_bigint_test.cmj test/caml_compare_test.cmi test/caml_compare_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_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_projector_test.cmi test/derive_projector_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/exotic_labels_test.cmi test/exotic_labels_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_pervasives_test.cmi test/ext_pervasives_test.cmj test/extensible_variant_test.cmi test/extensible_variant_test.cmj test/external_ppx.cmi test/external_ppx.cmj test/external_ppx2.cmi test/external_ppx2.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_record.cmi test/float_record.cmj test/float_test.cmi test/float_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/fun_pattern_match.cmi test/fun_pattern_match.cmj test/function_directives.cmi test/function_directives.cmj test/function_directives_no_inline.cmi test/function_directives_no_inline.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/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_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_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_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_5557.cmi test/gpr_5557.cmj test/gpr_5753.cmi test/gpr_5753.cmj test/gpr_658.cmi test/gpr_658.cmj test/gpr_7012_test.cmi test/gpr_7012_test.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/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/hello.foo.cmi test/hello.foo.cmj test/hello_res.cmi test/hello_res.cmj test/ignore_test.cmi test/ignore_test.cmj test/ignore_uncurry_attribute.cmi test/ignore_uncurry_attribute.cmj test/import2.cmi test/import2.cmj test/import_external.cmi test/import_external.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/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/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_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_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/keep_uncurry_attribute.cmi test/keep_uncurry_attribute.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/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/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/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_assert.cmi test/node_assert.cmj test/node_path_test.cmi test/node_path_test.cmj test/node_test.cmi test/node_test.cmj test/node_test_util.cmi test/node_test_util.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/offset.cmi test/offset.cmj test/omit_trailing_undefined_in_external_calls.cmi test/omit_trailing_undefined_in_external_calls.cmj test/option_encoding_test.cmi test/option_encoding_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/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/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/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/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/string_bound_get_test.cmi test/string_bound_get_test.cmj test/string_constant_compare.cmi test/string_constant_compare.cmj test/string_set.cmi test/string_set.cmj test/string_set_test.cmi test/string_set_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/tagged_template_test.cmi test/tagged_template_test.cmj test/tailcall_inline_test.cmi test/tailcall_inline_test.cmj test/template.cmi test/template.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_bool_equal.cmi test/test_bool_equal.cmj test/test_bs_this.cmi test/test_bs_this.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_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_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_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_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_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_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_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-coercion-free-vars.cmi test/type-coercion-free-vars.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_regression_test.cmi test/undef_regression_test.cmj test/unit_undefined_test.cmi test/unit_undefined_test.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/chn_test.js b/jscomp/test/chn_test.js index 95eff44b8c2..7c9d9cb8e9d 100644 --- a/jscomp/test/chn_test.js +++ b/jscomp/test/chn_test.js @@ -2,7 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); -let $$Array = require("../../lib/js/array.js"); +let Belt_List = require("../../lib/js/belt_List.js"); let Primitive_string = require("../../lib/js/primitive_string.js"); let suites = { @@ -33,7 +33,7 @@ console.log("你好,\n世界"); console.log("\x3f\u003f\b\t\n\v\f\r\0\"'"); function convert(s) { - return $$Array.to_list(Array.from(s, x => { + return Belt_List.fromArray(Array.from(s, x => { let x$1 = x.codePointAt(0); if (x$1 !== undefined) { return x$1; @@ -43,7 +43,7 @@ function convert(s) { RE_EXN_ID: "Assert_failure", _1: [ "chn_test.res", - 21, + 23, 16 ] } @@ -51,9 +51,9 @@ function convert(s) { })); } -eq("File \"chn_test.res\", line 29, characters 4-11", "你好,\n世界", "你好,\n世界"); +eq("File \"chn_test.res\", line 31, characters 4-11", "你好,\n世界", "你好,\n世界"); -eq("File \"chn_test.res\", line 35, characters 4-11", convert("汉字是世界上最美丽的character"), { +eq("File \"chn_test.res\", line 37, characters 4-11", convert("汉字是世界上最美丽的character"), { hd: 27721, tl: { hd: 23383, @@ -112,7 +112,7 @@ eq("File \"chn_test.res\", line 35, characters 4-11", convert("汉字是世界 } }); -eq("File \"chn_test.res\", line 59, characters 5-12", convert("\x3f\x3fa"), { +eq("File \"chn_test.res\", line 61, characters 5-12", convert("\x3f\x3fa"), { hd: 63, tl: { hd: 63, @@ -123,7 +123,7 @@ eq("File \"chn_test.res\", line 59, characters 5-12", convert("\x3f\x3fa"), { } }); -eq("File \"chn_test.res\", line 60, characters 5-12", convert("??a"), { +eq("File \"chn_test.res\", line 62, characters 5-12", convert("??a"), { hd: 63, tl: { hd: 63, @@ -134,7 +134,7 @@ eq("File \"chn_test.res\", line 60, characters 5-12", convert("??a"), { } }); -eq("File \"chn_test.res\", line 61, characters 5-12", convert("\u003f\x3fa"), { +eq("File \"chn_test.res\", line 63, characters 5-12", convert("\u003f\x3fa"), { hd: 63, tl: { hd: 63, @@ -145,7 +145,7 @@ eq("File \"chn_test.res\", line 61, characters 5-12", convert("\u003f\x3fa"), { } }); -eq("File \"chn_test.res\", line 62, characters 5-12", convert("🚀🚀a"), { +eq("File \"chn_test.res\", line 64, characters 5-12", convert("🚀🚀a"), { hd: 128640, tl: { hd: 128640, @@ -156,7 +156,7 @@ eq("File \"chn_test.res\", line 62, characters 5-12", convert("🚀🚀a"), { } }); -eq("File \"chn_test.res\", line 63, characters 5-12", convert("\uD83D\uDE80a"), { +eq("File \"chn_test.res\", line 65, characters 5-12", convert("\uD83D\uDE80a"), { hd: 128640, tl: { hd: 97, @@ -164,7 +164,7 @@ eq("File \"chn_test.res\", line 63, characters 5-12", convert("\uD83D\uDE80a"), } }); -eq("File \"chn_test.res\", line 64, characters 5-12", convert("\uD83D\uDE80\x3f"), { +eq("File \"chn_test.res\", line 66, characters 5-12", convert("\uD83D\uDE80\x3f"), { hd: 128640, tl: { hd: 63, @@ -172,7 +172,7 @@ eq("File \"chn_test.res\", line 64, characters 5-12", convert("\uD83D\uDE80\x3f" } }); -eq("File \"chn_test.res\", line 68, characters 5-12", convert("\uD83D\uDE80\uD83D\uDE80a"), { +eq("File \"chn_test.res\", line 70, characters 5-12", convert("\uD83D\uDE80\uD83D\uDE80a"), { hd: 128640, tl: { hd: 128640, @@ -185,16 +185,16 @@ eq("File \"chn_test.res\", line 68, characters 5-12", convert("\uD83D\uDE80\uD83 eq("No inline string length", "\uD83D\uDE80\0".length, 3); -eq("File \"chn_test.res\", line 75, characters 4-11", Primitive_string.get("\uD83D\uDE80\0", 0), 128640); +eq("File \"chn_test.res\", line 77, characters 4-11", Primitive_string.get("\uD83D\uDE80\0", 0), 128640); -eq("File \"chn_test.res\", line 80, characters 5-12", Primitive_string.get("🚀", 0), 128640); +eq("File \"chn_test.res\", line 82, characters 5-12", Primitive_string.get("🚀", 0), 128640); -eq("File \"chn_test.res\", line 85, characters 5-12", convert("\uD83D\uDE80"), { +eq("File \"chn_test.res\", line 87, characters 5-12", convert("\uD83D\uDE80"), { hd: 128640, tl: /* [] */0 }); -eq("File \"chn_test.res\", line 86, characters 5-12", convert("\uD83D\uDE80\uD83D\uDE80"), { +eq("File \"chn_test.res\", line 88, characters 5-12", convert("\uD83D\uDE80\uD83D\uDE80"), { hd: 128640, tl: { hd: 128640, @@ -202,7 +202,7 @@ eq("File \"chn_test.res\", line 86, characters 5-12", convert("\uD83D\uDE80\uD83 } }); -eq("File \"chn_test.res\", line 87, characters 5-12", convert(" \b\t\n\v\f\ra"), { +eq("File \"chn_test.res\", line 89, characters 5-12", convert(" \b\t\n\v\f\ra"), { hd: 32, tl: { hd: 8, @@ -228,7 +228,7 @@ eq("File \"chn_test.res\", line 87, characters 5-12", convert(" \b\t\n\v\f\ra"), } }); -eq("File \"chn_test.res\", line 93, characters 5-12", convert(" \b\t\n\v\f\r\"'\\\0a"), { +eq("File \"chn_test.res\", line 95, characters 5-12", convert(" \b\t\n\v\f\r\"'\\\0a"), { hd: 32, tl: { hd: 8, diff --git a/jscomp/test/chn_test.res b/jscomp/test/chn_test.res index 4d882a15fa6..9e9b7432454 100644 --- a/jscomp/test/chn_test.res +++ b/jscomp/test/chn_test.res @@ -1,3 +1,5 @@ +open Belt + let suites: ref = ref(list{}) let test_id = ref(0) let eq = (loc, x, y) => { @@ -15,7 +17,7 @@ Js.log(`你好, Js.log(`\x3f\u003f\b\t\n\v\f\r\0"'`) let convert = (s: string): list => - Array.to_list( + List.fromArray( Js_array2.fromMap(Js_string.castToArrayLike(s), x => switch Js_string2.codePointAt(x, 0) { | None => assert(false) diff --git a/jscomp/test/const_block_test.js b/jscomp/test/const_block_test.js index bbe5d66ae15..8710e9f35ab 100644 --- a/jscomp/test/const_block_test.js +++ b/jscomp/test/const_block_test.js @@ -2,7 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); -let Caml_array = require("../../lib/js/caml_array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); let a = [ 0, @@ -26,8 +26,8 @@ let c = [ ]; function f() { - Caml_array.set(a, 0, 3.0); - Caml_array.set(b, 0, 3); + Primitive_array.set(a, 0, 3.0); + Primitive_array.set(b, 0, 3); } function h() { @@ -39,8 +39,8 @@ function g() { return { TAG: "Eq", _0: [ - Caml_array.get(a, 0), - Caml_array.get(b, 0) + Primitive_array.get(a, 0), + Primitive_array.get(b, 0) ], _1: [ 3.0, @@ -58,8 +58,8 @@ let suites_1 = { hd: [ "avoid_mutable_inline_test", () => { - Caml_array.set(c, 0, 3); - Caml_array.set(c, 1, 4); + Primitive_array.set(c, 0, 3); + Primitive_array.set(c, 1, 4); return { TAG: "Eq", _0: [ diff --git a/jscomp/test/cps_test.js b/jscomp/test/cps_test.js index 89b9d6eb947..15eb645e43a 100644 --- a/jscomp/test/cps_test.js +++ b/jscomp/test/cps_test.js @@ -2,8 +2,8 @@ 'use strict'; let Mt = require("./mt.js"); -let $$Array = require("../../lib/js/array.js"); -let Caml_array = require("../../lib/js/caml_array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); function test() { let v = { @@ -32,13 +32,13 @@ function test_closure() { let v = { contents: 0 }; - let arr = Caml_array.make(6, x => x); + let arr = Belt_Array.make(6, x => x); for (let i = 0; i <= 5; ++i) { - Caml_array.set(arr, i, param => i); + Primitive_array.set(arr, i, param => i); } - $$Array.iter(i => { + Belt_Array.forEach(arr, i => { v.contents = v.contents + i(0) | 0; - }, arr); + }); return v.contents; } @@ -46,14 +46,14 @@ function test_closure2() { let v = { contents: 0 }; - let arr = Caml_array.make(6, x => x); + let arr = Belt_Array.make(6, x => x); for (let i = 0; i <= 5; ++i) { let j = i + i | 0; - Caml_array.set(arr, i, param => j); + Primitive_array.set(arr, i, param => j); } - $$Array.iter(i => { + Belt_Array.forEach(arr, i => { v.contents = v.contents + i(0) | 0; - }, arr); + }); return v.contents; } diff --git a/jscomp/test/cps_test.res b/jscomp/test/cps_test.res index 4c4ee709403..e02732305bc 100644 --- a/jscomp/test/cps_test.res +++ b/jscomp/test/cps_test.res @@ -1,3 +1,5 @@ +open Belt + let test = () => { let v = ref(0) let rec f = (n, acc) => @@ -20,7 +22,7 @@ let test_closure = () => { for i in 0 to n - 1 { arr[i] = _ => i } - Array.iter(i => v := v.contents + i(0), arr) + arr->Array.forEach(i => v := v.contents + i(0)) v.contents } @@ -32,7 +34,7 @@ let test_closure2 = () => { let j = i + i arr[i] = _ => j } - Array.iter(i => v := v.contents + i(0), arr) + arr->Array.forEach(i => v := v.contents + i(0)) v.contents } diff --git a/jscomp/test/earger_curry_test.js b/jscomp/test/earger_curry_test.js index 1a23013b447..c533e6a3137 100644 --- a/jscomp/test/earger_curry_test.js +++ b/jscomp/test/earger_curry_test.js @@ -2,7 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); -let Caml_array = require("../../lib/js/caml_array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); function map(f, a) { let f$1 = x => f(x); @@ -10,7 +10,7 @@ function map(f, a) { if (l === 0) { return []; } - let r = Caml_array.make(l, f$1(a[0])); + let r = Belt_Array.make(l, f$1(a[0])); for (let i = 1; i < l; ++i) { r[i] = f$1(a[i]); } @@ -30,7 +30,7 @@ function init(l, f) { } }); } - let res = Caml_array.make(l, f$1(0)); + let res = Belt_Array.make(l, f$1(0)); for (let i = 1; i < l; ++i) { res[i] = f$1(i); } @@ -47,9 +47,9 @@ function fold_left(f, x, a) { } function f2() { - let arr = init(30000000, i => i); - let b = map(i => i + i - 1, arr); - let v = fold_left((prim0, prim1) => prim0 + prim1, 0, b); + let arr = Belt_Array.init(30000000, i => i); + let b = Belt_Array.map(arr, i => i + i - 1); + let v = Belt_Array.reduceReverse(b, 0, (prim0, prim1) => prim0 + prim1); console.log(v.toString()); } @@ -122,15 +122,15 @@ let c = g(0)(3, 4); let d = g(0)(3, 5); -eq("File \"earger_curry_test.res\", line 145, characters 5-12", a, 10); +eq("File \"earger_curry_test.res\", line 148, characters 5-12", a, 10); -eq("File \"earger_curry_test.res\", line 146, characters 5-12", b, 11); +eq("File \"earger_curry_test.res\", line 149, characters 5-12", b, 11); -eq("File \"earger_curry_test.res\", line 147, characters 5-12", c, 10); +eq("File \"earger_curry_test.res\", line 150, characters 5-12", c, 10); -eq("File \"earger_curry_test.res\", line 148, characters 5-12", d, 11); +eq("File \"earger_curry_test.res\", line 151, characters 5-12", d, 11); -eq("File \"earger_curry_test.res\", line 149, characters 5-12", all_v.contents, { +eq("File \"earger_curry_test.res\", line 152, characters 5-12", all_v.contents, { hd: 8, tl: { hd: 6, diff --git a/jscomp/test/earger_curry_test.res b/jscomp/test/earger_curry_test.res index e9de6114f57..1f06624f6f7 100644 --- a/jscomp/test/earger_curry_test.res +++ b/jscomp/test/earger_curry_test.res @@ -1,3 +1,5 @@ +open Belt + let f = g => x => g(x) let map = (f, a) => { @@ -5,9 +7,9 @@ let map = (f, a) => { if l == 0 { [] } else { - let r = Array.make(l, f(Array.unsafe_get(a, 0))) + let r = Array.make(l, f(Array.getUnsafe(a, 0))) for i in 1 to l - 1 { - Array.unsafe_set(r, i, f(Array.unsafe_get(a, i))) + Array.setUnsafe(r, i, f(Array.getUnsafe(a, i))) } r } @@ -26,7 +28,7 @@ let init = (l, f) => let res = Array.make(l, f(0)) for i in 1 to pred(l) { - Array.unsafe_set(res, i, f(i)) + Array.setUnsafe(res, i, f(i)) } res } @@ -36,7 +38,7 @@ let init = (l, f) => init(l, x => f(x)) let fold_left = (f, x, a) => { let r = ref(x) for i in 0 to Array.length(a) - 1 { - r := f(r.contents, Array.unsafe_get(a, i)) + r := f(r.contents, Array.getUnsafe(a, i)) } r.contents } @@ -51,16 +53,17 @@ let f = { open Array () => { let arr = init(10000000, i => float_of_int(i)) - let b = map(i => i +. i -. 1., arr) - let v = fold_left(\"+.", 0., b) + let b = arr->map(i => i +. i -. 1.) + let v = b->reduceReverse(0., \"+.") v->Js.Float.toString->Js.log } } let f2 = () => { + open Array let arr = init(30_000_000, i => float_of_int(i)) - let b = map(i => i +. i -. 1., arr) - let v = fold_left(\"+.", 0., b) + let b = arr->map(i => i +. i -. 1.) + let v = b->reduceReverse(0., \"+.") v->Js.Float.toString->Js.log } diff --git a/jscomp/test/ext_array_test.js b/jscomp/test/ext_array_test.js index 7c824a62e79..ccf3df1334a 100644 --- a/jscomp/test/ext_array_test.js +++ b/jscomp/test/ext_array_test.js @@ -1,9 +1,8 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let List = require("../../lib/js/list.js"); -let $$Array = require("../../lib/js/array.js"); -let Caml_array = require("../../lib/js/caml_array.js"); +let Belt_List = require("../../lib/js/belt_List.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); let Caml_option = require("../../lib/js/caml_option.js"); function reverse_range(a, i, len) { @@ -26,7 +25,7 @@ function reverse(a) { if (b_len === 0) { return []; } - let b = $$Array.copy(a); + let b = a.slice(0); for (let i = 0; i < b_len; ++i) { b[i] = a[(b_len - 1 | 0) - i | 0]; } @@ -37,8 +36,8 @@ function reverse_of_list(x) { if (!x) { return []; } - let len = List.length(x); - let a = Caml_array.make(len, x.hd); + let len = Belt_List.length(x); + let a = Belt_Array.make(len, x.hd); let _i = 0; let _x = x.tl; while (true) { @@ -112,7 +111,7 @@ function range(from, to_) { } }); } - return $$Array.init((to_ - from | 0) + 1 | 0, i => i + from | 0); + return Belt_Array.init((to_ - from | 0) + 1 | 0, i => i + from | 0); } function map2i(f, a, b) { @@ -125,7 +124,7 @@ function map2i(f, a, b) { } }); } - return $$Array.mapi((i, a) => f(i, a, b[i]), a); + return Belt_Array.mapWithIndex(a, (i, a) => f(i, a, b[i])); } function tolist_aux(a, f, _i, _res) { @@ -160,8 +159,8 @@ function of_list_map(f, a) { } let tl = a.tl; let hd = f(a.hd); - let len = List.length(tl) + 1 | 0; - let arr = Caml_array.make(len, hd); + let len = Belt_List.length(tl) + 1 | 0; + let arr = Belt_Array.make(len, hd); let _i = 1; let _x = tl; while (true) { @@ -201,8 +200,8 @@ function rfind_and_split(arr, cmp, v) { return { NAME: "Split", VAL: [ - $$Array.sub(arr, 0, i), - $$Array.sub(arr, i + 1 | 0, (arr.length - i | 0) - 1 | 0) + Belt_Array.slice(arr, 0, i), + Belt_Array.slice(arr, i + 1 | 0, (arr.length - i | 0) - 1 | 0) ] }; } @@ -232,8 +231,8 @@ function find_and_split(arr, cmp, v) { return { NAME: "Split", VAL: [ - $$Array.sub(arr, 0, i), - $$Array.sub(arr, i + 1 | 0, (arr.length - i | 0) - 1 | 0) + Belt_Array.slice(arr, 0, i), + Belt_Array.slice(arr, i + 1 | 0, (arr.length - i | 0) - 1 | 0) ] }; } diff --git a/jscomp/test/ext_array_test.res b/jscomp/test/ext_array_test.res index 53a71e38947..c2fbe5e4f93 100644 --- a/jscomp/test/ext_array_test.res +++ b/jscomp/test/ext_array_test.res @@ -22,14 +22,16 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +open Belt + let reverse_range = (a, i, len) => if len == 0 { () } else { for k in 0 to (len - 1) / 2 { - let t = Array.unsafe_get(a, i + k) - Array.unsafe_set(a, i + k, Array.unsafe_get(a, i + len - 1 - k)) - Array.unsafe_set(a, i + len - 1 - k, t) + let t = Array.getUnsafe(a, i + k) + Array.setUnsafe(a, i + k, Array.getUnsafe(a, i + len - 1 - k)) + Array.setUnsafe(a, i + len - 1 - k, t) } } @@ -42,7 +44,7 @@ let reverse = a => { } else { let b = Array.copy(a) for i in 0 to b_len - 1 { - Array.unsafe_set(b, i, Array.unsafe_get(a, b_len - 1 - i)) + Array.setUnsafe(b, i, Array.getUnsafe(a, b_len - 1 - i)) } b } @@ -58,7 +60,7 @@ let reverse_of_list = x => switch x { | list{} => a | list{hd, ...tl} => - Array.unsafe_set(a, len - i - 2, hd) + Array.setUnsafe(a, len - i - 2, hd) fill(i + 1, tl) } fill(0, tl) @@ -70,7 +72,7 @@ let filter = (f, a) => { if i == arr_len { reverse_of_list(acc) } else { - let v = Array.unsafe_get(a, i) + let v = Array.getUnsafe(a, i) if f(v) { aux(list{v, ...acc}, i + 1) } else { @@ -86,7 +88,7 @@ let filter_map = (f: _ => option<_>, a) => { if i == arr_len { reverse_of_list(acc) } else { - let v = Array.unsafe_get(a, i) + let v = Array.getUnsafe(a, i) switch f(v) { | Some(v) => aux(list{v, ...acc}, i + 1) | None => aux(acc, i + 1) @@ -107,7 +109,7 @@ let map2i = (f, a, b) => { if len != Array.length(b) { invalid_arg("Ext_array_test.map2i") } else { - Array.mapi((i, a) => f(i, a, Array.unsafe_get(b, i)), a) + a->Array.mapWithIndex((i, a) => f(i, a, Array.getUnsafe(b, i))) } } @@ -115,7 +117,7 @@ let rec tolist_aux = (a, f, i, res) => if i < 0 { res } else { - let v = Array.unsafe_get(a, i) + let v = Array.getUnsafe(a, i) tolist_aux( a, f, @@ -143,7 +145,7 @@ let of_list_map = (f, a) => switch x { | list{} => arr | list{hd, ...tl} => - Array.unsafe_set(arr, i, f(hd)) + Array.setUnsafe(arr, i, f(hd)) fill(i + 1, tl) } fill(1, tl) @@ -166,7 +168,7 @@ let rfind_with_index = (arr, cmp, v) => { let rec aux = i => if i < 0 { i - } else if cmp(Array.unsafe_get(arr, i), v) { + } else if cmp(Array.getUnsafe(arr, i), v) { i } else { aux(i - 1) @@ -180,7 +182,10 @@ let rfind_and_split = (arr, cmp, v): split<_> => { if i < 0 { #No_split } else { - #Split(Array.sub(arr, 0, i), Array.sub(arr, i + 1, Array.length(arr) - i - 1)) + #Split( + Array.slice(arr, ~offset=0, ~len=i), + Array.slice(arr, ~offset=i + 1, ~len=Array.length(arr) - i - 1), + ) } } @@ -189,7 +194,7 @@ let find_with_index = (arr, cmp, v) => { let rec aux = (i, len) => if i >= len { -1 - } else if cmp(Array.unsafe_get(arr, i), v) { + } else if cmp(Array.getUnsafe(arr, i), v) { i } else { aux(i + 1, len) @@ -202,18 +207,19 @@ let find_and_split = (arr, cmp, v): split<_> => { if i < 0 { #No_split } else { - #Split(Array.sub(arr, 0, i), Array.sub(arr, i + 1, Array.length(arr) - i - 1)) + #Split( + Array.slice(arr, ~offset=0, ~len=i), + Array.slice(arr, ~offset=i + 1, ~len=Array.length(arr) - i - 1), + ) } } -/* TODO: available since 4.03, use {!Array.exists} */ - let exists = (p, a) => { let n = Array.length(a) let rec loop = i => if i == n { false - } else if p(Array.unsafe_get(a, i)) { + } else if p(Array.getUnsafe(a, i)) { true } else { loop(succ(i)) @@ -227,7 +233,7 @@ let rec unsafe_loop = (index, len, p, xs, ys) => if index >= len { true } else { - p(Array.unsafe_get(xs, index), Array.unsafe_get(ys, index)) && + p(Array.getUnsafe(xs, index), Array.getUnsafe(ys, index)) && unsafe_loop(succ(index), len, p, xs, ys) } diff --git a/jscomp/test/ffi_js_test.res b/jscomp/test/ffi_js_test.res index 9018b86f9d0..c47353cdb85 100644 --- a/jscomp/test/ffi_js_test.res +++ b/jscomp/test/ffi_js_test.res @@ -38,8 +38,8 @@ let same_type = ( ) let () = { - eq(__LOC__, (Array.length(Js_obj.keys(int_config)), 2)) - eq(__LOC__, (Array.length(Js_obj.keys(string_config)), 2)) + eq(__LOC__, (Belt.Array.length(Js_obj.keys(int_config)), 2)) + eq(__LOC__, (Belt.Array.length(Js_obj.keys(string_config)), 2)) } let u = ref(3) diff --git a/jscomp/test/ffi_test.res b/jscomp/test/ffi_test.res index 1bc6084b96a..fc3ef608d01 100644 --- a/jscomp/test/ffi_test.res +++ b/jscomp/test/ffi_test.res @@ -37,6 +37,6 @@ let f = () => { module Array = Int32Array let v = Array.create(32) - v[0] = 3 - v[0] + Int32Array.set(v, 0, 3) + Int32Array.get(v, 0) } diff --git a/jscomp/test/flexible_array_test.js b/jscomp/test/flexible_array_test.js index 7e932c4ae93..414c3c222f1 100644 --- a/jscomp/test/flexible_array_test.js +++ b/jscomp/test/flexible_array_test.js @@ -1,9 +1,9 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let $$Array = require("../../lib/js/array.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); -let Caml_array = require("../../lib/js/caml_array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); function sub(_tr, _k) { while (true) { @@ -277,7 +277,7 @@ function sort(s) { function of_array(arr) { let v = empty; for (let i = 0, i_finish = arr.length; i < i_finish; ++i) { - v = push_back(v, Caml_array.get(arr, i)); + v = push_back(v, Primitive_array.get(arr, i)); } return v; } @@ -331,9 +331,9 @@ if (!$eq$tilde(sort(u), [ }); } -let v = $$Array.init(500, i => 500 - i | 0); +let v = Belt_Array.init(500, i => 500 - i | 0); -$eq$tilde(sort(of_array(v)), $$Array.init(500, i => i + 1 | 0)); +$eq$tilde(sort(of_array(v)), Belt_Array.init(500, i => i + 1 | 0)); exports.sub = sub; exports.update = update; diff --git a/jscomp/test/flexible_array_test.res b/jscomp/test/flexible_array_test.res index 4ffee6666a5..5508abf8bd7 100644 --- a/jscomp/test/flexible_array_test.res +++ b/jscomp/test/flexible_array_test.res @@ -168,7 +168,7 @@ module Int_array: { } let of_array = arr => { let v = ref(empty) - for i in 0 to Array.length(arr) - 1 { + for i in 0 to Belt.Array.length(arr) - 1 { v := push_back(v.contents, arr[i]) } v.contents @@ -183,6 +183,6 @@ let _ = { let u = Int_array.of_array([1, 2, 2, 5, 3, 6]) assert(\"=~"(Int_array.sort(u), [1, 2, 2, 3, 5, 6])) let len = 500 - let v = Array.init(len, i => len - i) - \"=~"(Int_array.sort(Int_array.of_array(v)), Array.init(len, i => i + 1)) + let v = Belt.Array.init(len, i => len - i) + \"=~"(Int_array.sort(Int_array.of_array(v)), Belt.Array.init(len, i => i + 1)) } diff --git a/jscomp/test/float_test.js b/jscomp/test/float_test.js index 95ed08a8bd2..76b252af406 100644 --- a/jscomp/test/float_test.js +++ b/jscomp/test/float_test.js @@ -2,9 +2,10 @@ 'use strict'; let Mt = require("./mt.js"); -let $$Array = require("../../lib/js/array.js"); let Caml_obj = require("../../lib/js/caml_obj.js"); +let Belt_List = require("../../lib/js/belt_List.js"); let Mt_global = require("./mt_global.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); let Pervasives = require("../../lib/js/pervasives.js"); let Primitive_float = require("../../lib/js/primitive_float.js"); @@ -30,7 +31,7 @@ let match$1 = Primitive_float.frexp_float(0); let match$2 = Primitive_float.frexp_float(-12.0); -let results = $$Array.append([ +let results = Belt_Array.concat([ [ Math.log10(2), 0.301029995663981198 @@ -111,7 +112,7 @@ let results = $$Array.append([ ]); function from_pairs(ps) { - return $$Array.to_list($$Array.mapi((i, param) => { + return Belt_List.fromArray(Belt_Array.mapWithIndex(ps, (i, param) => { let b = param[1]; let a = param[0]; return [ @@ -122,7 +123,7 @@ function from_pairs(ps) { _1: b }) ]; - }, ps)); + })); } let float_compare = Primitive_float.compare; @@ -165,16 +166,16 @@ function float_greaterequal(x, y) { let generic_greaterequal = Caml_obj.greaterequal; -eq("File \"float_test.res\", line 55, characters 5-12", Pervasives.classify_float(3), "FP_normal"); +eq("File \"float_test.res\", line 59, characters 5-12", Pervasives.classify_float(3), "FP_normal"); -eq("File \"float_test.res\", line 56, characters 5-12", Primitive_float.modf_float(-3.125), [ +eq("File \"float_test.res\", line 60, characters 5-12", Primitive_float.modf_float(-3.125), [ -0.125, -3 ]); let match$3 = Primitive_float.modf_float(Number.NaN); -eq("File \"float_test.res\", line 58, characters 4-11", [ +eq("File \"float_test.res\", line 62, characters 4-11", [ Number.isNaN(match$3[0]), Number.isNaN(match$3[1]) ], [ @@ -182,15 +183,11 @@ eq("File \"float_test.res\", line 58, characters 4-11", [ true ]); -eq("File \"float_test.res\", line 66, characters 5-12", $$Array.map(x => { - if (x > 0) { - return 1; - } else if (x < 0) { - return -1; - } else { - return 0; - } -}, $$Array.map(param => Primitive_float.compare(param[0], param[1]), [ +eq("File \"float_test.res\", line 71, characters 4-11", [ + -1, + 1, + 1 +], Belt_Array.map(Belt_Array.map([ [ 1, 3 @@ -203,107 +200,111 @@ eq("File \"float_test.res\", line 66, characters 5-12", $$Array.map(x => { 3, 2 ] -])), [ - -1, - 1, - 1 -]); +], param => Primitive_float.compare(param[0], param[1])), x => { + if (x > 0) { + return 1; + } else if (x < 0) { + return -1; + } else { + return 0; + } +})); -eq("File \"float_test.res\", line 75, characters 5-12", Primitive_float.copysign_float(-3, 0), 3); +eq("File \"float_test.res\", line 85, characters 5-12", Primitive_float.copysign_float(-3, 0), 3); -eq("File \"float_test.res\", line 76, characters 5-12", Primitive_float.copysign_float(3, 0), 3); +eq("File \"float_test.res\", line 86, characters 5-12", Primitive_float.copysign_float(3, 0), 3); -eq("File \"float_test.res\", line 77, characters 5-12", Math.log10(10), 1); +eq("File \"float_test.res\", line 87, characters 5-12", Math.log10(10), 1); -eq("File \"float_test.res\", line 78, characters 5-12", Primitive_float.expm1_float(0), 0); +eq("File \"float_test.res\", line 88, characters 5-12", Primitive_float.expm1_float(0), 0); -eq("File \"float_test.res\", line 79, characters 5-12", Number("3.0"), 3.0); +eq("File \"float_test.res\", line 89, characters 5-12", Number("3.0"), 3.0); -approx("File \"float_test.res\", line 80, characters 9-16", Primitive_float.expm1_float(2), 6.38905609893065); +approx("File \"float_test.res\", line 90, characters 9-16", Primitive_float.expm1_float(2), 6.38905609893065); -eq("File \"float_test.res\", line 81, characters 5-12", Primitive_float.compare(NaN, NaN), 0); +eq("File \"float_test.res\", line 91, characters 5-12", Primitive_float.compare(NaN, NaN), 0); -eq("File \"float_test.res\", line 82, characters 5-12", Caml_obj.compare(NaN, NaN), 0); +eq("File \"float_test.res\", line 92, characters 5-12", Caml_obj.compare(NaN, NaN), 0); -eq("File \"float_test.res\", line 83, characters 5-12", Primitive_float.compare(NaN, Pervasives.neg_infinity), -1); +eq("File \"float_test.res\", line 93, characters 5-12", Primitive_float.compare(NaN, Pervasives.neg_infinity), -1); -eq("File \"float_test.res\", line 84, characters 5-12", Caml_obj.compare(NaN, Pervasives.neg_infinity), -1); +eq("File \"float_test.res\", line 94, characters 5-12", Caml_obj.compare(NaN, Pervasives.neg_infinity), -1); -eq("File \"float_test.res\", line 85, characters 5-12", Primitive_float.compare(Pervasives.neg_infinity, NaN), 1); +eq("File \"float_test.res\", line 95, characters 5-12", Primitive_float.compare(Pervasives.neg_infinity, NaN), 1); -eq("File \"float_test.res\", line 86, characters 5-12", Caml_obj.compare(Pervasives.neg_infinity, NaN), 1); +eq("File \"float_test.res\", line 96, characters 5-12", Caml_obj.compare(Pervasives.neg_infinity, NaN), 1); -eq("File \"float_test.res\", line 87, characters 5-12", NaN === NaN, false); +eq("File \"float_test.res\", line 97, characters 5-12", NaN === NaN, false); -eq("File \"float_test.res\", line 88, characters 5-12", Caml_obj.equal(NaN, NaN), false); +eq("File \"float_test.res\", line 98, characters 5-12", Caml_obj.equal(NaN, NaN), false); -eq("File \"float_test.res\", line 89, characters 5-12", 4.2 === NaN, false); +eq("File \"float_test.res\", line 99, characters 5-12", 4.2 === NaN, false); -eq("File \"float_test.res\", line 90, characters 5-12", Caml_obj.equal(4.2, NaN), false); +eq("File \"float_test.res\", line 100, characters 5-12", Caml_obj.equal(4.2, NaN), false); -eq("File \"float_test.res\", line 91, characters 5-12", NaN === 4.2, false); +eq("File \"float_test.res\", line 101, characters 5-12", NaN === 4.2, false); -eq("File \"float_test.res\", line 92, characters 5-12", Caml_obj.equal(NaN, 4.2), false); +eq("File \"float_test.res\", line 102, characters 5-12", Caml_obj.equal(NaN, 4.2), false); -eq("File \"float_test.res\", line 93, characters 5-12", NaN !== NaN, true); +eq("File \"float_test.res\", line 103, characters 5-12", NaN !== NaN, true); -eq("File \"float_test.res\", line 94, characters 5-12", Caml_obj.notequal(NaN, NaN), true); +eq("File \"float_test.res\", line 104, characters 5-12", Caml_obj.notequal(NaN, NaN), true); -eq("File \"float_test.res\", line 95, characters 5-12", 4.2 !== NaN, true); +eq("File \"float_test.res\", line 105, characters 5-12", 4.2 !== NaN, true); -eq("File \"float_test.res\", line 96, characters 5-12", Caml_obj.notequal(4.2, NaN), true); +eq("File \"float_test.res\", line 106, characters 5-12", Caml_obj.notequal(4.2, NaN), true); -eq("File \"float_test.res\", line 97, characters 5-12", NaN !== 4.2, true); +eq("File \"float_test.res\", line 107, characters 5-12", NaN !== 4.2, true); -eq("File \"float_test.res\", line 98, characters 5-12", Caml_obj.notequal(NaN, 4.2), true); +eq("File \"float_test.res\", line 108, characters 5-12", Caml_obj.notequal(NaN, 4.2), true); -eq("File \"float_test.res\", line 99, characters 5-12", NaN < NaN, false); +eq("File \"float_test.res\", line 109, characters 5-12", NaN < NaN, false); -eq("File \"float_test.res\", line 100, characters 5-12", Caml_obj.lessthan(NaN, NaN), false); +eq("File \"float_test.res\", line 110, characters 5-12", Caml_obj.lessthan(NaN, NaN), false); -eq("File \"float_test.res\", line 101, characters 5-12", 4.2 < NaN, false); +eq("File \"float_test.res\", line 111, characters 5-12", 4.2 < NaN, false); -eq("File \"float_test.res\", line 102, characters 5-12", Caml_obj.lessthan(4.2, NaN), false); +eq("File \"float_test.res\", line 112, characters 5-12", Caml_obj.lessthan(4.2, NaN), false); -eq("File \"float_test.res\", line 103, characters 5-12", NaN < 4.2, false); +eq("File \"float_test.res\", line 113, characters 5-12", NaN < 4.2, false); -eq("File \"float_test.res\", line 104, characters 5-12", Caml_obj.lessthan(NaN, 4.2), false); +eq("File \"float_test.res\", line 114, characters 5-12", Caml_obj.lessthan(NaN, 4.2), false); -eq("File \"float_test.res\", line 105, characters 5-12", NaN > NaN, false); +eq("File \"float_test.res\", line 115, characters 5-12", NaN > NaN, false); -eq("File \"float_test.res\", line 106, characters 5-12", Caml_obj.greaterthan(NaN, NaN), false); +eq("File \"float_test.res\", line 116, characters 5-12", Caml_obj.greaterthan(NaN, NaN), false); -eq("File \"float_test.res\", line 107, characters 5-12", 4.2 > NaN, false); +eq("File \"float_test.res\", line 117, characters 5-12", 4.2 > NaN, false); -eq("File \"float_test.res\", line 108, characters 5-12", Caml_obj.greaterthan(4.2, NaN), false); +eq("File \"float_test.res\", line 118, characters 5-12", Caml_obj.greaterthan(4.2, NaN), false); -eq("File \"float_test.res\", line 109, characters 5-12", NaN > 4.2, false); +eq("File \"float_test.res\", line 119, characters 5-12", NaN > 4.2, false); -eq("File \"float_test.res\", line 110, characters 5-12", Caml_obj.greaterthan(NaN, 4.2), false); +eq("File \"float_test.res\", line 120, characters 5-12", Caml_obj.greaterthan(NaN, 4.2), false); -eq("File \"float_test.res\", line 111, characters 5-12", NaN <= NaN, false); +eq("File \"float_test.res\", line 121, characters 5-12", NaN <= NaN, false); -eq("File \"float_test.res\", line 112, characters 5-12", Caml_obj.lessequal(NaN, NaN), false); +eq("File \"float_test.res\", line 122, characters 5-12", Caml_obj.lessequal(NaN, NaN), false); -eq("File \"float_test.res\", line 113, characters 5-12", 4.2 <= NaN, false); +eq("File \"float_test.res\", line 123, characters 5-12", 4.2 <= NaN, false); -eq("File \"float_test.res\", line 114, characters 5-12", Caml_obj.lessequal(4.2, NaN), false); +eq("File \"float_test.res\", line 124, characters 5-12", Caml_obj.lessequal(4.2, NaN), false); -eq("File \"float_test.res\", line 115, characters 5-12", NaN <= 4.2, false); +eq("File \"float_test.res\", line 125, characters 5-12", NaN <= 4.2, false); -eq("File \"float_test.res\", line 116, characters 5-12", Caml_obj.lessequal(NaN, 4.2), false); +eq("File \"float_test.res\", line 126, characters 5-12", Caml_obj.lessequal(NaN, 4.2), false); -eq("File \"float_test.res\", line 117, characters 5-12", NaN >= NaN, false); +eq("File \"float_test.res\", line 127, characters 5-12", NaN >= NaN, false); -eq("File \"float_test.res\", line 118, characters 5-12", Caml_obj.greaterequal(NaN, NaN), false); +eq("File \"float_test.res\", line 128, characters 5-12", Caml_obj.greaterequal(NaN, NaN), false); -eq("File \"float_test.res\", line 119, characters 5-12", 4.2 >= NaN, false); +eq("File \"float_test.res\", line 129, characters 5-12", 4.2 >= NaN, false); -eq("File \"float_test.res\", line 120, characters 5-12", Caml_obj.greaterequal(4.2, NaN), false); +eq("File \"float_test.res\", line 130, characters 5-12", Caml_obj.greaterequal(4.2, NaN), false); -eq("File \"float_test.res\", line 121, characters 5-12", NaN >= 4.2, false); +eq("File \"float_test.res\", line 131, characters 5-12", NaN >= 4.2, false); -eq("File \"float_test.res\", line 122, characters 5-12", Caml_obj.greaterequal(NaN, 4.2), false); +eq("File \"float_test.res\", line 132, characters 5-12", Caml_obj.greaterequal(NaN, 4.2), false); let match$4 = Primitive_float.modf_float(32.3); diff --git a/jscomp/test/float_test.res b/jscomp/test/float_test.res index 0baf115b2b0..a31f1a11799 100644 --- a/jscomp/test/float_test.res +++ b/jscomp/test/float_test.res @@ -1,8 +1,10 @@ +open Belt + let (test_id, suites) = (ref(0), ref(list{})) let eq = (loc, x, y) => Mt_global.collect_eq(test_id, suites, loc, x, y) let approx = (loc, x, y) => Mt_global.collect_approx(test_id, suites, loc, x, y) -let results = Array.append( +let results = Array.concat( [ (log10(2.), 0.301029995663981198), (ldexp(1., 6), 64.) /* 1. * 2. ^ 6 */, @@ -34,7 +36,9 @@ let results = Array.append( ) let from_pairs = ps => - Array.to_list(Array.mapi((i, (a, b)) => ("pair " ++ __unsafe_cast(i), _ => Mt.Approx(a, b)), ps)) + List.fromArray( + ps->Array.mapWithIndex((i, (a, b)) => ("pair " ++ __unsafe_cast(i), _ => Mt.Approx(a, b))), + ) let float_compare = (x: float, y) => Pervasives.compare(x, y) let generic_compare = Pervasives.compare @@ -63,7 +67,12 @@ let () = { (true, true), ) /* modf nan => (nan,nan) */ - eq(__LOC__, Array.map(x => + eq( + __LOC__, + [-1, 1, 1], + [(1., 3.), (2., 1.), (3., 2.)] + ->Array.map(((x, y)) => float_compare(x, y)) + ->Array.map(x => if x > 0 { 1 } else if x < 0 { @@ -71,7 +80,8 @@ let () = { } else { 0 } - , Array.map(((x, y)) => float_compare(x, y), [(1., 3.), (2., 1.), (3., 2.)])), [-1, 1, 1]) + ), + ) eq(__LOC__, copysign(-3., 0.), 3.) eq(__LOC__, copysign(3., 0.), 3.) eq(__LOC__, log10(10.), 1.) diff --git a/jscomp/test/for_loop_test.js b/jscomp/test/for_loop_test.js index 11a546508ae..aa2e40fc746 100644 --- a/jscomp/test/for_loop_test.js +++ b/jscomp/test/for_loop_test.js @@ -1,22 +1,22 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let List = require("../../lib/js/list.js"); -let $$Array = require("../../lib/js/array.js"); -let Caml_array = require("../../lib/js/caml_array.js"); +let Belt_List = require("../../lib/js/belt_List.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); function for_3(x) { let v = { contents: 0 }; - let arr = $$Array.map(param => (() => {}), x); + let arr = Belt_Array.map(x, param => (() => {})); for (let i = 0, i_finish = x.length; i < i_finish; ++i) { let j = (i << 1); - Caml_array.set(arr, i, () => { + Primitive_array.set(arr, i, () => { v.contents = v.contents + j | 0; }); } - $$Array.iter(x => x(), arr); + Belt_Array.forEach(arr, x => x()); return v.contents; } @@ -24,15 +24,15 @@ function for_4(x) { let v = { contents: 0 }; - let arr = $$Array.map(param => (() => {}), x); + let arr = Belt_Array.map(x, param => (() => {})); for (let i = 0, i_finish = x.length; i < i_finish; ++i) { let j = (i << 1); let k = (j << 1); - Caml_array.set(arr, i, () => { + Primitive_array.set(arr, i, () => { v.contents = v.contents + k | 0; }); } - $$Array.iter(x => x(), arr); + Belt_Array.forEach(arr, x => x()); return v.contents; } @@ -40,14 +40,14 @@ function for_5(x, u) { let v = { contents: 0 }; - let arr = $$Array.map(param => (() => {}), x); + let arr = Belt_Array.map(x, param => (() => {})); for (let i = 0, i_finish = x.length; i < i_finish; ++i) { let k = Math.imul((u << 1), u); - Caml_array.set(arr, i, () => { + Primitive_array.set(arr, i, () => { v.contents = v.contents + k | 0; }); } - $$Array.iter(x => x(), arr); + Belt_Array.forEach(arr, x => x()); return v.contents; } @@ -55,7 +55,7 @@ function for_6(x, u) { let v = { contents: 0 }; - let arr = $$Array.map(param => (() => {}), x); + let arr = Belt_Array.map(x, param => (() => {})); let v4 = { contents: 0 }; @@ -73,13 +73,13 @@ function for_6(x, u) { let k = Math.imul((u << 1), u); let h = (v5.contents << 1); v2.contents = v2.contents + 1 | 0; - Caml_array.set(arr, i, () => { + Primitive_array.set(arr, i, () => { v.contents = (((((v.contents + k | 0) + v2.contents | 0) + v4.contents | 0) + v5.contents | 0) + h | 0) + u | 0; }); } inspect_3 = v2.contents; } - $$Array.iter(x => x(), arr); + Belt_Array.forEach(arr, x => x()); return [ v.contents, v4.contents, @@ -92,15 +92,15 @@ function for_7() { let v = { contents: 0 }; - let arr = Caml_array.make(21, () => {}); + let arr = Belt_Array.make(21, () => {}); for (let i = 0; i <= 6; ++i) { for (let j = 0; j <= 2; ++j) { - Caml_array.set(arr, Math.imul(i, 3) + j | 0, () => { + Primitive_array.set(arr, Math.imul(i, 3) + j | 0, () => { v.contents = (v.contents + i | 0) + j | 0; }); } } - $$Array.iter(f => f(), arr); + Belt_Array.forEach(arr, f => f()); return v.contents; } @@ -108,17 +108,17 @@ function for_8() { let v = { contents: 0 }; - let arr = Caml_array.make(21, () => {}); + let arr = Belt_Array.make(21, () => {}); for (let i = 0; i <= 6; ++i) { let k = (i << 1); for (let j = 0; j <= 2; ++j) { let h = i + j | 0; - Caml_array.set(arr, Math.imul(i, 3) + j | 0, () => { + Primitive_array.set(arr, Math.imul(i, 3) + j | 0, () => { v.contents = (((v.contents + i | 0) + j | 0) + h | 0) + k | 0; }); } } - $$Array.iter(f => f(), arr); + Belt_Array.forEach(arr, f => f()); return v.contents; } @@ -138,8 +138,8 @@ function for_9() { let vv2 = { contents: 0 }; - let arr = Caml_array.make(4, () => {}); - let arr2 = Caml_array.make(2, () => {}); + let arr = Belt_Array.make(4, () => {}); + let arr2 = Belt_Array.make(2, () => {}); for (let i = 0; i <= 1; ++i) { let v$1 = { contents: 0 @@ -148,19 +148,19 @@ function for_9() { for (let j = 0; j <= 1; ++j) { v$1.contents = v$1.contents + 1 | 0; collect(v$1.contents); - Caml_array.set(arr, (i << 1) + j | 0, () => { + Primitive_array.set(arr, (i << 1) + j | 0, () => { vv.contents = vv.contents + v$1.contents | 0; }); } - Caml_array.set(arr2, i, () => { + Primitive_array.set(arr2, i, () => { vv2.contents = vv2.contents + v$1.contents | 0; }); } - $$Array.iter(f => f(), arr); - $$Array.iter(f => f(), arr2); + Belt_Array.forEach(arr, f => f()); + Belt_Array.forEach(arr2, f => f()); return [[ vv.contents, - $$Array.of_list(List.rev(v.contents)), + Belt_List.toArray(Belt_List.reverse(v.contents)), vv2.contents ]]; } @@ -170,7 +170,7 @@ let suites_0 = [ param => ({ TAG: "Eq", _0: 90, - _1: for_3(Caml_array.make(10, 2)) + _1: for_3(Belt_Array.make(10, 2)) }) ]; @@ -180,7 +180,7 @@ let suites_1 = { param => ({ TAG: "Eq", _0: 180, - _1: for_4(Caml_array.make(10, 2)) + _1: for_4(Belt_Array.make(10, 2)) }) ], tl: { @@ -189,7 +189,7 @@ let suites_1 = { param => ({ TAG: "Eq", _0: 2420, - _1: for_5(Caml_array.make(10, 2), 11) + _1: for_5(Belt_Array.make(10, 2), 11) }) ], tl: { @@ -203,7 +203,7 @@ let suites_1 = { 2, 3 ], - _1: for_6(Caml_array.make(3, 0), 0) + _1: for_6(Belt_Array.make(3, 0), 0) }) ], tl: { diff --git a/jscomp/test/for_loop_test.res b/jscomp/test/for_loop_test.res index 89f8085f078..5590be5a979 100644 --- a/jscomp/test/for_loop_test.res +++ b/jscomp/test/for_loop_test.res @@ -1,41 +1,43 @@ +open Belt + let for_3 = x => { let v = ref(0) - let arr = Array.map(_ => _ => (), x) + let arr = x->Array.map(_ => _ => ()) for i in 0 to Array.length(x) - 1 { let j = i * 2 arr[i] = _ => v := v.contents + j } - Array.iter(x => x(), arr) + arr->Array.forEach(x => x()) v.contents } let for_4 = x => { let v = ref(0) - let arr = Array.map(_ => _ => (), x) + let arr = x->Array.map(_ => _ => ()) for i in 0 to Array.length(x) - 1 { let j = i * 2 let k = 2 * j arr[i] = _ => v := v.contents + k } - Array.iter(x => x(), arr) + arr->Array.forEach(x => x()) v.contents } let for_5 = (x, u) => { let v = ref(0) - let arr = Array.map(_ => _ => (), x) + let arr = x->Array.map(_ => _ => ()) for i in 0 to Array.length(x) - 1 { let _j = i * 2 let k = 2 * u * u arr[i] = _ => v := v.contents + k } - Array.iter(x => x(), arr) + arr->Array.forEach(x => x()) v.contents } let for_6 = (x, u) => { let v = ref(0) - let arr = Array.map(_ => _ => (), x) + let arr = x->Array.map(_ => _ => ()) let v4 = ref(0) let v5 = ref(0) let inspect_3 = ref(-1) @@ -54,7 +56,7 @@ let for_6 = (x, u) => { } inspect_3 := v2.contents } - Array.iter(x => x(), arr) + arr->Array.forEach(x => x()) [v.contents, v4.contents, v5.contents, inspect_3.contents] } @@ -68,7 +70,7 @@ let for_7 = () => { arr[i * j_len + j] = _ => v := v.contents + i + j } } - Array.iter(f => f(), arr) + arr->Array.forEach(f => f()) v.contents } @@ -84,14 +86,14 @@ let for_8 = () => { arr[i * j_len + j] = _ => v := v.contents + i + j + h + k } } - Array.iter(f => f(), arr) + arr->Array.forEach(f => f()) v.contents } let for_9 = () => { let (collect, get) = { let v: ref> = ref(list{}) - (x => v := list{x, ...v.contents}, () => \"@@"(Array.of_list, List.rev(v.contents))) + (x => v := list{x, ...v.contents}, () => \"@@"(List.toArray, List.reverse(v.contents))) } let i_len = 2 @@ -128,8 +130,8 @@ let for_9 = () => { v is changed */ } - Array.iter(f => f(), arr) - Array.iter(f => f(), arr2) + arr->Array.forEach(f => f()) + arr2->Array.forEach(f => f()) [(vv.contents, get(), vv2.contents)] } diff --git a/jscomp/test/gpr_1409_test.js b/jscomp/test/gpr_1409_test.js index 5d0ae3b5913..bee73ffcdf4 100644 --- a/jscomp/test/gpr_1409_test.js +++ b/jscomp/test/gpr_1409_test.js @@ -2,7 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); -let $$Array = require("../../lib/js/array.js"); +let Belt_List = require("../../lib/js/belt_List.js"); let String_set = require("./string_set.js"); let Caml_option = require("../../lib/js/caml_option.js"); @@ -55,13 +55,13 @@ let a_ = make(undefined, undefined); let b_ = make(42, undefined); -eq("File \"gpr_1409_test.res\", line 29, characters 3-10", b_.foo, "42"); +eq("File \"gpr_1409_test.res\", line 31, characters 3-10", b_.foo, "42"); console.log(Object.keys(a_)); console.log(a, b, a_, b_); -eq("File \"gpr_1409_test.res\", line 34, characters 3-10", Object.keys(a_).length, 0); +eq("File \"gpr_1409_test.res\", line 36, characters 3-10", Object.keys(a_).length, 0); let test2 = { hi: 2 @@ -128,15 +128,15 @@ function test6(f, x) { } function keys(xs, ys) { - return String_set.equal(String_set.of_list(xs), String_set.of_list($$Array.to_list(ys))); + return String_set.equal(String_set.of_list(xs), String_set.of_list(Belt_List.fromArray(ys))); } -eq("File \"gpr_1409_test.res\", line 72, characters 3-10", keys({ +eq("File \"gpr_1409_test.res\", line 74, characters 3-10", keys({ hd: "hi", tl: /* [] */0 }, Object.keys(test3(undefined, undefined))), true); -eq("File \"gpr_1409_test.res\", line 74, characters 3-10", keys({ +eq("File \"gpr_1409_test.res\", line 76, characters 3-10", keys({ hd: "hi", tl: { hd: "_open", @@ -144,7 +144,7 @@ eq("File \"gpr_1409_test.res\", line 74, characters 3-10", keys({ } }, Object.keys(test3(2, undefined))), true); -eq("File \"gpr_1409_test.res\", line 76, characters 3-10", keys({ +eq("File \"gpr_1409_test.res\", line 78, characters 3-10", keys({ hd: "hi", tl: { hd: "_open", diff --git a/jscomp/test/gpr_1409_test.res b/jscomp/test/gpr_1409_test.res index 09a30bf715d..52455e2eb57 100644 --- a/jscomp/test/gpr_1409_test.res +++ b/jscomp/test/gpr_1409_test.res @@ -1,3 +1,5 @@ +open Belt + let suites: ref = ref(list{}) let test_id = ref(0) let eq = (loc, x, y) => { @@ -67,7 +69,7 @@ let test6 = (f, x) => { } let keys = (xs, ys) => - String_set.equal(String_set.of_list(xs), String_set.of_list(Array.to_list(ys))) + String_set.equal(String_set.of_list(xs), String_set.of_list(List.fromArray(ys))) eq(__LOC__, keys(list{"hi"}, Js.Obj.keys(test3(None, None))), true) diff --git a/jscomp/test/gpr_3931_test.js b/jscomp/test/gpr_3931_test.js index 95a5edd04af..0edb107db2f 100644 --- a/jscomp/test/gpr_3931_test.js +++ b/jscomp/test/gpr_3931_test.js @@ -1,7 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let $$Array = require("../../lib/js/array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); let Caml_module = require("../../lib/js/caml_module.js"); let PA = Caml_module.init_mod([ @@ -29,7 +29,7 @@ let P = Caml_module.init_mod([ }); function print(a) { - $$Array.iter(P.print, a); + Belt_Array.forEach(a, P.print); } Caml_module.update_mod({ diff --git a/jscomp/test/gpr_3931_test.res b/jscomp/test/gpr_3931_test.res index 8df1a03713e..a18788f1974 100644 --- a/jscomp/test/gpr_3931_test.res +++ b/jscomp/test/gpr_3931_test.res @@ -3,7 +3,7 @@ module rec PA: { } = { /* let () = P.print 3 */ let print = { - let iter = Array.iter(P.print, ...) + let iter = Belt.Array.forEach(_, P.print) a => iter(a) } } diff --git a/jscomp/test/hash_test.js b/jscomp/test/hash_test.js index 030f6e09e9d..e5aab10f8b0 100644 --- a/jscomp/test/hash_test.js +++ b/jscomp/test/hash_test.js @@ -2,9 +2,9 @@ 'use strict'; let Mt = require("./mt.js"); -let $$Array = require("../../lib/js/array.js"); let Hashtbl = require("../../lib/js/hashtbl.js"); let Mt_global = require("./mt_global.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); let suites = { contents: /* [] */0 @@ -18,7 +18,7 @@ function eq(f, x, y) { Mt_global.collect_eq(test_id, suites, f, x, y); } -let test_strings = $$Array.init(32, i => String.fromCodePoint(i).repeat(i)); +let test_strings = Belt_Array.init(32, i => String.fromCodePoint(i).repeat(i)); let test_strings_hash_results = [ 0, @@ -63,13 +63,13 @@ function caml_hash(x) { return Hashtbl.hash(x) & 1073741823; } -eq("File \"hash_test.res\", line 44, characters 12-19", $$Array.map(caml_hash, test_strings), test_strings_hash_results); +eq("File \"hash_test.res\", line 46, characters 12-19", Belt_Array.map(test_strings, caml_hash), test_strings_hash_results); -eq("File \"hash_test.res\", line 46, characters 12-19", Hashtbl.hash(0) & 1073741823, 129913994); +eq("File \"hash_test.res\", line 48, characters 12-19", Hashtbl.hash(0) & 1073741823, 129913994); -eq("File \"hash_test.res\", line 48, characters 12-19", Hashtbl.hash("x") & 1073741823, 780510073); +eq("File \"hash_test.res\", line 50, characters 12-19", Hashtbl.hash("x") & 1073741823, 780510073); -eq("File \"hash_test.res\", line 50, characters 12-19", Hashtbl.hash("xy") & 1073741823, 194127723); +eq("File \"hash_test.res\", line 52, characters 12-19", Hashtbl.hash("xy") & 1073741823, 194127723); Mt.from_pair_suites("Hash_test", suites.contents); diff --git a/jscomp/test/hash_test.res b/jscomp/test/hash_test.res index f71007343f3..ba578bbb285 100644 --- a/jscomp/test/hash_test.res +++ b/jscomp/test/hash_test.res @@ -1,3 +1,5 @@ +open Belt + let suites: ref = ref(list{}) let test_id = ref(0) let eq = (f, x, y) => Mt_global.collect_eq(test_id, suites, f, x, y) @@ -41,7 +43,7 @@ let test_strings_hash_results = [ let normalize = x => land(x, 0x3FFFFFFF) let caml_hash = x => normalize(Hashtbl.hash(x)) -let () = eq(__LOC__, Array.map(caml_hash, test_strings), test_strings_hash_results) +let () = eq(__LOC__, test_strings->Array.map(caml_hash), test_strings_hash_results) let () = eq(__LOC__, normalize(Hashtbl.hash(0)), 129913994) diff --git a/jscomp/test/js_json_test.js b/jscomp/test/js_json_test.js index b3c9921c477..85e80fb59ec 100644 --- a/jscomp/test/js_json_test.js +++ b/jscomp/test/js_json_test.js @@ -2,13 +2,12 @@ 'use strict'; let Mt = require("./mt.js"); -let $$Array = require("../../lib/js/array.js"); let Js_dict = require("../../lib/js/js_dict.js"); let Js_json = require("../../lib/js/js_json.js"); let Belt_List = require("../../lib/js/belt_List.js"); let Belt_Array = require("../../lib/js/belt_Array.js"); -let Caml_array = require("../../lib/js/caml_array.js"); let Caml_option = require("../../lib/js/caml_option.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); let suites = { contents: /* [] */0 @@ -324,7 +323,7 @@ function eq_at_i(loc, json, i, kind, expected) { _0: false })); } - let ty$1 = Js_json.classify(Caml_array.get(ty._0, i)); + let ty$1 = Js_json.classify(Primitive_array.get(ty._0, i)); switch (kind) { case "String" : if (typeof ty$1 !== "object") { @@ -422,11 +421,11 @@ function eq_at_i(loc, json, i, kind, expected) { } } -let json$5 = JSON.parse(JSON.stringify($$Array.map(prim => prim, [ +let json$5 = JSON.parse(JSON.stringify(Belt_Array.map([ "string 0", "string 1", "string 2" -]))); +], prim => prim))); eq_at_i("File \"js_json_test.res\", line 198, characters 10-17", json$5, 0, "String", "string 0"); @@ -454,11 +453,11 @@ let a = [ let json$7 = JSON.parse(JSON.stringify(a)); -eq_at_i("File \"js_json_test.res\", line 218, characters 10-17", json$7, 0, "Number", Caml_array.get(a, 0)); +eq_at_i("File \"js_json_test.res\", line 218, characters 10-17", json$7, 0, "Number", Primitive_array.get(a, 0)); -eq_at_i("File \"js_json_test.res\", line 219, characters 10-17", json$7, 1, "Number", Caml_array.get(a, 1)); +eq_at_i("File \"js_json_test.res\", line 219, characters 10-17", json$7, 1, "Number", Primitive_array.get(a, 1)); -eq_at_i("File \"js_json_test.res\", line 220, characters 10-17", json$7, 2, "Number", Caml_array.get(a, 2)); +eq_at_i("File \"js_json_test.res\", line 220, characters 10-17", json$7, 2, "Number", Primitive_array.get(a, 2)); let a$1 = [ 0, @@ -466,13 +465,13 @@ let a$1 = [ -268391749 ]; -let json$8 = JSON.parse(JSON.stringify($$Array.map(prim => prim, a$1))); +let json$8 = JSON.parse(JSON.stringify(Belt_Array.map(a$1, prim => prim))); -eq_at_i("File \"js_json_test.res\", line 229, characters 10-17", json$8, 0, "Number", Caml_array.get(a$1, 0)); +eq_at_i("File \"js_json_test.res\", line 229, characters 10-17", json$8, 0, "Number", Primitive_array.get(a$1, 0)); -eq_at_i("File \"js_json_test.res\", line 230, characters 10-17", json$8, 1, "Number", Caml_array.get(a$1, 1)); +eq_at_i("File \"js_json_test.res\", line 230, characters 10-17", json$8, 1, "Number", Primitive_array.get(a$1, 1)); -eq_at_i("File \"js_json_test.res\", line 231, characters 10-17", json$8, 2, "Number", Caml_array.get(a$1, 2)); +eq_at_i("File \"js_json_test.res\", line 231, characters 10-17", json$8, 2, "Number", Primitive_array.get(a$1, 2)); let a$2 = [ true, @@ -482,11 +481,11 @@ let a$2 = [ let json$9 = JSON.parse(JSON.stringify(a$2)); -eq_at_i("File \"js_json_test.res\", line 240, characters 10-17", json$9, 0, "Boolean", Caml_array.get(a$2, 0)); +eq_at_i("File \"js_json_test.res\", line 240, characters 10-17", json$9, 0, "Boolean", Primitive_array.get(a$2, 0)); -eq_at_i("File \"js_json_test.res\", line 241, characters 10-17", json$9, 1, "Boolean", Caml_array.get(a$2, 1)); +eq_at_i("File \"js_json_test.res\", line 241, characters 10-17", json$9, 1, "Boolean", Primitive_array.get(a$2, 1)); -eq_at_i("File \"js_json_test.res\", line 242, characters 10-17", json$9, 2, "Boolean", Caml_array.get(a$2, 2)); +eq_at_i("File \"js_json_test.res\", line 242, characters 10-17", json$9, 2, "Boolean", Primitive_array.get(a$2, 2)); function make_d(s, i) { let d = {}; @@ -510,7 +509,7 @@ if (typeof ty$6 !== "object") { _0: false })); } else if (ty$6.TAG === "JSONArray") { - let ty$7 = Js_json.classify(Caml_array.get(ty$6._0, 1)); + let ty$7 = Js_json.classify(Primitive_array.get(ty$6._0, 1)); if (typeof ty$7 !== "object") { add_test("File \"js_json_test.res\", line 268, characters 18-25", () => ({ TAG: "Ok", diff --git a/jscomp/test/js_json_test.res b/jscomp/test/js_json_test.res index be6cf6cfd6a..58e03d5e80b 100644 --- a/jscomp/test/js_json_test.res +++ b/jscomp/test/js_json_test.res @@ -192,7 +192,7 @@ let eq_at_i = (type a, loc: string, json: J.t, i: int, kind: J.Kind.t, expect let () = { let json = J.parseExn( - J.stringify(J.array(Array.map(J.string, ["string 0", "string 1", "string 2"]))), + J.stringify(J.array(Belt.Array.map(["string 0", "string 1", "string 2"], J.string))), ) eq_at_i(__LOC__, json, 0, J.Kind.String, "string 0") @@ -223,7 +223,7 @@ let () = { let () = { let a = [0, 0xAFAFAFAF, 0xF000AABB] - let json = J.parseExn(J.stringify(J.numberArray(Array.map(float_of_int, a)))) + let json = J.parseExn(J.stringify(J.numberArray(a->Belt.Array.map(float_of_int)))) /* Loop is unrolled to keep relevant location information */ eq_at_i(__LOC__, json, 0, J.Kind.Number, float_of_int(a[0])) diff --git a/jscomp/test/js_obj_test.res b/jscomp/test/js_obj_test.res index 8787d2f3675..985ebe6fb2f 100644 --- a/jscomp/test/js_obj_test.res +++ b/jscomp/test/js_obj_test.res @@ -5,7 +5,7 @@ type x = {"say": int => int} let suites = { open Mt list{ - ("empty", _ => Eq(0, Array.length(keys(empty())))), + ("empty", _ => Eq(0, Belt.Array.length(keys(empty())))), ("assign", _ => Eq({"a": 1}, assign(empty(), {"a": 1}))), } } diff --git a/jscomp/test/js_re_test.js b/jscomp/test/js_re_test.js index 2fdc4f2d080..2cb84440f87 100644 --- a/jscomp/test/js_re_test.js +++ b/jscomp/test/js_re_test.js @@ -2,8 +2,8 @@ 'use strict'; let Mt = require("./mt.js"); -let Caml_array = require("../../lib/js/caml_array.js"); let Caml_option = require("../../lib/js/caml_option.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); let suites_0 = [ "captures", @@ -16,8 +16,8 @@ let suites_0 = [ _0: undefined }; } - let defined = Caml_array.get(result, 1); - let $$undefined = Caml_array.get(result, 2); + let defined = Primitive_array.get(result, 1); + let $$undefined = Primitive_array.get(result, 2); return { TAG: "Eq", _0: [ @@ -39,7 +39,7 @@ let suites_1 = { let contentOf = (tag, xmlString) => { let x = Caml_option.null_to_opt(new RegExp("<" + (tag + (">(.*?)<\\/" + (tag + ">")))).exec(xmlString)); if (x !== undefined) { - return Caml_option.nullable_to_opt(Caml_array.get(Caml_option.valFromOption(x), 1)); + return Caml_option.nullable_to_opt(Primitive_array.get(Caml_option.valFromOption(x), 1)); } }; @@ -59,7 +59,7 @@ let suites_1 = { return { TAG: "Eq", _0: "http://xxx", - _1: Caml_array.get(res, 0) + _1: Primitive_array.get(res, 0) }; } else { return { diff --git a/jscomp/test/list_test.js b/jscomp/test/list_test.js index ffac3925d27..ce27208264f 100644 --- a/jscomp/test/list_test.js +++ b/jscomp/test/list_test.js @@ -2,16 +2,19 @@ 'use strict'; let Mt = require("./mt.js"); -let List = require("../../lib/js/list.js"); -let $$Array = require("../../lib/js/array.js"); +let Caml_obj = require("../../lib/js/caml_obj.js"); +let Belt_List = require("../../lib/js/belt_List.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); let Primitive_int = require("../../lib/js/primitive_int.js"); +let eq = Caml_obj.equal; + let list_suites_0 = [ "length", param => ({ TAG: "Eq", _0: 1, - _1: List.length({ + _1: Belt_List.length({ hd: [ 0, 1, @@ -30,7 +33,7 @@ let list_suites_1 = { param => ({ TAG: "Eq", _0: 5, - _1: List.length({ + _1: Belt_List.length({ hd: 0, tl: { hd: 1, @@ -54,7 +57,7 @@ let list_suites_1 = { param => ({ TAG: "Eq", _0: 30000, - _1: List.length($$Array.to_list($$Array.init(30000, param => 0))) + _1: Belt_List.length(Belt_List.fromArray(Belt_Array.init(30000, param => 0))) }) ], tl: { @@ -62,7 +65,7 @@ let list_suites_1 = { "sort", param => ({ TAG: "Eq", - _0: List.sort(Primitive_int.compare, { + _0: Belt_List.sort({ hd: 4, tl: { hd: 1, @@ -74,7 +77,7 @@ let list_suites_1 = { } } } - }), + }, Primitive_int.compare), _1: { hd: 1, tl: { @@ -92,11 +95,11 @@ let list_suites_1 = { ], tl: { hd: [ - "File \"list_test.res\", line 20, characters 5-12", + "File \"list_test.res\", line 23, characters 5-12", param => ({ TAG: "Eq", _0: true, - _1: List.mem(3, { + _1: Belt_List.has({ hd: 1, tl: { hd: 2, @@ -105,16 +108,16 @@ let list_suites_1 = { tl: /* [] */0 } } - }) + }, 3, eq) }) ], tl: { hd: [ - "File \"list_test.res\", line 21, characters 5-12", + "File \"list_test.res\", line 24, characters 5-12", param => ({ TAG: "Eq", _0: false, - _1: List.mem(4, { + _1: Belt_List.has({ hd: 1, tl: { hd: 2, @@ -123,16 +126,16 @@ let list_suites_1 = { tl: /* [] */0 } } - }) + }, 4, eq) }) ], tl: { hd: [ - "File \"list_test.res\", line 22, characters 5-12", + "File \"list_test.res\", line 25, characters 5-12", param => ({ TAG: "Eq", _0: 9, - _1: List.assoc(4, { + _1: Belt_List.getAssoc({ hd: [ 1, 2 @@ -144,7 +147,7 @@ let list_suites_1 = { ], tl: /* [] */0 } - }) + }, 4, eq) }) ], tl: /* [] */0 diff --git a/jscomp/test/list_test.res b/jscomp/test/list_test.res index 1febc6413f7..2ce33df3b2a 100644 --- a/jscomp/test/list_test.res +++ b/jscomp/test/list_test.res @@ -1,5 +1,8 @@ +open Belt + let list_suites = { open Mt + let eq = (a, b) => a == b list{ ("length", _ => Eq(1, List.length(list{(0, 1, 2, 3, 4)})) /* This is tuple haha */), ("length2", _ => Eq(5, List.length(list{0, 1, 2, 3, 4})) /* This is tuple haha */), @@ -7,19 +10,19 @@ let list_suites = { "long_length", _ => { let v = 30_000 - Eq(v, List.length(Array.to_list(Array.init(v, _ => 0)))) + Eq(v, List.length(List.fromArray(Array.init(v, _ => 0)))) }, ), ( "sort", _ => Eq( - List.sort((x: int, y) => Pervasives.compare(x, y), list{4, 1, 2, 3}), + list{4, 1, 2, 3}->List.sort((x: int, y) => Pervasives.compare(x, y)), list{1, 2, 3, 4}, ), ), - (__LOC__, _ => Eq(true, List.mem(3, list{1, 2, 3}))), - (__LOC__, _ => Eq(false, List.mem(4, list{1, 2, 3}))), - (__LOC__, _ => Eq(9, List.assoc(4, list{(1, 2), (4, 9)}))), + (__LOC__, _ => Eq(true, List.has(list{1, 2, 3}, 3, eq))), + (__LOC__, _ => Eq(false, List.has(list{1, 2, 3}, 4, eq))), + (__LOC__, _ => Eq(Some(9), List.getAssoc(list{(1, 2), (4, 9)}, 4, eq))), } } diff --git a/jscomp/test/module_missing_conversion.js b/jscomp/test/module_missing_conversion.js index d3bdb1668be..e167fea675c 100644 --- a/jscomp/test/module_missing_conversion.js +++ b/jscomp/test/module_missing_conversion.js @@ -1,48 +1,97 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let $$Array = require("../../lib/js/array.js"); let $$String = require("../../lib/js/string.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); function f(x) { return x; } let XX = { - init: $$Array.init, - make_matrix: $$Array.make_matrix, - create_matrix: $$Array.create_matrix, - append: $$Array.append, - concat: $$Array.concat, - sub: $$Array.sub, - copy: $$Array.copy, - fill: $$Array.fill, - blit: $$Array.blit, - to_list: $$Array.to_list, - of_list: $$Array.of_list, - iter: $$Array.iter, - iteri: $$Array.iteri, - map: $$Array.map, - mapi: $$Array.mapi, - fold_left: $$Array.fold_left, - fold_right: $$Array.fold_right, - iter2: $$Array.iter2, - map2: $$Array.map2, - for_all: $$Array.for_all, - exists: $$Array.exists, - mem: $$Array.mem, - memq: $$Array.memq, - sort: $$Array.sort, - stable_sort: $$Array.stable_sort, - fast_sort: $$Array.fast_sort, + get: Belt_Array.get, + getExn: Belt_Array.getExn, + set: Belt_Array.set, + setExn: Belt_Array.setExn, + shuffleInPlace: Belt_Array.shuffleInPlace, + shuffle: Belt_Array.shuffle, + reverseInPlace: Belt_Array.reverseInPlace, + reverse: Belt_Array.reverse, + make: Belt_Array.make, + range: Belt_Array.range, + rangeBy: Belt_Array.rangeBy, + makeByU: Belt_Array.makeByU, + makeBy: Belt_Array.makeBy, + makeByAndShuffleU: Belt_Array.makeByAndShuffleU, + makeByAndShuffle: Belt_Array.makeByAndShuffle, + zip: Belt_Array.zip, + zipByU: Belt_Array.zipByU, + zipBy: Belt_Array.zipBy, + unzip: Belt_Array.unzip, + concat: Belt_Array.concat, + concatMany: Belt_Array.concatMany, + slice: Belt_Array.slice, + sliceToEnd: Belt_Array.sliceToEnd, + fill: Belt_Array.fill, + blit: Belt_Array.blit, + blitUnsafe: Belt_Array.blitUnsafe, + forEachU: Belt_Array.forEachU, + forEach: Belt_Array.forEach, + mapU: Belt_Array.mapU, + map: Belt_Array.map, + flatMapU: Belt_Array.flatMapU, + flatMap: Belt_Array.flatMap, + getByU: Belt_Array.getByU, + getBy: Belt_Array.getBy, + getIndexByU: Belt_Array.getIndexByU, + getIndexBy: Belt_Array.getIndexBy, + keepU: Belt_Array.keepU, + keep: Belt_Array.keep, + keepWithIndexU: Belt_Array.keepWithIndexU, + keepWithIndex: Belt_Array.keepWithIndex, + keepMapU: Belt_Array.keepMapU, + keepMap: Belt_Array.keepMap, + forEachWithIndexU: Belt_Array.forEachWithIndexU, + forEachWithIndex: Belt_Array.forEachWithIndex, + mapWithIndexU: Belt_Array.mapWithIndexU, + mapWithIndex: Belt_Array.mapWithIndex, + partitionU: Belt_Array.partitionU, + partition: Belt_Array.partition, + reduceU: Belt_Array.reduceU, + reduce: Belt_Array.reduce, + reduceReverseU: Belt_Array.reduceReverseU, + reduceReverse: Belt_Array.reduceReverse, + reduceReverse2U: Belt_Array.reduceReverse2U, + reduceReverse2: Belt_Array.reduceReverse2, + reduceWithIndexU: Belt_Array.reduceWithIndexU, + reduceWithIndex: Belt_Array.reduceWithIndex, + joinWithU: Belt_Array.joinWithU, + joinWith: Belt_Array.joinWith, + someU: Belt_Array.someU, + some: Belt_Array.some, + everyU: Belt_Array.everyU, + every: Belt_Array.every, + every2U: Belt_Array.every2U, + every2: Belt_Array.every2, + some2U: Belt_Array.some2U, + some2: Belt_Array.some2, + cmpU: Belt_Array.cmpU, + cmp: Belt_Array.cmp, + eqU: Belt_Array.eqU, + eq: Belt_Array.eq, + initU: Belt_Array.initU, + init: Belt_Array.init, f: f }; let u = [$$String]; +Primitive_array.get(u, 0); + let hh = "x".length; exports.XX = XX; exports.u = u; exports.hh = hh; -/* No side effect */ +/* Not a pure module */ diff --git a/jscomp/test/module_missing_conversion.res b/jscomp/test/module_missing_conversion.res index eb91bd2fbc5..840637ee299 100644 --- a/jscomp/test/module_missing_conversion.res +++ b/jscomp/test/module_missing_conversion.res @@ -1,7 +1,7 @@ module type S = module type of String module XX = { - include Array + include Belt.Array let f = x => x } let u = [module(String: S)] diff --git a/jscomp/test/mt.js b/jscomp/test/mt.js index 01c21b6d1b5..fb9f189cb07 100644 --- a/jscomp/test/mt.js +++ b/jscomp/test/mt.js @@ -1,18 +1,17 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let List = require("../../lib/js/list.js"); let Path = require("path"); -let $$Array = require("../../lib/js/array.js"); let Assert = require("assert"); let Process = require("process"); +let Belt_List = require("../../lib/js/belt_List.js"); function assert_fail(msg) { Assert.fail(undefined, undefined, msg, ""); } function is_mocha() { - let match = $$Array.to_list(Process.argv); + let match = Belt_List.fromArray(Process.argv); if (!match) { return false; } @@ -28,16 +27,16 @@ function is_mocha() { } } -let from_suites = (function from_suites(name, suite) { - var match = $$Array.to_list(Process.argv); +let from_suites = (function from_suites(name, suites) { + var match = Belt_List.fromArray(Process.argv); if (match && is_mocha(undefined)) { describe(name, (function () { - return List.iter((function (param) { + return Belt_List.forEach(suites, (function (param) { var partial_arg = param[1]; it(param[0], (function () { return partial_arg(undefined); })); - }), suite); + })); })); return ; } @@ -95,16 +94,16 @@ function handleCode(spec) { } let from_pair_suites = (function from_pair_suites(name, suites) { - var match = $$Array.to_list(Process.argv); + var match = Belt_List.fromArray(Process.argv); if (match) { if (is_mocha(undefined)) { describe(name, (function () { - return List.iter((function (param) { + return Belt_List.forEach(suites, (function (param) { var code = param[1]; it(param[0], (function () { return handleCode(code(undefined)); })); - }), suites); + })); })); return ; } else { @@ -112,7 +111,7 @@ let from_pair_suites = (function from_pair_suites(name, suites) { name, "testing" ]); - return List.iter((function (param) { + return Belt_List.forEach(suites, (function (param) { var name = param[0]; var fn = param[1](undefined); switch (fn.TAG) { @@ -184,7 +183,7 @@ let from_pair_suites = (function from_pair_suites(name, suites) { return ; } - }), suites); + })); } } @@ -193,11 +192,11 @@ let from_pair_suites = (function from_pair_suites(name, suites) { let val_unit = Promise.resolve(); let from_promise_suites = (function from_promise_suites(name, suites) { - var match = $$Array.to_list(Process.argv); + var match = Belt_List.fromArray(Process.argv); if (match) { if (is_mocha(undefined)) { describe(name, (function () { - return List.iter((function (param) { + return Belt_List.forEach(suites, (function (param) { var code = param[1]; it(param[0], (function () { var arg1 = function (x) { @@ -206,7 +205,7 @@ let from_promise_suites = (function from_promise_suites(name, suites) { }; return code.then(arg1); })); - }), suites); + })); })); } else { console.log("promise suites"); @@ -217,16 +216,16 @@ let from_promise_suites = (function from_promise_suites(name, suites) { }); function old_from_promise_suites_donotuse(name, suites) { - let match = $$Array.to_list(Process.argv); + let match = Belt_List.fromArray(Process.argv); if (match) { if (is_mocha()) { - describe(name, () => List.iter(param => { + describe(name, () => Belt_List.forEach(suites, param => { let code = param[1]; it(param[0], () => code.then(x => { handleCode(x); return val_unit; })); - }, suites)); + })); } else { console.log("promise suites"); } diff --git a/jscomp/test/mt.res b/jscomp/test/mt.res index 814c7ca8ffb..133a2d7faea 100644 --- a/jscomp/test/mt.res +++ b/jscomp/test/mt.res @@ -34,7 +34,7 @@ let assert_fail = msg => fail((), (), Js.Undefined.return(msg), "") @module("path") external basename: string => string = "basename" let is_mocha = () => - switch Array.to_list(argv) { + switch Belt.List.fromArray(argv) { | list{_node, mocha, ..._} => let exec = basename(mocha) exec == "mocha" || exec == "_mocha" @@ -44,16 +44,16 @@ let is_mocha = () => */ let from_suites = %raw(` -function from_suites(name, suite) { - var match = $$Array.to_list(Process.argv); +function from_suites(name, suites) { + var match = Belt_List.fromArray(Process.argv); if (match && is_mocha(undefined)) { describe(name, (function () { - return List.iter((function (param) { + return Belt_List.forEach(suites, (function (param) { var partial_arg = param[1]; it(param[0], (function () { return partial_arg(undefined); })); - }), suite); + })); })); return ; } @@ -118,16 +118,16 @@ let handleCode = spec => let from_pair_suites = %raw(` function from_pair_suites(name, suites) { - var match = $$Array.to_list(Process.argv); + var match = Belt_List.fromArray(Process.argv); if (match) { if (is_mocha(undefined)) { describe(name, (function () { - return List.iter((function (param) { + return Belt_List.forEach(suites, (function (param) { var code = param[1]; it(param[0], (function () { return handleCode(code(undefined)); })); - }), suites); + })); })); return ; } else { @@ -135,7 +135,7 @@ function from_pair_suites(name, suites) { name, "testing" ]); - return List.iter((function (param) { + return Belt_List.forEach(suites, (function (param) { var name = param[0]; var fn = param[1](undefined); switch (fn.TAG) { @@ -207,7 +207,7 @@ function from_pair_suites(name, suites) { return ; } - }), suites); + })); } } @@ -218,11 +218,11 @@ let val_unit = Js.Promise.resolve() let from_promise_suites = %raw(` function from_promise_suites(name, suites) { - var match = $$Array.to_list(Process.argv); + var match = Belt_List.fromArray(Process.argv); if (match) { if (is_mocha(undefined)) { describe(name, (function () { - return List.iter((function (param) { + return Belt_List.forEach(suites, (function (param) { var code = param[1]; it(param[0], (function () { var arg1 = function (x) { @@ -231,7 +231,7 @@ function from_promise_suites(name, suites) { }; return code.then(arg1); })); - }), suites); + })); })); } else { console.log("promise suites"); @@ -243,10 +243,11 @@ function from_promise_suites(name, suites) { `) let old_from_promise_suites_donotuse = (name, suites: list<(string, Js.Promise.t<_>)>) => - switch Array.to_list(argv) { + switch Belt.List.fromArray(argv) { | list{cmd, ..._} => if is_mocha() { - describe(name, () => List.iter(((name, code)) => + describe(name, () => + suites->Belt.List.forEach(((name, code)) => it_promise( name, _ => @@ -258,7 +259,8 @@ let old_from_promise_suites_donotuse = (name, suites: list<(string, Js.Promise.t code, ), ) - , suites)) + ) + ) } else { Js.log("promise suites") } /* TODO */ diff --git a/jscomp/test/obj_literal_ppx.res b/jscomp/test/obj_literal_ppx.res index 50b30a939bd..16487495d8d 100644 --- a/jscomp/test/obj_literal_ppx.res +++ b/jscomp/test/obj_literal_ppx.res @@ -2,7 +2,7 @@ let a = {"x": 3, "y": [1]} let b = {"x": 3, "y": [1], "z": 3, "u": (x, y) => x + y} -let f = obj => obj["x"] + Array.length(obj["y"]) +let f = obj => obj["x"] + Belt.Array.length(obj["y"]) let u = f(a) diff --git a/jscomp/test/queue_test.js b/jscomp/test/queue_test.js index 84e93e0b062..06778c8fe64 100644 --- a/jscomp/test/queue_test.js +++ b/jscomp/test/queue_test.js @@ -2,23 +2,23 @@ 'use strict'; let Mt = require("./mt.js"); -let $$Array = require("../../lib/js/array.js"); let Queue = require("../../lib/js/queue.js"); let Queue_402 = require("./queue_402.js"); -let Caml_array = require("../../lib/js/caml_array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); function Test(Queue) { let to_array = q => { - let v = Caml_array.make(Queue.length(q), 0); + let v = Belt_Array.make(Queue.length(q), 0); Queue.fold((i, e) => { - Caml_array.set(v, i, e); + Primitive_array.set(v, i, e); return i + 1 | 0; }, 0, q); return v; }; let queue_1 = x => { let q = Queue.create(); - $$Array.iter(x => Queue.add(x, q), x); + Belt_Array.forEach(x, x => Queue.add(x, q)); return to_array(q); }; return { @@ -28,9 +28,9 @@ function Test(Queue) { } function to_array(q) { - let v = Caml_array.make(q.length, 0); + let v = Belt_Array.make(q.length, 0); Queue.fold((i, e) => { - Caml_array.set(v, i, e); + Primitive_array.set(v, i, e); return i + 1 | 0; }, 0, q); return v; @@ -42,7 +42,7 @@ function queue_1(x) { first: "Nil", last: "Nil" }; - $$Array.iter(x => Queue.add(x, q), x); + Belt_Array.forEach(x, x => Queue.add(x, q)); return to_array(q); } @@ -52,9 +52,9 @@ let T1 = { }; function to_array$1(q) { - let v = Caml_array.make(q.length, 0); + let v = Belt_Array.make(q.length, 0); Queue_402.fold((i, e) => { - Caml_array.set(v, i, e); + Primitive_array.set(v, i, e); return i + 1 | 0; }, 0, q); return v; @@ -65,7 +65,7 @@ function queue_1$1(x) { length: 0, tail: undefined }; - $$Array.iter(x => Queue_402.add(x, q), x); + Belt_Array.forEach(x, x => Queue_402.add(x, q)); return to_array$1(q); } @@ -75,7 +75,7 @@ let T2 = { }; let suites_0 = [ - "File \"queue_test.res\", line 33, characters 6-13", + "File \"queue_test.res\", line 35, characters 6-13", param => { let x = [ 3, @@ -93,7 +93,7 @@ let suites_0 = [ let suites_1 = { hd: [ - "File \"queue_test.res\", line 40, characters 6-13", + "File \"queue_test.res\", line 42, characters 6-13", param => { let x = [ 3, diff --git a/jscomp/test/queue_test.res b/jscomp/test/queue_test.res index 022a6ac1a6b..9bc7bbc5892 100644 --- a/jscomp/test/queue_test.res +++ b/jscomp/test/queue_test.res @@ -1,3 +1,5 @@ +open Belt + module Test = (Queue: module type of Queue) => { let to_array = q => { let v = Array.make(Queue.length(q), 0) @@ -12,7 +14,7 @@ module Test = (Queue: module type of Queue) => { let queue_1 = x => { let q = Queue.create() /* dump [|q|]; */ - Array.iter(x => Queue.add(x, q), x) + x->Array.forEach(x => Queue.add(x, q)) /* dump [|q|]; */ to_array(q) } diff --git a/jscomp/test/reactDOMRe.res b/jscomp/test/reactDOMRe.res index 8b9b8bb68cb..1b3801d6ddb 100644 --- a/jscomp/test/reactDOMRe.res +++ b/jscomp/test/reactDOMRe.res @@ -21,7 +21,7 @@ let renderToElementWithClassName = (reactElement, className) => (className ++ " found in the HTML."), ) - | elements => render(reactElement, Array.unsafe_get(elements, 0)) + | elements => render(reactElement, Belt.Array.getUnsafe(elements, 0)) } let renderToElementWithId = (reactElement, id) => @@ -49,7 +49,7 @@ module Experimental = { (className ++ " found in the HTML."), ) - | elements => Ok(createRoot(Array.unsafe_get(elements, 0))) + | elements => Ok(createRoot(Belt.Array.getUnsafe(elements, 0))) } let createRootWithId = id => @@ -73,7 +73,7 @@ let hydrateToElementWithClassName = (reactElement, className) => (className ++ " found in the HTML."), ) - | elements => hydrate(reactElement, Array.unsafe_get(elements, 0)) + | elements => hydrate(reactElement, Belt.Array.getUnsafe(elements, 0)) } let hydrateToElementWithId = (reactElement, id) => diff --git a/jscomp/test/reasonReactRouter.res b/jscomp/test/reasonReactRouter.res index 1d60ed77cbe..295ab3d4131 100644 --- a/jscomp/test/reasonReactRouter.res +++ b/jscomp/test/reasonReactRouter.res @@ -51,11 +51,12 @@ let safeMakeEvent = eventName => /* This is copied from array.ml. We want to cut dependencies for ReasonReact so that it's friendlier to use in size-constrained codebases */ let arrayToList = a => { + open Belt let rec tolist = (i, res) => if i < 0 { res } else { - tolist(i - 1, list{Array.unsafe_get(a, i), ...res}) + tolist(i - 1, list{Array.getUnsafe(a, i), ...res}) } tolist(Array.length(a) - 1, list{}) } diff --git a/jscomp/test/set_gen.res b/jscomp/test/set_gen.res index bd743ec4ddb..6d5a4d54812 100644 --- a/jscomp/test/set_gen.res +++ b/jscomp/test/set_gen.res @@ -459,27 +459,27 @@ let of_sorted_array = l => { if n == 0 { Empty } else if n == 1 { - let x0 = Array.unsafe_get(l, start) + let x0 = Belt.Array.getUnsafe(l, start) Node(Empty, x0, Empty, 1) } else if n == 2 { - let x0 = Array.unsafe_get(l, start) - let x1 = Array.unsafe_get(l, start + 1) + let x0 = Belt.Array.getUnsafe(l, start) + let x1 = Belt.Array.getUnsafe(l, start + 1) Node(Node(Empty, x0, Empty, 1), x1, Empty, 2) } else if n == 3 { - let x0 = Array.unsafe_get(l, start) - let x1 = Array.unsafe_get(l, start + 1) - let x2 = Array.unsafe_get(l, start + 2) + let x0 = Belt.Array.getUnsafe(l, start) + let x1 = Belt.Array.getUnsafe(l, start + 1) + let x2 = Belt.Array.getUnsafe(l, start + 2) Node(Node(Empty, x0, Empty, 1), x1, Node(Empty, x2, Empty, 1), 2) } else { let nl = n / 2 let left = sub(start, nl, l) let mid = start + nl - let v = Array.unsafe_get(l, mid) + let v = Belt.Array.getUnsafe(l, mid) let right = sub(mid + 1, n - nl - 1, l) create(left, v, right) } - sub(0, Array.length(l), l) + sub(0, Belt.Array.length(l), l) } let is_ordered = (cmp, tree) => { diff --git a/jscomp/test/splice_test.js b/jscomp/test/splice_test.js index 44d8589fa6a..6dff9decc77 100644 --- a/jscomp/test/splice_test.js +++ b/jscomp/test/splice_test.js @@ -2,7 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); -let Caml_array = require("../../lib/js/caml_array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); let Caml_splice_call = require("../../lib/js/caml_splice_call.js"); let suites = { @@ -29,7 +29,7 @@ let a = []; a.push(1, 2, 3, 4); -eq("File \"splice_test.res\", line 23, characters 5-12", a, [ +eq("File \"splice_test.res\", line 25, characters 5-12", a, [ 1, 2, 3, @@ -42,13 +42,10 @@ function dynamic(arr) { 1, arr ]); - eq("File \"splice_test.res\", line 29, characters 5-12", a, Caml_array.concat({ - hd: [1], - tl: { - hd: arr, - tl: /* [] */0 - } - })); + eq("File \"splice_test.res\", line 31, characters 5-12", a, Belt_Array.concatMany([ + [1], + arr + ])); } dynamic([ @@ -67,7 +64,7 @@ dynamic([ let a$1 = new Array(1, 2, 3, 4); -eq("File \"splice_test.res\", line 44, characters 5-12", a$1, [ +eq("File \"splice_test.res\", line 46, characters 5-12", a$1, [ 1, 2, 3, @@ -80,16 +77,13 @@ function dynamicNew(arr) { 2, arr ]); - eq("File \"splice_test.res\", line 49, characters 5-12", a, Caml_array.concat({ - hd: [ + eq("File \"splice_test.res\", line 51, characters 5-12", a, Belt_Array.concatMany([ + [ 1, 2 ], - tl: { - hd: arr, - tl: /* [] */0 - } - })); + arr + ])); } dynamicNew([ @@ -113,7 +107,7 @@ class Foo { let f = new Foo("a", "b", "c"); -eq("File \"splice_test.res\", line 71, characters 5-12", f.names, [ +eq("File \"splice_test.res\", line 73, characters 5-12", f.names, [ "a", "b", "c" @@ -121,7 +115,7 @@ eq("File \"splice_test.res\", line 71, characters 5-12", f.names, [ function dynamicFoo(arr) { let f = Caml_splice_call.spliceNewApply(Foo, [arr]); - eq("File \"splice_test.res\", line 76, characters 5-12", f.names, arr); + eq("File \"splice_test.res\", line 78, characters 5-12", f.names, arr); } dynamicFoo([]); @@ -138,7 +132,7 @@ let a$2 = []; a$2.push(1, 2, 3, 4); -eq("File \"splice_test.res\", line 93, characters 7-14", a$2, [ +eq("File \"splice_test.res\", line 95, characters 7-14", a$2, [ 1, 2, 3, @@ -151,13 +145,10 @@ function dynamic$1(arr) { 1, arr ]); - eq("File \"splice_test.res\", line 99, characters 7-14", a, Caml_array.concat({ - hd: [1], - tl: { - hd: arr, - tl: /* [] */0 - } - })); + eq("File \"splice_test.res\", line 101, characters 7-14", a, Belt_Array.concatMany([ + [1], + arr + ])); } dynamic$1([ @@ -185,11 +176,11 @@ function f1(c) { ]); } -eq("File \"splice_test.res\", line 109, characters 3-10", Math.max(1, 2, 3), 3); +eq("File \"splice_test.res\", line 111, characters 3-10", Math.max(1, 2, 3), 3); -eq("File \"splice_test.res\", line 110, characters 3-10", Math.max(1), 1); +eq("File \"splice_test.res\", line 112, characters 3-10", Math.max(1), 1); -eq("File \"splice_test.res\", line 111, characters 3-10", Math.max(1, 1, 2, 3, 4, 5, 2, 3), 5); +eq("File \"splice_test.res\", line 113, characters 3-10", Math.max(1, 1, 2, 3, 4, 5, 2, 3), 5); Mt.from_pair_suites("splice_test.res", suites.contents); diff --git a/jscomp/test/splice_test.res b/jscomp/test/splice_test.res index 447574bfd0b..cd568ecce42 100644 --- a/jscomp/test/splice_test.res +++ b/jscomp/test/splice_test.res @@ -1,3 +1,5 @@ +open Belt + let suites: ref = ref(list{}) let test_id = ref(0) let eq = (loc, x, y) => Mt.eq_suites(~test_id, ~suites, loc, x, y) @@ -26,7 +28,7 @@ let () = { let dynamic = arr => { let a = [] a->push(1, arr) - eq(__LOC__, a, Array.concat(list{[1], arr})) + eq(__LOC__, a, Array.concatMany([[1], arr])) } dynamic([2, 3, 4]) @@ -46,7 +48,7 @@ let () = { let dynamicNew = arr => { let a = newArr(1, 2, arr) - eq(__LOC__, a, Array.concat(list{[1, 2], arr})) + eq(__LOC__, a, Array.concatMany([[1, 2], arr])) } dynamicNew([3, 4]) @@ -96,7 +98,7 @@ module Pipe = { let dynamic = arr => { let a = [] a->push(1, arr) - eq(__LOC__, a, Array.concat(list{[1], arr})) + eq(__LOC__, a, Array.concatMany([[1], arr])) } dynamic([2, 3, 4]) diff --git a/jscomp/test/string_set.js b/jscomp/test/string_set.js index e9baa03dee0..f47a2101a97 100644 --- a/jscomp/test/string_set.js +++ b/jscomp/test/string_set.js @@ -2,9 +2,9 @@ 'use strict'; let List = require("../../lib/js/list.js"); -let $$Array = require("../../lib/js/array.js"); let $$String = require("../../lib/js/string.js"); let Set_gen = require("./set_gen.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); let Primitive_string = require("../../lib/js/primitive_string.js"); function split(x, tree) { @@ -272,7 +272,7 @@ function of_list(l) { } function of_array(l) { - return $$Array.fold_left((acc, x) => add(x, acc), "Empty", l); + return Belt_Array.reduceReverse(l, "Empty", (acc, x) => add(x, acc)); } function invariant(t) { diff --git a/jscomp/test/string_set.res b/jscomp/test/string_set.res index c8e41c0f5e9..508ba18359c 100644 --- a/jscomp/test/string_set.res +++ b/jscomp/test/string_set.res @@ -195,7 +195,7 @@ let of_list = l => | _ => of_sorted_list(List.sort_uniq(compare_elt, l)) } -let of_array = l => Array.fold_left((acc, x) => add(x, acc), empty, l) +let of_array = l => l->Belt.Array.reduceReverse(empty, (acc, x) => add(x, acc)) /* also check order */ let invariant = t => { diff --git a/jscomp/test/tagged_template_test.js b/jscomp/test/tagged_template_test.js index 6b3604b55d9..ed03b5d1e1b 100644 --- a/jscomp/test/tagged_template_test.js +++ b/jscomp/test/tagged_template_test.js @@ -2,7 +2,7 @@ 'use strict'; let Mt = require("./mt.js"); -let Caml_array = require("../../lib/js/caml_array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); let Caml_splice_call = require("../../lib/js/caml_splice_call.js"); let Tagged_template_libJs = require("./tagged_template_lib.js"); @@ -31,9 +31,9 @@ function foo(strings, values) { let res = ""; let valueCount = values.length; for (let i = 0; i < valueCount; ++i) { - res = res + Caml_array.get(strings, i) + Math.imul(Caml_array.get(values, i), 10).toString(); + res = res + Primitive_array.get(strings, i) + Math.imul(Primitive_array.get(values, i), 10).toString(); } - return res + Caml_array.get(strings, valueCount); + return res + Primitive_array.get(strings, valueCount); } let res = foo([ diff --git a/jscomp/test/tagged_template_test.res b/jscomp/test/tagged_template_test.res index 9487e58aeda..6ed29697d4f 100644 --- a/jscomp/test/tagged_template_test.res +++ b/jscomp/test/tagged_template_test.res @@ -19,7 +19,7 @@ let length = length`hello ${extraLength} what's the total length? Is it ${3}?` let foo = (strings, values) => { let res = ref("") - let valueCount = Array.length(values) + let valueCount = Belt.Array.length(values) for i in 0 to valueCount - 1 { res := res.contents ++ strings[i] ++ Js.Int.toString(values[i] * 10) } diff --git a/jscomp/test/tailcall_inline_test.js b/jscomp/test/tailcall_inline_test.js index 7308fc182ec..9861af68fab 100644 --- a/jscomp/test/tailcall_inline_test.js +++ b/jscomp/test/tailcall_inline_test.js @@ -2,8 +2,8 @@ 'use strict'; let Mt = require("./mt.js"); -let $$Array = require("../../lib/js/array.js"); -let Caml_array = require("../../lib/js/caml_array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); function f() { let f$1 = (_acc, _n) => { @@ -18,9 +18,9 @@ function f() { continue; }; }; - let v = Caml_array.make(10, 0); + let v = Belt_Array.make(10, 0); for (let i = 0; i <= 9; ++i) { - Caml_array.set(v, i, f$1(0, i)); + Primitive_array.set(v, i, f$1(0, i)); } return v; } @@ -45,34 +45,9 @@ let suites_0 = [ }) ]; -let suites_1 = { - hd: [ - "array_to_list", - param => ({ - TAG: "Eq", - _0: { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, - _1: $$Array.to_list([ - 1, - 2, - 3 - ]) - }) - ], - tl: /* [] */0 -}; - let suites = { hd: suites_0, - tl: suites_1 + tl: /* [] */0 }; Mt.from_pair_suites("Tailcall_inline_test", suites); diff --git a/jscomp/test/tailcall_inline_test.res b/jscomp/test/tailcall_inline_test.res index e769c8cf05f..646bf974324 100644 --- a/jscomp/test/tailcall_inline_test.res +++ b/jscomp/test/tailcall_inline_test.res @@ -6,7 +6,7 @@ let f = () => { acc } let len = 10 - let v = Array.make(len, 0) + let v = Belt.Array.make(len, 0) for i in 0 to len - 1 { v[i] = f(0, i) } @@ -15,10 +15,7 @@ let f = () => { let suites = { open Mt - list{ - ("acc", _ => Eq(f(), [0, 1, 3, 6, 10, 15, 21, 28, 36, 45])), - ("array_to_list", _ => Eq(list{1, 2, 3}, Array.to_list([1, 2, 3]))), - } + list{("acc", _ => Eq(f(), [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]))} } Mt.from_pair_suites(__MODULE__, suites) diff --git a/jscomp/test/test_array.js b/jscomp/test/test_array.js index e2ea1dbb13f..11d30a3f9fc 100644 --- a/jscomp/test/test_array.js +++ b/jscomp/test/test_array.js @@ -1,14 +1,13 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let $$Array = require("../../lib/js/array.js"); -let Caml_array = require("../../lib/js/caml_array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); -let v = Caml_array.make(6, 5); +let v = Belt_Array.make(6, 5); -let h = $$Array.sub(v, 0, 2); +let h = Belt_Array.slice(v, 0, 2); -let hhh = $$Array.append([ +let hhh = Belt_Array.concat([ 1, 2, 3, @@ -20,31 +19,26 @@ let hhh = $$Array.append([ 5 ]); -let u = Caml_array.concat({ - hd: [ +let u = Belt_Array.concatMany([ + [ 1, 2 ], - tl: { - hd: [ - 2, - 3 - ], - tl: { - hd: [ - 3, - 4 - ], - tl: /* [] */0 - } - } -}); + [ + 2, + 3 + ], + [ + 3, + 4 + ] +]); -let hh = $$Array.blit; +let hh = Belt_Array.blit; exports.v = v; exports.h = h; exports.hh = hh; exports.hhh = hhh; exports.u = u; -/* h Not a pure module */ +/* v Not a pure module */ diff --git a/jscomp/test/test_array.res b/jscomp/test/test_array.res index 15d7392438e..777ea333506 100644 --- a/jscomp/test/test_array.res +++ b/jscomp/test/test_array.res @@ -1,9 +1,10 @@ +open Belt + let v = Array.make(6, 5) -let h = Array.sub(v, 0, 2) +let h = Array.slice(v, ~offset=0, ~len=2) let hh = Array.blit -let hhh = Array.append([1, 2, 3, 4], [1, 2, 3, 5]) +let hhh = Array.concat([1, 2, 3, 4], [1, 2, 3, 5]) -let u = Array.concat(list{[1, 2], [2, 3], [3, 4]}) -/* console.log(v ) */ +let u = Array.concatMany([[1, 2], [2, 3], [3, 4]]) diff --git a/jscomp/test/test_array_append.js b/jscomp/test/test_array_append.js index 58cc5d41923..71c58810ff6 100644 --- a/jscomp/test/test_array_append.js +++ b/jscomp/test/test_array_append.js @@ -1,9 +1,9 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let $$Array = require("../../lib/js/array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); -let const_v = $$Array.append([ +let const_v = Belt_Array.concat([ 1, 2 ], [3]); diff --git a/jscomp/test/test_array_append.res b/jscomp/test/test_array_append.res index 4cf4d58efc2..e48887f99a9 100644 --- a/jscomp/test/test_array_append.res +++ b/jscomp/test/test_array_append.res @@ -1 +1 @@ -let const_v = Array.append([1, 2], [3]) +let const_v = Belt.Array.concat([1, 2], [3]) diff --git a/jscomp/test/test_array_primitive.js b/jscomp/test/test_array_primitive.js deleted file mode 100644 index 3ac46e92e8f..00000000000 --- a/jscomp/test/test_array_primitive.js +++ /dev/null @@ -1,50 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - -let Caml_array = require("../../lib/js/caml_array.js"); - -function caml_array_sub(x, offset, len) { - let result = new Array(len); - for (let j = 0; j < len; ++j) { - Caml_array.set(result, j, Caml_array.get(x, offset + j | 0)); - } - return result; -} - -function caml_array_set(xs, index, newval) { - if (index < 0 || index >= xs.length) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "index out of bounds" - } - }); - } - Caml_array.set(xs, index, newval); -} - -function caml_array_get(xs, index) { - if (index < 0 || index >= xs.length) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "index out of bounds" - } - }); - } - return Caml_array.get(xs, index); -} - -function caml_make_vect(len, init) { - let b = new Array(len); - for (let i = 0; i < len; ++i) { - Caml_array.set(b, i, init); - } - return b; -} - -exports.caml_array_sub = caml_array_sub; -exports.caml_array_set = caml_array_set; -exports.caml_array_get = caml_array_get; -exports.caml_make_vect = caml_make_vect; -/* No side effect */ diff --git a/jscomp/test/test_array_primitive.res b/jscomp/test/test_array_primitive.res deleted file mode 100644 index f971831ef2b..00000000000 --- a/jscomp/test/test_array_primitive.res +++ /dev/null @@ -1,40 +0,0 @@ -@new("Array") external new_uninitialized_array: int => array<'a> = "" - -let caml_array_sub = (x: array<'a>, offset: int, len: int) => { - let result = new_uninitialized_array(len) - for j in 0 to len - 1 { - result[j] = x[offset + j] - } - result -} - -/* let rec len l = */ -/* match l with */ -/* | [] -> 0 */ -/* | x::xs -> Array.length x + len xs */ - -/* let caml_array_concat (l : 'a array list) : 'a array = */ -/* let v = len l in */ -/* let result = new_uninitialized_array v in */ - -let caml_array_set = (xs, index, newval) => - if index < 0 || index >= Array.length(xs) { - invalid_arg("index out of bounds") - } else { - xs[index] = newval - } - -let caml_array_get = (xs, index) => - if index < 0 || index >= Array.length(xs) { - invalid_arg("index out of bounds") - } else { - xs[index] - } - -let caml_make_vect = (len, init) => { - let b = new_uninitialized_array(len) - for i in 0 to len - 1 { - b[i] = init - } - b -} diff --git a/jscomp/test/test_closure.js b/jscomp/test/test_closure.js index 50cf48ad0aa..e711183d288 100644 --- a/jscomp/test/test_closure.js +++ b/jscomp/test/test_closure.js @@ -1,17 +1,17 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let $$Array = require("../../lib/js/array.js"); -let Caml_array = require("../../lib/js/caml_array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); let v = { contents: 0 }; function f() { - let arr = Caml_array.make(10, param => {}); + let arr = Belt_Array.make(10, param => {}); for (let i = 0; i <= 9; ++i) { - Caml_array.set(arr, i, param => { + Primitive_array.set(arr, i, param => { v.contents = v.contents + i | 0; }); } @@ -20,7 +20,7 @@ function f() { let u = f(); -$$Array.iter(x => x(), u); +Belt_Array.forEach(u, x => x()); if (v.contents !== 45) { throw new Error("Assert_failure", { diff --git a/jscomp/test/test_closure.res b/jscomp/test/test_closure.res index 1c2f3e9bbbb..240102d95eb 100644 --- a/jscomp/test/test_closure.res +++ b/jscomp/test/test_closure.res @@ -39,7 +39,7 @@ This means inline is tricky in javascript, here we try to inline [_loop]? */ let f = () => { let n = 10 - let arr = Array.make(10, _ => ()) + let arr = Belt.Array.make(10, _ => ()) for i in 0 to n - 1 { arr[i] = _ => v := v.contents + i } @@ -48,6 +48,6 @@ let f = () => { let () = { let u = f() - Array.iter(x => x(), u) + u->Belt.Array.forEach(x => x()) assert(v.contents == 45) } diff --git a/jscomp/test/test_cps.js b/jscomp/test/test_cps.js index c90ba80a024..e901dd19858 100644 --- a/jscomp/test/test_cps.js +++ b/jscomp/test/test_cps.js @@ -1,7 +1,8 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let Caml_array = require("../../lib/js/caml_array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); function f(_n, _acc) { while (true) { @@ -20,9 +21,9 @@ function f(_n, _acc) { } function test_closure() { - let arr = Caml_array.make(6, x => x); + let arr = Belt_Array.make(6, x => x); for (let i = 0; i <= 6; ++i) { - Caml_array.set(arr, i, param => i); + Primitive_array.set(arr, i, param => i); } return arr; } diff --git a/jscomp/test/test_cps.res b/jscomp/test/test_cps.res index c4e89698d53..bb9c78d5ca6 100644 --- a/jscomp/test/test_cps.res +++ b/jscomp/test/test_cps.res @@ -90,7 +90,7 @@ let rec f = (n, acc) => */ let test_closure = () => { let n = 6 - let arr = Array.make(n, x => x) + let arr = Belt.Array.make(n, x => x) for i in 0 to n { arr[i] = _ => i } diff --git a/jscomp/test/test_for_loop.js b/jscomp/test/test_for_loop.js index 0f6d8cfd28a..49bd328a26a 100644 --- a/jscomp/test/test_for_loop.js +++ b/jscomp/test/test_for_loop.js @@ -1,18 +1,18 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let $$Array = require("../../lib/js/array.js"); -let Caml_array = require("../../lib/js/caml_array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); function for_(x) { for (let i = 0, i_finish = (console.log("hi"), x.length); i <= i_finish; ++i) { - console.log(Caml_array.get(x, i)); + console.log(Primitive_array.get(x, i)); } } function for_2(x) { for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { - console.log(Caml_array.get(x, i)); + console.log(Primitive_array.get(x, i)); } } @@ -20,14 +20,14 @@ function for_3(x) { let v = { contents: 0 }; - let arr = $$Array.map(param => (() => {}), x); + let arr = Belt_Array.map(x, param => (() => {})); for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { let j = (i << 1); - Caml_array.set(arr, i, () => { + Primitive_array.set(arr, i, () => { v.contents = v.contents + j | 0; }); } - $$Array.iter(x => x(), arr); + Belt_Array.forEach(arr, x => x()); return v.contents; } @@ -35,15 +35,15 @@ function for_4(x) { let v = { contents: 0 }; - let arr = $$Array.map(param => (() => {}), x); + let arr = Belt_Array.map(x, param => (() => {})); for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { let j = (i << 1); let k = (j << 1); - Caml_array.set(arr, i, () => { + Primitive_array.set(arr, i, () => { v.contents = v.contents + k | 0; }); } - $$Array.iter(x => x(), arr); + Belt_Array.forEach(arr, x => x()); return v.contents; } @@ -51,14 +51,14 @@ function for_5(x, u) { let v = { contents: 0 }; - let arr = $$Array.map(param => (() => {}), x); + let arr = Belt_Array.map(x, param => (() => {})); for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { let k = Math.imul((u << 1), u); - Caml_array.set(arr, i, () => { + Primitive_array.set(arr, i, () => { v.contents = v.contents + k | 0; }); } - $$Array.iter(x => x(), arr); + Belt_Array.forEach(arr, x => x()); return v.contents; } @@ -66,7 +66,7 @@ function for_6(x, u) { let v = { contents: 0 }; - let arr = $$Array.map(param => (() => {}), x); + let arr = Belt_Array.map(x, param => (() => {})); let v4 = { contents: 0 }; @@ -83,12 +83,12 @@ function for_6(x, u) { let k = Math.imul((u << 1), u); let h = (v5.contents << 1); v2.contents = v2.contents + 1 | 0; - Caml_array.set(arr, i, () => { + Primitive_array.set(arr, i, () => { v.contents = (((((v.contents + k | 0) + v2.contents | 0) + u | 0) + v4.contents | 0) + v5.contents | 0) + h | 0; }); } } - $$Array.iter(x => x(), arr); + Belt_Array.forEach(arr, x => x()); return v.contents; } diff --git a/jscomp/test/test_for_loop.res b/jscomp/test/test_for_loop.res index e1be363d6a1..d2f7178178c 100644 --- a/jscomp/test/test_for_loop.res +++ b/jscomp/test/test_for_loop.res @@ -1,3 +1,5 @@ +open Belt + let for_ = x => for i in 0 to { Js.log("hi") @@ -14,42 +16,42 @@ let for_2 = x => let for_3 = x => { let v = ref(0) - let arr = Array.map(_ => _ => (), x) + let arr = x->Array.map(_ => _ => ()) for i in 0 to Array.length(x) { let j = i * 2 arr[i] = _ => v := v.contents + j } - Array.iter(x => x(), arr) + arr->Array.forEach(x => x()) v.contents } let for_4 = x => { let v = ref(0) - let arr = Array.map(_ => _ => (), x) + let arr = x->Array.map(_ => _ => ()) for i in 0 to Array.length(x) { let j = i * 2 let k = 2 * j arr[i] = _ => v := v.contents + k } - Array.iter(x => x(), arr) + arr->Array.forEach(x => x()) v.contents } let for_5 = (x, u) => { let v = ref(0) - let arr = Array.map(_ => _ => (), x) + let arr = x->Array.map(_ => _ => ()) for i in 0 to Array.length(x) { let _j = i * 2 let k = 2 * u * u arr[i] = _ => v := v.contents + k } - Array.iter(x => x(), arr) + arr->Array.forEach(x => x()) v.contents } let for_6 = (x, u) => { let v = ref(0) - let arr = Array.map(_ => _ => (), x) + let arr = x->Array.map(_ => _ => ()) let v4 = ref(0) let v5 = ref(0) incr(v4) @@ -65,6 +67,6 @@ let for_6 = (x, u) => { arr[i] = _ => v := v.contents + k + v2.contents + v3 + v4.contents + v5.contents + h } } - Array.iter(x => x(), arr) + arr->Array.forEach(x => x()) v.contents } diff --git a/jscomp/test/test_google_closure.js b/jscomp/test/test_google_closure.js index dc0b99b1cfb..de792660901 100644 --- a/jscomp/test/test_google_closure.js +++ b/jscomp/test/test_google_closure.js @@ -1,8 +1,8 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let $$Array = require("../../lib/js/array.js"); -let Caml_array = require("../../lib/js/caml_array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); function f(a, b, param) { return a + b | 0; @@ -20,11 +20,11 @@ function f3(extra) { let b = f3(2); -let arr = $$Array.init(2, param => 0); +let arr = Belt_Array.init(2, param => 0); for (let i = 0; i <= 1; ++i) { let f3$1 = extra => i + 1 | 0; - Caml_array.set(arr, i, f3$1(2)); + Primitive_array.set(arr, i, f3$1(2)); } console.log([ diff --git a/jscomp/test/test_google_closure.res b/jscomp/test/test_google_closure.res index 4a9e1a0fd7b..5e016273a9a 100644 --- a/jscomp/test/test_google_closure.res +++ b/jscomp/test/test_google_closure.res @@ -9,7 +9,7 @@ let (a, b, c) = ( f3(2) }, { - let arr = Array.init(2, _ => 0) + let arr = Belt.Array.init(2, _ => 0) for i in 0 to 1 { let f3 = f2(i) arr[i] = f3(2) diff --git a/jscomp/test/test_primitive.js b/jscomp/test/test_primitive.js index b6e4698c1f4..1ac4c31a285 100644 --- a/jscomp/test/test_primitive.js +++ b/jscomp/test/test_primitive.js @@ -1,7 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let Caml_array = require("../../lib/js/caml_array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); let CamlinternalLazy = require("../../lib/js/camlinternalLazy.js"); let Primitive_string = require("../../lib/js/primitive_string.js"); @@ -57,7 +57,7 @@ function f2(h, b, param) { return h(b ? 32 : 7); } -Caml_array.set(v, 1, 3.0); +Primitive_array.set(v, 1, 3.0); let unboxed_x = { u: 0, diff --git a/jscomp/test/test_runtime_encoding.js b/jscomp/test/test_runtime_encoding.js index 77edc3a296a..e2efc9814fc 100644 --- a/jscomp/test/test_runtime_encoding.js +++ b/jscomp/test/test_runtime_encoding.js @@ -1,7 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let Caml_array = require("../../lib/js/caml_array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); function g(x) { return [ @@ -25,11 +25,11 @@ function fff(vv, uu) { } function a(x) { - return Caml_array.get(x, 0); + return Primitive_array.get(x, 0); } function aa(x) { - return Caml_array.get(x, 0); + return Primitive_array.get(x, 0); } function aaa(x) { @@ -42,7 +42,7 @@ function aaaa(x) { function f(x) { for (let i = 0; i <= 10; ++i) { - Caml_array.set(x, i, i); + Primitive_array.set(x, i, i); } } diff --git a/jscomp/test/test_simple_include.js b/jscomp/test/test_simple_include.js index 2b1f9d5ce9e..2d55cc0b51d 100644 --- a/jscomp/test/test_simple_include.js +++ b/jscomp/test/test_simple_include.js @@ -1,7 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let $$Array = require("../../lib/js/array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); let v = { contents: 32 @@ -23,86 +23,224 @@ let NN = { v: v$1 }; -let init = $$Array.init; +let get = Belt_Array.get; -let make_matrix = $$Array.make_matrix; +let getExn = Belt_Array.getExn; -let create_matrix = $$Array.create_matrix; +let set = Belt_Array.set; -let append = $$Array.append; +let setExn = Belt_Array.setExn; -let concat = $$Array.concat; +let shuffleInPlace = Belt_Array.shuffleInPlace; -let sub = $$Array.sub; +let shuffle = Belt_Array.shuffle; -let copy = $$Array.copy; +let reverseInPlace = Belt_Array.reverseInPlace; -let fill = $$Array.fill; +let reverse = Belt_Array.reverse; -let blit = $$Array.blit; +let make = Belt_Array.make; -let to_list = $$Array.to_list; +let range = Belt_Array.range; -let of_list = $$Array.of_list; +let rangeBy = Belt_Array.rangeBy; -let iter = $$Array.iter; +let makeByU = Belt_Array.makeByU; -let iteri = $$Array.iteri; +let makeBy = Belt_Array.makeBy; -let map = $$Array.map; +let makeByAndShuffleU = Belt_Array.makeByAndShuffleU; -let mapi = $$Array.mapi; +let makeByAndShuffle = Belt_Array.makeByAndShuffle; -let fold_left = $$Array.fold_left; +let zip = Belt_Array.zip; -let fold_right = $$Array.fold_right; +let zipByU = Belt_Array.zipByU; -let iter2 = $$Array.iter2; +let zipBy = Belt_Array.zipBy; -let map2 = $$Array.map2; +let unzip = Belt_Array.unzip; -let for_all = $$Array.for_all; +let concat = Belt_Array.concat; -let exists = $$Array.exists; +let concatMany = Belt_Array.concatMany; -let mem = $$Array.mem; +let slice = Belt_Array.slice; -let memq = $$Array.memq; +let sliceToEnd = Belt_Array.sliceToEnd; -let sort = $$Array.sort; +let fill = Belt_Array.fill; -let stable_sort = $$Array.stable_sort; +let blit = Belt_Array.blit; -let fast_sort = $$Array.fast_sort; +let blitUnsafe = Belt_Array.blitUnsafe; + +let forEachU = Belt_Array.forEachU; + +let forEach = Belt_Array.forEach; + +let mapU = Belt_Array.mapU; + +let map = Belt_Array.map; + +let flatMapU = Belt_Array.flatMapU; + +let flatMap = Belt_Array.flatMap; + +let getByU = Belt_Array.getByU; + +let getBy = Belt_Array.getBy; + +let getIndexByU = Belt_Array.getIndexByU; + +let getIndexBy = Belt_Array.getIndexBy; + +let keepU = Belt_Array.keepU; + +let keep = Belt_Array.keep; + +let keepWithIndexU = Belt_Array.keepWithIndexU; + +let keepWithIndex = Belt_Array.keepWithIndex; + +let keepMapU = Belt_Array.keepMapU; + +let keepMap = Belt_Array.keepMap; + +let forEachWithIndexU = Belt_Array.forEachWithIndexU; + +let forEachWithIndex = Belt_Array.forEachWithIndex; + +let mapWithIndexU = Belt_Array.mapWithIndexU; + +let mapWithIndex = Belt_Array.mapWithIndex; + +let partitionU = Belt_Array.partitionU; + +let partition = Belt_Array.partition; + +let reduceU = Belt_Array.reduceU; + +let reduce = Belt_Array.reduce; + +let reduceReverseU = Belt_Array.reduceReverseU; + +let reduceReverse = Belt_Array.reduceReverse; + +let reduceReverse2U = Belt_Array.reduceReverse2U; + +let reduceReverse2 = Belt_Array.reduceReverse2; + +let reduceWithIndexU = Belt_Array.reduceWithIndexU; + +let reduceWithIndex = Belt_Array.reduceWithIndex; + +let joinWithU = Belt_Array.joinWithU; + +let joinWith = Belt_Array.joinWith; + +let someU = Belt_Array.someU; + +let some = Belt_Array.some; + +let everyU = Belt_Array.everyU; + +let every = Belt_Array.every; + +let every2U = Belt_Array.every2U; + +let every2 = Belt_Array.every2; + +let some2U = Belt_Array.some2U; + +let some2 = Belt_Array.some2; + +let cmpU = Belt_Array.cmpU; + +let cmp = Belt_Array.cmp; + +let eqU = Belt_Array.eqU; + +let eq = Belt_Array.eq; + +let initU = Belt_Array.initU; + +let init = Belt_Array.init; let a = 3; -exports.init = init; -exports.make_matrix = make_matrix; -exports.create_matrix = create_matrix; -exports.append = append; +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.sub = sub; -exports.copy = copy; +exports.concatMany = concatMany; +exports.slice = slice; +exports.sliceToEnd = sliceToEnd; exports.fill = fill; exports.blit = blit; -exports.to_list = to_list; -exports.of_list = of_list; -exports.iter = iter; -exports.iteri = iteri; +exports.blitUnsafe = blitUnsafe; +exports.forEachU = forEachU; +exports.forEach = forEach; +exports.mapU = mapU; exports.map = map; -exports.mapi = mapi; -exports.fold_left = fold_left; -exports.fold_right = fold_right; -exports.iter2 = iter2; -exports.map2 = map2; -exports.for_all = for_all; -exports.exists = exists; -exports.mem = mem; -exports.memq = memq; -exports.sort = sort; -exports.stable_sort = stable_sort; -exports.fast_sort = fast_sort; +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; exports.N = N; exports.NN = NN; exports.a = a; diff --git a/jscomp/test/test_simple_include.res b/jscomp/test/test_simple_include.res index d6325f00631..6586d3401dd 100644 --- a/jscomp/test/test_simple_include.res +++ b/jscomp/test/test_simple_include.res @@ -1,4 +1,4 @@ -include Array +include Belt.Array include { assert(1 + 2 == 3) diff --git a/jscomp/test/test_while_closure.js b/jscomp/test/test_while_closure.js index 1481749130b..440055012e9 100644 --- a/jscomp/test/test_while_closure.js +++ b/jscomp/test/test_while_closure.js @@ -1,20 +1,20 @@ // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -let $$Array = require("../../lib/js/array.js"); -let Caml_array = require("../../lib/js/caml_array.js"); +let Belt_Array = require("../../lib/js/belt_Array.js"); +let Primitive_array = require("../../lib/js/primitive_array.js"); let v = { contents: 0 }; -let arr = Caml_array.make(10, () => {}); +let arr = Belt_Array.make(10, () => {}); function f() { let n = 0; while (n < 10) { let j = n; - Caml_array.set(arr, j, () => { + Primitive_array.set(arr, j, () => { v.contents = v.contents + j | 0; }); n = n + 1 | 0; @@ -23,7 +23,7 @@ function f() { f(); -$$Array.iter(x => x(), arr); +Belt_Array.forEach(arr, x => x()); console.log(v.contents.toString()); @@ -46,4 +46,4 @@ exports.v = v; exports.count = count; exports.arr = arr; exports.f = f; -/* Not a pure module */ +/* arr Not a pure module */ diff --git a/jscomp/test/test_while_closure.res b/jscomp/test/test_while_closure.res index 9d967a4ffcd..58fa9ad580f 100644 --- a/jscomp/test/test_while_closure.res +++ b/jscomp/test/test_while_closure.res @@ -38,7 +38,7 @@ This means inline is tricky in javascript, here we try to inline [_loop]? let v = ref(0) let count = 10 -let arr = Array.make(count, _ => ()) +let arr = Belt.Array.make(count, _ => ()) let f = () => { let n = ref(0) while n.contents < count { @@ -50,7 +50,7 @@ let f = () => { let () = { f() - Array.iter(x => x(), arr) + arr->Belt.Array.forEach(x => x()) v.contents->Js.Int.toString->Js.log assert(v.contents == 45) } diff --git a/lib/es6/array.js b/lib/es6/array.js deleted file mode 100644 index 15020c270b4..00000000000 --- a/lib/es6/array.js +++ /dev/null @@ -1,513 +0,0 @@ - - -import * as Caml_array from "./caml_array.js"; -import * as Caml_exceptions from "./caml_exceptions.js"; -import * as Caml_js_exceptions from "./caml_js_exceptions.js"; - -function init(l, f) { - if (l === 0) { - return []; - } - if (l < 0) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.init" - } - }); - } - let res = Caml_array.make(l, f(0)); - for (let i = 1; i < l; ++i) { - res[i] = f(i); - } - return res; -} - -function make_matrix(sx, sy, init) { - let res = Caml_array.make(sx, []); - for (let x = 0; x < sx; ++x) { - res[x] = Caml_array.make(sy, init); - } - return res; -} - -function copy(a) { - let l = a.length; - if (l === 0) { - return []; - } else { - return Caml_array.sub(a, 0, l); - } -} - -function append(a1, a2) { - let l1 = a1.length; - if (l1 === 0) { - return copy(a2); - } else if (a2.length === 0) { - return Caml_array.sub(a1, 0, l1); - } else { - return a1.concat(a2); - } -} - -function sub(a, ofs, len) { - if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.sub" - } - }); - } - return Caml_array.sub(a, ofs, len); -} - -function fill(a, ofs, len, v) { - if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.fill" - } - }); - } - for (let i = ofs, i_finish = ofs + len | 0; i < i_finish; ++i) { - a[i] = v; - } -} - -function blit(a1, ofs1, a2, ofs2, len) { - if (len < 0 || ofs1 < 0 || ofs1 > (a1.length - len | 0) || ofs2 < 0 || ofs2 > (a2.length - len | 0)) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.blit" - } - }); - } - Caml_array.blit(a1, ofs1, a2, ofs2, len); -} - -function iter(f, a) { - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - f(a[i]); - } -} - -function iter2(f, a, b) { - if (a.length !== b.length) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.iter2: arrays must have the same length" - } - }); - } - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - f(a[i], b[i]); - } -} - -function map(f, a) { - let l = a.length; - if (l === 0) { - return []; - } - let r = Caml_array.make(l, f(a[0])); - for (let i = 1; i < l; ++i) { - r[i] = f(a[i]); - } - return r; -} - -function map2(f, a, b) { - let la = a.length; - let lb = b.length; - if (la !== lb) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.map2: arrays must have the same length" - } - }); - } - if (la === 0) { - return []; - } - let r = Caml_array.make(la, f(a[0], b[0])); - for (let i = 1; i < la; ++i) { - r[i] = f(a[i], b[i]); - } - return r; -} - -function iteri(f, a) { - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - f(i, a[i]); - } -} - -function mapi(f, a) { - let l = a.length; - if (l === 0) { - return []; - } - let r = Caml_array.make(l, f(0, a[0])); - for (let i = 1; i < l; ++i) { - r[i] = f(i, a[i]); - } - return r; -} - -function to_list(a) { - let _i = a.length - 1 | 0; - let _res = /* [] */0; - while (true) { - let res = _res; - let i = _i; - if (i < 0) { - return res; - } - _res = { - hd: a[i], - tl: res - }; - _i = i - 1 | 0; - continue; - }; -} - -function list_length(_accu, _param) { - while (true) { - let param = _param; - let accu = _accu; - if (!param) { - return accu; - } - _param = param.tl; - _accu = accu + 1 | 0; - continue; - }; -} - -function of_list(param) { - if (!param) { - return []; - } - let a = Caml_array.make(list_length(0, param), param.hd); - let _i = 1; - let _param = param.tl; - while (true) { - let param$1 = _param; - let i = _i; - if (!param$1) { - return a; - } - a[i] = param$1.hd; - _param = param$1.tl; - _i = i + 1 | 0; - continue; - }; -} - -function fold_left(f, x, a) { - let r = x; - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - r = f(r, a[i]); - } - return r; -} - -function fold_right(f, a, x) { - let r = x; - for (let i = a.length - 1 | 0; i >= 0; --i) { - r = f(a[i], r); - } - return r; -} - -function exists(p, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return false; - } - if (p(a[i])) { - return true; - } - _i = i + 1 | 0; - continue; - }; -} - -function for_all(p, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return true; - } - if (!p(a[i])) { - return false; - } - _i = i + 1 | 0; - continue; - }; -} - -function mem(x, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return false; - } - if (a[i] === x) { - return true; - } - _i = i + 1 | 0; - continue; - }; -} - -function memq(x, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return false; - } - if (x === a[i]) { - return true; - } - _i = i + 1 | 0; - continue; - }; -} - -let Bottom = /* @__PURE__ */Caml_exceptions.create("Array.Bottom"); - -function sort(cmp, a) { - let maxson = (l, i) => { - let i31 = ((i + i | 0) + i | 0) + 1 | 0; - let x = i31; - if ((i31 + 2 | 0) < l) { - if (cmp(Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { - x = i31 + 1 | 0; - } - if (cmp(Caml_array.get(a, x), Caml_array.get(a, i31 + 2 | 0)) < 0) { - x = i31 + 2 | 0; - } - return x; - } - if ((i31 + 1 | 0) < l && cmp(Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { - return i31 + 1 | 0; - } - if (i31 < l) { - return i31; - } - throw new Error(Bottom, { - cause: { - RE_EXN_ID: Bottom, - _1: i - } - }); - }; - let trickle = (l, i, e) => { - try { - let _i = i; - while (true) { - let i$1 = _i; - let j = maxson(l, i$1); - if (cmp(Caml_array.get(a, j), e) <= 0) { - return Caml_array.set(a, i$1, e); - } - Caml_array.set(a, i$1, Caml_array.get(a, j)); - _i = j; - continue; - }; - } catch (raw_i) { - let i$2 = Caml_js_exceptions.internalToOCamlException(raw_i); - if (i$2.RE_EXN_ID === Bottom) { - return Caml_array.set(a, i$2._1, e); - } - throw new Error(i$2.RE_EXN_ID, { - cause: i$2 - }); - } - }; - let bubble = (l, i) => { - try { - let _i = i; - while (true) { - let i$1 = _i; - let j = maxson(l, i$1); - Caml_array.set(a, i$1, Caml_array.get(a, j)); - _i = j; - continue; - }; - } catch (raw_i) { - let i$2 = Caml_js_exceptions.internalToOCamlException(raw_i); - if (i$2.RE_EXN_ID === Bottom) { - return i$2._1; - } - throw new Error(i$2.RE_EXN_ID, { - cause: i$2 - }); - } - }; - let trickleup = (_i, e) => { - while (true) { - let i = _i; - let father = (i - 1 | 0) / 3 | 0; - if (i === father) { - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "array.res", - 310, - 4 - ] - } - }); - } - if (cmp(Caml_array.get(a, father), e) >= 0) { - return Caml_array.set(a, i, e); - } - Caml_array.set(a, i, Caml_array.get(a, father)); - if (father <= 0) { - return Caml_array.set(a, 0, e); - } - _i = father; - continue; - }; - }; - let l = a.length; - for (let i = ((l + 1 | 0) / 3 | 0) - 1 | 0; i >= 0; --i) { - trickle(l, i, Caml_array.get(a, i)); - } - for (let i$1 = l - 1 | 0; i$1 >= 2; --i$1) { - let e = Caml_array.get(a, i$1); - Caml_array.set(a, i$1, Caml_array.get(a, 0)); - trickleup(bubble(i$1, 0), e); - } - if (l <= 1) { - return; - } - let e$1 = Caml_array.get(a, 1); - Caml_array.set(a, 1, Caml_array.get(a, 0)); - Caml_array.set(a, 0, e$1); -} - -function stable_sort(cmp, a) { - let merge = (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { - let src1r = src1ofs + src1len | 0; - let src2r = src2ofs + src2len | 0; - let _i1 = src1ofs; - let _s1 = Caml_array.get(a, src1ofs); - let _i2 = src2ofs; - let _s2 = Caml_array.get(src2, src2ofs); - let _d = dstofs; - while (true) { - let d = _d; - let s2 = _s2; - let i2 = _i2; - let s1 = _s1; - let i1 = _i1; - if (cmp(s1, s2) <= 0) { - Caml_array.set(dst, d, s1); - let i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return blit(src2, i2, dst, d + 1 | 0, src2r - i2 | 0); - } - _d = d + 1 | 0; - _s1 = Caml_array.get(a, i1$1); - _i1 = i1$1; - continue; - } - Caml_array.set(dst, d, s2); - let i2$1 = i2 + 1 | 0; - if (i2$1 >= src2r) { - return blit(a, i1, dst, d + 1 | 0, src1r - i1 | 0); - } - _d = d + 1 | 0; - _s2 = Caml_array.get(src2, i2$1); - _i2 = i2$1; - continue; - }; - }; - let isortto = (srcofs, dst, dstofs, len) => { - for (let i = 0; i < len; ++i) { - let e = Caml_array.get(a, srcofs + i | 0); - let j = (dstofs + i | 0) - 1 | 0; - while (j >= dstofs && cmp(Caml_array.get(dst, j), e) > 0) { - Caml_array.set(dst, j + 1 | 0, Caml_array.get(dst, j)); - j = j - 1 | 0; - }; - Caml_array.set(dst, j + 1 | 0, e); - } - }; - let sortto = (srcofs, dst, dstofs, len) => { - if (len <= 5) { - return isortto(srcofs, dst, dstofs, len); - } - let l1 = len / 2 | 0; - let l2 = len - l1 | 0; - sortto(srcofs + l1 | 0, dst, dstofs + l1 | 0, l2); - sortto(srcofs, a, srcofs + l2 | 0, l1); - merge(srcofs + l2 | 0, l1, dst, dstofs + l1 | 0, l2, dst, dstofs); - }; - let l = a.length; - if (l <= 5) { - return isortto(0, a, 0, l); - } - let l1 = l / 2 | 0; - let l2 = l - l1 | 0; - let t = Caml_array.make(l2, Caml_array.get(a, 0)); - sortto(l1, t, 0, l2); - sortto(0, a, l2, l1); - merge(l2, l1, t, 0, l2, a, 0); -} - -let create_matrix = make_matrix; - -let concat = Caml_array.concat; - -let fast_sort = stable_sort; - -export { - init, - make_matrix, - create_matrix, - append, - concat, - sub, - copy, - fill, - blit, - to_list, - of_list, - iter, - iteri, - map, - mapi, - fold_left, - fold_right, - iter2, - map2, - for_all, - exists, - mem, - memq, - sort, - stable_sort, - fast_sort, -} -/* No side effect */ diff --git a/lib/es6/arrayLabels.js b/lib/es6/arrayLabels.js deleted file mode 100644 index 1c2f4ecdf09..00000000000 --- a/lib/es6/arrayLabels.js +++ /dev/null @@ -1,513 +0,0 @@ - - -import * as Caml_array from "./caml_array.js"; -import * as Caml_exceptions from "./caml_exceptions.js"; -import * as Caml_js_exceptions from "./caml_js_exceptions.js"; - -function init(l, f) { - if (l === 0) { - return []; - } - if (l < 0) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.init" - } - }); - } - let res = Caml_array.make(l, f(0)); - for (let i = 1; i < l; ++i) { - res[i] = f(i); - } - return res; -} - -function make_matrix(sx, sy, init) { - let res = Caml_array.make(sx, []); - for (let x = 0; x < sx; ++x) { - res[x] = Caml_array.make(sy, init); - } - return res; -} - -function copy(a) { - let l = a.length; - if (l === 0) { - return []; - } else { - return Caml_array.sub(a, 0, l); - } -} - -function append(a1, a2) { - let l1 = a1.length; - if (l1 === 0) { - return copy(a2); - } else if (a2.length === 0) { - return Caml_array.sub(a1, 0, l1); - } else { - return a1.concat(a2); - } -} - -function sub(a, ofs, len) { - if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.sub" - } - }); - } - return Caml_array.sub(a, ofs, len); -} - -function fill(a, ofs, len, v) { - if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.fill" - } - }); - } - for (let i = ofs, i_finish = ofs + len | 0; i < i_finish; ++i) { - a[i] = v; - } -} - -function blit(a1, ofs1, a2, ofs2, len) { - if (len < 0 || ofs1 < 0 || ofs1 > (a1.length - len | 0) || ofs2 < 0 || ofs2 > (a2.length - len | 0)) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.blit" - } - }); - } - Caml_array.blit(a1, ofs1, a2, ofs2, len); -} - -function iter(f, a) { - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - f(a[i]); - } -} - -function iter2(f, a, b) { - if (a.length !== b.length) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.iter2: arrays must have the same length" - } - }); - } - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - f(a[i], b[i]); - } -} - -function map(f, a) { - let l = a.length; - if (l === 0) { - return []; - } - let r = Caml_array.make(l, f(a[0])); - for (let i = 1; i < l; ++i) { - r[i] = f(a[i]); - } - return r; -} - -function map2(f, a, b) { - let la = a.length; - let lb = b.length; - if (la !== lb) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.map2: arrays must have the same length" - } - }); - } - if (la === 0) { - return []; - } - let r = Caml_array.make(la, f(a[0], b[0])); - for (let i = 1; i < la; ++i) { - r[i] = f(a[i], b[i]); - } - return r; -} - -function iteri(f, a) { - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - f(i, a[i]); - } -} - -function mapi(f, a) { - let l = a.length; - if (l === 0) { - return []; - } - let r = Caml_array.make(l, f(0, a[0])); - for (let i = 1; i < l; ++i) { - r[i] = f(i, a[i]); - } - return r; -} - -function to_list(a) { - let _i = a.length - 1 | 0; - let _res = /* [] */0; - while (true) { - let res = _res; - let i = _i; - if (i < 0) { - return res; - } - _res = { - hd: a[i], - tl: res - }; - _i = i - 1 | 0; - continue; - }; -} - -function list_length(_accu, _param) { - while (true) { - let param = _param; - let accu = _accu; - if (!param) { - return accu; - } - _param = param.tl; - _accu = accu + 1 | 0; - continue; - }; -} - -function of_list(param) { - if (!param) { - return []; - } - let a = Caml_array.make(list_length(0, param), param.hd); - let _i = 1; - let _param = param.tl; - while (true) { - let param$1 = _param; - let i = _i; - if (!param$1) { - return a; - } - a[i] = param$1.hd; - _param = param$1.tl; - _i = i + 1 | 0; - continue; - }; -} - -function fold_left(f, x, a) { - let r = x; - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - r = f(r, a[i]); - } - return r; -} - -function fold_right(f, a, x) { - let r = x; - for (let i = a.length - 1 | 0; i >= 0; --i) { - r = f(a[i], r); - } - return r; -} - -function exists(p, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return false; - } - if (p(a[i])) { - return true; - } - _i = i + 1 | 0; - continue; - }; -} - -function for_all(p, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return true; - } - if (!p(a[i])) { - return false; - } - _i = i + 1 | 0; - continue; - }; -} - -function mem(x, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return false; - } - if (a[i] === x) { - return true; - } - _i = i + 1 | 0; - continue; - }; -} - -function memq(x, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return false; - } - if (x === a[i]) { - return true; - } - _i = i + 1 | 0; - continue; - }; -} - -let Bottom = /* @__PURE__ */Caml_exceptions.create("ArrayLabels.Bottom"); - -function sort(cmp, a) { - let maxson = (l, i) => { - let i31 = ((i + i | 0) + i | 0) + 1 | 0; - let x = i31; - if ((i31 + 2 | 0) < l) { - if (cmp(Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { - x = i31 + 1 | 0; - } - if (cmp(Caml_array.get(a, x), Caml_array.get(a, i31 + 2 | 0)) < 0) { - x = i31 + 2 | 0; - } - return x; - } - if ((i31 + 1 | 0) < l && cmp(Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { - return i31 + 1 | 0; - } - if (i31 < l) { - return i31; - } - throw new Error(Bottom, { - cause: { - RE_EXN_ID: Bottom, - _1: i - } - }); - }; - let trickle = (l, i, e) => { - try { - let _i = i; - while (true) { - let i$1 = _i; - let j = maxson(l, i$1); - if (cmp(Caml_array.get(a, j), e) <= 0) { - return Caml_array.set(a, i$1, e); - } - Caml_array.set(a, i$1, Caml_array.get(a, j)); - _i = j; - continue; - }; - } catch (raw_i) { - let i$2 = Caml_js_exceptions.internalToOCamlException(raw_i); - if (i$2.RE_EXN_ID === Bottom) { - return Caml_array.set(a, i$2._1, e); - } - throw new Error(i$2.RE_EXN_ID, { - cause: i$2 - }); - } - }; - let bubble = (l, i) => { - try { - let _i = i; - while (true) { - let i$1 = _i; - let j = maxson(l, i$1); - Caml_array.set(a, i$1, Caml_array.get(a, j)); - _i = j; - continue; - }; - } catch (raw_i) { - let i$2 = Caml_js_exceptions.internalToOCamlException(raw_i); - if (i$2.RE_EXN_ID === Bottom) { - return i$2._1; - } - throw new Error(i$2.RE_EXN_ID, { - cause: i$2 - }); - } - }; - let trickleup = (_i, e) => { - while (true) { - let i = _i; - let father = (i - 1 | 0) / 3 | 0; - if (i === father) { - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "arrayLabels.res", - 310, - 4 - ] - } - }); - } - if (cmp(Caml_array.get(a, father), e) >= 0) { - return Caml_array.set(a, i, e); - } - Caml_array.set(a, i, Caml_array.get(a, father)); - if (father <= 0) { - return Caml_array.set(a, 0, e); - } - _i = father; - continue; - }; - }; - let l = a.length; - for (let i = ((l + 1 | 0) / 3 | 0) - 1 | 0; i >= 0; --i) { - trickle(l, i, Caml_array.get(a, i)); - } - for (let i$1 = l - 1 | 0; i$1 >= 2; --i$1) { - let e = Caml_array.get(a, i$1); - Caml_array.set(a, i$1, Caml_array.get(a, 0)); - trickleup(bubble(i$1, 0), e); - } - if (l <= 1) { - return; - } - let e$1 = Caml_array.get(a, 1); - Caml_array.set(a, 1, Caml_array.get(a, 0)); - Caml_array.set(a, 0, e$1); -} - -function stable_sort(cmp, a) { - let merge = (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { - let src1r = src1ofs + src1len | 0; - let src2r = src2ofs + src2len | 0; - let _i1 = src1ofs; - let _s1 = Caml_array.get(a, src1ofs); - let _i2 = src2ofs; - let _s2 = Caml_array.get(src2, src2ofs); - let _d = dstofs; - while (true) { - let d = _d; - let s2 = _s2; - let i2 = _i2; - let s1 = _s1; - let i1 = _i1; - if (cmp(s1, s2) <= 0) { - Caml_array.set(dst, d, s1); - let i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return blit(src2, i2, dst, d + 1 | 0, src2r - i2 | 0); - } - _d = d + 1 | 0; - _s1 = Caml_array.get(a, i1$1); - _i1 = i1$1; - continue; - } - Caml_array.set(dst, d, s2); - let i2$1 = i2 + 1 | 0; - if (i2$1 >= src2r) { - return blit(a, i1, dst, d + 1 | 0, src1r - i1 | 0); - } - _d = d + 1 | 0; - _s2 = Caml_array.get(src2, i2$1); - _i2 = i2$1; - continue; - }; - }; - let isortto = (srcofs, dst, dstofs, len) => { - for (let i = 0; i < len; ++i) { - let e = Caml_array.get(a, srcofs + i | 0); - let j = (dstofs + i | 0) - 1 | 0; - while (j >= dstofs && cmp(Caml_array.get(dst, j), e) > 0) { - Caml_array.set(dst, j + 1 | 0, Caml_array.get(dst, j)); - j = j - 1 | 0; - }; - Caml_array.set(dst, j + 1 | 0, e); - } - }; - let sortto = (srcofs, dst, dstofs, len) => { - if (len <= 5) { - return isortto(srcofs, dst, dstofs, len); - } - let l1 = len / 2 | 0; - let l2 = len - l1 | 0; - sortto(srcofs + l1 | 0, dst, dstofs + l1 | 0, l2); - sortto(srcofs, a, srcofs + l2 | 0, l1); - merge(srcofs + l2 | 0, l1, dst, dstofs + l1 | 0, l2, dst, dstofs); - }; - let l = a.length; - if (l <= 5) { - return isortto(0, a, 0, l); - } - let l1 = l / 2 | 0; - let l2 = l - l1 | 0; - let t = Caml_array.make(l2, Caml_array.get(a, 0)); - sortto(l1, t, 0, l2); - sortto(0, a, l2, l1); - merge(l2, l1, t, 0, l2, a, 0); -} - -let create_matrix = make_matrix; - -let concat = Caml_array.concat; - -let fast_sort = stable_sort; - -export { - init, - make_matrix, - create_matrix, - append, - concat, - sub, - copy, - fill, - blit, - to_list, - of_list, - iter, - map, - iteri, - mapi, - fold_left, - fold_right, - iter2, - map2, - exists, - for_all, - mem, - memq, - sort, - stable_sort, - fast_sort, -} -/* No side effect */ diff --git a/lib/es6/caml_array.js b/lib/es6/caml_array.js deleted file mode 100644 index 17679e810bf..00000000000 --- a/lib/es6/caml_array.js +++ /dev/null @@ -1,115 +0,0 @@ - - - -function sub(x, offset, len) { - let result = new Array(len); - let j = 0; - let i = offset; - while (j < len) { - result[j] = x[i]; - j = j + 1 | 0; - i = i + 1 | 0; - }; - return result; -} - -function len(_acc, _l) { - while (true) { - let l = _l; - let acc = _acc; - if (!l) { - return acc; - } - _l = l.tl; - _acc = l.hd.length + acc | 0; - continue; - }; -} - -function fill(arr, _i, _l) { - while (true) { - let l = _l; - let i = _i; - if (!l) { - return; - } - let x = l.hd; - let l$1 = x.length; - let k = i; - let j = 0; - while (j < l$1) { - arr[k] = x[j]; - k = k + 1 | 0; - j = j + 1 | 0; - }; - _l = l.tl; - _i = k; - continue; - }; -} - -function concat(l) { - let v = len(0, l); - let result = new Array(v); - fill(result, 0, l); - return result; -} - -function set(xs, index, newval) { - if (index < 0 || index >= xs.length) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "index out of bounds" - } - }); - } - xs[index] = newval; -} - -function get(xs, index) { - if (index < 0 || index >= xs.length) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "index out of bounds" - } - }); - } - return xs[index]; -} - -function make(len, init) { - let b = new Array(len); - for (let i = 0; i < len; ++i) { - b[i] = init; - } - return b; -} - -function blit(a1, i1, a2, i2, len) { - if (i2 <= i1) { - for (let j = 0; j < len; ++j) { - a2[j + i2 | 0] = a1[j + i1 | 0]; - } - return; - } - for (let j$1 = len - 1 | 0; j$1 >= 0; --j$1) { - a2[j$1 + i2 | 0] = a1[j$1 + i1 | 0]; - } -} - -function dup(prim) { - return prim.slice(0); -} - -export { - dup, - sub, - concat, - make, - blit, - get, - set, -} -/* No side effect */ diff --git a/lib/es6/caml_array_extern.js b/lib/es6/caml_array_extern.js deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/lib/es6/caml_array_extern.js +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/lib/es6/caml_bigint_extern.js b/lib/es6/caml_bigint_extern.js deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/lib/es6/caml_bigint_extern.js +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/lib/es6/curry.js b/lib/es6/curry.js index 793b2d7f9ab..80d2f9b0436 100644 --- a/lib/es6/curry.js +++ b/lib/es6/curry.js @@ -1,6 +1,5 @@ -import * as Caml_array from "./caml_array.js"; function app(_f, _args) { while (true) { @@ -16,8 +15,8 @@ function app(_f, _args) { if (d >= 0) { return x => app(f, args.concat([x])); } - _args = Caml_array.sub(args, arity, -d | 0); - _f = f.apply(null, Caml_array.sub(args, 0, arity)); + _args = args.slice(arity, len); + _f = f.apply(null, args.slice(0, arity)); continue; }; } diff --git a/lib/es6/primitive_array.js b/lib/es6/primitive_array.js new file mode 100644 index 00000000000..b894a33d503 --- /dev/null +++ b/lib/es6/primitive_array.js @@ -0,0 +1,32 @@ + + + +function get(xs, index) { + if (index < 0 || index >= xs.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds" + } + }); + } + return xs[index]; +} + +function set(xs, index, newval) { + if (index < 0 || index >= xs.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds" + } + }); + } + xs[index] = newval; +} + +export { + get, + set, +} +/* No side effect */ diff --git a/lib/es6/sort.js b/lib/es6/sort.js deleted file mode 100644 index 98d609d6e5a..00000000000 --- a/lib/es6/sort.js +++ /dev/null @@ -1,168 +0,0 @@ - - - -function merge(order, l1, l2) { - if (!l1) { - return l2; - } - if (!l2) { - return l1; - } - let h2 = l2.hd; - let h1 = l1.hd; - if (order(h1, h2)) { - return { - hd: h1, - tl: merge(order, l1.tl, l2) - }; - } else { - return { - hd: h2, - tl: merge(order, l1, l2.tl) - }; - } -} - -function list(order, l) { - let initlist = param => { - if (!param) { - return /* [] */0; - } - let match = param.tl; - let e = param.hd; - if (!match) { - return { - hd: { - hd: e, - tl: /* [] */0 - }, - tl: /* [] */0 - }; - } - let e2 = match.hd; - return { - hd: order(e, e2) ? ({ - hd: e, - tl: { - hd: e2, - tl: /* [] */0 - } - }) : ({ - hd: e2, - tl: { - hd: e, - tl: /* [] */0 - } - }), - tl: initlist(match.tl) - }; - }; - let merge2 = param => { - if (!param) { - return param; - } - let match = param.tl; - if (match) { - return { - hd: merge(order, param.hd, match.hd), - tl: merge2(match.tl) - }; - } else { - return param; - } - }; - let _param = initlist(l); - while (true) { - let param = _param; - if (!param) { - return /* [] */0; - } - if (!param.tl) { - return param.hd; - } - _param = merge2(param); - continue; - }; -} - -function swap(arr, i, j) { - let tmp = arr[i]; - arr[i] = arr[j]; - arr[j] = tmp; -} - -function array(cmp, arr) { - let qsort = (_lo, _hi) => { - while (true) { - let hi = _hi; - let lo = _lo; - if ((hi - lo | 0) < 6) { - return; - } - let mid = ((lo + hi | 0) >>> 1); - if (cmp(arr[mid], arr[lo])) { - swap(arr, mid, lo); - } - if (cmp(arr[hi], arr[mid])) { - swap(arr, mid, hi); - if (cmp(arr[mid], arr[lo])) { - swap(arr, mid, lo); - } - - } - let pivot = arr[mid]; - let i = lo + 1 | 0; - let j = hi - 1 | 0; - if (!cmp(pivot, arr[hi]) || !cmp(arr[lo], pivot)) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Sort.array" - } - }); - } - while (i < j) { - while (!cmp(pivot, arr[i])) { - i = i + 1 | 0; - }; - while (!cmp(arr[j], pivot)) { - j = j - 1 | 0; - }; - if (i < j) { - swap(arr, i, j); - } - i = i + 1 | 0; - j = j - 1 | 0; - }; - if ((j - lo | 0) <= (hi - i | 0)) { - qsort(lo, j); - _lo = i; - continue; - } - qsort(i, hi); - _hi = j; - continue; - }; - }; - qsort(0, arr.length - 1 | 0); - for (let i = 1, i_finish = arr.length; i < i_finish; ++i) { - let val_i = arr[i]; - if (!cmp(arr[i - 1 | 0], val_i)) { - arr[i] = arr[i - 1 | 0]; - let j = i - 1 | 0; - while (j >= 1 && !cmp(arr[j - 1 | 0], val_i)) { - arr[j] = arr[j - 1 | 0]; - j = j - 1 | 0; - }; - arr[j] = val_i; - } - - } -} - -export { - list, - array, - merge, -} -/* No side effect */ diff --git a/lib/es6/stdLabels.js b/lib/es6/stdLabels.js deleted file mode 100644 index 5f65b11a770..00000000000 --- a/lib/es6/stdLabels.js +++ /dev/null @@ -1,12 +0,0 @@ - - - -let $$Array; - -let List; - -export { - $$Array, - List, -} -/* No side effect */ diff --git a/lib/js/array.js b/lib/js/array.js deleted file mode 100644 index 4a1b8d946d3..00000000000 --- a/lib/js/array.js +++ /dev/null @@ -1,511 +0,0 @@ -'use strict'; - -let Caml_array = require("./caml_array.js"); -let Caml_exceptions = require("./caml_exceptions.js"); -let Caml_js_exceptions = require("./caml_js_exceptions.js"); - -function init(l, f) { - if (l === 0) { - return []; - } - if (l < 0) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.init" - } - }); - } - let res = Caml_array.make(l, f(0)); - for (let i = 1; i < l; ++i) { - res[i] = f(i); - } - return res; -} - -function make_matrix(sx, sy, init) { - let res = Caml_array.make(sx, []); - for (let x = 0; x < sx; ++x) { - res[x] = Caml_array.make(sy, init); - } - return res; -} - -function copy(a) { - let l = a.length; - if (l === 0) { - return []; - } else { - return Caml_array.sub(a, 0, l); - } -} - -function append(a1, a2) { - let l1 = a1.length; - if (l1 === 0) { - return copy(a2); - } else if (a2.length === 0) { - return Caml_array.sub(a1, 0, l1); - } else { - return a1.concat(a2); - } -} - -function sub(a, ofs, len) { - if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.sub" - } - }); - } - return Caml_array.sub(a, ofs, len); -} - -function fill(a, ofs, len, v) { - if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.fill" - } - }); - } - for (let i = ofs, i_finish = ofs + len | 0; i < i_finish; ++i) { - a[i] = v; - } -} - -function blit(a1, ofs1, a2, ofs2, len) { - if (len < 0 || ofs1 < 0 || ofs1 > (a1.length - len | 0) || ofs2 < 0 || ofs2 > (a2.length - len | 0)) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.blit" - } - }); - } - Caml_array.blit(a1, ofs1, a2, ofs2, len); -} - -function iter(f, a) { - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - f(a[i]); - } -} - -function iter2(f, a, b) { - if (a.length !== b.length) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.iter2: arrays must have the same length" - } - }); - } - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - f(a[i], b[i]); - } -} - -function map(f, a) { - let l = a.length; - if (l === 0) { - return []; - } - let r = Caml_array.make(l, f(a[0])); - for (let i = 1; i < l; ++i) { - r[i] = f(a[i]); - } - return r; -} - -function map2(f, a, b) { - let la = a.length; - let lb = b.length; - if (la !== lb) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.map2: arrays must have the same length" - } - }); - } - if (la === 0) { - return []; - } - let r = Caml_array.make(la, f(a[0], b[0])); - for (let i = 1; i < la; ++i) { - r[i] = f(a[i], b[i]); - } - return r; -} - -function iteri(f, a) { - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - f(i, a[i]); - } -} - -function mapi(f, a) { - let l = a.length; - if (l === 0) { - return []; - } - let r = Caml_array.make(l, f(0, a[0])); - for (let i = 1; i < l; ++i) { - r[i] = f(i, a[i]); - } - return r; -} - -function to_list(a) { - let _i = a.length - 1 | 0; - let _res = /* [] */0; - while (true) { - let res = _res; - let i = _i; - if (i < 0) { - return res; - } - _res = { - hd: a[i], - tl: res - }; - _i = i - 1 | 0; - continue; - }; -} - -function list_length(_accu, _param) { - while (true) { - let param = _param; - let accu = _accu; - if (!param) { - return accu; - } - _param = param.tl; - _accu = accu + 1 | 0; - continue; - }; -} - -function of_list(param) { - if (!param) { - return []; - } - let a = Caml_array.make(list_length(0, param), param.hd); - let _i = 1; - let _param = param.tl; - while (true) { - let param$1 = _param; - let i = _i; - if (!param$1) { - return a; - } - a[i] = param$1.hd; - _param = param$1.tl; - _i = i + 1 | 0; - continue; - }; -} - -function fold_left(f, x, a) { - let r = x; - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - r = f(r, a[i]); - } - return r; -} - -function fold_right(f, a, x) { - let r = x; - for (let i = a.length - 1 | 0; i >= 0; --i) { - r = f(a[i], r); - } - return r; -} - -function exists(p, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return false; - } - if (p(a[i])) { - return true; - } - _i = i + 1 | 0; - continue; - }; -} - -function for_all(p, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return true; - } - if (!p(a[i])) { - return false; - } - _i = i + 1 | 0; - continue; - }; -} - -function mem(x, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return false; - } - if (a[i] === x) { - return true; - } - _i = i + 1 | 0; - continue; - }; -} - -function memq(x, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return false; - } - if (x === a[i]) { - return true; - } - _i = i + 1 | 0; - continue; - }; -} - -let Bottom = /* @__PURE__ */Caml_exceptions.create("Array.Bottom"); - -function sort(cmp, a) { - let maxson = (l, i) => { - let i31 = ((i + i | 0) + i | 0) + 1 | 0; - let x = i31; - if ((i31 + 2 | 0) < l) { - if (cmp(Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { - x = i31 + 1 | 0; - } - if (cmp(Caml_array.get(a, x), Caml_array.get(a, i31 + 2 | 0)) < 0) { - x = i31 + 2 | 0; - } - return x; - } - if ((i31 + 1 | 0) < l && cmp(Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { - return i31 + 1 | 0; - } - if (i31 < l) { - return i31; - } - throw new Error(Bottom, { - cause: { - RE_EXN_ID: Bottom, - _1: i - } - }); - }; - let trickle = (l, i, e) => { - try { - let _i = i; - while (true) { - let i$1 = _i; - let j = maxson(l, i$1); - if (cmp(Caml_array.get(a, j), e) <= 0) { - return Caml_array.set(a, i$1, e); - } - Caml_array.set(a, i$1, Caml_array.get(a, j)); - _i = j; - continue; - }; - } catch (raw_i) { - let i$2 = Caml_js_exceptions.internalToOCamlException(raw_i); - if (i$2.RE_EXN_ID === Bottom) { - return Caml_array.set(a, i$2._1, e); - } - throw new Error(i$2.RE_EXN_ID, { - cause: i$2 - }); - } - }; - let bubble = (l, i) => { - try { - let _i = i; - while (true) { - let i$1 = _i; - let j = maxson(l, i$1); - Caml_array.set(a, i$1, Caml_array.get(a, j)); - _i = j; - continue; - }; - } catch (raw_i) { - let i$2 = Caml_js_exceptions.internalToOCamlException(raw_i); - if (i$2.RE_EXN_ID === Bottom) { - return i$2._1; - } - throw new Error(i$2.RE_EXN_ID, { - cause: i$2 - }); - } - }; - let trickleup = (_i, e) => { - while (true) { - let i = _i; - let father = (i - 1 | 0) / 3 | 0; - if (i === father) { - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "array.res", - 310, - 4 - ] - } - }); - } - if (cmp(Caml_array.get(a, father), e) >= 0) { - return Caml_array.set(a, i, e); - } - Caml_array.set(a, i, Caml_array.get(a, father)); - if (father <= 0) { - return Caml_array.set(a, 0, e); - } - _i = father; - continue; - }; - }; - let l = a.length; - for (let i = ((l + 1 | 0) / 3 | 0) - 1 | 0; i >= 0; --i) { - trickle(l, i, Caml_array.get(a, i)); - } - for (let i$1 = l - 1 | 0; i$1 >= 2; --i$1) { - let e = Caml_array.get(a, i$1); - Caml_array.set(a, i$1, Caml_array.get(a, 0)); - trickleup(bubble(i$1, 0), e); - } - if (l <= 1) { - return; - } - let e$1 = Caml_array.get(a, 1); - Caml_array.set(a, 1, Caml_array.get(a, 0)); - Caml_array.set(a, 0, e$1); -} - -function stable_sort(cmp, a) { - let merge = (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { - let src1r = src1ofs + src1len | 0; - let src2r = src2ofs + src2len | 0; - let _i1 = src1ofs; - let _s1 = Caml_array.get(a, src1ofs); - let _i2 = src2ofs; - let _s2 = Caml_array.get(src2, src2ofs); - let _d = dstofs; - while (true) { - let d = _d; - let s2 = _s2; - let i2 = _i2; - let s1 = _s1; - let i1 = _i1; - if (cmp(s1, s2) <= 0) { - Caml_array.set(dst, d, s1); - let i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return blit(src2, i2, dst, d + 1 | 0, src2r - i2 | 0); - } - _d = d + 1 | 0; - _s1 = Caml_array.get(a, i1$1); - _i1 = i1$1; - continue; - } - Caml_array.set(dst, d, s2); - let i2$1 = i2 + 1 | 0; - if (i2$1 >= src2r) { - return blit(a, i1, dst, d + 1 | 0, src1r - i1 | 0); - } - _d = d + 1 | 0; - _s2 = Caml_array.get(src2, i2$1); - _i2 = i2$1; - continue; - }; - }; - let isortto = (srcofs, dst, dstofs, len) => { - for (let i = 0; i < len; ++i) { - let e = Caml_array.get(a, srcofs + i | 0); - let j = (dstofs + i | 0) - 1 | 0; - while (j >= dstofs && cmp(Caml_array.get(dst, j), e) > 0) { - Caml_array.set(dst, j + 1 | 0, Caml_array.get(dst, j)); - j = j - 1 | 0; - }; - Caml_array.set(dst, j + 1 | 0, e); - } - }; - let sortto = (srcofs, dst, dstofs, len) => { - if (len <= 5) { - return isortto(srcofs, dst, dstofs, len); - } - let l1 = len / 2 | 0; - let l2 = len - l1 | 0; - sortto(srcofs + l1 | 0, dst, dstofs + l1 | 0, l2); - sortto(srcofs, a, srcofs + l2 | 0, l1); - merge(srcofs + l2 | 0, l1, dst, dstofs + l1 | 0, l2, dst, dstofs); - }; - let l = a.length; - if (l <= 5) { - return isortto(0, a, 0, l); - } - let l1 = l / 2 | 0; - let l2 = l - l1 | 0; - let t = Caml_array.make(l2, Caml_array.get(a, 0)); - sortto(l1, t, 0, l2); - sortto(0, a, l2, l1); - merge(l2, l1, t, 0, l2, a, 0); -} - -let create_matrix = make_matrix; - -let concat = Caml_array.concat; - -let fast_sort = stable_sort; - -exports.init = init; -exports.make_matrix = make_matrix; -exports.create_matrix = create_matrix; -exports.append = append; -exports.concat = concat; -exports.sub = sub; -exports.copy = copy; -exports.fill = fill; -exports.blit = blit; -exports.to_list = to_list; -exports.of_list = of_list; -exports.iter = iter; -exports.iteri = iteri; -exports.map = map; -exports.mapi = mapi; -exports.fold_left = fold_left; -exports.fold_right = fold_right; -exports.iter2 = iter2; -exports.map2 = map2; -exports.for_all = for_all; -exports.exists = exists; -exports.mem = mem; -exports.memq = memq; -exports.sort = sort; -exports.stable_sort = stable_sort; -exports.fast_sort = fast_sort; -/* No side effect */ diff --git a/lib/js/arrayLabels.js b/lib/js/arrayLabels.js deleted file mode 100644 index f9afd1c90f5..00000000000 --- a/lib/js/arrayLabels.js +++ /dev/null @@ -1,511 +0,0 @@ -'use strict'; - -let Caml_array = require("./caml_array.js"); -let Caml_exceptions = require("./caml_exceptions.js"); -let Caml_js_exceptions = require("./caml_js_exceptions.js"); - -function init(l, f) { - if (l === 0) { - return []; - } - if (l < 0) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.init" - } - }); - } - let res = Caml_array.make(l, f(0)); - for (let i = 1; i < l; ++i) { - res[i] = f(i); - } - return res; -} - -function make_matrix(sx, sy, init) { - let res = Caml_array.make(sx, []); - for (let x = 0; x < sx; ++x) { - res[x] = Caml_array.make(sy, init); - } - return res; -} - -function copy(a) { - let l = a.length; - if (l === 0) { - return []; - } else { - return Caml_array.sub(a, 0, l); - } -} - -function append(a1, a2) { - let l1 = a1.length; - if (l1 === 0) { - return copy(a2); - } else if (a2.length === 0) { - return Caml_array.sub(a1, 0, l1); - } else { - return a1.concat(a2); - } -} - -function sub(a, ofs, len) { - if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.sub" - } - }); - } - return Caml_array.sub(a, ofs, len); -} - -function fill(a, ofs, len, v) { - if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.fill" - } - }); - } - for (let i = ofs, i_finish = ofs + len | 0; i < i_finish; ++i) { - a[i] = v; - } -} - -function blit(a1, ofs1, a2, ofs2, len) { - if (len < 0 || ofs1 < 0 || ofs1 > (a1.length - len | 0) || ofs2 < 0 || ofs2 > (a2.length - len | 0)) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.blit" - } - }); - } - Caml_array.blit(a1, ofs1, a2, ofs2, len); -} - -function iter(f, a) { - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - f(a[i]); - } -} - -function iter2(f, a, b) { - if (a.length !== b.length) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.iter2: arrays must have the same length" - } - }); - } - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - f(a[i], b[i]); - } -} - -function map(f, a) { - let l = a.length; - if (l === 0) { - return []; - } - let r = Caml_array.make(l, f(a[0])); - for (let i = 1; i < l; ++i) { - r[i] = f(a[i]); - } - return r; -} - -function map2(f, a, b) { - let la = a.length; - let lb = b.length; - if (la !== lb) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Array.map2: arrays must have the same length" - } - }); - } - if (la === 0) { - return []; - } - let r = Caml_array.make(la, f(a[0], b[0])); - for (let i = 1; i < la; ++i) { - r[i] = f(a[i], b[i]); - } - return r; -} - -function iteri(f, a) { - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - f(i, a[i]); - } -} - -function mapi(f, a) { - let l = a.length; - if (l === 0) { - return []; - } - let r = Caml_array.make(l, f(0, a[0])); - for (let i = 1; i < l; ++i) { - r[i] = f(i, a[i]); - } - return r; -} - -function to_list(a) { - let _i = a.length - 1 | 0; - let _res = /* [] */0; - while (true) { - let res = _res; - let i = _i; - if (i < 0) { - return res; - } - _res = { - hd: a[i], - tl: res - }; - _i = i - 1 | 0; - continue; - }; -} - -function list_length(_accu, _param) { - while (true) { - let param = _param; - let accu = _accu; - if (!param) { - return accu; - } - _param = param.tl; - _accu = accu + 1 | 0; - continue; - }; -} - -function of_list(param) { - if (!param) { - return []; - } - let a = Caml_array.make(list_length(0, param), param.hd); - let _i = 1; - let _param = param.tl; - while (true) { - let param$1 = _param; - let i = _i; - if (!param$1) { - return a; - } - a[i] = param$1.hd; - _param = param$1.tl; - _i = i + 1 | 0; - continue; - }; -} - -function fold_left(f, x, a) { - let r = x; - for (let i = 0, i_finish = a.length; i < i_finish; ++i) { - r = f(r, a[i]); - } - return r; -} - -function fold_right(f, a, x) { - let r = x; - for (let i = a.length - 1 | 0; i >= 0; --i) { - r = f(a[i], r); - } - return r; -} - -function exists(p, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return false; - } - if (p(a[i])) { - return true; - } - _i = i + 1 | 0; - continue; - }; -} - -function for_all(p, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return true; - } - if (!p(a[i])) { - return false; - } - _i = i + 1 | 0; - continue; - }; -} - -function mem(x, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return false; - } - if (a[i] === x) { - return true; - } - _i = i + 1 | 0; - continue; - }; -} - -function memq(x, a) { - let n = a.length; - let _i = 0; - while (true) { - let i = _i; - if (i === n) { - return false; - } - if (x === a[i]) { - return true; - } - _i = i + 1 | 0; - continue; - }; -} - -let Bottom = /* @__PURE__ */Caml_exceptions.create("ArrayLabels.Bottom"); - -function sort(cmp, a) { - let maxson = (l, i) => { - let i31 = ((i + i | 0) + i | 0) + 1 | 0; - let x = i31; - if ((i31 + 2 | 0) < l) { - if (cmp(Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { - x = i31 + 1 | 0; - } - if (cmp(Caml_array.get(a, x), Caml_array.get(a, i31 + 2 | 0)) < 0) { - x = i31 + 2 | 0; - } - return x; - } - if ((i31 + 1 | 0) < l && cmp(Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { - return i31 + 1 | 0; - } - if (i31 < l) { - return i31; - } - throw new Error(Bottom, { - cause: { - RE_EXN_ID: Bottom, - _1: i - } - }); - }; - let trickle = (l, i, e) => { - try { - let _i = i; - while (true) { - let i$1 = _i; - let j = maxson(l, i$1); - if (cmp(Caml_array.get(a, j), e) <= 0) { - return Caml_array.set(a, i$1, e); - } - Caml_array.set(a, i$1, Caml_array.get(a, j)); - _i = j; - continue; - }; - } catch (raw_i) { - let i$2 = Caml_js_exceptions.internalToOCamlException(raw_i); - if (i$2.RE_EXN_ID === Bottom) { - return Caml_array.set(a, i$2._1, e); - } - throw new Error(i$2.RE_EXN_ID, { - cause: i$2 - }); - } - }; - let bubble = (l, i) => { - try { - let _i = i; - while (true) { - let i$1 = _i; - let j = maxson(l, i$1); - Caml_array.set(a, i$1, Caml_array.get(a, j)); - _i = j; - continue; - }; - } catch (raw_i) { - let i$2 = Caml_js_exceptions.internalToOCamlException(raw_i); - if (i$2.RE_EXN_ID === Bottom) { - return i$2._1; - } - throw new Error(i$2.RE_EXN_ID, { - cause: i$2 - }); - } - }; - let trickleup = (_i, e) => { - while (true) { - let i = _i; - let father = (i - 1 | 0) / 3 | 0; - if (i === father) { - throw new Error("Assert_failure", { - cause: { - RE_EXN_ID: "Assert_failure", - _1: [ - "arrayLabels.res", - 310, - 4 - ] - } - }); - } - if (cmp(Caml_array.get(a, father), e) >= 0) { - return Caml_array.set(a, i, e); - } - Caml_array.set(a, i, Caml_array.get(a, father)); - if (father <= 0) { - return Caml_array.set(a, 0, e); - } - _i = father; - continue; - }; - }; - let l = a.length; - for (let i = ((l + 1 | 0) / 3 | 0) - 1 | 0; i >= 0; --i) { - trickle(l, i, Caml_array.get(a, i)); - } - for (let i$1 = l - 1 | 0; i$1 >= 2; --i$1) { - let e = Caml_array.get(a, i$1); - Caml_array.set(a, i$1, Caml_array.get(a, 0)); - trickleup(bubble(i$1, 0), e); - } - if (l <= 1) { - return; - } - let e$1 = Caml_array.get(a, 1); - Caml_array.set(a, 1, Caml_array.get(a, 0)); - Caml_array.set(a, 0, e$1); -} - -function stable_sort(cmp, a) { - let merge = (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) => { - let src1r = src1ofs + src1len | 0; - let src2r = src2ofs + src2len | 0; - let _i1 = src1ofs; - let _s1 = Caml_array.get(a, src1ofs); - let _i2 = src2ofs; - let _s2 = Caml_array.get(src2, src2ofs); - let _d = dstofs; - while (true) { - let d = _d; - let s2 = _s2; - let i2 = _i2; - let s1 = _s1; - let i1 = _i1; - if (cmp(s1, s2) <= 0) { - Caml_array.set(dst, d, s1); - let i1$1 = i1 + 1 | 0; - if (i1$1 >= src1r) { - return blit(src2, i2, dst, d + 1 | 0, src2r - i2 | 0); - } - _d = d + 1 | 0; - _s1 = Caml_array.get(a, i1$1); - _i1 = i1$1; - continue; - } - Caml_array.set(dst, d, s2); - let i2$1 = i2 + 1 | 0; - if (i2$1 >= src2r) { - return blit(a, i1, dst, d + 1 | 0, src1r - i1 | 0); - } - _d = d + 1 | 0; - _s2 = Caml_array.get(src2, i2$1); - _i2 = i2$1; - continue; - }; - }; - let isortto = (srcofs, dst, dstofs, len) => { - for (let i = 0; i < len; ++i) { - let e = Caml_array.get(a, srcofs + i | 0); - let j = (dstofs + i | 0) - 1 | 0; - while (j >= dstofs && cmp(Caml_array.get(dst, j), e) > 0) { - Caml_array.set(dst, j + 1 | 0, Caml_array.get(dst, j)); - j = j - 1 | 0; - }; - Caml_array.set(dst, j + 1 | 0, e); - } - }; - let sortto = (srcofs, dst, dstofs, len) => { - if (len <= 5) { - return isortto(srcofs, dst, dstofs, len); - } - let l1 = len / 2 | 0; - let l2 = len - l1 | 0; - sortto(srcofs + l1 | 0, dst, dstofs + l1 | 0, l2); - sortto(srcofs, a, srcofs + l2 | 0, l1); - merge(srcofs + l2 | 0, l1, dst, dstofs + l1 | 0, l2, dst, dstofs); - }; - let l = a.length; - if (l <= 5) { - return isortto(0, a, 0, l); - } - let l1 = l / 2 | 0; - let l2 = l - l1 | 0; - let t = Caml_array.make(l2, Caml_array.get(a, 0)); - sortto(l1, t, 0, l2); - sortto(0, a, l2, l1); - merge(l2, l1, t, 0, l2, a, 0); -} - -let create_matrix = make_matrix; - -let concat = Caml_array.concat; - -let fast_sort = stable_sort; - -exports.init = init; -exports.make_matrix = make_matrix; -exports.create_matrix = create_matrix; -exports.append = append; -exports.concat = concat; -exports.sub = sub; -exports.copy = copy; -exports.fill = fill; -exports.blit = blit; -exports.to_list = to_list; -exports.of_list = of_list; -exports.iter = iter; -exports.map = map; -exports.iteri = iteri; -exports.mapi = mapi; -exports.fold_left = fold_left; -exports.fold_right = fold_right; -exports.iter2 = iter2; -exports.map2 = map2; -exports.exists = exists; -exports.for_all = for_all; -exports.mem = mem; -exports.memq = memq; -exports.sort = sort; -exports.stable_sort = stable_sort; -exports.fast_sort = fast_sort; -/* No side effect */ diff --git a/lib/js/caml_array.js b/lib/js/caml_array.js deleted file mode 100644 index a79561a9289..00000000000 --- a/lib/js/caml_array.js +++ /dev/null @@ -1,113 +0,0 @@ -'use strict'; - - -function sub(x, offset, len) { - let result = new Array(len); - let j = 0; - let i = offset; - while (j < len) { - result[j] = x[i]; - j = j + 1 | 0; - i = i + 1 | 0; - }; - return result; -} - -function len(_acc, _l) { - while (true) { - let l = _l; - let acc = _acc; - if (!l) { - return acc; - } - _l = l.tl; - _acc = l.hd.length + acc | 0; - continue; - }; -} - -function fill(arr, _i, _l) { - while (true) { - let l = _l; - let i = _i; - if (!l) { - return; - } - let x = l.hd; - let l$1 = x.length; - let k = i; - let j = 0; - while (j < l$1) { - arr[k] = x[j]; - k = k + 1 | 0; - j = j + 1 | 0; - }; - _l = l.tl; - _i = k; - continue; - }; -} - -function concat(l) { - let v = len(0, l); - let result = new Array(v); - fill(result, 0, l); - return result; -} - -function set(xs, index, newval) { - if (index < 0 || index >= xs.length) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "index out of bounds" - } - }); - } - xs[index] = newval; -} - -function get(xs, index) { - if (index < 0 || index >= xs.length) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "index out of bounds" - } - }); - } - return xs[index]; -} - -function make(len, init) { - let b = new Array(len); - for (let i = 0; i < len; ++i) { - b[i] = init; - } - return b; -} - -function blit(a1, i1, a2, i2, len) { - if (i2 <= i1) { - for (let j = 0; j < len; ++j) { - a2[j + i2 | 0] = a1[j + i1 | 0]; - } - return; - } - for (let j$1 = len - 1 | 0; j$1 >= 0; --j$1) { - a2[j$1 + i2 | 0] = a1[j$1 + i1 | 0]; - } -} - -function dup(prim) { - return prim.slice(0); -} - -exports.dup = dup; -exports.sub = sub; -exports.concat = concat; -exports.make = make; -exports.blit = blit; -exports.get = get; -exports.set = set; -/* No side effect */ diff --git a/lib/js/caml_array_extern.js b/lib/js/caml_array_extern.js deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/lib/js/caml_array_extern.js +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/lib/js/caml_bigint_extern.js b/lib/js/caml_bigint_extern.js deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/lib/js/caml_bigint_extern.js +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/lib/js/curry.js b/lib/js/curry.js index 5b6f7bd1eb8..8af8b029994 100644 --- a/lib/js/curry.js +++ b/lib/js/curry.js @@ -1,6 +1,5 @@ 'use strict'; -let Caml_array = require("./caml_array.js"); function app(_f, _args) { while (true) { @@ -16,8 +15,8 @@ function app(_f, _args) { if (d >= 0) { return x => app(f, args.concat([x])); } - _args = Caml_array.sub(args, arity, -d | 0); - _f = f.apply(null, Caml_array.sub(args, 0, arity)); + _args = args.slice(arity, len); + _f = f.apply(null, args.slice(0, arity)); continue; }; } diff --git a/lib/js/primitive_array.js b/lib/js/primitive_array.js new file mode 100644 index 00000000000..75813375733 --- /dev/null +++ b/lib/js/primitive_array.js @@ -0,0 +1,30 @@ +'use strict'; + + +function get(xs, index) { + if (index < 0 || index >= xs.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds" + } + }); + } + return xs[index]; +} + +function set(xs, index, newval) { + if (index < 0 || index >= xs.length) { + throw new Error("Invalid_argument", { + cause: { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds" + } + }); + } + xs[index] = newval; +} + +exports.get = get; +exports.set = set; +/* No side effect */ diff --git a/lib/js/sort.js b/lib/js/sort.js deleted file mode 100644 index d4556f5ccda..00000000000 --- a/lib/js/sort.js +++ /dev/null @@ -1,166 +0,0 @@ -'use strict'; - - -function merge(order, l1, l2) { - if (!l1) { - return l2; - } - if (!l2) { - return l1; - } - let h2 = l2.hd; - let h1 = l1.hd; - if (order(h1, h2)) { - return { - hd: h1, - tl: merge(order, l1.tl, l2) - }; - } else { - return { - hd: h2, - tl: merge(order, l1, l2.tl) - }; - } -} - -function list(order, l) { - let initlist = param => { - if (!param) { - return /* [] */0; - } - let match = param.tl; - let e = param.hd; - if (!match) { - return { - hd: { - hd: e, - tl: /* [] */0 - }, - tl: /* [] */0 - }; - } - let e2 = match.hd; - return { - hd: order(e, e2) ? ({ - hd: e, - tl: { - hd: e2, - tl: /* [] */0 - } - }) : ({ - hd: e2, - tl: { - hd: e, - tl: /* [] */0 - } - }), - tl: initlist(match.tl) - }; - }; - let merge2 = param => { - if (!param) { - return param; - } - let match = param.tl; - if (match) { - return { - hd: merge(order, param.hd, match.hd), - tl: merge2(match.tl) - }; - } else { - return param; - } - }; - let _param = initlist(l); - while (true) { - let param = _param; - if (!param) { - return /* [] */0; - } - if (!param.tl) { - return param.hd; - } - _param = merge2(param); - continue; - }; -} - -function swap(arr, i, j) { - let tmp = arr[i]; - arr[i] = arr[j]; - arr[j] = tmp; -} - -function array(cmp, arr) { - let qsort = (_lo, _hi) => { - while (true) { - let hi = _hi; - let lo = _lo; - if ((hi - lo | 0) < 6) { - return; - } - let mid = ((lo + hi | 0) >>> 1); - if (cmp(arr[mid], arr[lo])) { - swap(arr, mid, lo); - } - if (cmp(arr[hi], arr[mid])) { - swap(arr, mid, hi); - if (cmp(arr[mid], arr[lo])) { - swap(arr, mid, lo); - } - - } - let pivot = arr[mid]; - let i = lo + 1 | 0; - let j = hi - 1 | 0; - if (!cmp(pivot, arr[hi]) || !cmp(arr[lo], pivot)) { - throw new Error("Invalid_argument", { - cause: { - RE_EXN_ID: "Invalid_argument", - _1: "Sort.array" - } - }); - } - while (i < j) { - while (!cmp(pivot, arr[i])) { - i = i + 1 | 0; - }; - while (!cmp(arr[j], pivot)) { - j = j - 1 | 0; - }; - if (i < j) { - swap(arr, i, j); - } - i = i + 1 | 0; - j = j - 1 | 0; - }; - if ((j - lo | 0) <= (hi - i | 0)) { - qsort(lo, j); - _lo = i; - continue; - } - qsort(i, hi); - _hi = j; - continue; - }; - }; - qsort(0, arr.length - 1 | 0); - for (let i = 1, i_finish = arr.length; i < i_finish; ++i) { - let val_i = arr[i]; - if (!cmp(arr[i - 1 | 0], val_i)) { - arr[i] = arr[i - 1 | 0]; - let j = i - 1 | 0; - while (j >= 1 && !cmp(arr[j - 1 | 0], val_i)) { - arr[j] = arr[j - 1 | 0]; - j = j - 1 | 0; - }; - arr[j] = val_i; - } - - } -} - -exports.list = list; -exports.array = array; -exports.merge = merge; -/* No side effect */ diff --git a/lib/js/stdLabels.js b/lib/js/stdLabels.js deleted file mode 100644 index d5c4434c6ff..00000000000 --- a/lib/js/stdLabels.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - - -let $$Array; - -let List; - -exports.$$Array = $$Array; -exports.List = List; -/* No side effect */