From a8ed7127bf6896030e5fbbf0ccaee88245741eae Mon Sep 17 00:00:00 2001 From: prometheansacrifice <3097018+ManasJayanth@users.noreply.github.com> Date: Sun, 19 May 2024 16:51:01 +0530 Subject: [PATCH] MDN canvas tutorial in Reason and Webpack (#35) * .gitignore: add emacs *~ files * Adds a basic canvas with ball bouncing off walls * MDN tutorial rewritten with webpack-reason-loader * Temporarily add melange runtime libs * CI: copy melange runtime lib to node_modules * Add merlin and dot-merlin-reader * Ignore .merlin files from VCS * Split hello.re into two Reason files --- .github/workflows/deploy.yml | 4 + .github/workflows/test-deploy.yml | 4 + .gitignore | 13 +- docusaurus.config.js | 2 + esy.json | 15 + esy.lock/.gitattributes | 3 + esy.lock/.gitignore | 3 + esy.lock/index.json | 1686 ++++ esy.lock/opam/astring.0.8.5/opam | 37 + esy.lock/opam/base-bytes.base/opam | 9 + esy.lock/opam/base-threads.base/opam | 6 + esy.lock/opam/base-unix.base/opam | 6 + esy.lock/opam/base.v0.16.3/opam | 40 + esy.lock/opam/camlp-streams.5.0.1/opam | 59 + esy.lock/opam/chrome-trace.3.15.2/opam | 40 + esy.lock/opam/cmdliner.1.2.0/opam | 39 + esy.lock/opam/conf-bash.1/opam | 14 + esy.lock/opam/cppo.1.6.9/opam | 39 + esy.lock/opam/csexp.1.5.2/opam | 58 + esy.lock/opam/dot-merlin-reader.4.9/opam | 30 + esy.lock/opam/dune-build-info.3.15.2/opam | 46 + esy.lock/opam/dune-configurator.3.15.2/opam | 50 + esy.lock/opam/dune-rpc.3.15.2/opam | 44 + esy.lock/opam/dune.3.15.2/opam | 57 + esy.lock/opam/dyn.3.15.2/opam | 41 + esy.lock/opam/either.1.0.0/opam | 40 + esy.lock/opam/fiber.3.7.0/opam | 39 + esy.lock/opam/fix.20230505/opam | 26 + esy.lock/opam/fpath.0.7.3/opam | 36 + esy.lock/opam/melange.3.0.0-51/opam | 47 + esy.lock/opam/menhir.20231231/opam | 30 + esy.lock/opam/menhirCST.20231231/opam | 29 + esy.lock/opam/menhirLib.20231231/opam | 30 + esy.lock/opam/menhirSdk.20231231/opam | 30 + esy.lock/opam/merlin-extend.0.6.1/opam | 30 + esy.lock/opam/merlin-lib.4.14-501/opam | 34 + esy.lock/opam/merlin.4.14-501/opam | 81 + .../opam/ocaml-compiler-libs.v0.12.4/opam | 39 + esy.lock/opam/ocaml-lsp-server.1.17.0/opam | 67 + esy.lock/opam/ocaml-version.3.6.7/opam | 55 + esy.lock/opam/ocamlbuild.0.14.3/opam | 40 + esy.lock/opam/ocamlc-loc.3.15.2/opam | 44 + .../files/0001-Harden-test-for-OCaml-5.patch | 12 + esy.lock/opam/ocamlfind.1.9.6/opam | 48 + esy.lock/opam/ocamlformat-lib.0.26.2/opam | 68 + esy.lock/opam/ocamlformat-rpc-lib.0.26.2/opam | 49 + esy.lock/opam/ocamlformat-rpc.removed/opam | 18 + esy.lock/opam/ocamlformat.0.26.2/opam | 58 + esy.lock/opam/ocp-indent.1.8.1/opam | 57 + esy.lock/opam/ordering.3.15.2/opam | 39 + esy.lock/opam/pp.1.2.0/opam | 59 + esy.lock/opam/ppx_derivers.1.2.1/opam | 23 + .../opam/ppx_yojson_conv_lib.v0.16.0/opam | 24 + esy.lock/opam/ppxlib.0.32.1/opam | 63 + esy.lock/opam/re.1.11.0/opam | 46 + esy.lock/opam/reason.3.11.0/opam | 51 + esy.lock/opam/result.1.5/opam | 22 + esy.lock/opam/seq.base/files/META.seq | 4 + esy.lock/opam/seq.base/files/seq.install | 3 + esy.lock/opam/seq.base/opam | 15 + esy.lock/opam/sexplib0.v0.16.0/opam | 26 + esy.lock/opam/spawn.v0.15.1/opam | 56 + esy.lock/opam/stdio.v0.16.0/opam | 27 + esy.lock/opam/stdlib-shims.0.3.0/opam | 31 + esy.lock/opam/stdune.3.15.2/opam | 45 + esy.lock/opam/topkg.1.0.7/opam | 47 + esy.lock/opam/uucp.15.1.0/opam | 51 + esy.lock/opam/uuseg.15.1.0/opam | 55 + esy.lock/opam/uutf.1.0.3/opam | 36 + esy.lock/opam/xdg.3.15.2/opam | 40 + esy.lock/opam/yojson.2.1.2/opam | 48 + .../files/darwin.patch | 26 + .../package.json | 27 + ...indows-build-error-Not-a-binary-file.patch | 34 + .../files/awk.patch | 33 + .../package.json | 15 + .../files/ocamlbuild-0.14.2.patch | 0 .../files/winpatch.patch | 11 + .../package.json | 29 + .../files/findlib.patch | 11 + .../package.json | 61 + melange-node-modules/melange.belt/belt.js | 2 + .../melange.belt/belt_Array.js | 764 ++ .../melange.belt/belt_Float.js | 16 + .../melange.belt/belt_HashMap.js | 274 + .../melange.belt/belt_HashMapInt.js | 264 + .../melange.belt/belt_HashMapString.js | 264 + .../melange.belt/belt_HashSet.js | 216 + .../melange.belt/belt_HashSetInt.js | 207 + .../melange.belt/belt_HashSetString.js | 207 + melange-node-modules/melange.belt/belt_Id.js | 71 + melange-node-modules/melange.belt/belt_Int.js | 16 + .../melange.belt/belt_List.js | 1512 ++++ melange-node-modules/melange.belt/belt_Map.js | 367 + .../melange.belt/belt_MapDict.js | 423 + .../melange.belt/belt_MapInt.js | 311 + .../melange.belt/belt_MapString.js | 311 + .../melange.belt/belt_MutableMap.js | 390 + .../melange.belt/belt_MutableMapInt.js | 363 + .../melange.belt/belt_MutableMapString.js | 363 + .../melange.belt/belt_MutableQueue.js | 307 + .../melange.belt/belt_MutableSet.js | 540 ++ .../melange.belt/belt_MutableSetInt.js | 508 ++ .../melange.belt/belt_MutableSetString.js | 508 ++ .../melange.belt/belt_MutableStack.js | 141 + .../melange.belt/belt_Option.js | 151 + .../melange.belt/belt_Range.js | 109 + .../melange.belt/belt_Result.js | 136 + melange-node-modules/melange.belt/belt_Set.js | 305 + .../melange.belt/belt_SetDict.js | 370 + .../melange.belt/belt_SetInt.js | 366 + .../melange.belt/belt_SetString.js | 366 + .../melange.belt/belt_SortArray.js | 421 + .../melange.belt/belt_SortArrayInt.js | 374 + .../melange.belt/belt_SortArrayString.js | 374 + melange-node-modules/melange.belt/belt__.js | 9 + .../melange.belt/belt_internalAVLset.js | 965 +++ .../melange.belt/belt_internalAVLtree.js | 1173 +++ .../melange.belt/belt_internalBuckets.js | 284 + .../melange.belt/belt_internalBucketsType.js | 49 + .../melange.belt/belt_internalMapInt.js | 367 + .../melange.belt/belt_internalMapString.js | 367 + .../melange.belt/belt_internalSetBuckets.js | 188 + .../melange.belt/belt_internalSetInt.js | 207 + .../melange.belt/belt_internalSetString.js | 207 + melange-node-modules/melange.dom/dom.js | 2 + melange-node-modules/melange.dom/dom__.js | 9 + .../melange.dom/dom_storage.js | 2 + .../melange.dom/dom_storage2.js | 2 + melange-node-modules/melange.js/caml.js | 214 + melange-node-modules/melange.js/caml_array.js | 122 + .../melange.js/caml_array_extern.js | 2 + melange-node-modules/melange.js/caml_bytes.js | 404 + .../melange.js/caml_exceptions.js | 45 + .../melange.js/caml_external_polyfill.js | 32 + melange-node-modules/melange.js/caml_float.js | 134 + .../melange.js/caml_float_extern.js | 2 + .../melange.js/caml_format.js | 831 ++ melange-node-modules/melange.js/caml_gc.js | 55 + melange-node-modules/melange.js/caml_hash.js | 105 + .../melange.js/caml_hash_primitive.js | 51 + melange-node-modules/melange.js/caml_int32.js | 28 + .../melange.js/caml_int32_extern.js | 9 + melange-node-modules/melange.js/caml_int64.js | 598 ++ .../melange.js/caml_int64_extern.js | 2 + melange-node-modules/melange.js/caml_io.js | 82 + .../melange.js/caml_js_exceptions.js | 32 + melange-node-modules/melange.js/caml_lexer.js | 258 + melange-node-modules/melange.js/caml_md5.js | 168 + .../melange.js/caml_module.js | 117 + .../melange.js/caml_nativeint_extern.js | 2 + melange-node-modules/melange.js/caml_obj.js | 438 + melange-node-modules/melange.js/caml_oo.js | 49 + .../melange.js/caml_oo_curry.js | 54 + .../melange.js/caml_option.js | 86 + .../melange.js/caml_parser.js | 303 + .../melange.js/caml_splice_call.js | 52 + .../melange.js/caml_string.js | 23 + .../melange.js/caml_string_extern.js | 2 + melange-node-modules/melange.js/caml_sys.js | 108 + .../melange.js/caml_undefined_extern.js | 2 + melange-node-modules/melange.js/curry.js | 526 ++ melange-node-modules/melange.js/js.js | 24 + melange-node-modules/melange.js/js_OO.js | 15 + melange-node-modules/melange.js/js__.js | 9 + melange-node-modules/melange.js/js_array.js | 2 + melange-node-modules/melange.js/js_array2.js | 2 + melange-node-modules/melange.js/js_bigint.js | 2 + melange-node-modules/melange.js/js_cast.js | 2 + melange-node-modules/melange.js/js_console.js | 2 + melange-node-modules/melange.js/js_date.js | 2 + melange-node-modules/melange.js/js_dict.js | 85 + melange-node-modules/melange.js/js_exn.js | 48 + melange-node-modules/melange.js/js_float.js | 2 + melange-node-modules/melange.js/js_global.js | 2 + melange-node-modules/melange.js/js_int.js | 17 + .../melange.js/js_internal.js | 12 + melange-node-modules/melange.js/js_json.js | 172 + melange-node-modules/melange.js/js_list.js | 334 + melange-node-modules/melange.js/js_map.js | 2 + .../melange.js/js_mapperRt.js | 54 + melange-node-modules/melange.js/js_math.js | 50 + melange-node-modules/melange.js/js_null.js | 49 + .../melange.js/js_null_undefined.js | 35 + melange-node-modules/melange.js/js_option.js | 103 + melange-node-modules/melange.js/js_promise.js | 2 + melange-node-modules/melange.js/js_re.js | 2 + melange-node-modules/melange.js/js_result.js | 2 + melange-node-modules/melange.js/js_set.js | 2 + melange-node-modules/melange.js/js_string.js | 2 + melange-node-modules/melange.js/js_string2.js | 2 + .../melange.js/js_typed_array.js | 39 + .../melange.js/js_typed_array2.js | 39 + melange-node-modules/melange.js/js_types.js | 77 + .../melange.js/js_undefined.js | 52 + melange-node-modules/melange.js/js_vector.js | 134 + melange-node-modules/melange.js/js_weakmap.js | 2 + melange-node-modules/melange.js/js_weakset.js | 2 + .../melange.js/melange_mini_stdlib.js | 12 + melange-node-modules/melange/arg.js | 1027 +++ melange-node-modules/melange/array.js | 786 ++ melange-node-modules/melange/arrayLabels.js | 127 + melange-node-modules/melange/atomic.js | 31 + melange-node-modules/melange/bool.js | 58 + melange-node-modules/melange/buffer.js | 569 ++ melange-node-modules/melange/bytes.js | 1596 ++++ melange-node-modules/melange/bytesLabels.js | 157 + melange-node-modules/melange/callback.js | 19 + .../melange/camlinternalAtomic.js | 58 + .../melange/camlinternalFormat.js | 7495 +++++++++++++++++ .../melange/camlinternalFormatBasics.js | 350 + .../melange/camlinternalLazy.js | 69 + .../melange/camlinternalMod.js | 2 + .../melange/camlinternalOO.js | 810 ++ melange-node-modules/melange/char.js | 119 + melange-node-modules/melange/complex.js | 164 + melange-node-modules/melange/digest.js | 142 + melange-node-modules/melange/domain.js | 299 + melange-node-modules/melange/either.js | 143 + melange-node-modules/melange/ephemeron.js | 3199 +++++++ melange-node-modules/melange/filename.js | 802 ++ melange-node-modules/melange/float.js | 911 ++ melange-node-modules/melange/format.js | 2164 +++++ melange-node-modules/melange/fun.js | 68 + melange-node-modules/melange/gc.js | 498 ++ melange-node-modules/melange/hashtbl.js | 1337 +++ melange-node-modules/melange/in_channel.js | 327 + melange-node-modules/melange/int.js | 79 + melange-node-modules/melange/int32.js | 161 + melange-node-modules/melange/int64.js | 144 + melange-node-modules/melange/lazy.js | 62 + melange-node-modules/melange/lexing.js | 260 + melange-node-modules/melange/list.js | 2347 ++++++ melange-node-modules/melange/listLabels.js | 202 + melange-node-modules/melange/map.js | 1087 +++ melange-node-modules/melange/marshal.js | 100 + melange-node-modules/melange/moreLabels.js | 18 + melange-node-modules/melange/mutex.js | 49 + melange-node-modules/melange/obj.js | 227 + melange-node-modules/melange/oo.js | 16 + melange-node-modules/melange/option.js | 155 + melange-node-modules/melange/out_channel.js | 108 + melange-node-modules/melange/parsing.js | 237 + melange-node-modules/melange/printexc.js | 562 ++ melange-node-modules/melange/printf.js | 92 + melange-node-modules/melange/queue.js | 248 + melange-node-modules/melange/random.js | 355 + melange-node-modules/melange/result.js | 205 + melange-node-modules/melange/scanf.js | 2236 +++++ melange-node-modules/melange/seq.js | 1203 +++ melange-node-modules/melange/set.js | 1157 +++ melange-node-modules/melange/stack.js | 147 + melange-node-modules/melange/stdLabels.js | 2 + melange-node-modules/melange/std_exit.js | 10 + melange-node-modules/melange/stdlib.js | 852 ++ melange-node-modules/melange/string.js | 469 ++ melange-node-modules/melange/stringLabels.js | 133 + melange-node-modules/melange/sys.js | 197 + melange-node-modules/melange/type.js | 35 + melange-node-modules/melange/uchar.js | 224 + melange-node-modules/melange/unit.js | 21 + melange-node-modules/melange/weak.js | 463 + package-lock.json | 9 +- package.json | 3 +- plugins/docusaurus-webpack-plugin/index.js | 24 + .../package-lock.json | 18 + .../docusaurus-webpack-plugin/package.json | 7 + .../reason-loader.js | 14 + src/pages/mdn-game-tutorial/Animation.re | 60 + src/pages/mdn-game-tutorial/bindings.re | 24 + src/pages/mdn-game-tutorial/index.js | 27 + 271 files changed, 63260 insertions(+), 4 deletions(-) create mode 100644 esy.json create mode 100644 esy.lock/.gitattributes create mode 100644 esy.lock/.gitignore create mode 100644 esy.lock/index.json create mode 100644 esy.lock/opam/astring.0.8.5/opam create mode 100644 esy.lock/opam/base-bytes.base/opam create mode 100644 esy.lock/opam/base-threads.base/opam create mode 100644 esy.lock/opam/base-unix.base/opam create mode 100644 esy.lock/opam/base.v0.16.3/opam create mode 100644 esy.lock/opam/camlp-streams.5.0.1/opam create mode 100644 esy.lock/opam/chrome-trace.3.15.2/opam create mode 100644 esy.lock/opam/cmdliner.1.2.0/opam create mode 100644 esy.lock/opam/conf-bash.1/opam create mode 100644 esy.lock/opam/cppo.1.6.9/opam create mode 100644 esy.lock/opam/csexp.1.5.2/opam create mode 100644 esy.lock/opam/dot-merlin-reader.4.9/opam create mode 100644 esy.lock/opam/dune-build-info.3.15.2/opam create mode 100644 esy.lock/opam/dune-configurator.3.15.2/opam create mode 100644 esy.lock/opam/dune-rpc.3.15.2/opam create mode 100644 esy.lock/opam/dune.3.15.2/opam create mode 100644 esy.lock/opam/dyn.3.15.2/opam create mode 100644 esy.lock/opam/either.1.0.0/opam create mode 100644 esy.lock/opam/fiber.3.7.0/opam create mode 100644 esy.lock/opam/fix.20230505/opam create mode 100644 esy.lock/opam/fpath.0.7.3/opam create mode 100644 esy.lock/opam/melange.3.0.0-51/opam create mode 100644 esy.lock/opam/menhir.20231231/opam create mode 100644 esy.lock/opam/menhirCST.20231231/opam create mode 100644 esy.lock/opam/menhirLib.20231231/opam create mode 100644 esy.lock/opam/menhirSdk.20231231/opam create mode 100644 esy.lock/opam/merlin-extend.0.6.1/opam create mode 100644 esy.lock/opam/merlin-lib.4.14-501/opam create mode 100644 esy.lock/opam/merlin.4.14-501/opam create mode 100644 esy.lock/opam/ocaml-compiler-libs.v0.12.4/opam create mode 100644 esy.lock/opam/ocaml-lsp-server.1.17.0/opam create mode 100644 esy.lock/opam/ocaml-version.3.6.7/opam create mode 100644 esy.lock/opam/ocamlbuild.0.14.3/opam create mode 100644 esy.lock/opam/ocamlc-loc.3.15.2/opam create mode 100644 esy.lock/opam/ocamlfind.1.9.6/files/0001-Harden-test-for-OCaml-5.patch create mode 100644 esy.lock/opam/ocamlfind.1.9.6/opam create mode 100644 esy.lock/opam/ocamlformat-lib.0.26.2/opam create mode 100644 esy.lock/opam/ocamlformat-rpc-lib.0.26.2/opam create mode 100644 esy.lock/opam/ocamlformat-rpc.removed/opam create mode 100644 esy.lock/opam/ocamlformat.0.26.2/opam create mode 100644 esy.lock/opam/ocp-indent.1.8.1/opam create mode 100644 esy.lock/opam/ordering.3.15.2/opam create mode 100644 esy.lock/opam/pp.1.2.0/opam create mode 100644 esy.lock/opam/ppx_derivers.1.2.1/opam create mode 100644 esy.lock/opam/ppx_yojson_conv_lib.v0.16.0/opam create mode 100644 esy.lock/opam/ppxlib.0.32.1/opam create mode 100644 esy.lock/opam/re.1.11.0/opam create mode 100644 esy.lock/opam/reason.3.11.0/opam create mode 100644 esy.lock/opam/result.1.5/opam create mode 100644 esy.lock/opam/seq.base/files/META.seq create mode 100644 esy.lock/opam/seq.base/files/seq.install create mode 100644 esy.lock/opam/seq.base/opam create mode 100644 esy.lock/opam/sexplib0.v0.16.0/opam create mode 100644 esy.lock/opam/spawn.v0.15.1/opam create mode 100644 esy.lock/opam/stdio.v0.16.0/opam create mode 100644 esy.lock/opam/stdlib-shims.0.3.0/opam create mode 100644 esy.lock/opam/stdune.3.15.2/opam create mode 100644 esy.lock/opam/topkg.1.0.7/opam create mode 100644 esy.lock/opam/uucp.15.1.0/opam create mode 100644 esy.lock/opam/uuseg.15.1.0/opam create mode 100644 esy.lock/opam/uutf.1.0.3/opam create mode 100644 esy.lock/opam/xdg.3.15.2/opam create mode 100644 esy.lock/opam/yojson.2.1.2/opam create mode 100644 esy.lock/overrides/opam__s__dune_configurator_opam__c__3.15.2_opam_override/files/darwin.patch create mode 100644 esy.lock/overrides/opam__s__dune_configurator_opam__c__3.15.2_opam_override/package.json create mode 100644 esy.lock/overrides/opam__s__melange_opam__c__3.0.0_51_opam_override/files/0001-Fixes-Windows-build-error-Not-a-binary-file.patch create mode 100644 esy.lock/overrides/opam__s__melange_opam__c__3.0.0_51_opam_override/files/awk.patch create mode 100644 esy.lock/overrides/opam__s__melange_opam__c__3.0.0_51_opam_override/package.json create mode 100644 esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.3_opam_override/files/ocamlbuild-0.14.2.patch create mode 100644 esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.3_opam_override/files/winpatch.patch create mode 100644 esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.3_opam_override/package.json create mode 100644 esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.6_opam_override/files/findlib.patch create mode 100644 esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.6_opam_override/package.json create mode 100644 melange-node-modules/melange.belt/belt.js create mode 100644 melange-node-modules/melange.belt/belt_Array.js create mode 100644 melange-node-modules/melange.belt/belt_Float.js create mode 100644 melange-node-modules/melange.belt/belt_HashMap.js create mode 100644 melange-node-modules/melange.belt/belt_HashMapInt.js create mode 100644 melange-node-modules/melange.belt/belt_HashMapString.js create mode 100644 melange-node-modules/melange.belt/belt_HashSet.js create mode 100644 melange-node-modules/melange.belt/belt_HashSetInt.js create mode 100644 melange-node-modules/melange.belt/belt_HashSetString.js create mode 100644 melange-node-modules/melange.belt/belt_Id.js create mode 100644 melange-node-modules/melange.belt/belt_Int.js create mode 100644 melange-node-modules/melange.belt/belt_List.js create mode 100644 melange-node-modules/melange.belt/belt_Map.js create mode 100644 melange-node-modules/melange.belt/belt_MapDict.js create mode 100644 melange-node-modules/melange.belt/belt_MapInt.js create mode 100644 melange-node-modules/melange.belt/belt_MapString.js create mode 100644 melange-node-modules/melange.belt/belt_MutableMap.js create mode 100644 melange-node-modules/melange.belt/belt_MutableMapInt.js create mode 100644 melange-node-modules/melange.belt/belt_MutableMapString.js create mode 100644 melange-node-modules/melange.belt/belt_MutableQueue.js create mode 100644 melange-node-modules/melange.belt/belt_MutableSet.js create mode 100644 melange-node-modules/melange.belt/belt_MutableSetInt.js create mode 100644 melange-node-modules/melange.belt/belt_MutableSetString.js create mode 100644 melange-node-modules/melange.belt/belt_MutableStack.js create mode 100644 melange-node-modules/melange.belt/belt_Option.js create mode 100644 melange-node-modules/melange.belt/belt_Range.js create mode 100644 melange-node-modules/melange.belt/belt_Result.js create mode 100644 melange-node-modules/melange.belt/belt_Set.js create mode 100644 melange-node-modules/melange.belt/belt_SetDict.js create mode 100644 melange-node-modules/melange.belt/belt_SetInt.js create mode 100644 melange-node-modules/melange.belt/belt_SetString.js create mode 100644 melange-node-modules/melange.belt/belt_SortArray.js create mode 100644 melange-node-modules/melange.belt/belt_SortArrayInt.js create mode 100644 melange-node-modules/melange.belt/belt_SortArrayString.js create mode 100644 melange-node-modules/melange.belt/belt__.js create mode 100644 melange-node-modules/melange.belt/belt_internalAVLset.js create mode 100644 melange-node-modules/melange.belt/belt_internalAVLtree.js create mode 100644 melange-node-modules/melange.belt/belt_internalBuckets.js create mode 100644 melange-node-modules/melange.belt/belt_internalBucketsType.js create mode 100644 melange-node-modules/melange.belt/belt_internalMapInt.js create mode 100644 melange-node-modules/melange.belt/belt_internalMapString.js create mode 100644 melange-node-modules/melange.belt/belt_internalSetBuckets.js create mode 100644 melange-node-modules/melange.belt/belt_internalSetInt.js create mode 100644 melange-node-modules/melange.belt/belt_internalSetString.js create mode 100644 melange-node-modules/melange.dom/dom.js create mode 100644 melange-node-modules/melange.dom/dom__.js create mode 100644 melange-node-modules/melange.dom/dom_storage.js create mode 100644 melange-node-modules/melange.dom/dom_storage2.js create mode 100644 melange-node-modules/melange.js/caml.js create mode 100644 melange-node-modules/melange.js/caml_array.js create mode 100644 melange-node-modules/melange.js/caml_array_extern.js create mode 100644 melange-node-modules/melange.js/caml_bytes.js create mode 100644 melange-node-modules/melange.js/caml_exceptions.js create mode 100644 melange-node-modules/melange.js/caml_external_polyfill.js create mode 100644 melange-node-modules/melange.js/caml_float.js create mode 100644 melange-node-modules/melange.js/caml_float_extern.js create mode 100644 melange-node-modules/melange.js/caml_format.js create mode 100644 melange-node-modules/melange.js/caml_gc.js create mode 100644 melange-node-modules/melange.js/caml_hash.js create mode 100644 melange-node-modules/melange.js/caml_hash_primitive.js create mode 100644 melange-node-modules/melange.js/caml_int32.js create mode 100644 melange-node-modules/melange.js/caml_int32_extern.js create mode 100644 melange-node-modules/melange.js/caml_int64.js create mode 100644 melange-node-modules/melange.js/caml_int64_extern.js create mode 100644 melange-node-modules/melange.js/caml_io.js create mode 100644 melange-node-modules/melange.js/caml_js_exceptions.js create mode 100644 melange-node-modules/melange.js/caml_lexer.js create mode 100644 melange-node-modules/melange.js/caml_md5.js create mode 100644 melange-node-modules/melange.js/caml_module.js create mode 100644 melange-node-modules/melange.js/caml_nativeint_extern.js create mode 100644 melange-node-modules/melange.js/caml_obj.js create mode 100644 melange-node-modules/melange.js/caml_oo.js create mode 100644 melange-node-modules/melange.js/caml_oo_curry.js create mode 100644 melange-node-modules/melange.js/caml_option.js create mode 100644 melange-node-modules/melange.js/caml_parser.js create mode 100644 melange-node-modules/melange.js/caml_splice_call.js create mode 100644 melange-node-modules/melange.js/caml_string.js create mode 100644 melange-node-modules/melange.js/caml_string_extern.js create mode 100644 melange-node-modules/melange.js/caml_sys.js create mode 100644 melange-node-modules/melange.js/caml_undefined_extern.js create mode 100644 melange-node-modules/melange.js/curry.js create mode 100644 melange-node-modules/melange.js/js.js create mode 100644 melange-node-modules/melange.js/js_OO.js create mode 100644 melange-node-modules/melange.js/js__.js create mode 100644 melange-node-modules/melange.js/js_array.js create mode 100644 melange-node-modules/melange.js/js_array2.js create mode 100644 melange-node-modules/melange.js/js_bigint.js create mode 100644 melange-node-modules/melange.js/js_cast.js create mode 100644 melange-node-modules/melange.js/js_console.js create mode 100644 melange-node-modules/melange.js/js_date.js create mode 100644 melange-node-modules/melange.js/js_dict.js create mode 100644 melange-node-modules/melange.js/js_exn.js create mode 100644 melange-node-modules/melange.js/js_float.js create mode 100644 melange-node-modules/melange.js/js_global.js create mode 100644 melange-node-modules/melange.js/js_int.js create mode 100644 melange-node-modules/melange.js/js_internal.js create mode 100644 melange-node-modules/melange.js/js_json.js create mode 100644 melange-node-modules/melange.js/js_list.js create mode 100644 melange-node-modules/melange.js/js_map.js create mode 100644 melange-node-modules/melange.js/js_mapperRt.js create mode 100644 melange-node-modules/melange.js/js_math.js create mode 100644 melange-node-modules/melange.js/js_null.js create mode 100644 melange-node-modules/melange.js/js_null_undefined.js create mode 100644 melange-node-modules/melange.js/js_option.js create mode 100644 melange-node-modules/melange.js/js_promise.js create mode 100644 melange-node-modules/melange.js/js_re.js create mode 100644 melange-node-modules/melange.js/js_result.js create mode 100644 melange-node-modules/melange.js/js_set.js create mode 100644 melange-node-modules/melange.js/js_string.js create mode 100644 melange-node-modules/melange.js/js_string2.js create mode 100644 melange-node-modules/melange.js/js_typed_array.js create mode 100644 melange-node-modules/melange.js/js_typed_array2.js create mode 100644 melange-node-modules/melange.js/js_types.js create mode 100644 melange-node-modules/melange.js/js_undefined.js create mode 100644 melange-node-modules/melange.js/js_vector.js create mode 100644 melange-node-modules/melange.js/js_weakmap.js create mode 100644 melange-node-modules/melange.js/js_weakset.js create mode 100644 melange-node-modules/melange.js/melange_mini_stdlib.js create mode 100644 melange-node-modules/melange/arg.js create mode 100644 melange-node-modules/melange/array.js create mode 100644 melange-node-modules/melange/arrayLabels.js create mode 100644 melange-node-modules/melange/atomic.js create mode 100644 melange-node-modules/melange/bool.js create mode 100644 melange-node-modules/melange/buffer.js create mode 100644 melange-node-modules/melange/bytes.js create mode 100644 melange-node-modules/melange/bytesLabels.js create mode 100644 melange-node-modules/melange/callback.js create mode 100644 melange-node-modules/melange/camlinternalAtomic.js create mode 100644 melange-node-modules/melange/camlinternalFormat.js create mode 100644 melange-node-modules/melange/camlinternalFormatBasics.js create mode 100644 melange-node-modules/melange/camlinternalLazy.js create mode 100644 melange-node-modules/melange/camlinternalMod.js create mode 100644 melange-node-modules/melange/camlinternalOO.js create mode 100644 melange-node-modules/melange/char.js create mode 100644 melange-node-modules/melange/complex.js create mode 100644 melange-node-modules/melange/digest.js create mode 100644 melange-node-modules/melange/domain.js create mode 100644 melange-node-modules/melange/either.js create mode 100644 melange-node-modules/melange/ephemeron.js create mode 100644 melange-node-modules/melange/filename.js create mode 100644 melange-node-modules/melange/float.js create mode 100644 melange-node-modules/melange/format.js create mode 100644 melange-node-modules/melange/fun.js create mode 100644 melange-node-modules/melange/gc.js create mode 100644 melange-node-modules/melange/hashtbl.js create mode 100644 melange-node-modules/melange/in_channel.js create mode 100644 melange-node-modules/melange/int.js create mode 100644 melange-node-modules/melange/int32.js create mode 100644 melange-node-modules/melange/int64.js create mode 100644 melange-node-modules/melange/lazy.js create mode 100644 melange-node-modules/melange/lexing.js create mode 100644 melange-node-modules/melange/list.js create mode 100644 melange-node-modules/melange/listLabels.js create mode 100644 melange-node-modules/melange/map.js create mode 100644 melange-node-modules/melange/marshal.js create mode 100644 melange-node-modules/melange/moreLabels.js create mode 100644 melange-node-modules/melange/mutex.js create mode 100644 melange-node-modules/melange/obj.js create mode 100644 melange-node-modules/melange/oo.js create mode 100644 melange-node-modules/melange/option.js create mode 100644 melange-node-modules/melange/out_channel.js create mode 100644 melange-node-modules/melange/parsing.js create mode 100644 melange-node-modules/melange/printexc.js create mode 100644 melange-node-modules/melange/printf.js create mode 100644 melange-node-modules/melange/queue.js create mode 100644 melange-node-modules/melange/random.js create mode 100644 melange-node-modules/melange/result.js create mode 100644 melange-node-modules/melange/scanf.js create mode 100644 melange-node-modules/melange/seq.js create mode 100644 melange-node-modules/melange/set.js create mode 100644 melange-node-modules/melange/stack.js create mode 100644 melange-node-modules/melange/stdLabels.js create mode 100644 melange-node-modules/melange/std_exit.js create mode 100644 melange-node-modules/melange/stdlib.js create mode 100644 melange-node-modules/melange/string.js create mode 100644 melange-node-modules/melange/stringLabels.js create mode 100644 melange-node-modules/melange/sys.js create mode 100644 melange-node-modules/melange/type.js create mode 100644 melange-node-modules/melange/uchar.js create mode 100644 melange-node-modules/melange/unit.js create mode 100644 melange-node-modules/melange/weak.js create mode 100644 plugins/docusaurus-webpack-plugin/index.js create mode 100644 plugins/docusaurus-webpack-plugin/package-lock.json create mode 100644 plugins/docusaurus-webpack-plugin/package.json create mode 100644 plugins/docusaurus-webpack-plugin/reason-loader.js create mode 100644 src/pages/mdn-game-tutorial/Animation.re create mode 100644 src/pages/mdn-game-tutorial/bindings.re create mode 100644 src/pages/mdn-game-tutorial/index.js diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b075d22..13bd3aa 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -19,6 +19,10 @@ jobs: - name: Install dependencies run: npm ci + + - name: Copy melange runtime libs + bash: cp -R melange-node-modules/* ./node_modules/ + - name: Build website run: npm run build diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml index a8b1571..de8c023 100644 --- a/.github/workflows/test-deploy.yml +++ b/.github/workflows/test-deploy.yml @@ -22,6 +22,10 @@ jobs: - name: Install dependencies run: npm ci + + - name: Copy melange runtime libs + bash: cp -R melange-node-modules/* ./node_modules/ + - name: Test build website run: npm run build diff --git a/.gitignore b/.gitignore index 0f820f0..f119b12 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # Dependencies -/node_modules +node_modules # Production /build @@ -20,4 +20,13 @@ yarn-debug.log* yarn-error.log* # Emacs -*~ \ No newline at end of file +*~ + +# esy +_esy + +# webpack-reason-loader +.cache + +# Merlin +.merlin \ No newline at end of file diff --git a/docusaurus.config.js b/docusaurus.config.js index 29d7501..e190761 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -107,6 +107,8 @@ const config = { darkTheme: prismThemes.dracula, }, }), + + plugins: ["./plugins/docusaurus-webpack-plugin"], }; export default config; diff --git a/esy.json b/esy.json new file mode 100644 index 0000000..232905f --- /dev/null +++ b/esy.json @@ -0,0 +1,15 @@ +{ + "dependencies": { + "ocaml": "5.x", + "@opam/dune": "*", + "@opam/melange": "*", + "@opam/reason": "*" + }, + "devDependencies": { + "@opam/merlin": "*", + "@opam/dot-merlin-reader": "*", + "@opam/ocamlformat": "*", + "@opam/ocamlformat-rpc": "*", + "@opam/ocaml-lsp-server": "*" + } +} diff --git a/esy.lock/.gitattributes b/esy.lock/.gitattributes new file mode 100644 index 0000000..e0b4e26 --- /dev/null +++ b/esy.lock/.gitattributes @@ -0,0 +1,3 @@ + +# Set eol to LF so files aren't converted to CRLF-eol on Windows. +* text eol=lf linguist-generated diff --git a/esy.lock/.gitignore b/esy.lock/.gitignore new file mode 100644 index 0000000..a221be2 --- /dev/null +++ b/esy.lock/.gitignore @@ -0,0 +1,3 @@ + +# Reset any possible .gitignore, we want all esy.lock to be un-ignored. +!* diff --git a/esy.lock/index.json b/esy.lock/index.json new file mode 100644 index 0000000..ca5220a --- /dev/null +++ b/esy.lock/index.json @@ -0,0 +1,1686 @@ +{ + "checksum": "00a9ccd7922d248b791f1386273bfd6a", + "root": "reason-bangalore.github.io@link-dev:./esy.json", + "node": { + "reason-bangalore.github.io@link-dev:./esy.json": { + "id": "reason-bangalore.github.io@link-dev:./esy.json", + "name": "reason-bangalore.github.io", + "version": "link-dev:./esy.json", + "source": { "type": "link-dev", "path": ".", "manifest": "esy.json" }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/reason@opam:3.11.0@6ad0e561", + "@opam/melange@opam:3.0.0-51@8246e3ca", + "@opam/dune@opam:3.15.2@d8da42a0" + ], + "devDependencies": [ + "@opam/ocamlformat-rpc@opam:removed@440abe07", + "@opam/ocamlformat@opam:0.26.2@fc61a2f3", + "@opam/ocaml-lsp-server@opam:1.17.0@12f65153", + "@opam/merlin@opam:4.14-501@c3b7d93d", + "@opam/dot-merlin-reader@opam:4.9@67cd78e1" + ] + }, + "ocaml@5.1.1000@d41d8cd9": { + "id": "ocaml@5.1.1000@d41d8cd9", + "name": "ocaml", + "version": "5.1.1000", + "source": { + "type": "install", + "source": [ + "archive:https://registry.npmjs.org/ocaml/-/ocaml-5.1.1000.tgz#sha1:9b6a5209b47f1eb23e828c325b115940240ee3df" + ] + }, + "overrides": [], + "dependencies": [], + "devDependencies": [] + }, + "@opam/yojson@opam:2.1.2@9fd14300": { + "id": "@opam/yojson@opam:2.1.2@9fd14300", + "name": "@opam/yojson", + "version": "opam:2.1.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/59/59f2f1abbfc8a7ccbdbf608894e5c75e8a76006e34899254446f83e200dfb4f9#sha256:59f2f1abbfc8a7ccbdbf608894e5c75e8a76006e34899254446f83e200dfb4f9", + "archive:https://github.com/ocaml-community/yojson/releases/download/2.1.2/yojson-2.1.2.tbz#sha256:59f2f1abbfc8a7ccbdbf608894e5c75e8a76006e34899254446f83e200dfb4f9" + ], + "opam": { + "name": "yojson", + "version": "2.1.2", + "path": "esy.lock/opam/yojson.2.1.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/seq@opam:base@d8d7de1d", + "@opam/dune@opam:3.15.2@d8da42a0", "@opam/cppo@opam:1.6.9@db929a12", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/seq@opam:base@d8d7de1d", + "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/xdg@opam:3.15.2@f80e2f13": { + "id": "@opam/xdg@opam:3.15.2@f80e2f13", + "name": "@opam/xdg", + "version": "opam:3.15.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/f9/f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933", + "archive:https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + ], + "opam": { + "name": "xdg", + "version": "3.15.2", + "path": "esy.lock/opam/xdg.3.15.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/uutf@opam:1.0.3@47c95a18": { + "id": "@opam/uutf@opam:1.0.3@47c95a18", + "name": "@opam/uutf", + "version": "opam:1.0.3", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha512/50/50cc4486021da46fb08156e9daec0d57b4ca469b07309c508d5a9a41e9dbcf1f32dec2ed7be027326544453dcaf9c2534919395fd826dc7768efc6cc4bfcc9f8#sha512:50cc4486021da46fb08156e9daec0d57b4ca469b07309c508d5a9a41e9dbcf1f32dec2ed7be027326544453dcaf9c2534919395fd826dc7768efc6cc4bfcc9f8", + "archive:https://erratique.ch/software/uutf/releases/uutf-1.0.3.tbz#sha512:50cc4486021da46fb08156e9daec0d57b4ca469b07309c508d5a9a41e9dbcf1f32dec2ed7be027326544453dcaf9c2534919395fd826dc7768efc6cc4bfcc9f8" + ], + "opam": { + "name": "uutf", + "version": "1.0.3", + "path": "esy.lock/opam/uutf.1.0.3" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/topkg@opam:1.0.7@7ee47d76", + "@opam/ocamlfind@opam:1.9.6@da5169c7", + "@opam/ocamlbuild@opam:0.14.3@6ab20ab3", + "@opam/cmdliner@opam:1.2.0@b0c6143c", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ "ocaml@5.1.1000@d41d8cd9" ] + }, + "@opam/uuseg@opam:15.1.0@af4a84a3": { + "id": "@opam/uuseg@opam:15.1.0@af4a84a3", + "name": "@opam/uuseg", + "version": "opam:15.1.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha512/1e/1e9460dc5a856c985d40c61fd1560bdfdb8bbaf8d7430405814589b47d4a7f7869658d1e3198c7a9132412e9b4b85402ceb4bda5040da426b69e9aef4222a23a#sha512:1e9460dc5a856c985d40c61fd1560bdfdb8bbaf8d7430405814589b47d4a7f7869658d1e3198c7a9132412e9b4b85402ceb4bda5040da426b69e9aef4222a23a", + "archive:https://erratique.ch/software/uuseg/releases/uuseg-15.1.0.tbz#sha512:1e9460dc5a856c985d40c61fd1560bdfdb8bbaf8d7430405814589b47d4a7f7869658d1e3198c7a9132412e9b4b85402ceb4bda5040da426b69e9aef4222a23a" + ], + "opam": { + "name": "uuseg", + "version": "15.1.0", + "path": "esy.lock/opam/uuseg.15.1.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/uutf@opam:1.0.3@47c95a18", + "@opam/uucp@opam:15.1.0@ef3e0a4e", "@opam/topkg@opam:1.0.7@7ee47d76", + "@opam/ocamlfind@opam:1.9.6@da5169c7", + "@opam/ocamlbuild@opam:0.14.3@6ab20ab3", + "@opam/cmdliner@opam:1.2.0@b0c6143c", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/uucp@opam:15.1.0@ef3e0a4e" + ] + }, + "@opam/uucp@opam:15.1.0@ef3e0a4e": { + "id": "@opam/uucp@opam:15.1.0@ef3e0a4e", + "name": "@opam/uucp", + "version": "opam:15.1.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha512/99/998f94fadb72357b15a3042a3d11c31b3e16f281822673f2defdd515cd1394d55de1817628be8bd5c030175f9e62c53630d4139a1c0253800f9fb898b0f11364#sha512:998f94fadb72357b15a3042a3d11c31b3e16f281822673f2defdd515cd1394d55de1817628be8bd5c030175f9e62c53630d4139a1c0253800f9fb898b0f11364", + "archive:https://erratique.ch/software/uucp/releases/uucp-15.1.0.tbz#sha512:998f94fadb72357b15a3042a3d11c31b3e16f281822673f2defdd515cd1394d55de1817628be8bd5c030175f9e62c53630d4139a1c0253800f9fb898b0f11364" + ], + "opam": { + "name": "uucp", + "version": "15.1.0", + "path": "esy.lock/opam/uucp.15.1.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/topkg@opam:1.0.7@7ee47d76", + "@opam/ocamlfind@opam:1.9.6@da5169c7", + "@opam/ocamlbuild@opam:0.14.3@6ab20ab3", + "@opam/cmdliner@opam:1.2.0@b0c6143c", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ "ocaml@5.1.1000@d41d8cd9" ] + }, + "@opam/topkg@opam:1.0.7@7ee47d76": { + "id": "@opam/topkg@opam:1.0.7@7ee47d76", + "name": "@opam/topkg", + "version": "opam:1.0.7", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha512/09/09e59f1759bf4db8471f02d0aefd8db602b44932a291c05c312b1423796e7a15d1598d3c62a0cec7f083eff8e410fac09363533dc4bd2120914bb9664efea535#sha512:09e59f1759bf4db8471f02d0aefd8db602b44932a291c05c312b1423796e7a15d1598d3c62a0cec7f083eff8e410fac09363533dc4bd2120914bb9664efea535", + "archive:https://erratique.ch/software/topkg/releases/topkg-1.0.7.tbz#sha512:09e59f1759bf4db8471f02d0aefd8db602b44932a291c05c312b1423796e7a15d1598d3c62a0cec7f083eff8e410fac09363533dc4bd2120914bb9664efea535" + ], + "opam": { + "name": "topkg", + "version": "1.0.7", + "path": "esy.lock/opam/topkg.1.0.7" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/ocamlfind@opam:1.9.6@da5169c7", + "@opam/ocamlbuild@opam:0.14.3@6ab20ab3", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/ocamlbuild@opam:0.14.3@6ab20ab3" + ] + }, + "@opam/stdune@opam:3.15.2@ebe58743": { + "id": "@opam/stdune@opam:3.15.2@ebe58743", + "name": "@opam/stdune", + "version": "opam:3.15.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/f9/f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933", + "archive:https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + ], + "opam": { + "name": "stdune", + "version": "3.15.2", + "path": "esy.lock/opam/stdune.3.15.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/pp@opam:1.2.0@16430027", + "@opam/ordering@opam:3.15.2@7bb37d5b", + "@opam/dyn@opam:3.15.2@93dae848", "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/csexp@opam:1.5.2@46614bf4", + "@opam/base-unix@opam:base@87d0b2eb", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/pp@opam:1.2.0@16430027", + "@opam/ordering@opam:3.15.2@7bb37d5b", + "@opam/dyn@opam:3.15.2@93dae848", "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/csexp@opam:1.5.2@46614bf4", + "@opam/base-unix@opam:base@87d0b2eb" + ] + }, + "@opam/stdlib-shims@opam:0.3.0@72c7bc98": { + "id": "@opam/stdlib-shims@opam:0.3.0@72c7bc98", + "name": "@opam/stdlib-shims", + "version": "opam:0.3.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/ba/babf72d3917b86f707885f0c5528e36c63fccb698f4b46cf2bab5c7ccdd6d84a#sha256:babf72d3917b86f707885f0c5528e36c63fccb698f4b46cf2bab5c7ccdd6d84a", + "archive:https://github.com/ocaml/stdlib-shims/releases/download/0.3.0/stdlib-shims-0.3.0.tbz#sha256:babf72d3917b86f707885f0c5528e36c63fccb698f4b46cf2bab5c7ccdd6d84a" + ], + "opam": { + "name": "stdlib-shims", + "version": "0.3.0", + "path": "esy.lock/opam/stdlib-shims.0.3.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/stdio@opam:v0.16.0@a75c1ca1": { + "id": "@opam/stdio@opam:v0.16.0@a75c1ca1", + "name": "@opam/stdio", + "version": "opam:v0.16.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/61/61f0b75950614ac5378c6ec0d822cce6463402d919d5810b736fc46522b3a73e#sha256:61f0b75950614ac5378c6ec0d822cce6463402d919d5810b736fc46522b3a73e", + "archive:https://ocaml.janestreet.com/ocaml-core/v0.16/files/stdio-v0.16.0.tar.gz#sha256:61f0b75950614ac5378c6ec0d822cce6463402d919d5810b736fc46522b3a73e" + ], + "opam": { + "name": "stdio", + "version": "v0.16.0", + "path": "esy.lock/opam/stdio.v0.16.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/base@opam:v0.16.3@162b7c08", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/base@opam:v0.16.3@162b7c08" + ] + }, + "@opam/spawn@opam:v0.15.1@85e9d6f1": { + "id": "@opam/spawn@opam:v0.15.1@85e9d6f1", + "name": "@opam/spawn", + "version": "opam:v0.15.1", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/9a/9afdee314fab6c3fcd689ab6eb5608d6b78078e6dede3953a47debde06c19d50#sha256:9afdee314fab6c3fcd689ab6eb5608d6b78078e6dede3953a47debde06c19d50", + "archive:https://github.com/janestreet/spawn/archive/v0.15.1.tar.gz#sha256:9afdee314fab6c3fcd689ab6eb5608d6b78078e6dede3953a47debde06c19d50" + ], + "opam": { + "name": "spawn", + "version": "v0.15.1", + "path": "esy.lock/opam/spawn.v0.15.1" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/sexplib0@opam:v0.16.0@c0ffad0c": { + "id": "@opam/sexplib0@opam:v0.16.0@c0ffad0c", + "name": "@opam/sexplib0", + "version": "opam:v0.16.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/86/86dba26468194512f789f2fb709063515a9cb4e5c4461c021c239a369590701d#sha256:86dba26468194512f789f2fb709063515a9cb4e5c4461c021c239a369590701d", + "archive:https://ocaml.janestreet.com/ocaml-core/v0.16/files/sexplib0-v0.16.0.tar.gz#sha256:86dba26468194512f789f2fb709063515a9cb4e5c4461c021c239a369590701d" + ], + "opam": { + "name": "sexplib0", + "version": "v0.16.0", + "path": "esy.lock/opam/sexplib0.v0.16.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/seq@opam:base@d8d7de1d": { + "id": "@opam/seq@opam:base@d8d7de1d", + "name": "@opam/seq", + "version": "opam:base", + "source": { + "type": "install", + "source": [ "no-source:" ], + "opam": { + "name": "seq", + "version": "base", + "path": "esy.lock/opam/seq.base" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ "ocaml@5.1.1000@d41d8cd9" ] + }, + "@opam/result@opam:1.5@1c6a6533": { + "id": "@opam/result@opam:1.5@1c6a6533", + "name": "@opam/result", + "version": "opam:1.5", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/1b/1b82dec78849680b49ae9a8a365b831b#md5:1b82dec78849680b49ae9a8a365b831b", + "archive:https://github.com/janestreet/result/releases/download/1.5/result-1.5.tbz#md5:1b82dec78849680b49ae9a8a365b831b" + ], + "opam": { + "name": "result", + "version": "1.5", + "path": "esy.lock/opam/result.1.5" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/reason@opam:3.11.0@6ad0e561": { + "id": "@opam/reason@opam:3.11.0@6ad0e561", + "name": "@opam/reason", + "version": "opam:3.11.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/a5/a58837f14a79f047c8eb99d5518aeb16ee64353574286cfd5b284c98a1a27250#sha256:a58837f14a79f047c8eb99d5518aeb16ee64353574286cfd5b284c98a1a27250", + "archive:https://github.com/reasonml/reason/releases/download/3.11.0/reason-3.11.0.tbz#sha256:a58837f14a79f047c8eb99d5518aeb16ee64353574286cfd5b284c98a1a27250" + ], + "opam": { + "name": "reason", + "version": "3.11.0", + "path": "esy.lock/opam/reason.3.11.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/ppxlib@opam:0.32.1@9897cafd", + "@opam/ppx_derivers@opam:1.2.1@e2cbad12", + "@opam/ocamlfind@opam:1.9.6@da5169c7", + "@opam/merlin-extend@opam:0.6.1@7d979feb", + "@opam/menhir@opam:20231231@f35eae6a", + "@opam/fix@opam:20230505@941a65ff", + "@opam/dune-build-info@opam:3.15.2@5f3c54ae", + "@opam/dune@opam:3.15.2@d8da42a0", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/ppxlib@opam:0.32.1@9897cafd", + "@opam/ppx_derivers@opam:1.2.1@e2cbad12", + "@opam/merlin-extend@opam:0.6.1@7d979feb", + "@opam/menhir@opam:20231231@f35eae6a", + "@opam/fix@opam:20230505@941a65ff", + "@opam/dune-build-info@opam:3.15.2@5f3c54ae", + "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/re@opam:1.11.0@87deb463": { + "id": "@opam/re@opam:1.11.0@87deb463", + "name": "@opam/re", + "version": "opam:1.11.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/01/01fc244780c0f6be72ae796b1fb750f367de18624fd75d07ee79782ed6df8d4f#sha256:01fc244780c0f6be72ae796b1fb750f367de18624fd75d07ee79782ed6df8d4f", + "archive:https://github.com/ocaml/ocaml-re/releases/download/1.11.0/re-1.11.0.tbz#sha256:01fc244780c0f6be72ae796b1fb750f367de18624fd75d07ee79782ed6df8d4f" + ], + "opam": { + "name": "re", + "version": "1.11.0", + "path": "esy.lock/opam/re.1.11.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/seq@opam:base@d8d7de1d", + "@opam/dune@opam:3.15.2@d8da42a0", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/seq@opam:base@d8d7de1d", + "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/ppxlib@opam:0.32.1@9897cafd": { + "id": "@opam/ppxlib@opam:0.32.1@9897cafd", + "name": "@opam/ppxlib", + "version": "opam:0.32.1", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/9d/9dbad8bcb1c8b4f3df3f58bca60a5ed23d86531f0da34b4196c86bd585c09d7f#sha256:9dbad8bcb1c8b4f3df3f58bca60a5ed23d86531f0da34b4196c86bd585c09d7f", + "archive:https://github.com/ocaml-ppx/ppxlib/releases/download/0.32.1/ppxlib-0.32.1.tbz#sha256:9dbad8bcb1c8b4f3df3f58bca60a5ed23d86531f0da34b4196c86bd585c09d7f" + ], + "opam": { + "name": "ppxlib", + "version": "0.32.1", + "path": "esy.lock/opam/ppxlib.0.32.1" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/stdlib-shims@opam:0.3.0@72c7bc98", + "@opam/sexplib0@opam:v0.16.0@c0ffad0c", + "@opam/ppx_derivers@opam:1.2.1@e2cbad12", + "@opam/ocaml-compiler-libs@opam:v0.12.4@57a85ad1", + "@opam/dune@opam:3.15.2@d8da42a0", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/stdlib-shims@opam:0.3.0@72c7bc98", + "@opam/sexplib0@opam:v0.16.0@c0ffad0c", + "@opam/ppx_derivers@opam:1.2.1@e2cbad12", + "@opam/ocaml-compiler-libs@opam:v0.12.4@57a85ad1", + "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/ppx_yojson_conv_lib@opam:v0.16.0@33740c3c": { + "id": "@opam/ppx_yojson_conv_lib@opam:v0.16.0@33740c3c", + "name": "@opam/ppx_yojson_conv_lib", + "version": "opam:v0.16.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/55/557c43c88d365b4cbb514d809f1eecc54d7b9976b0669bc55b02169e6c86ec7d#sha256:557c43c88d365b4cbb514d809f1eecc54d7b9976b0669bc55b02169e6c86ec7d", + "archive:https://ocaml.janestreet.com/ocaml-core/v0.16/files/ppx_yojson_conv_lib-v0.16.0.tar.gz#sha256:557c43c88d365b4cbb514d809f1eecc54d7b9976b0669bc55b02169e6c86ec7d" + ], + "opam": { + "name": "ppx_yojson_conv_lib", + "version": "v0.16.0", + "path": "esy.lock/opam/ppx_yojson_conv_lib.v0.16.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/yojson@opam:2.1.2@9fd14300", + "@opam/dune@opam:3.15.2@d8da42a0", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/yojson@opam:2.1.2@9fd14300", + "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/ppx_derivers@opam:1.2.1@e2cbad12": { + "id": "@opam/ppx_derivers@opam:1.2.1@e2cbad12", + "name": "@opam/ppx_derivers", + "version": "opam:1.2.1", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/5d/5dc2bf130c1db3c731fe0fffc5648b41#md5:5dc2bf130c1db3c731fe0fffc5648b41", + "archive:https://github.com/ocaml-ppx/ppx_derivers/archive/1.2.1.tar.gz#md5:5dc2bf130c1db3c731fe0fffc5648b41" + ], + "opam": { + "name": "ppx_derivers", + "version": "1.2.1", + "path": "esy.lock/opam/ppx_derivers.1.2.1" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/pp@opam:1.2.0@16430027": { + "id": "@opam/pp@opam:1.2.0@16430027", + "name": "@opam/pp", + "version": "opam:1.2.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/a5/a5e822573c55afb42db29ec56eacd1f2acd8f65cf2df2878e291de374ce6909c#sha256:a5e822573c55afb42db29ec56eacd1f2acd8f65cf2df2878e291de374ce6909c", + "archive:https://github.com/ocaml-dune/pp/releases/download/1.2.0/pp-1.2.0.tbz#sha256:a5e822573c55afb42db29ec56eacd1f2acd8f65cf2df2878e291de374ce6909c" + ], + "opam": { + "name": "pp", + "version": "1.2.0", + "path": "esy.lock/opam/pp.1.2.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/ordering@opam:3.15.2@7bb37d5b": { + "id": "@opam/ordering@opam:3.15.2@7bb37d5b", + "name": "@opam/ordering", + "version": "opam:3.15.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/f9/f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933", + "archive:https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + ], + "opam": { + "name": "ordering", + "version": "3.15.2", + "path": "esy.lock/opam/ordering.3.15.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/ocp-indent@opam:1.8.1@e32a3c50": { + "id": "@opam/ocp-indent@opam:1.8.1@e32a3c50", + "name": "@opam/ocp-indent", + "version": "opam:1.8.1", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/70/70db6649a8c08a682ad63730c9752e31#md5:70db6649a8c08a682ad63730c9752e31", + "archive:https://github.com/OCamlPro/ocp-indent/archive/1.8.1.tar.gz#md5:70db6649a8c08a682ad63730c9752e31" + ], + "opam": { + "name": "ocp-indent", + "version": "1.8.1", + "path": "esy.lock/opam/ocp-indent.1.8.1" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/ocamlfind@opam:1.9.6@da5169c7", + "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/cmdliner@opam:1.2.0@b0c6143c", + "@opam/base-bytes@opam:base@19d0c2ff", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/ocamlfind@opam:1.9.6@da5169c7", + "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/cmdliner@opam:1.2.0@b0c6143c", + "@opam/base-bytes@opam:base@19d0c2ff" + ] + }, + "@opam/ocamlformat-rpc-lib@opam:0.26.2@f94d170f": { + "id": "@opam/ocamlformat-rpc-lib@opam:0.26.2@f94d170f", + "name": "@opam/ocamlformat-rpc-lib", + "version": "opam:0.26.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/2e/2e4f596bf7aa367a844fe83ba0f6b0bf14b2a65179ddc082363fe9793d0375c5#sha256:2e4f596bf7aa367a844fe83ba0f6b0bf14b2a65179ddc082363fe9793d0375c5", + "archive:https://github.com/ocaml-ppx/ocamlformat/releases/download/0.26.2/ocamlformat-0.26.2.tbz#sha256:2e4f596bf7aa367a844fe83ba0f6b0bf14b2a65179ddc082363fe9793d0375c5" + ], + "opam": { + "name": "ocamlformat-rpc-lib", + "version": "0.26.2", + "path": "esy.lock/opam/ocamlformat-rpc-lib.0.26.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/csexp@opam:1.5.2@46614bf4", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/csexp@opam:1.5.2@46614bf4" + ] + }, + "@opam/ocamlformat-rpc@opam:removed@440abe07": { + "id": "@opam/ocamlformat-rpc@opam:removed@440abe07", + "name": "@opam/ocamlformat-rpc", + "version": "opam:removed", + "source": { + "type": "install", + "source": [ "no-source:" ], + "opam": { + "name": "ocamlformat-rpc", + "version": "removed", + "path": "esy.lock/opam/ocamlformat-rpc.removed" + } + }, + "overrides": [], + "dependencies": [ "@esy-ocaml/substs@0.0.1@d41d8cd9" ], + "devDependencies": [] + }, + "@opam/ocamlformat-lib@opam:0.26.2@ba69315f": { + "id": "@opam/ocamlformat-lib@opam:0.26.2@ba69315f", + "name": "@opam/ocamlformat-lib", + "version": "opam:0.26.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/2e/2e4f596bf7aa367a844fe83ba0f6b0bf14b2a65179ddc082363fe9793d0375c5#sha256:2e4f596bf7aa367a844fe83ba0f6b0bf14b2a65179ddc082363fe9793d0375c5", + "archive:https://github.com/ocaml-ppx/ocamlformat/releases/download/0.26.2/ocamlformat-0.26.2.tbz#sha256:2e4f596bf7aa367a844fe83ba0f6b0bf14b2a65179ddc082363fe9793d0375c5" + ], + "opam": { + "name": "ocamlformat-lib", + "version": "0.26.2", + "path": "esy.lock/opam/ocamlformat-lib.0.26.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/uutf@opam:1.0.3@47c95a18", + "@opam/uuseg@opam:15.1.0@af4a84a3", + "@opam/stdio@opam:v0.16.0@a75c1ca1", + "@opam/result@opam:1.5@1c6a6533", + "@opam/ocp-indent@opam:1.8.1@e32a3c50", + "@opam/ocaml-version@opam:3.6.7@b719e7df", + "@opam/menhirSdk@opam:20231231@b20b8a51", + "@opam/menhirLib@opam:20231231@14d79986", + "@opam/menhir@opam:20231231@f35eae6a", + "@opam/fpath@opam:0.7.3@674d8125", + "@opam/fix@opam:20230505@941a65ff", + "@opam/either@opam:1.0.0@be5a1416", + "@opam/dune-build-info@opam:3.15.2@5f3c54ae", + "@opam/dune@opam:3.15.2@d8da42a0", "@opam/csexp@opam:1.5.2@46614bf4", + "@opam/camlp-streams@opam:5.0.1@daaa0f94", + "@opam/base@opam:v0.16.3@162b7c08", + "@opam/astring@opam:0.8.5@1300cee8", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/uutf@opam:1.0.3@47c95a18", + "@opam/uuseg@opam:15.1.0@af4a84a3", + "@opam/stdio@opam:v0.16.0@a75c1ca1", + "@opam/result@opam:1.5@1c6a6533", + "@opam/ocp-indent@opam:1.8.1@e32a3c50", + "@opam/ocaml-version@opam:3.6.7@b719e7df", + "@opam/menhirSdk@opam:20231231@b20b8a51", + "@opam/menhirLib@opam:20231231@14d79986", + "@opam/menhir@opam:20231231@f35eae6a", + "@opam/fpath@opam:0.7.3@674d8125", + "@opam/fix@opam:20230505@941a65ff", + "@opam/either@opam:1.0.0@be5a1416", + "@opam/dune-build-info@opam:3.15.2@5f3c54ae", + "@opam/dune@opam:3.15.2@d8da42a0", "@opam/csexp@opam:1.5.2@46614bf4", + "@opam/camlp-streams@opam:5.0.1@daaa0f94", + "@opam/base@opam:v0.16.3@162b7c08", + "@opam/astring@opam:0.8.5@1300cee8" + ] + }, + "@opam/ocamlformat@opam:0.26.2@fc61a2f3": { + "id": "@opam/ocamlformat@opam:0.26.2@fc61a2f3", + "name": "@opam/ocamlformat", + "version": "opam:0.26.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/2e/2e4f596bf7aa367a844fe83ba0f6b0bf14b2a65179ddc082363fe9793d0375c5#sha256:2e4f596bf7aa367a844fe83ba0f6b0bf14b2a65179ddc082363fe9793d0375c5", + "archive:https://github.com/ocaml-ppx/ocamlformat/releases/download/0.26.2/ocamlformat-0.26.2.tbz#sha256:2e4f596bf7aa367a844fe83ba0f6b0bf14b2a65179ddc082363fe9793d0375c5" + ], + "opam": { + "name": "ocamlformat", + "version": "0.26.2", + "path": "esy.lock/opam/ocamlformat.0.26.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/re@opam:1.11.0@87deb463", + "@opam/ocamlformat-lib@opam:0.26.2@ba69315f", + "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/cmdliner@opam:1.2.0@b0c6143c", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/re@opam:1.11.0@87deb463", + "@opam/ocamlformat-lib@opam:0.26.2@ba69315f", + "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/cmdliner@opam:1.2.0@b0c6143c" + ] + }, + "@opam/ocamlfind@opam:1.9.6@da5169c7": { + "id": "@opam/ocamlfind@opam:1.9.6@da5169c7", + "name": "@opam/ocamlfind", + "version": "opam:1.9.6", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/96/96c6ee50a32cca9ca277321262dbec57#md5:96c6ee50a32cca9ca277321262dbec57", + "archive:http://download.camlcity.org/download/findlib-1.9.6.tar.gz#md5:96c6ee50a32cca9ca277321262dbec57" + ], + "opam": { + "name": "ocamlfind", + "version": "1.9.6", + "path": "esy.lock/opam/ocamlfind.1.9.6" + } + }, + "overrides": [ + { + "opamoverride": "esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.6_opam_override" + } + ], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ "ocaml@5.1.1000@d41d8cd9" ] + }, + "@opam/ocamlc-loc@opam:3.15.2@4d55743d": { + "id": "@opam/ocamlc-loc@opam:3.15.2@4d55743d", + "name": "@opam/ocamlc-loc", + "version": "opam:3.15.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/f9/f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933", + "archive:https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + ], + "opam": { + "name": "ocamlc-loc", + "version": "3.15.2", + "path": "esy.lock/opam/ocamlc-loc.3.15.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dyn@opam:3.15.2@93dae848", + "@opam/dune@opam:3.15.2@d8da42a0", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dyn@opam:3.15.2@93dae848", + "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/ocamlbuild@opam:0.14.3@6ab20ab3": { + "id": "@opam/ocamlbuild@opam:0.14.3@6ab20ab3", + "name": "@opam/ocamlbuild", + "version": "opam:0.14.3", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/22/220df59060c916e8aac2eb471c870485#md5:220df59060c916e8aac2eb471c870485", + "archive:https://github.com/ocaml/ocamlbuild/archive/refs/tags/0.14.3.tar.gz#md5:220df59060c916e8aac2eb471c870485" + ], + "opam": { + "name": "ocamlbuild", + "version": "0.14.3", + "path": "esy.lock/opam/ocamlbuild.0.14.3" + } + }, + "overrides": [ + { + "opamoverride": "esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.3_opam_override" + } + ], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ "ocaml@5.1.1000@d41d8cd9" ] + }, + "@opam/ocaml-version@opam:3.6.7@b719e7df": { + "id": "@opam/ocaml-version@opam:3.6.7@b719e7df", + "name": "@opam/ocaml-version", + "version": "opam:3.6.7", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/d5/d50ffd5b669d33edb0d889c476a71de4888d90008d58336038d210ced28f810c#sha256:d50ffd5b669d33edb0d889c476a71de4888d90008d58336038d210ced28f810c", + "archive:https://github.com/ocurrent/ocaml-version/releases/download/v3.6.7/ocaml-version-3.6.7.tbz#sha256:d50ffd5b669d33edb0d889c476a71de4888d90008d58336038d210ced28f810c" + ], + "opam": { + "name": "ocaml-version", + "version": "3.6.7", + "path": "esy.lock/opam/ocaml-version.3.6.7" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/ocaml-lsp-server@opam:1.17.0@12f65153": { + "id": "@opam/ocaml-lsp-server@opam:1.17.0@12f65153", + "name": "@opam/ocaml-lsp-server", + "version": "opam:1.17.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/8f/8fb8bbd717eefd2608b4d83458105b660e0de3a1134dc8fc216ae659d4d19600#sha256:8fb8bbd717eefd2608b4d83458105b660e0de3a1134dc8fc216ae659d4d19600", + "archive:https://github.com/ocaml/ocaml-lsp/releases/download/1.17.0/lsp-1.17.0.tbz#sha256:8fb8bbd717eefd2608b4d83458105b660e0de3a1134dc8fc216ae659d4d19600" + ], + "opam": { + "name": "ocaml-lsp-server", + "version": "1.17.0", + "path": "esy.lock/opam/ocaml-lsp-server.1.17.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/yojson@opam:2.1.2@9fd14300", + "@opam/xdg@opam:3.15.2@f80e2f13", "@opam/uutf@opam:1.0.3@47c95a18", + "@opam/stdune@opam:3.15.2@ebe58743", + "@opam/spawn@opam:v0.15.1@85e9d6f1", "@opam/re@opam:1.11.0@87deb463", + "@opam/ppx_yojson_conv_lib@opam:v0.16.0@33740c3c", + "@opam/pp@opam:1.2.0@16430027", + "@opam/ordering@opam:3.15.2@7bb37d5b", + "@opam/ocamlformat-rpc-lib@opam:0.26.2@f94d170f", + "@opam/ocamlc-loc@opam:3.15.2@4d55743d", + "@opam/merlin-lib@opam:4.14-501@006c5533", + "@opam/fiber@opam:3.7.0@d70e2471", "@opam/dyn@opam:3.15.2@93dae848", + "@opam/dune-rpc@opam:3.15.2@f40bd235", + "@opam/dune-build-info@opam:3.15.2@5f3c54ae", + "@opam/dune@opam:3.15.2@d8da42a0", "@opam/csexp@opam:1.5.2@46614bf4", + "@opam/chrome-trace@opam:3.15.2@325fb81e", + "@opam/camlp-streams@opam:5.0.1@daaa0f94", + "@opam/astring@opam:0.8.5@1300cee8", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/yojson@opam:2.1.2@9fd14300", + "@opam/xdg@opam:3.15.2@f80e2f13", "@opam/uutf@opam:1.0.3@47c95a18", + "@opam/stdune@opam:3.15.2@ebe58743", + "@opam/spawn@opam:v0.15.1@85e9d6f1", "@opam/re@opam:1.11.0@87deb463", + "@opam/ppx_yojson_conv_lib@opam:v0.16.0@33740c3c", + "@opam/pp@opam:1.2.0@16430027", + "@opam/ordering@opam:3.15.2@7bb37d5b", + "@opam/ocamlformat-rpc-lib@opam:0.26.2@f94d170f", + "@opam/ocamlc-loc@opam:3.15.2@4d55743d", + "@opam/merlin-lib@opam:4.14-501@006c5533", + "@opam/fiber@opam:3.7.0@d70e2471", "@opam/dyn@opam:3.15.2@93dae848", + "@opam/dune-rpc@opam:3.15.2@f40bd235", + "@opam/dune-build-info@opam:3.15.2@5f3c54ae", + "@opam/dune@opam:3.15.2@d8da42a0", "@opam/csexp@opam:1.5.2@46614bf4", + "@opam/chrome-trace@opam:3.15.2@325fb81e", + "@opam/camlp-streams@opam:5.0.1@daaa0f94", + "@opam/astring@opam:0.8.5@1300cee8" + ] + }, + "@opam/ocaml-compiler-libs@opam:v0.12.4@57a85ad1": { + "id": "@opam/ocaml-compiler-libs@opam:v0.12.4@57a85ad1", + "name": "@opam/ocaml-compiler-libs", + "version": "opam:v0.12.4", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/4e/4ec9c9ec35cc45c18c7a143761154ef1d7663036a29297f80381f47981a07760#sha256:4ec9c9ec35cc45c18c7a143761154ef1d7663036a29297f80381f47981a07760", + "archive:https://github.com/janestreet/ocaml-compiler-libs/releases/download/v0.12.4/ocaml-compiler-libs-v0.12.4.tbz#sha256:4ec9c9ec35cc45c18c7a143761154ef1d7663036a29297f80381f47981a07760" + ], + "opam": { + "name": "ocaml-compiler-libs", + "version": "v0.12.4", + "path": "esy.lock/opam/ocaml-compiler-libs.v0.12.4" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/merlin-lib@opam:4.14-501@006c5533": { + "id": "@opam/merlin-lib@opam:4.14-501@006c5533", + "name": "@opam/merlin-lib", + "version": "opam:4.14-501", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/b7/b7e9e96e924058c2ce429642788aa2e390720d441e224538bcf494a65203a292#sha256:b7e9e96e924058c2ce429642788aa2e390720d441e224538bcf494a65203a292", + "archive:https://github.com/ocaml/merlin/releases/download/v4.14-501/merlin-4.14-501.tbz#sha256:b7e9e96e924058c2ce429642788aa2e390720d441e224538bcf494a65203a292" + ], + "opam": { + "name": "merlin-lib", + "version": "4.14-501", + "path": "esy.lock/opam/merlin-lib.4.14-501" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/csexp@opam:1.5.2@46614bf4", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/csexp@opam:1.5.2@46614bf4" + ] + }, + "@opam/merlin-extend@opam:0.6.1@7d979feb": { + "id": "@opam/merlin-extend@opam:0.6.1@7d979feb", + "name": "@opam/merlin-extend", + "version": "opam:0.6.1", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/5e/5ec84b355ddb2d129a5948b132bfacc93adcbde2158c7de695f7bfc3650bead7#sha256:5ec84b355ddb2d129a5948b132bfacc93adcbde2158c7de695f7bfc3650bead7", + "archive:https://github.com/let-def/merlin-extend/releases/download/v0.6.1/merlin-extend-0.6.1.tbz#sha256:5ec84b355ddb2d129a5948b132bfacc93adcbde2158c7de695f7bfc3650bead7" + ], + "opam": { + "name": "merlin-extend", + "version": "0.6.1", + "path": "esy.lock/opam/merlin-extend.0.6.1" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/cppo@opam:1.6.9@db929a12", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/merlin@opam:4.14-501@c3b7d93d": { + "id": "@opam/merlin@opam:4.14-501@c3b7d93d", + "name": "@opam/merlin", + "version": "opam:4.14-501", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/b7/b7e9e96e924058c2ce429642788aa2e390720d441e224538bcf494a65203a292#sha256:b7e9e96e924058c2ce429642788aa2e390720d441e224538bcf494a65203a292", + "archive:https://github.com/ocaml/merlin/releases/download/v4.14-501/merlin-4.14-501.tbz#sha256:b7e9e96e924058c2ce429642788aa2e390720d441e224538bcf494a65203a292" + ], + "opam": { + "name": "merlin", + "version": "4.14-501", + "path": "esy.lock/opam/merlin.4.14-501" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/yojson@opam:2.1.2@9fd14300", + "@opam/merlin-lib@opam:4.14-501@006c5533", + "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/dot-merlin-reader@opam:4.9@67cd78e1", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/yojson@opam:2.1.2@9fd14300", + "@opam/merlin-lib@opam:4.14-501@006c5533", + "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/dot-merlin-reader@opam:4.9@67cd78e1" + ] + }, + "@opam/menhirSdk@opam:20231231@b20b8a51": { + "id": "@opam/menhirSdk@opam:20231231@b20b8a51", + "name": "@opam/menhirSdk", + "version": "opam:20231231", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/79/799748bc3b7a542798a85956c7863865#md5:799748bc3b7a542798a85956c7863865", + "archive:https://gitlab.inria.fr/fpottier/menhir/-/archive/20231231/archive.tar.gz#md5:799748bc3b7a542798a85956c7863865" + ], + "opam": { + "name": "menhirSdk", + "version": "20231231", + "path": "esy.lock/opam/menhirSdk.20231231" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/menhirLib@opam:20231231@14d79986": { + "id": "@opam/menhirLib@opam:20231231@14d79986", + "name": "@opam/menhirLib", + "version": "opam:20231231", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/79/799748bc3b7a542798a85956c7863865#md5:799748bc3b7a542798a85956c7863865", + "archive:https://gitlab.inria.fr/fpottier/menhir/-/archive/20231231/archive.tar.gz#md5:799748bc3b7a542798a85956c7863865" + ], + "opam": { + "name": "menhirLib", + "version": "20231231", + "path": "esy.lock/opam/menhirLib.20231231" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/menhirCST@opam:20231231@0f42b5d1": { + "id": "@opam/menhirCST@opam:20231231@0f42b5d1", + "name": "@opam/menhirCST", + "version": "opam:20231231", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/79/799748bc3b7a542798a85956c7863865#md5:799748bc3b7a542798a85956c7863865", + "archive:https://gitlab.inria.fr/fpottier/menhir/-/archive/20231231/archive.tar.gz#md5:799748bc3b7a542798a85956c7863865" + ], + "opam": { + "name": "menhirCST", + "version": "20231231", + "path": "esy.lock/opam/menhirCST.20231231" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/menhir@opam:20231231@f35eae6a": { + "id": "@opam/menhir@opam:20231231@f35eae6a", + "name": "@opam/menhir", + "version": "opam:20231231", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/79/799748bc3b7a542798a85956c7863865#md5:799748bc3b7a542798a85956c7863865", + "archive:https://gitlab.inria.fr/fpottier/menhir/-/archive/20231231/archive.tar.gz#md5:799748bc3b7a542798a85956c7863865" + ], + "opam": { + "name": "menhir", + "version": "20231231", + "path": "esy.lock/opam/menhir.20231231" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/menhirSdk@opam:20231231@b20b8a51", + "@opam/menhirLib@opam:20231231@14d79986", + "@opam/menhirCST@opam:20231231@0f42b5d1", + "@opam/dune@opam:3.15.2@d8da42a0", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/menhirSdk@opam:20231231@b20b8a51", + "@opam/menhirLib@opam:20231231@14d79986", + "@opam/menhirCST@opam:20231231@0f42b5d1", + "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/melange@opam:3.0.0-51@8246e3ca": { + "id": "@opam/melange@opam:3.0.0-51@8246e3ca", + "name": "@opam/melange", + "version": "opam:3.0.0-51", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/1e/1ebcf29c95ccea9f40e1f39192ae5a37fba9c64768f9ff8f998ff011415fe947#sha256:1ebcf29c95ccea9f40e1f39192ae5a37fba9c64768f9ff8f998ff011415fe947", + "archive:https://github.com/melange-re/melange/releases/download/3.0.0-51/melange-3.0.0-51.tbz#sha256:1ebcf29c95ccea9f40e1f39192ae5a37fba9c64768f9ff8f998ff011415fe947" + ], + "opam": { + "name": "melange", + "version": "3.0.0-51", + "path": "esy.lock/opam/melange.3.0.0-51" + } + }, + "overrides": [ + { + "opamoverride": "esy.lock/overrides/opam__s__melange_opam__c__3.0.0_51_opam_override" + } + ], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/ppxlib@opam:0.32.1@9897cafd", + "@opam/pp@opam:1.2.0@16430027", + "@opam/menhir@opam:20231231@f35eae6a", + "@opam/dune-build-info@opam:3.15.2@5f3c54ae", + "@opam/dune@opam:3.15.2@d8da42a0", "@opam/cppo@opam:1.6.9@db929a12", + "@opam/cmdliner@opam:1.2.0@b0c6143c", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/ppxlib@opam:0.32.1@9897cafd", + "@opam/pp@opam:1.2.0@16430027", + "@opam/menhir@opam:20231231@f35eae6a", + "@opam/dune-build-info@opam:3.15.2@5f3c54ae", + "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/cmdliner@opam:1.2.0@b0c6143c" + ] + }, + "@opam/fpath@opam:0.7.3@674d8125": { + "id": "@opam/fpath@opam:0.7.3@674d8125", + "name": "@opam/fpath", + "version": "opam:0.7.3", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/07/0740b530e8fed5b0adc5eee8463cfc2f#md5:0740b530e8fed5b0adc5eee8463cfc2f", + "archive:https://erratique.ch/software/fpath/releases/fpath-0.7.3.tbz#md5:0740b530e8fed5b0adc5eee8463cfc2f" + ], + "opam": { + "name": "fpath", + "version": "0.7.3", + "path": "esy.lock/opam/fpath.0.7.3" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/topkg@opam:1.0.7@7ee47d76", + "@opam/ocamlfind@opam:1.9.6@da5169c7", + "@opam/ocamlbuild@opam:0.14.3@6ab20ab3", + "@opam/astring@opam:0.8.5@1300cee8", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/astring@opam:0.8.5@1300cee8" + ] + }, + "@opam/fix@opam:20230505@941a65ff": { + "id": "@opam/fix@opam:20230505@941a65ff", + "name": "@opam/fix", + "version": "opam:20230505", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/2a/2a4afa633128c5010677222f7b3c9451#md5:2a4afa633128c5010677222f7b3c9451", + "archive:https://gitlab.inria.fr/fpottier/fix/-/archive/20230505/archive.tar.gz#md5:2a4afa633128c5010677222f7b3c9451" + ], + "opam": { + "name": "fix", + "version": "20230505", + "path": "esy.lock/opam/fix.20230505" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/fiber@opam:3.7.0@d70e2471": { + "id": "@opam/fiber@opam:3.7.0@d70e2471", + "name": "@opam/fiber", + "version": "opam:3.7.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/86/8648a15ae93fe6942999ce36887429a3913b62829c4714e520cc0e7a1c3b9682#sha256:8648a15ae93fe6942999ce36887429a3913b62829c4714e520cc0e7a1c3b9682", + "archive:https://github.com/ocaml-dune/fiber/releases/download/3.7.0/fiber-lwt-3.7.0.tbz#sha256:8648a15ae93fe6942999ce36887429a3913b62829c4714e520cc0e7a1c3b9682" + ], + "opam": { + "name": "fiber", + "version": "3.7.0", + "path": "esy.lock/opam/fiber.3.7.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/stdune@opam:3.15.2@ebe58743", + "@opam/dyn@opam:3.15.2@93dae848", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/stdune@opam:3.15.2@ebe58743", + "@opam/dyn@opam:3.15.2@93dae848", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/either@opam:1.0.0@be5a1416": { + "id": "@opam/either@opam:1.0.0@be5a1416", + "name": "@opam/either", + "version": "opam:1.0.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/bf/bf674de3312dee7b7215f07df1e8a96eb3d679164b8a918cdd95b8d97e505884#sha256:bf674de3312dee7b7215f07df1e8a96eb3d679164b8a918cdd95b8d97e505884", + "archive:https://github.com/mirage/either/releases/download/1.0.0/either-1.0.0.tbz#sha256:bf674de3312dee7b7215f07df1e8a96eb3d679164b8a918cdd95b8d97e505884" + ], + "opam": { + "name": "either", + "version": "1.0.0", + "path": "esy.lock/opam/either.1.0.0" + } + }, + "overrides": [], + "dependencies": [ + "@opam/dune@opam:3.15.2@d8da42a0", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ "@opam/dune@opam:3.15.2@d8da42a0" ] + }, + "@opam/dyn@opam:3.15.2@93dae848": { + "id": "@opam/dyn@opam:3.15.2@93dae848", + "name": "@opam/dyn", + "version": "opam:3.15.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/f9/f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933", + "archive:https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + ], + "opam": { + "name": "dyn", + "version": "3.15.2", + "path": "esy.lock/opam/dyn.3.15.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/pp@opam:1.2.0@16430027", + "@opam/ordering@opam:3.15.2@7bb37d5b", + "@opam/dune@opam:3.15.2@d8da42a0", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/pp@opam:1.2.0@16430027", + "@opam/ordering@opam:3.15.2@7bb37d5b", + "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/dune-rpc@opam:3.15.2@f40bd235": { + "id": "@opam/dune-rpc@opam:3.15.2@f40bd235", + "name": "@opam/dune-rpc", + "version": "opam:3.15.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/f9/f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933", + "archive:https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + ], + "opam": { + "name": "dune-rpc", + "version": "3.15.2", + "path": "esy.lock/opam/dune-rpc.3.15.2" + } + }, + "overrides": [], + "dependencies": [ + "@opam/xdg@opam:3.15.2@f80e2f13", + "@opam/stdune@opam:3.15.2@ebe58743", "@opam/pp@opam:1.2.0@16430027", + "@opam/ordering@opam:3.15.2@7bb37d5b", + "@opam/dyn@opam:3.15.2@93dae848", "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/csexp@opam:1.5.2@46614bf4", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "@opam/xdg@opam:3.15.2@f80e2f13", + "@opam/stdune@opam:3.15.2@ebe58743", "@opam/pp@opam:1.2.0@16430027", + "@opam/ordering@opam:3.15.2@7bb37d5b", + "@opam/dyn@opam:3.15.2@93dae848", "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/csexp@opam:1.5.2@46614bf4" + ] + }, + "@opam/dune-configurator@opam:3.15.2@17c55e1e": { + "id": "@opam/dune-configurator@opam:3.15.2@17c55e1e", + "name": "@opam/dune-configurator", + "version": "opam:3.15.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/f9/f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933", + "archive:https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + ], + "opam": { + "name": "dune-configurator", + "version": "3.15.2", + "path": "esy.lock/opam/dune-configurator.3.15.2" + } + }, + "overrides": [ + { + "opamoverride": "esy.lock/overrides/opam__s__dune_configurator_opam__c__3.15.2_opam_override" + } + ], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/csexp@opam:1.5.2@46614bf4", + "@opam/base-unix@opam:base@87d0b2eb", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/csexp@opam:1.5.2@46614bf4", + "@opam/base-unix@opam:base@87d0b2eb" + ] + }, + "@opam/dune-build-info@opam:3.15.2@5f3c54ae": { + "id": "@opam/dune-build-info@opam:3.15.2@5f3c54ae", + "name": "@opam/dune-build-info", + "version": "opam:3.15.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/f9/f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933", + "archive:https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + ], + "opam": { + "name": "dune-build-info", + "version": "3.15.2", + "path": "esy.lock/opam/dune-build-info.3.15.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/dune@opam:3.15.2@d8da42a0": { + "id": "@opam/dune@opam:3.15.2@d8da42a0", + "name": "@opam/dune", + "version": "opam:3.15.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/f9/f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933", + "archive:https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + ], + "opam": { + "name": "dune", + "version": "3.15.2", + "path": "esy.lock/opam/dune.3.15.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/base-unix@opam:base@87d0b2eb", + "@opam/base-threads@opam:base@36803084", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/base-unix@opam:base@87d0b2eb", + "@opam/base-threads@opam:base@36803084" + ] + }, + "@opam/dot-merlin-reader@opam:4.9@67cd78e1": { + "id": "@opam/dot-merlin-reader@opam:4.9@67cd78e1", + "name": "@opam/dot-merlin-reader", + "version": "opam:4.9", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/e2/e23fc47813591269ff9d27c820988e520a662c89dd0af7ea652b21517499cbfd#sha256:e23fc47813591269ff9d27c820988e520a662c89dd0af7ea652b21517499cbfd", + "archive:https://github.com/ocaml/merlin/releases/download/v4.9-414/merlin-4.9-414.tbz#sha256:e23fc47813591269ff9d27c820988e520a662c89dd0af7ea652b21517499cbfd" + ], + "opam": { + "name": "dot-merlin-reader", + "version": "4.9", + "path": "esy.lock/opam/dot-merlin-reader.4.9" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/ocamlfind@opam:1.9.6@da5169c7", + "@opam/merlin-lib@opam:4.14-501@006c5533", + "@opam/dune@opam:3.15.2@d8da42a0", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/ocamlfind@opam:1.9.6@da5169c7", + "@opam/merlin-lib@opam:4.14-501@006c5533", + "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/csexp@opam:1.5.2@46614bf4": { + "id": "@opam/csexp@opam:1.5.2@46614bf4", + "name": "@opam/csexp", + "version": "opam:1.5.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/1a/1a14dd04bb4379a41990248550628c77913a9c07f3c35c1370b6960e697787ff#sha256:1a14dd04bb4379a41990248550628c77913a9c07f3c35c1370b6960e697787ff", + "archive:https://github.com/ocaml-dune/csexp/releases/download/1.5.2/csexp-1.5.2.tbz#sha256:1a14dd04bb4379a41990248550628c77913a9c07f3c35c1370b6960e697787ff" + ], + "opam": { + "name": "csexp", + "version": "1.5.2", + "path": "esy.lock/opam/csexp.1.5.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/cppo@opam:1.6.9@db929a12": { + "id": "@opam/cppo@opam:1.6.9@db929a12", + "name": "@opam/cppo", + "version": "opam:1.6.9", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/d2/d23ffe85ac7dc8f0afd1ddf622770d09#md5:d23ffe85ac7dc8f0afd1ddf622770d09", + "archive:https://github.com/ocaml-community/cppo/archive/v1.6.9.tar.gz#md5:d23ffe85ac7dc8f0afd1ddf622770d09" + ], + "opam": { + "name": "cppo", + "version": "1.6.9", + "path": "esy.lock/opam/cppo.1.6.9" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/base-unix@opam:base@87d0b2eb", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@opam/base-unix@opam:base@87d0b2eb" + ] + }, + "@opam/conf-bash@opam:1@46c43d96": { + "id": "@opam/conf-bash@opam:1@46c43d96", + "name": "@opam/conf-bash", + "version": "opam:1", + "source": { + "type": "install", + "source": [ "no-source:" ], + "opam": { + "name": "conf-bash", + "version": "1", + "path": "esy.lock/opam/conf-bash.1" + } + }, + "overrides": [], + "dependencies": [ "@esy-ocaml/substs@0.0.1@d41d8cd9" ], + "devDependencies": [] + }, + "@opam/cmdliner@opam:1.2.0@b0c6143c": { + "id": "@opam/cmdliner@opam:1.2.0@b0c6143c", + "name": "@opam/cmdliner", + "version": "opam:1.2.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha512/6f/6fcd6a59a6fbc6986b1aecdc3e4ce7a0dc43c65a16b427d6caa5504b10b51384f6b0bc703af646b09f5f1caeb6827b37d4480ce350ca8006204c850785f2810b#sha512:6fcd6a59a6fbc6986b1aecdc3e4ce7a0dc43c65a16b427d6caa5504b10b51384f6b0bc703af646b09f5f1caeb6827b37d4480ce350ca8006204c850785f2810b", + "archive:https://erratique.ch/software/cmdliner/releases/cmdliner-1.2.0.tbz#sha512:6fcd6a59a6fbc6986b1aecdc3e4ce7a0dc43c65a16b427d6caa5504b10b51384f6b0bc703af646b09f5f1caeb6827b37d4480ce350ca8006204c850785f2810b" + ], + "opam": { + "name": "cmdliner", + "version": "1.2.0", + "path": "esy.lock/opam/cmdliner.1.2.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ "ocaml@5.1.1000@d41d8cd9" ] + }, + "@opam/chrome-trace@opam:3.15.2@325fb81e": { + "id": "@opam/chrome-trace@opam:3.15.2@325fb81e", + "name": "@opam/chrome-trace", + "version": "opam:3.15.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/f9/f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933", + "archive:https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz#sha256:f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + ], + "opam": { + "name": "chrome-trace", + "version": "3.15.2", + "path": "esy.lock/opam/chrome-trace.3.15.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/camlp-streams@opam:5.0.1@daaa0f94": { + "id": "@opam/camlp-streams@opam:5.0.1@daaa0f94", + "name": "@opam/camlp-streams", + "version": "opam:5.0.1", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/af/afc874b25f7a1f13e8f5cfc1182b51a7#md5:afc874b25f7a1f13e8f5cfc1182b51a7", + "archive:https://github.com/ocaml/camlp-streams/archive/v5.0.1.tar.gz#md5:afc874b25f7a1f13e8f5cfc1182b51a7" + ], + "opam": { + "name": "camlp-streams", + "version": "5.0.1", + "path": "esy.lock/opam/camlp-streams.5.0.1" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/dune@opam:3.15.2@d8da42a0" + ] + }, + "@opam/base-unix@opam:base@87d0b2eb": { + "id": "@opam/base-unix@opam:base@87d0b2eb", + "name": "@opam/base-unix", + "version": "opam:base", + "source": { + "type": "install", + "source": [ "no-source:" ], + "opam": { + "name": "base-unix", + "version": "base", + "path": "esy.lock/opam/base-unix.base" + } + }, + "overrides": [], + "dependencies": [ "@esy-ocaml/substs@0.0.1@d41d8cd9" ], + "devDependencies": [] + }, + "@opam/base-threads@opam:base@36803084": { + "id": "@opam/base-threads@opam:base@36803084", + "name": "@opam/base-threads", + "version": "opam:base", + "source": { + "type": "install", + "source": [ "no-source:" ], + "opam": { + "name": "base-threads", + "version": "base", + "path": "esy.lock/opam/base-threads.base" + } + }, + "overrides": [], + "dependencies": [ "@esy-ocaml/substs@0.0.1@d41d8cd9" ], + "devDependencies": [] + }, + "@opam/base-bytes@opam:base@19d0c2ff": { + "id": "@opam/base-bytes@opam:base@19d0c2ff", + "name": "@opam/base-bytes", + "version": "opam:base", + "source": { + "type": "install", + "source": [ "no-source:" ], + "opam": { + "name": "base-bytes", + "version": "base", + "path": "esy.lock/opam/base-bytes.base" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/ocamlfind@opam:1.9.6@da5169c7", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/ocamlfind@opam:1.9.6@da5169c7" + ] + }, + "@opam/base@opam:v0.16.3@162b7c08": { + "id": "@opam/base@opam:v0.16.3@162b7c08", + "name": "@opam/base", + "version": "opam:v0.16.3", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/04/04572fc23a4651604cfcab83f720cb4c#md5:04572fc23a4651604cfcab83f720cb4c", + "archive:https://github.com/janestreet/base/archive/refs/tags/v0.16.3.tar.gz#md5:04572fc23a4651604cfcab83f720cb4c" + ], + "opam": { + "name": "base", + "version": "v0.16.3", + "path": "esy.lock/opam/base.v0.16.3" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/sexplib0@opam:v0.16.0@c0ffad0c", + "@opam/dune-configurator@opam:3.15.2@17c55e1e", + "@opam/dune@opam:3.15.2@d8da42a0", "@opam/conf-bash@opam:1@46c43d96", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/sexplib0@opam:v0.16.0@c0ffad0c", + "@opam/dune-configurator@opam:3.15.2@17c55e1e", + "@opam/dune@opam:3.15.2@d8da42a0", "@opam/conf-bash@opam:1@46c43d96" + ] + }, + "@opam/astring@opam:0.8.5@1300cee8": { + "id": "@opam/astring@opam:0.8.5@1300cee8", + "name": "@opam/astring", + "version": "opam:0.8.5", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/e1/e148907c24157d1df43bec89b58b3ec8#md5:e148907c24157d1df43bec89b58b3ec8", + "archive:https://erratique.ch/software/astring/releases/astring-0.8.5.tbz#md5:e148907c24157d1df43bec89b58b3ec8" + ], + "opam": { + "name": "astring", + "version": "0.8.5", + "path": "esy.lock/opam/astring.0.8.5" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@5.1.1000@d41d8cd9", "@opam/topkg@opam:1.0.7@7ee47d76", + "@opam/ocamlfind@opam:1.9.6@da5169c7", + "@opam/ocamlbuild@opam:0.14.3@6ab20ab3", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ "ocaml@5.1.1000@d41d8cd9" ] + }, + "@esy-ocaml/substs@0.0.1@d41d8cd9": { + "id": "@esy-ocaml/substs@0.0.1@d41d8cd9", + "name": "@esy-ocaml/substs", + "version": "0.0.1", + "source": { + "type": "install", + "source": [ + "archive:https://registry.npmjs.org/@esy-ocaml/substs/-/substs-0.0.1.tgz#sha1:59ebdbbaedcda123fc7ed8fb2b302b7d819e9a46" + ] + }, + "overrides": [], + "dependencies": [], + "devDependencies": [] + } + } +} \ No newline at end of file diff --git a/esy.lock/opam/astring.0.8.5/opam b/esy.lock/opam/astring.0.8.5/opam new file mode 100644 index 0000000..338a06a --- /dev/null +++ b/esy.lock/opam/astring.0.8.5/opam @@ -0,0 +1,37 @@ +opam-version: "2.0" +maintainer: "Daniel Bünzli " +authors: ["The astring programmers"] +homepage: "https://erratique.ch/software/astring" +doc: "https://erratique.ch/software/astring/doc" +dev-repo: "git+http://erratique.ch/repos/astring.git" +bug-reports: "https://github.com/dbuenzli/astring/issues" +tags: [ "string" "org:erratique" ] +license: "ISC" +depends: [ + "ocaml" {>= "4.05.0"} + "ocamlfind" {build} + "ocamlbuild" {build} + "topkg" {build} ] +build: [[ "ocaml" "pkg/pkg.ml" "build" "--pinned" "%{pinned}%" ]] + +synopsis: """Alternative String module for OCaml""" +description: """\ + +Astring exposes an alternative `String` module for OCaml. This module +tries to balance minimality and expressiveness for basic, index-free, +string processing and provides types and functions for substrings, +string sets and string maps. + +Remaining compatible with the OCaml `String` module is a non-goal. The +`String` module exposed by Astring has exception safe functions, +removes deprecated and rarely used functions, alters some signatures +and names, adds a few missing functions and fully exploits OCaml's +newfound string immutability. + +Astring depends only on the OCaml standard library. It is distributed +under the ISC license. +""" +url { +archive: "https://erratique.ch/software/astring/releases/astring-0.8.5.tbz" +checksum: "e148907c24157d1df43bec89b58b3ec8" +} diff --git a/esy.lock/opam/base-bytes.base/opam b/esy.lock/opam/base-bytes.base/opam new file mode 100644 index 0000000..f1cae50 --- /dev/null +++ b/esy.lock/opam/base-bytes.base/opam @@ -0,0 +1,9 @@ +opam-version: "2.0" +maintainer: " " +authors: " " +homepage: " " +depends: [ + "ocaml" {>= "4.02.0"} + "ocamlfind" {>= "1.5.3"} +] +synopsis: "Bytes library distributed with the OCaml compiler" diff --git a/esy.lock/opam/base-threads.base/opam b/esy.lock/opam/base-threads.base/opam new file mode 100644 index 0000000..914ff50 --- /dev/null +++ b/esy.lock/opam/base-threads.base/opam @@ -0,0 +1,6 @@ +opam-version: "2.0" +maintainer: "https://github.com/ocaml/opam-repository/issues" +description: """ +Threads library distributed with the OCaml compiler +""" + diff --git a/esy.lock/opam/base-unix.base/opam b/esy.lock/opam/base-unix.base/opam new file mode 100644 index 0000000..b973540 --- /dev/null +++ b/esy.lock/opam/base-unix.base/opam @@ -0,0 +1,6 @@ +opam-version: "2.0" +maintainer: "https://github.com/ocaml/opam-repository/issues" +description: """ +Unix library distributed with the OCaml compiler +""" + diff --git a/esy.lock/opam/base.v0.16.3/opam b/esy.lock/opam/base.v0.16.3/opam new file mode 100644 index 0000000..c54e000 --- /dev/null +++ b/esy.lock/opam/base.v0.16.3/opam @@ -0,0 +1,40 @@ +opam-version: "2.0" +maintainer: "Jane Street developers" +authors: ["Jane Street Group, LLC"] +homepage: "https://github.com/janestreet/base" +bug-reports: "https://github.com/janestreet/base/issues" +dev-repo: "git+https://github.com/janestreet/base.git" +doc: "https://ocaml.janestreet.com/ocaml-core/latest/doc/base/index.html" +license: "MIT" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" {>= "4.14.0"} + "sexplib0" {>= "v0.16" & < "v0.17"} + "dune" {>= "2.0.0"} + "dune-configurator" + "conf-bash" +] +synopsis: "Full standard library replacement for OCaml" +description: " +Full standard library replacement for OCaml + +Base is a complete and portable alternative to the OCaml standard +library. It provides all standard functionalities one would expect +from a language standard library. It uses consistent conventions +across all of its module. + +Base aims to be usable in any context. As a result system dependent +features such as I/O are not offered by Base. They are instead +provided by companion libraries such as stdio: + + https://github.com/janestreet/stdio +" +url { + src: "https://github.com/janestreet/base/archive/refs/tags/v0.16.3.tar.gz" + checksum: [ + "md5=04572fc23a4651604cfcab83f720cb4c" + "sha512=69380ed392faf4495459f97f70a10a6959fce71d2e6ba093472fc272141646307fd7872407de855dfa48ef0435f6587eae5aa50f4a67eac40a9e1946d0c3c070" + ] +} diff --git a/esy.lock/opam/camlp-streams.5.0.1/opam b/esy.lock/opam/camlp-streams.5.0.1/opam new file mode 100644 index 0000000..60e5131 --- /dev/null +++ b/esy.lock/opam/camlp-streams.5.0.1/opam @@ -0,0 +1,59 @@ +opam-version: "2.0" +synopsis: "The Stream and Genlex libraries for use with Camlp4 and Camlp5" +description: """ + +This package provides two library modules: +- Stream: imperative streams, with in-place update and memoization + of the latest element produced. +- Genlex: a small parameterized lexical analyzer producing streams + of tokens from streams of characters. + +The two modules are designed for use with Camlp4 and Camlp5: +- The stream patterns and stream expressions of Camlp4/Camlp5 consume + and produce data of type 'a Stream.t. +- The Genlex tokenizer can be used as a simple lexical analyzer for + Camlp4/Camlp5-generated parsers. + +The Stream module can also be used by hand-written recursive-descent +parsers, but is not very convenient for this purpose. + +The Stream and Genlex modules have been part of the OCaml standard library +for a long time, and have been distributed as part of the core OCaml system. +They will be removed from the OCaml standard library at some future point, +but will be maintained and distributed separately in this camlpstreams package. +""" +maintainer: [ + "Florian Angeletti " + "Xavier Leroy " +] +authors: ["Daniel de Rauglaudre" "Xavier Leroy"] +license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" +homepage: "https://github.com/ocaml/camlp-streams" +bug-reports: "https://github.com/ocaml/camlp-streams/issues" +depends: [ + "dune" {>= "2.7"} + "ocaml" {>= "4.02.3"} + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/ocaml/camlp-streams.git" +url { + src: "https://github.com/ocaml/camlp-streams/archive/v5.0.1.tar.gz" + checksum: [ + "md5=afc874b25f7a1f13e8f5cfc1182b51a7" + "sha512=2efa8dd4a636217c8d49bac1e4e7e5558fc2f45cfea66514140a59fd99dd08d61fb9f1e17804997ff648b71b13820a5d4a1eb70fed9d848aa2abd6e41f853c86" + ] +} diff --git a/esy.lock/opam/chrome-trace.3.15.2/opam b/esy.lock/opam/chrome-trace.3.15.2/opam new file mode 100644 index 0000000..65faba3 --- /dev/null +++ b/esy.lock/opam/chrome-trace.3.15.2/opam @@ -0,0 +1,40 @@ +opam-version: "2.0" +synopsis: "Chrome trace event generation library" +description: + "This library offers no backwards compatibility guarantees. Use at your own risk." +maintainer: ["Jane Street Group, LLC "] +authors: ["Jane Street Group, LLC "] +license: "MIT" +homepage: "https://github.com/ocaml/dune" +doc: "https://dune.readthedocs.io/" +bug-reports: "https://github.com/ocaml/dune/issues" +depends: [ + "dune" {>= "3.12"} + "ocaml" {>= "4.08.0"} + "odoc" {with-doc} +] +dev-repo: "git+https://github.com/ocaml/dune.git" +build: [ + ["dune" "subst"] {dev} + ["rm" "-rf" "vendor/csexp"] + ["rm" "-rf" "vendor/pp"] + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@doc" {with-doc} + ] +] +url { + src: + "https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz" + checksum: [ + "sha256=f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + "sha512=d752b8c09130cf3d564b3a524e3148783b581daa3f9a61d0f52bf4d6995ef73258e71877dbfd8b7516f9a4bac5ad973e80f4fed596df9446e704acc724aac55e" + ] +} +x-commit-hash: "c28817c416ac0b381f6a6938236419ab5d86d6e1" diff --git a/esy.lock/opam/cmdliner.1.2.0/opam b/esy.lock/opam/cmdliner.1.2.0/opam new file mode 100644 index 0000000..b29bd29 --- /dev/null +++ b/esy.lock/opam/cmdliner.1.2.0/opam @@ -0,0 +1,39 @@ +opam-version: "2.0" +synopsis: "Declarative definition of command line interfaces for OCaml" +description: """\ +Cmdliner allows the declarative definition of command line interfaces +for OCaml. + +It provides a simple and compositional mechanism to convert command +line arguments to OCaml values and pass them to your functions. The +module automatically handles syntax errors, help messages and UNIX man +page generation. It supports programs with single or multiple commands +and respects most of the [POSIX][1] and [GNU][2] conventions. + +Cmdliner has no dependencies and is distributed under the ISC license. + +[1]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html +[2]: http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html + +Home page: http://erratique.ch/software/cmdliner""" +maintainer: "Daniel Bünzli " +authors: "The cmdliner programmers" +license: "ISC" +tags: ["cli" "system" "declarative" "org:erratique"] +homepage: "https://erratique.ch/software/cmdliner" +doc: "https://erratique.ch/software/cmdliner/doc" +bug-reports: "https://github.com/dbuenzli/cmdliner/issues" +depends: [ + "ocaml" {>= "4.08.0"} +] +build: [make "all" "PREFIX=%{prefix}%"] +install: [ + [make "install" "LIBDIR=%{_:lib}%" "DOCDIR=%{_:doc}%"] + [make "install-doc" "LIBDIR=%{_:lib}%" "DOCDIR=%{_:doc}%"] +] +dev-repo: "git+https://erratique.ch/repos/cmdliner.git" +url { + src: "https://erratique.ch/software/cmdliner/releases/cmdliner-1.2.0.tbz" + checksum: + "sha512=6fcd6a59a6fbc6986b1aecdc3e4ce7a0dc43c65a16b427d6caa5504b10b51384f6b0bc703af646b09f5f1caeb6827b37d4480ce350ca8006204c850785f2810b" +} \ No newline at end of file diff --git a/esy.lock/opam/conf-bash.1/opam b/esy.lock/opam/conf-bash.1/opam new file mode 100644 index 0000000..c427672 --- /dev/null +++ b/esy.lock/opam/conf-bash.1/opam @@ -0,0 +1,14 @@ +opam-version: "2.0" +maintainer: "code@bnwr.net" +homepage: "https://www.gnu.org/software/bash/" +bug-reports: "https://github.com/ocaml/opam-repository/issues" +license: "GPL-3.0-or-later" +build: ["bash" "--version"] +depexts: [ + ["bash"] {os-family = "bsd"} + ["bash"] {os-distribution = "alpine"} +] +synopsis: "Virtual package to install the Bash shell" +description: "This package will install a system bash" +authors: "code@bnwr.net" +flags: conf diff --git a/esy.lock/opam/cppo.1.6.9/opam b/esy.lock/opam/cppo.1.6.9/opam new file mode 100644 index 0000000..9c51ec6 --- /dev/null +++ b/esy.lock/opam/cppo.1.6.9/opam @@ -0,0 +1,39 @@ +opam-version: "2.0" +synopsis: "Code preprocessor like cpp for OCaml" +description: """\ +Cppo is an equivalent of the C preprocessor for OCaml programs. +It allows the definition of simple macros and file inclusion. + +Cppo is: + +* more OCaml-friendly than cpp +* easy to learn without consulting a manual +* reasonably fast +* simple to install and to maintain""" +maintainer: [ + "Martin Jambon " "Yishuai Li " +] +authors: "Martin Jambon" +license: "BSD-3-Clause" +homepage: "https://github.com/ocaml-community/cppo" +doc: "https://ocaml-community.github.io/cppo" +bug-reports: "https://github.com/ocaml-community/cppo/issues" +depends: [ + "ocaml" {>= "4.02.3"} + "dune" {>= "1.10"} + "base-unix" +] +build: [ + ["dune" "subst"] {dev} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} + ["dune" "build" "-p" name "@doc"] {with-doc} +] +dev-repo: "git+https://github.com/ocaml-community/cppo.git" +url { + src: "https://github.com/ocaml-community/cppo/archive/v1.6.9.tar.gz" + checksum: [ + "md5=d23ffe85ac7dc8f0afd1ddf622770d09" + "sha512=26ff5a7b7f38c460661974b23ca190f0feae3a99f1974e0fd12ccf08745bd7d91b7bc168c70a5385b837bfff9530e0e4e41cf269f23dd8cf16ca658008244b44" + ] +} \ No newline at end of file diff --git a/esy.lock/opam/csexp.1.5.2/opam b/esy.lock/opam/csexp.1.5.2/opam new file mode 100644 index 0000000..7d511ab --- /dev/null +++ b/esy.lock/opam/csexp.1.5.2/opam @@ -0,0 +1,58 @@ +opam-version: "2.0" +synopsis: "Parsing and printing of S-expressions in Canonical form" +description: """ + +This library provides minimal support for Canonical S-expressions +[1]. Canonical S-expressions are a binary encoding of S-expressions +that is super simple and well suited for communication between +programs. + +This library only provides a few helpers for simple applications. If +you need more advanced support, such as parsing from more fancy input +sources, you should consider copying the code of this library given +how simple parsing S-expressions in canonical form is. + +To avoid a dependency on a particular S-expression library, the only +module of this library is parameterised by the type of S-expressions. + +[1] https://en.wikipedia.org/wiki/Canonical_S-expressions +""" +maintainer: ["Jeremie Dimino "] +authors: [ + "Quentin Hocquet " + "Jane Street Group, LLC " + "Jeremie Dimino " +] +license: "MIT" +homepage: "https://github.com/ocaml-dune/csexp" +doc: "https://ocaml-dune.github.io/csexp/" +bug-reports: "https://github.com/ocaml-dune/csexp/issues" +depends: [ + "dune" {>= "3.4"} + "ocaml" {>= "4.03.0"} + "odoc" {with-doc} +] +dev-repo: "git+https://github.com/ocaml-dune/csexp.git" +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" +# "@runtest" {with-test & ocaml:version >= "4.04"} + "@doc" {with-doc} + ] +] +url { + src: + "https://github.com/ocaml-dune/csexp/releases/download/1.5.2/csexp-1.5.2.tbz" + checksum: [ + "sha256=1a14dd04bb4379a41990248550628c77913a9c07f3c35c1370b6960e697787ff" + "sha512=be281018bcfc20d4db14894ef51c4b836d6338d2fdfe22e63d46f405f8dea7349e16f1c0ecd65f73d4c85a2a80e618cdbb8c9dafcbb9f229f04f1adca5b1973c" + ] +} +x-commit-hash: "e6c4768e10c61bcb04d09748744dad55602149c6" diff --git a/esy.lock/opam/dot-merlin-reader.4.9/opam b/esy.lock/opam/dot-merlin-reader.4.9/opam new file mode 100644 index 0000000..78b63a1 --- /dev/null +++ b/esy.lock/opam/dot-merlin-reader.4.9/opam @@ -0,0 +1,30 @@ +opam-version: "2.0" +maintainer: "defree@gmail.com" +authors: "The Merlin team" +synopsis: "Reads config files for merlin" +homepage: "https://github.com/ocaml/merlin" +bug-reports: "https://github.com/ocaml/merlin/issues" +dev-repo: "git+https://github.com/ocaml/merlin.git" +license: "MIT" +build: [ + ["dune" "subst"] {dev} + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" {>= "4.08" & < "5.2"} + "dune" {>= "2.9.0"} + "merlin-lib" {>= "4.9" & < "4.14-502"} + "ocamlfind" {>= "1.6.0"} +] +description: + "Helper process: reads .merlin files and outputs the normalized content to + stdout." +url { + src: + "https://github.com/ocaml/merlin/releases/download/v4.9-414/merlin-4.9-414.tbz" + checksum: [ + "sha256=e23fc47813591269ff9d27c820988e520a662c89dd0af7ea652b21517499cbfd" + "sha512=2199f963368597d10cc197e41ebb883f6a166018c9da3fe259c354550df41b713781003598a2fe5956b0a4ae96f8c07ba33831d3cf6f9d494b731944f87e491e" + ] +} +x-commit-hash: "df75a4550704c113ac29505fd68ef9b7893d4bf5" diff --git a/esy.lock/opam/dune-build-info.3.15.2/opam b/esy.lock/opam/dune-build-info.3.15.2/opam new file mode 100644 index 0000000..f29d3c6 --- /dev/null +++ b/esy.lock/opam/dune-build-info.3.15.2/opam @@ -0,0 +1,46 @@ +opam-version: "2.0" +synopsis: "Embed build information inside executable" +description: """ +The build-info library allows to access information about how the +executable was built, such as the version of the project at which it +was built or the list of statically linked libraries with their +versions. It supports reporting the version from the version control +system during development to get an precise reference of when the +executable was built. +""" +maintainer: ["Jane Street Group, LLC "] +authors: ["Jane Street Group, LLC "] +license: "MIT" +homepage: "https://github.com/ocaml/dune" +doc: "https://dune.readthedocs.io/" +bug-reports: "https://github.com/ocaml/dune/issues" +depends: [ + "dune" {>= "3.12"} + "ocaml" {>= "4.08"} + "odoc" {with-doc} +] +dev-repo: "git+https://github.com/ocaml/dune.git" +build: [ + ["dune" "subst"] {dev} + ["rm" "-rf" "vendor/csexp"] + ["rm" "-rf" "vendor/pp"] + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@doc" {with-doc} + ] +] +url { + src: + "https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz" + checksum: [ + "sha256=f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + "sha512=d752b8c09130cf3d564b3a524e3148783b581daa3f9a61d0f52bf4d6995ef73258e71877dbfd8b7516f9a4bac5ad973e80f4fed596df9446e704acc724aac55e" + ] +} +x-commit-hash: "c28817c416ac0b381f6a6938236419ab5d86d6e1" diff --git a/esy.lock/opam/dune-configurator.3.15.2/opam b/esy.lock/opam/dune-configurator.3.15.2/opam new file mode 100644 index 0000000..3f0ee8c --- /dev/null +++ b/esy.lock/opam/dune-configurator.3.15.2/opam @@ -0,0 +1,50 @@ +opam-version: "2.0" +synopsis: "Helper library for gathering system configuration" +description: """ +dune-configurator is a small library that helps writing OCaml scripts that +test features available on the system, in order to generate config.h +files for instance. +Among other things, dune-configurator allows one to: +- test if a C program compiles +- query pkg-config +- import #define from OCaml header files +- generate config.h file +""" +maintainer: ["Jane Street Group, LLC "] +authors: ["Jane Street Group, LLC "] +license: "MIT" +homepage: "https://github.com/ocaml/dune" +doc: "https://dune.readthedocs.io/" +bug-reports: "https://github.com/ocaml/dune/issues" +depends: [ + "dune" {>= "3.12"} + "ocaml" {>= "4.04.0"} + "base-unix" + "csexp" {>= "1.5.0"} + "odoc" {with-doc} +] +dev-repo: "git+https://github.com/ocaml/dune.git" +build: [ + ["dune" "subst"] {dev} + ["rm" "-rf" "vendor/csexp"] + ["rm" "-rf" "vendor/pp"] + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@doc" {with-doc} + ] +] +url { + src: + "https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz" + checksum: [ + "sha256=f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + "sha512=d752b8c09130cf3d564b3a524e3148783b581daa3f9a61d0f52bf4d6995ef73258e71877dbfd8b7516f9a4bac5ad973e80f4fed596df9446e704acc724aac55e" + ] +} +x-commit-hash: "c28817c416ac0b381f6a6938236419ab5d86d6e1" diff --git a/esy.lock/opam/dune-rpc.3.15.2/opam b/esy.lock/opam/dune-rpc.3.15.2/opam new file mode 100644 index 0000000..20721bf --- /dev/null +++ b/esy.lock/opam/dune-rpc.3.15.2/opam @@ -0,0 +1,44 @@ +opam-version: "2.0" +synopsis: "Communicate with dune using rpc" +description: "Library to connect and control a running dune instance" +maintainer: ["Jane Street Group, LLC "] +authors: ["Jane Street Group, LLC "] +license: "MIT" +homepage: "https://github.com/ocaml/dune" +doc: "https://dune.readthedocs.io/" +bug-reports: "https://github.com/ocaml/dune/issues" +depends: [ + "dune" {>= "3.12"} + "csexp" + "ordering" + "dyn" + "xdg" + "stdune" {= version} + "pp" {>= "1.1.0"} + "odoc" {with-doc} +] +dev-repo: "git+https://github.com/ocaml/dune.git" +build: [ + ["dune" "subst"] {dev} + ["rm" "-rf" "vendor/csexp"] + ["rm" "-rf" "vendor/pp"] + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@doc" {with-doc} + ] +] +url { + src: + "https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz" + checksum: [ + "sha256=f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + "sha512=d752b8c09130cf3d564b3a524e3148783b581daa3f9a61d0f52bf4d6995ef73258e71877dbfd8b7516f9a4bac5ad973e80f4fed596df9446e704acc724aac55e" + ] +} +x-commit-hash: "c28817c416ac0b381f6a6938236419ab5d86d6e1" diff --git a/esy.lock/opam/dune.3.15.2/opam b/esy.lock/opam/dune.3.15.2/opam new file mode 100644 index 0000000..499dbf3 --- /dev/null +++ b/esy.lock/opam/dune.3.15.2/opam @@ -0,0 +1,57 @@ +opam-version: "2.0" +synopsis: "Fast, portable, and opinionated build system" +description: """ + +Dune is a build system that was designed to simplify the release of +Jane Street packages. It reads metadata from "dune" files following a +very simple s-expression syntax. + +Dune is fast, has very low-overhead, and supports parallel builds on +all platforms. It has no system dependencies; all you need to build +dune or packages using dune is OCaml. You don't need make or bash +as long as the packages themselves don't use bash explicitly. + +Dune is composable; supporting multi-package development by simply +dropping multiple repositories into the same directory. + +Dune also supports multi-context builds, such as building against +several opam roots/switches simultaneously. This helps maintaining +packages across several versions of OCaml and gives cross-compilation +for free. +""" +maintainer: ["Jane Street Group, LLC "] +authors: ["Jane Street Group, LLC "] +license: "MIT" +homepage: "https://github.com/ocaml/dune" +doc: "https://dune.readthedocs.io/" +bug-reports: "https://github.com/ocaml/dune/issues" +conflicts: [ + "merlin" {< "3.4.0"} + "ocaml-lsp-server" {< "1.3.0"} + "dune-configurator" {< "2.3.0"} + "odoc" {< "2.0.1"} + "dune-release" {< "1.3.0"} + "js_of_ocaml-compiler" {< "3.6.0"} + "jbuilder" {= "transition"} +] +dev-repo: "git+https://github.com/ocaml/dune.git" +build: [ + ["ocaml" "boot/bootstrap.ml" "-j" jobs] + ["./_boot/dune.exe" "build" "dune.install" "--release" "--profile" "dune-bootstrap" "-j" jobs] +] +depends: [ + # Please keep the lower bound in sync with .github/workflows/workflow.yml, + # dune-project and min_ocaml_version in bootstrap.ml + ("ocaml" {>= "4.08"} | ("ocaml" {>= "4.02" & < "4.08~~"} & "ocamlfind-secondary")) + "base-unix" + "base-threads" +] +url { + src: + "https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz" + checksum: [ + "sha256=f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + "sha512=d752b8c09130cf3d564b3a524e3148783b581daa3f9a61d0f52bf4d6995ef73258e71877dbfd8b7516f9a4bac5ad973e80f4fed596df9446e704acc724aac55e" + ] +} +x-commit-hash: "c28817c416ac0b381f6a6938236419ab5d86d6e1" diff --git a/esy.lock/opam/dyn.3.15.2/opam b/esy.lock/opam/dyn.3.15.2/opam new file mode 100644 index 0000000..f6c52b1 --- /dev/null +++ b/esy.lock/opam/dyn.3.15.2/opam @@ -0,0 +1,41 @@ +opam-version: "2.0" +synopsis: "Dynamic type" +description: "Dynamic type" +maintainer: ["Jane Street Group, LLC "] +authors: ["Jane Street Group, LLC "] +license: "MIT" +homepage: "https://github.com/ocaml/dune" +doc: "https://dune.readthedocs.io/" +bug-reports: "https://github.com/ocaml/dune/issues" +depends: [ + "dune" {>= "3.12"} + "ocaml" {>= "4.08.0"} + "ordering" {= version} + "pp" {>= "1.1.0"} + "odoc" {with-doc} +] +dev-repo: "git+https://github.com/ocaml/dune.git" +build: [ + ["dune" "subst"] {dev} + ["rm" "-rf" "vendor/csexp"] + ["rm" "-rf" "vendor/pp"] + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@doc" {with-doc} + ] +] +url { + src: + "https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz" + checksum: [ + "sha256=f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + "sha512=d752b8c09130cf3d564b3a524e3148783b581daa3f9a61d0f52bf4d6995ef73258e71877dbfd8b7516f9a4bac5ad973e80f4fed596df9446e704acc724aac55e" + ] +} +x-commit-hash: "c28817c416ac0b381f6a6938236419ab5d86d6e1" diff --git a/esy.lock/opam/either.1.0.0/opam b/esy.lock/opam/either.1.0.0/opam new file mode 100644 index 0000000..651c06e --- /dev/null +++ b/esy.lock/opam/either.1.0.0/opam @@ -0,0 +1,40 @@ +opam-version: "2.0" +synopsis: "Compatibility Either module" +description: """ +Projects that want to use the Either module defined in OCaml 4.12.0 while +staying compatible with older versions of OCaml should use this library +instead. +""" +maintainer: ["Craig Ferguson "] +authors: ["Craig Ferguson "] +license: "MIT" +homepage: "https://github.com/mirage/either" +doc: "https://mirage.github.io/either" +bug-reports: "https://github.com/mirage/either/issues" +depends: [ + "dune" {>= "2.0"} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/mirage/either.git" +x-commit-hash: "a270ceac58e3e5bed6fe7e8bfb7132b14ee9c322" +url { + src: + "https://github.com/mirage/either/releases/download/1.0.0/either-1.0.0.tbz" + checksum: [ + "sha256=bf674de3312dee7b7215f07df1e8a96eb3d679164b8a918cdd95b8d97e505884" + "sha512=147854c09f897dd028b18a9f19acea8666107aaa7b1aab3c92f568af531364f57298edcaf3897d74246d3857d52e9bfb7ad0fc39220d988d9f14694ca1d5e9ed" + ] +} diff --git a/esy.lock/opam/fiber.3.7.0/opam b/esy.lock/opam/fiber.3.7.0/opam new file mode 100644 index 0000000..6a40276 --- /dev/null +++ b/esy.lock/opam/fiber.3.7.0/opam @@ -0,0 +1,39 @@ +opam-version: "2.0" +synopsis: "Dune's monadic structured concurrency library" +maintainer: ["Jane Street Group, LLC "] +authors: ["Jane Street Group, LLC "] +license: "MIT" +homepage: "https://github.com/ocaml-dune/fiber" +bug-reports: "https://github.com/ocaml-dune/fiber/issues" +depends: [ + "dune" {>= "3.6"} + "ocaml" {>= "4.08"} + "ppx_expect" {with-test} + "dyn" + "stdune" + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test & ocaml:version >= "4.13"} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/ocaml-dune/fiber.git" +url { + src: + "https://github.com/ocaml-dune/fiber/releases/download/3.7.0/fiber-lwt-3.7.0.tbz" + checksum: [ + "sha256=8648a15ae93fe6942999ce36887429a3913b62829c4714e520cc0e7a1c3b9682" + "sha512=348b28b28ffd87de035e90753f677658e8ad58421caf3ac086e4c0bbab8508fa5fe2f55d137c425afaf790ebcf45291e16d70eac5cb766b6d9786f042b58b19b" + ] +} +x-commit-hash: "dd66893a530759da26b66bd1c8939fd77f369afb" diff --git a/esy.lock/opam/fix.20230505/opam b/esy.lock/opam/fix.20230505/opam new file mode 100644 index 0000000..6278f49 --- /dev/null +++ b/esy.lock/opam/fix.20230505/opam @@ -0,0 +1,26 @@ + +opam-version: "2.0" +maintainer: "francois.pottier@inria.fr" +authors: [ + "François Pottier " +] +homepage: "https://gitlab.inria.fr/fpottier/fix" +dev-repo: "git+https://gitlab.inria.fr/fpottier/fix.git" +bug-reports: "francois.pottier@inria.fr" +license: "LGPL-2.0-only" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" { >= "4.03" } + "dune" { >= "1.3" } +] +synopsis: "Algorithmic building blocks for memoization, recursion, and more" +url { + src: + "https://gitlab.inria.fr/fpottier/fix/-/archive/20230505/archive.tar.gz" + checksum: [ + "md5=2a4afa633128c5010677222f7b3c9451" + "sha512=30d446ba6c19aef78b52d9831eb26f8f6ac10e88bd1eff36d16fbbfb32278b2637e31e63a160aec4abbbfdb1e7612ed25d68c936f4cbf2073e51d713ff3a8adf" + ] +} diff --git a/esy.lock/opam/fpath.0.7.3/opam b/esy.lock/opam/fpath.0.7.3/opam new file mode 100644 index 0000000..ae3336e --- /dev/null +++ b/esy.lock/opam/fpath.0.7.3/opam @@ -0,0 +1,36 @@ +opam-version: "2.0" +maintainer: "Daniel Bünzli " +authors: ["The fpath programmers"] +homepage: "https://erratique.ch/software/fpath" +doc: "https://erratique.ch/software/fpath/doc" +dev-repo: "git+https://erratique.ch/repos/fpath.git" +bug-reports: "https://github.com/dbuenzli/fpath/issues" +tags: [ "file" "system" "path" "org:erratique" ] +license: "ISC" +depends: [ + "ocaml" {>= "4.03.0"} + "ocamlfind" {build} + "ocamlbuild" {build} + "topkg" {build & >= "0.9.0"} + "astring" +] +build: [[ + "ocaml" "pkg/pkg.ml" "build" + "--dev-pkg=true" {dev} ]] + +synopsis: """File system paths for OCaml""" +description: """\ + +Fpath is an OCaml module for handling file system paths with POSIX or +Windows conventions. Fpath processes paths without accessing the file +system and is independent from any system library. + +Fpath depends on [Astring][astring] and is distributed under the ISC +license. + +[astring]: http://erratique.ch/software/astring +""" +url { +archive: "https://erratique.ch/software/fpath/releases/fpath-0.7.3.tbz" +checksum: "0740b530e8fed5b0adc5eee8463cfc2f" +} diff --git a/esy.lock/opam/melange.3.0.0-51/opam b/esy.lock/opam/melange.3.0.0-51/opam new file mode 100644 index 0000000..ae0c23a --- /dev/null +++ b/esy.lock/opam/melange.3.0.0-51/opam @@ -0,0 +1,47 @@ +# This file is generated by dune, edit dune-project instead +opam-version: "2.0" +synopsis: "Toolchain to produce JS from Reason/OCaml" +maintainer: ["Antonio Nuno Monteiro "] +authors: ["Antonio Nuno Monteiro "] +license: "LGPL-2.1-or-later" +homepage: "https://github.com/melange-re/melange" +bug-reports: "https://github.com/melange-re/melange/issues" +depends: [ + "dune" {>= "3.8"} + "ocaml" {>= "5.1" & < "5.2"} + "cmdliner" {>= "1.1.0"} + "dune-build-info" + "cppo" {build} + "ounit" {with-test} + "reason" {with-test & >= "3.9.0"} + "ppxlib" {>= "0.30.0"} + "menhir" {>= "20201214"} + "pp" + "reason-react-ppx" {with-test & post} + "merlin" {with-test} + "odoc" {with-doc} +] +available: arch != "x86_32" & arch != "arm32" +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/melange-re/melange.git" +url { + src: + "https://github.com/melange-re/melange/releases/download/3.0.0-51/melange-3.0.0-51.tbz" + checksum: [ + "sha256=1ebcf29c95ccea9f40e1f39192ae5a37fba9c64768f9ff8f998ff011415fe947" + "sha512=97da717b0446a7527b43c785676933a1e6974d2cf747ace68e6de5c120d03dc196ae706fef20e4139c6090036d10c350fc9b6bd093bd8a7092d0275ae56f3777" + ] +} +x-commit-hash: "766b65d21dbe60fbcab74d458395606c2676d2bd" diff --git a/esy.lock/opam/menhir.20231231/opam b/esy.lock/opam/menhir.20231231/opam new file mode 100644 index 0000000..adf52bf --- /dev/null +++ b/esy.lock/opam/menhir.20231231/opam @@ -0,0 +1,30 @@ + +opam-version: "2.0" +maintainer: "francois.pottier@inria.fr" +authors: [ + "François Pottier " + "Yann Régis-Gianas " +] +homepage: "http://gitlab.inria.fr/fpottier/menhir" +dev-repo: "git+https://gitlab.inria.fr/fpottier/menhir.git" +bug-reports: "https://gitlab.inria.fr/fpottier/menhir/-/issues" +license: "GPL-2.0-only" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" {>= "4.03.0"} + "dune" {>= "2.8.0"} + "menhirLib" {= version} + "menhirSdk" {= version} + "menhirCST" {= version} +] +synopsis: "An LR(1) parser generator" +url { + src: + "https://gitlab.inria.fr/fpottier/menhir/-/archive/20231231/archive.tar.gz" + checksum: [ + "md5=799748bc3b7a542798a85956c7863865" + "sha512=620ff3443143535e03ac98c5e8ee2ddf9ba48f8cfe441302118def1da3e03ffac7f48d4d4cb129766b625ecad0fb341da1baa0169dee8b6d07a5b0bbb735cf2f" + ] +} diff --git a/esy.lock/opam/menhirCST.20231231/opam b/esy.lock/opam/menhirCST.20231231/opam new file mode 100644 index 0000000..9a49a85 --- /dev/null +++ b/esy.lock/opam/menhirCST.20231231/opam @@ -0,0 +1,29 @@ + +opam-version: "2.0" +maintainer: "francois.pottier@inria.fr" +authors: [ + "François Pottier " +] +homepage: "http://gitlab.inria.fr/fpottier/menhir" +dev-repo: "git+https://gitlab.inria.fr/fpottier/menhir.git" +bug-reports: "https://gitlab.inria.fr/fpottier/menhir/-/issues" +license: "LGPL-2.0-only with OCaml-LGPL-linking-exception" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" { >= "4.08" } + "dune" { >= "2.8.0" } +] +conflicts: [ + "menhir" { != version } +] +synopsis: "Runtime support library for parsers generated by Menhir" +url { + src: + "https://gitlab.inria.fr/fpottier/menhir/-/archive/20231231/archive.tar.gz" + checksum: [ + "md5=799748bc3b7a542798a85956c7863865" + "sha512=620ff3443143535e03ac98c5e8ee2ddf9ba48f8cfe441302118def1da3e03ffac7f48d4d4cb129766b625ecad0fb341da1baa0169dee8b6d07a5b0bbb735cf2f" + ] +} diff --git a/esy.lock/opam/menhirLib.20231231/opam b/esy.lock/opam/menhirLib.20231231/opam new file mode 100644 index 0000000..1f321b1 --- /dev/null +++ b/esy.lock/opam/menhirLib.20231231/opam @@ -0,0 +1,30 @@ + +opam-version: "2.0" +maintainer: "francois.pottier@inria.fr" +authors: [ + "François Pottier " + "Yann Régis-Gianas " +] +homepage: "http://gitlab.inria.fr/fpottier/menhir" +dev-repo: "git+https://gitlab.inria.fr/fpottier/menhir.git" +bug-reports: "https://gitlab.inria.fr/fpottier/menhir/-/issues" +license: "LGPL-2.0-only with OCaml-LGPL-linking-exception" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" { >= "4.03.0" } + "dune" { >= "2.8.0" } +] +conflicts: [ + "menhir" { != version } +] +synopsis: "Runtime support library for parsers generated by Menhir" +url { + src: + "https://gitlab.inria.fr/fpottier/menhir/-/archive/20231231/archive.tar.gz" + checksum: [ + "md5=799748bc3b7a542798a85956c7863865" + "sha512=620ff3443143535e03ac98c5e8ee2ddf9ba48f8cfe441302118def1da3e03ffac7f48d4d4cb129766b625ecad0fb341da1baa0169dee8b6d07a5b0bbb735cf2f" + ] +} diff --git a/esy.lock/opam/menhirSdk.20231231/opam b/esy.lock/opam/menhirSdk.20231231/opam new file mode 100644 index 0000000..0e2649f --- /dev/null +++ b/esy.lock/opam/menhirSdk.20231231/opam @@ -0,0 +1,30 @@ + +opam-version: "2.0" +maintainer: "francois.pottier@inria.fr" +authors: [ + "François Pottier " + "Yann Régis-Gianas " +] +homepage: "http://gitlab.inria.fr/fpottier/menhir" +dev-repo: "git+https://gitlab.inria.fr/fpottier/menhir.git" +bug-reports: "https://gitlab.inria.fr/fpottier/menhir/-/issues" +license: "LGPL-2.0-only with OCaml-LGPL-linking-exception" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" { >= "4.03.0" } + "dune" { >= "2.8.0" } +] +conflicts: [ + "menhir" { != version } +] +synopsis: "Compile-time library for auxiliary tools related to Menhir" +url { + src: + "https://gitlab.inria.fr/fpottier/menhir/-/archive/20231231/archive.tar.gz" + checksum: [ + "md5=799748bc3b7a542798a85956c7863865" + "sha512=620ff3443143535e03ac98c5e8ee2ddf9ba48f8cfe441302118def1da3e03ffac7f48d4d4cb129766b625ecad0fb341da1baa0169dee8b6d07a5b0bbb735cf2f" + ] +} diff --git a/esy.lock/opam/merlin-extend.0.6.1/opam b/esy.lock/opam/merlin-extend.0.6.1/opam new file mode 100644 index 0000000..9f99365 --- /dev/null +++ b/esy.lock/opam/merlin-extend.0.6.1/opam @@ -0,0 +1,30 @@ +opam-version: "2.0" +maintainer: "Frederic Bour " +authors: "Frederic Bour " +homepage: "https://github.com/let-def/merlin-extend" +bug-reports: "https://github.com/let-def/merlin-extend" +license: "MIT" +dev-repo: "git+https://github.com/let-def/merlin-extend.git" +build: [ + ["dune" "subst"] {dev} + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "dune" {>= "1.0"} + "cppo" {build & >= "1.1.0"} + "ocaml" {>= "4.02.3"} +] +synopsis: "A protocol to provide custom frontend to Merlin" +description: """ +This protocol allows to replace the OCaml frontend of Merlin. +It extends what used to be done with the `-pp' flag to handle a few more cases.""" +doc: "https://let-def.github.io/merlin-extend" +url { + src: + "https://github.com/let-def/merlin-extend/releases/download/v0.6.1/merlin-extend-0.6.1.tbz" + checksum: [ + "sha256=5ec84b355ddb2d129a5948b132bfacc93adcbde2158c7de695f7bfc3650bead7" + "sha512=631fc96aab2f35e12a078c9b4907ca7b0db9f1e3a4026040e6c23b82e0171c256a89fb5d4c887f1d156eb9e3152783cdf7a546b2496051007a1bcf5777417396" + ] +} +x-commit-hash: "cf2707bbe8e034c6ecf5d0fecd3fd889f6ab14bf" diff --git a/esy.lock/opam/merlin-lib.4.14-501/opam b/esy.lock/opam/merlin-lib.4.14-501/opam new file mode 100644 index 0000000..a2721f0 --- /dev/null +++ b/esy.lock/opam/merlin-lib.4.14-501/opam @@ -0,0 +1,34 @@ +opam-version: "2.0" +maintainer: "defree@gmail.com" +authors: "The Merlin team" +homepage: "https://github.com/ocaml/merlin" +bug-reports: "https://github.com/ocaml/merlin/issues" +dev-repo: "git+https://github.com/ocaml/merlin.git" +license: "MIT" +build: [ + ["dune" "subst"] {dev} + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" {>= "5.1.1" & < "5.2"} + "dune" {>= "2.9.0"} + "csexp" {>= "1.5.1"} + "menhir" {dev & >= "20201216"} + "menhirLib" {dev & >= "20201216"} + "menhirSdk" {dev & >= "20201216"} +] +synopsis: + "Merlin's libraries" +description: + "These libraries provides access to low-level compiler interfaces and the + standard higher-level merlin protocol. The library is provided as-is, is not + thoroughly documented, and its public API might break with any new release." +url { + src: + "https://github.com/ocaml/merlin/releases/download/v4.14-501/merlin-4.14-501.tbz" + checksum: [ + "sha256=b7e9e96e924058c2ce429642788aa2e390720d441e224538bcf494a65203a292" + "sha512=734d760b1f73652bbd1d25736d08336c2df15f4eaa1d4c7aed345e83d1375b54266cb78dbeb698870a668633fbd2c7fece4dd161a50fba92f245dfad4b69c4c9" + ] +} +x-commit-hash: "7d7f525180f5979516e10c05d0cd49823edb5ef1" diff --git a/esy.lock/opam/merlin.4.14-501/opam b/esy.lock/opam/merlin.4.14-501/opam new file mode 100644 index 0000000..28c1cd8 --- /dev/null +++ b/esy.lock/opam/merlin.4.14-501/opam @@ -0,0 +1,81 @@ +opam-version: "2.0" +maintainer: "defree@gmail.com" +authors: "The Merlin team" +homepage: "https://github.com/ocaml/merlin" +bug-reports: "https://github.com/ocaml/merlin/issues" +dev-repo: "git+https://github.com/ocaml/merlin.git" +license: "MIT" +build: [ + ["dune" "subst"] {dev} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} +] +depends: [ + "ocaml" {>= "5.1" & < "5.2"} + "dune" {>= "2.9.0"} + "merlin-lib" {= version} + "dot-merlin-reader" {>= "4.9"} + "yojson" {>= "2.0.0"} + "conf-jq" {with-test} + "ppxlib" {with-test} +] +conflicts: [ + "seq" {!= "base"} + "base-effects" +] +synopsis: + "Editor helper, provides completion, typing and source browsing in Vim and Emacs" +description: + "Merlin is an assistant for editing OCaml code. It aims to provide the features available in modern IDEs: error reporting, auto completion, source browsing and much more." +post-messages: [ + "merlin installed. + +Quick setup for VIM +------------------- +Append this to your .vimrc to add merlin to vim's runtime-path: + let g:opamshare = substitute(system('opam var share'),'\\n$','','''') + execute \"set rtp+=\" . g:opamshare . \"/merlin/vim\" + +Also run the following line in vim to index the documentation: + :execute \"helptags \" . g:opamshare . \"/merlin/vim/doc\" + +Quick setup for EMACS +------------------- +Add opam emacs directory to your load-path by appending this to your .emacs: + (let ((opam-share (ignore-errors (car (process-lines \"opam\" \"var\" \"share\"))))) + (when (and opam-share (file-directory-p opam-share)) + ;; Register Merlin + (add-to-list 'load-path (expand-file-name \"emacs/site-lisp\" opam-share)) + (autoload 'merlin-mode \"merlin\" nil t nil) + ;; Automatically start it in OCaml buffers + (add-hook 'tuareg-mode-hook 'merlin-mode t) + (add-hook 'caml-mode-hook 'merlin-mode t) + ;; Use opam switch to lookup ocamlmerlin binary + (setq merlin-command 'opam) + ;; To easily change opam switches within a given Emacs session, you can + ;; install the minor mode https://github.com/ProofGeneral/opam-switch-mode + ;; and use one of its \"OPSW\" menus. + )) +Take a look at https://github.com/ocaml/merlin for more information + +Quick setup with opam-user-setup +-------------------------------- + +Opam-user-setup support Merlin. + + $ opam user-setup install + +should take care of basic setup. +See https://github.com/OCamlPro/opam-user-setup +" + {success & !user-setup:installed} +] +url { + src: + "https://github.com/ocaml/merlin/releases/download/v4.14-501/merlin-4.14-501.tbz" + checksum: [ + "sha256=b7e9e96e924058c2ce429642788aa2e390720d441e224538bcf494a65203a292" + "sha512=734d760b1f73652bbd1d25736d08336c2df15f4eaa1d4c7aed345e83d1375b54266cb78dbeb698870a668633fbd2c7fece4dd161a50fba92f245dfad4b69c4c9" + ] +} +x-commit-hash: "7d7f525180f5979516e10c05d0cd49823edb5ef1" diff --git a/esy.lock/opam/ocaml-compiler-libs.v0.12.4/opam b/esy.lock/opam/ocaml-compiler-libs.v0.12.4/opam new file mode 100644 index 0000000..a2df8c6 --- /dev/null +++ b/esy.lock/opam/ocaml-compiler-libs.v0.12.4/opam @@ -0,0 +1,39 @@ +opam-version: "2.0" +synopsis: "OCaml compiler libraries repackaged" +description: """ +This packages exposes the OCaml compiler libraries repackages under +the toplevel names Ocaml_common, Ocaml_bytecomp, Ocaml_optcomp, ...""" +maintainer: ["Jane Street developers"] +authors: ["Jane Street Group, LLC"] +license: "MIT" +homepage: "https://github.com/janestreet/ocaml-compiler-libs" +bug-reports: "https://github.com/janestreet/ocaml-compiler-libs/issues" +depends: [ + "dune" {>= "2.8"} + "ocaml" {>= "4.04.1" & < "5.2.0"} + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/janestreet/ocaml-compiler-libs.git" +url { + src: + "https://github.com/janestreet/ocaml-compiler-libs/releases/download/v0.12.4/ocaml-compiler-libs-v0.12.4.tbz" + checksum: [ + "sha256=4ec9c9ec35cc45c18c7a143761154ef1d7663036a29297f80381f47981a07760" + "sha512=978dba8dfa61f98fa24fda7a9c26c2e837081f37d1685fe636dc19cfc3278a940cf01a10293504b185c406706bc1008bc54313d50f023bcdea6d5ac6c0788b35" + ] +} +x-commit-hash: "8cd12f18bb7171c2b67d661868c4271fae528d93" diff --git a/esy.lock/opam/ocaml-lsp-server.1.17.0/opam b/esy.lock/opam/ocaml-lsp-server.1.17.0/opam new file mode 100644 index 0000000..e3a53b0 --- /dev/null +++ b/esy.lock/opam/ocaml-lsp-server.1.17.0/opam @@ -0,0 +1,67 @@ +opam-version: "2.0" +synopsis: "LSP Server for OCaml" +description: "An LSP server for OCaml." +maintainer: ["Rudi Grinberg "] +authors: [ + "Andrey Popp <8mayday@gmail.com>" + "Rusty Key " + "Louis Roché " + "Oleksiy Golovko " + "Rudi Grinberg " + "Sacha Ayoun " + "cannorin " + "Ulugbek Abdullaev " + "Thibaut Mattio " + "Max Lantas " +] +license: "ISC" +homepage: "https://github.com/ocaml/ocaml-lsp" +bug-reports: "https://github.com/ocaml/ocaml-lsp/issues" +depends: [ + "dune" {>= "3.0"} + "yojson" + "re" {>= "1.5.0"} + "ppx_yojson_conv_lib" {>= "v0.14"} + "dune-rpc" {>= "3.4.0"} + "chrome-trace" {>= "3.3.0"} + "dyn" + "stdune" + "fiber" {>= "3.1.1" & < "4.0.0"} + "xdg" + "ordering" + "dune-build-info" + "spawn" + "astring" + "camlp-streams" + "ppx_expect" {>= "v0.15.0" & with-test} + "ocamlformat" {with-test & = "0.24.1"} + "ocamlc-loc" {>= "3.7.0"} + "uutf" {>= "1.0.2"} + "pp" {>= "1.1.2"} + "csexp" {>= "1.5"} + "ocamlformat-rpc-lib" {>= "0.21.0"} + "odoc" {with-doc} + "ocaml" {>= "4.14" & < "5.2"} + "merlin-lib" {>= "4.9" & < "5.0"} +] +dev-repo: "git+https://github.com/ocaml/ocaml-lsp.git" +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-j" + jobs + "ocaml-lsp-server.install" + "--release" + ] +] +url { + src: + "https://github.com/ocaml/ocaml-lsp/releases/download/1.17.0/lsp-1.17.0.tbz" + checksum: [ + "sha256=8fb8bbd717eefd2608b4d83458105b660e0de3a1134dc8fc216ae659d4d19600" + "sha512=6876df760dbcb51f85e7fd9d08cc8498c69ede38a52f4e12407187da3fbd9657c71f3223f9490ad97edd5259cfdeb2819d943db65bb9ce3c2a18dace3b65ffa8" + ] +} +x-commit-hash: "d3d8de5a4213c2a16e43ac4f87cbbe88a894d05f" diff --git a/esy.lock/opam/ocaml-version.3.6.7/opam b/esy.lock/opam/ocaml-version.3.6.7/opam new file mode 100644 index 0000000..f8cb243 --- /dev/null +++ b/esy.lock/opam/ocaml-version.3.6.7/opam @@ -0,0 +1,55 @@ +opam-version: "2.0" +synopsis: "Manipulate, parse and generate OCaml compiler version strings" +description: """ +This library provides facilities to parse version numbers of the OCaml compiler, and enumerates the various official OCaml releases and configuration variants. + +OCaml version numbers are of the form `major.minor.patch+extra`, where the `patch` and `extra` fields are optional. This library offers the following functionality: + +- Functions to parse and serialise OCaml compiler version numbers. +- Enumeration of official OCaml compiler version releases. +- Test compiler versions for a particular feature (e.g. the `bytes` type) +- [opam](https://opam.ocaml.org) compiler switch enumeration. + +### Further information + +- **Discussion:** Post on with the `ocaml` tag under the Ecosystem category. +- **Bugs:** +- **Docs:** +""" +maintainer: ["Anil Madhavapeddy "] +authors: ["Anil Madhavapeddy "] +license: "ISC" +tags: ["org:ocamllabs"] +homepage: "https://github.com/ocurrent/ocaml-version" +doc: "https://ocurrent.github.io/ocaml-version/doc" +bug-reports: "https://github.com/ocurrent/ocaml-version/issues" +depends: [ + "dune" {>= "3.6"} + "ocaml" {>= "4.07.0"} + "alcotest" {with-test} + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/ocurrent/ocaml-version.git" +url { + src: + "https://github.com/ocurrent/ocaml-version/releases/download/v3.6.7/ocaml-version-3.6.7.tbz" + checksum: [ + "sha256=d50ffd5b669d33edb0d889c476a71de4888d90008d58336038d210ced28f810c" + "sha512=128c2777152d6050a1cc07e520876aa7bef380459dd6a3dbcc8e42352afcbd7ebb8f8ef1751beb865346d49ba6f0c2dc45359f2367e5d4c53906008fc51d95eb" + ] +} +x-commit-hash: "1fd32aebc48b86a81e3f825229180f530a94729a" diff --git a/esy.lock/opam/ocamlbuild.0.14.3/opam b/esy.lock/opam/ocamlbuild.0.14.3/opam new file mode 100644 index 0000000..d1c725b --- /dev/null +++ b/esy.lock/opam/ocamlbuild.0.14.3/opam @@ -0,0 +1,40 @@ +opam-version: "2.0" +synopsis: + "OCamlbuild is a build system with builtin rules to easily build most OCaml projects" +maintainer: "Gabriel Scherer " +authors: ["Nicolas Pouillard" "Berke Durak"] +license: "LGPL-2.0-or-later WITH OCaml-LGPL-linking-exception" +homepage: "https://github.com/ocaml/ocamlbuild/" +doc: "https://github.com/ocaml/ocamlbuild/blob/master/manual/manual.adoc" +bug-reports: "https://github.com/ocaml/ocamlbuild/issues" +depends: [ + "ocaml" {>= "4.03"} +] +conflicts: [ + "base-ocamlbuild" + "ocamlfind" {< "1.6.2"} +] +build: [ + [ + make + "-f" + "configure.make" + "all" + "OCAMLBUILD_PREFIX=%{prefix}%" + "OCAMLBUILD_BINDIR=%{bin}%" + "OCAMLBUILD_LIBDIR=%{lib}%" + "OCAMLBUILD_MANDIR=%{man}%" + "OCAML_NATIVE=%{ocaml:native}%" + "OCAML_NATIVE_TOOLS=%{ocaml:native}%" + ] + [make "check-if-preinstalled" "all" "opam-install"] +] +dev-repo: "git+https://github.com/ocaml/ocamlbuild.git" +available: os != "win32" +url { + src: "https://github.com/ocaml/ocamlbuild/archive/refs/tags/0.14.3.tar.gz" + checksum: [ + "md5=220df59060c916e8aac2eb471c870485" + "sha512=def8fa1d5488905fda31f72b7f6f0ebdccefa55a8e984a6ea4a7c1e0856e8ea1f7814410202e0f7f7d5e72aca7e8ae0d6623f7f2bade78b0dd82155de76ec4e5" + ] +} \ No newline at end of file diff --git a/esy.lock/opam/ocamlc-loc.3.15.2/opam b/esy.lock/opam/ocamlc-loc.3.15.2/opam new file mode 100644 index 0000000..7ba50aa --- /dev/null +++ b/esy.lock/opam/ocamlc-loc.3.15.2/opam @@ -0,0 +1,44 @@ +opam-version: "2.0" +synopsis: "Parse ocaml compiler output into structured form" +description: + "This library offers no backwards compatibility guarantees. Use at your own risk." +maintainer: ["Jane Street Group, LLC "] +authors: ["Jane Street Group, LLC "] +license: "MIT" +homepage: "https://github.com/ocaml/dune" +doc: "https://dune.readthedocs.io/" +bug-reports: "https://github.com/ocaml/dune/issues" +depends: [ + "dune" {>= "3.12"} + "ocaml" {>= "4.08.0"} + "dyn" {= version} + "odoc" {with-doc} +] +conflicts: [ + "ocaml-lsp-server" {< "1.15.0"} +] +dev-repo: "git+https://github.com/ocaml/dune.git" +build: [ + ["dune" "subst"] {dev} + ["rm" "-rf" "vendor/csexp"] + ["rm" "-rf" "vendor/pp"] + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@doc" {with-doc} + ] +] +url { + src: + "https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz" + checksum: [ + "sha256=f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + "sha512=d752b8c09130cf3d564b3a524e3148783b581daa3f9a61d0f52bf4d6995ef73258e71877dbfd8b7516f9a4bac5ad973e80f4fed596df9446e704acc724aac55e" + ] +} +x-commit-hash: "c28817c416ac0b381f6a6938236419ab5d86d6e1" diff --git a/esy.lock/opam/ocamlfind.1.9.6/files/0001-Harden-test-for-OCaml-5.patch b/esy.lock/opam/ocamlfind.1.9.6/files/0001-Harden-test-for-OCaml-5.patch new file mode 100644 index 0000000..8011238 --- /dev/null +++ b/esy.lock/opam/ocamlfind.1.9.6/files/0001-Harden-test-for-OCaml-5.patch @@ -0,0 +1,12 @@ +diff a/configure b/configure +--- a/configure ++++ b/configure +@@ -294,7 +294,7 @@ + # If findlib has been configured -sitelib $(ocamlc -where) then there's + # nothing to do, but otherwise we need to put OCaml's Standard Library + # into the path setting. +- if [ ! -e "${ocaml_sitelib}/stdlib/META" ]; then ++ if [ ! -e "${ocaml_sitelib}/stdlib.cmi" ]; then + ocamlpath="${ocaml_core_stdlib}${path_sep}${ocamlpath}" + fi + fi diff --git a/esy.lock/opam/ocamlfind.1.9.6/opam b/esy.lock/opam/ocamlfind.1.9.6/opam new file mode 100644 index 0000000..a81f0c5 --- /dev/null +++ b/esy.lock/opam/ocamlfind.1.9.6/opam @@ -0,0 +1,48 @@ +opam-version: "2.0" +synopsis: "A library manager for OCaml" +description: """ +Findlib is a library manager for OCaml. It provides a convention how +to store libraries, and a file format ("META") to describe the +properties of libraries. There is also a tool (ocamlfind) for +interpreting the META files, so that it is very easy to use libraries +in programs and scripts. +""" +license: "MIT" +maintainer: "Thomas Gazagnaire " +authors: "Gerd Stolpmann " +homepage: "http://projects.camlcity.org/projects/findlib.html" +bug-reports: "https://github.com/ocaml/ocamlfind/issues" +depends: [ + "ocaml" {>= "3.08.0"} +] +depopts: ["graphics"] +build: [ + [ + "./configure" + "-bindir" bin + "-sitelib" lib + "-mandir" man + "-config" "%{lib}%/findlib.conf" + "-no-custom" + "-no-camlp4" {!ocaml:preinstalled & ocaml:version >= "4.02.0"} + "-no-topfind" {ocaml:preinstalled} + ] + [make "all"] + [make "opt"] {ocaml:native} +] +install: [ + [make "install"] + ["install" "-m" "0755" "ocaml-stub" "%{bin}%/ocaml"] {ocaml:preinstalled} +] +extra-files: ["0001-Harden-test-for-OCaml-5.patch" "md5=3cddbf72164c29d4e50e077a92a37c6c"] +# See https://github.com/ocaml/ocamlfind/pull/61 +patches: ["0001-Harden-test-for-OCaml-5.patch"] +dev-repo: "git+https://github.com/ocaml/ocamlfind.git" +url { + src: "http://download.camlcity.org/download/findlib-1.9.6.tar.gz" + checksum: [ + "md5=96c6ee50a32cca9ca277321262dbec57" + "sha512=cfaf1872d6ccda548f07d32cc6b90c3aafe136d2aa6539e03143702171ee0199add55269bba894c77115535dc46a5835901a5d7c75768999e72db503bfd83027" + ] +} +available: os != "win32" diff --git a/esy.lock/opam/ocamlformat-lib.0.26.2/opam b/esy.lock/opam/ocamlformat-lib.0.26.2/opam new file mode 100644 index 0000000..bdfe850 --- /dev/null +++ b/esy.lock/opam/ocamlformat-lib.0.26.2/opam @@ -0,0 +1,68 @@ +opam-version: "2.0" +synopsis: "OCaml Code Formatter" +description: + "OCamlFormat is a tool to automatically format OCaml code in a uniform style." +maintainer: [ + "Guillaume Petiot " + "Jules Aguillon " + "Emile Trotignon " +] +authors: [ + "Josh Berdine " + "Hugo Heuzard " + "Etienne Millon " + "Guillaume Petiot " + "Jules Aguillon " +] +homepage: "https://github.com/ocaml-ppx/ocamlformat" +bug-reports: "https://github.com/ocaml-ppx/ocamlformat/issues" +depends: [ + "ocaml" {>= "4.08"} + "alcotest" {with-test & >= "1.3.0"} + "base" {>= "v0.12.0"} + "dune" {>= "2.8"} + "dune-build-info" + "either" + "fix" + "fpath" + "menhir" {>= "20201216"} + "menhirLib" {>= "20201216"} + "menhirSdk" {>= "20201216"} + "ocaml-version" {>= "3.5.0"} + "ocamlformat-rpc-lib" {with-test & = version} + "ocp-indent" {with-test = "false" & >= "1.8.0" | with-test & >= "1.8.1"} + "stdio" + "uuseg" {>= "10.0.0"} + "uutf" {>= "1.0.1"} + "csexp" {>= "1.4.0"} + "astring" + "result" + "camlp-streams" + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/ocaml-ppx/ocamlformat.git" +# OCamlFormat is distributed under the MIT license. Parts of the OCaml library are vendored for OCamlFormat and distributed under their original LGPL 2.1 license +license: ["MIT" "LGPL-2.1-only WITH OCaml-LGPL-linking-exception"] +url { + src: + "https://github.com/ocaml-ppx/ocamlformat/releases/download/0.26.2/ocamlformat-0.26.2.tbz" + checksum: [ + "sha256=2e4f596bf7aa367a844fe83ba0f6b0bf14b2a65179ddc082363fe9793d0375c5" + "sha512=b03d57462e65b11aa9f78dd5c4548251e8d1c5a1c9662f7502bdb10472aeb9df33c1d407350767a5223fbff9c01d53de85bafacd0274b49abc4b43701b159bee" + ] +} +x-commit-hash: "f5727b32127730a2722f86c7119eb6d8f884e26d" diff --git a/esy.lock/opam/ocamlformat-rpc-lib.0.26.2/opam b/esy.lock/opam/ocamlformat-rpc-lib.0.26.2/opam new file mode 100644 index 0000000..df66873 --- /dev/null +++ b/esy.lock/opam/ocamlformat-rpc-lib.0.26.2/opam @@ -0,0 +1,49 @@ +opam-version: "2.0" +synopsis: "Auto-formatter for OCaml code (RPC mode)" +description: + "OCamlFormat is a tool to automatically format OCaml code in a uniform style. This package defines a RPC interface to OCamlFormat" +maintainer: [ + "Guillaume Petiot " + "Jules Aguillon " + "Emile Trotignon " +] +authors: [ + "Josh Berdine " + "Hugo Heuzard " + "Etienne Millon " + "Guillaume Petiot " + "Jules Aguillon " +] +license: "MIT" +homepage: "https://github.com/ocaml-ppx/ocamlformat" +bug-reports: "https://github.com/ocaml-ppx/ocamlformat/issues" +depends: [ + "dune" {>= "2.8"} + "ocaml" {>= "4.08"} + "csexp" {>= "1.4.0"} + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/ocaml-ppx/ocamlformat.git" +url { + src: + "https://github.com/ocaml-ppx/ocamlformat/releases/download/0.26.2/ocamlformat-0.26.2.tbz" + checksum: [ + "sha256=2e4f596bf7aa367a844fe83ba0f6b0bf14b2a65179ddc082363fe9793d0375c5" + "sha512=b03d57462e65b11aa9f78dd5c4548251e8d1c5a1c9662f7502bdb10472aeb9df33c1d407350767a5223fbff9c01d53de85bafacd0274b49abc4b43701b159bee" + ] +} +x-commit-hash: "f5727b32127730a2722f86c7119eb6d8f884e26d" diff --git a/esy.lock/opam/ocamlformat-rpc.removed/opam b/esy.lock/opam/ocamlformat-rpc.removed/opam new file mode 100644 index 0000000..4fb18e1 --- /dev/null +++ b/esy.lock/opam/ocamlformat-rpc.removed/opam @@ -0,0 +1,18 @@ +opam-version: "2.0" +synopsis: "Auto-formatter for OCaml code (RPC mode)" +description: + "OCamlFormat is a tool to automatically format OCaml code in a uniform style. This package defines a RPC interface to OCamlFormat" +maintainer: ["OCamlFormat Team "] +authors: ["Josh Berdine "] +homepage: "https://github.com/ocaml-ppx/ocamlformat" +bug-reports: "https://github.com/ocaml-ppx/ocamlformat/issues" +depends: [] +build: [] +dev-repo: "git+https://github.com/ocaml-ppx/ocamlformat.git" +license: ["MIT" "LGPL-2.1-only WITH OCaml-LGPL-linking-exception"] +messages: [ + "The `ocamlformat` package ships the RPC mode since version 0.22.4. This package is no longer necessary." {installed} +] +conflicts: [ + "ocamlformat" {< "0.22.4"} +] diff --git a/esy.lock/opam/ocamlformat.0.26.2/opam b/esy.lock/opam/ocamlformat.0.26.2/opam new file mode 100644 index 0000000..23328d8 --- /dev/null +++ b/esy.lock/opam/ocamlformat.0.26.2/opam @@ -0,0 +1,58 @@ +opam-version: "2.0" +synopsis: "Auto-formatter for OCaml code" +description: """ +**ocamlformat** is a code formatter for OCaml. It comes with opinionated default settings but is also fully customizable to suit your coding style. + +- **Profiles:** ocamlformat offers profiles we predefined formatting configurations. Profiles include `default`, `ocamlformat`, `janestreet`. +- **Configurable:** Users can change the formatting profile and configure every option in their `.ocamlformat` configuration file. +- **Format Comments:** ocamlformat can format comments, docstrings, and even code blocks in your comments. +- **RPC:** ocamlformat provides an RPC server that can be used by other tools to easily format OCaml Code.""" +maintainer: [ + "Guillaume Petiot " + "Jules Aguillon " + "Emile Trotignon " +] +authors: [ + "Josh Berdine " + "Hugo Heuzard " + "Etienne Millon " + "Guillaume Petiot " + "Jules Aguillon " +] +homepage: "https://github.com/ocaml-ppx/ocamlformat" +bug-reports: "https://github.com/ocaml-ppx/ocamlformat/issues" +depends: [ + "ocaml" {>= "4.08"} + "cmdliner" {with-test = "false" & >= "1.1.0" | with-test & >= "1.2.0"} + "dune" {>= "2.8"} + "ocamlformat-lib" {= version} + "ocamlformat-rpc-lib" {with-test & = version} + "re" {>= "1.10.3"} + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/ocaml-ppx/ocamlformat.git" +# OCamlFormat is distributed under the MIT license. Parts of the OCaml library are vendored for OCamlFormat and distributed under their original LGPL 2.1 license +license: ["MIT" "LGPL-2.1-only WITH OCaml-LGPL-linking-exception"] +url { + src: + "https://github.com/ocaml-ppx/ocamlformat/releases/download/0.26.2/ocamlformat-0.26.2.tbz" + checksum: [ + "sha256=2e4f596bf7aa367a844fe83ba0f6b0bf14b2a65179ddc082363fe9793d0375c5" + "sha512=b03d57462e65b11aa9f78dd5c4548251e8d1c5a1c9662f7502bdb10472aeb9df33c1d407350767a5223fbff9c01d53de85bafacd0274b49abc4b43701b159bee" + ] +} +x-commit-hash: "f5727b32127730a2722f86c7119eb6d8f884e26d" diff --git a/esy.lock/opam/ocp-indent.1.8.1/opam b/esy.lock/opam/ocp-indent.1.8.1/opam new file mode 100644 index 0000000..4210bee --- /dev/null +++ b/esy.lock/opam/ocp-indent.1.8.1/opam @@ -0,0 +1,57 @@ +opam-version: "2.0" +maintainer: "contact@ocamlpro.com" +synopsis: "A simple tool to indent OCaml programs" +description: """ +Ocp-indent is based on an approximate, tolerant OCaml parser and a simple stack +machine ; this is much faster and more reliable than using regexps. Presets and +configuration options available, with the possibility to set them project-wide. +Supports most common syntax extensions, and extensible for others. + +Includes: +- An indentor program, callable from the command-line or from within editors +- Bindings for popular editors +- A library that can be directly used by editor writers, or just for + fault-tolerant/approximate parsing. +""" +authors: [ + "Louis Gesbert " + "Thomas Gazagnaire " + "Jun Furuse" +] +homepage: "http://www.typerex.org/ocp-indent.html" +bug-reports: "https://github.com/OCamlPro/ocp-indent/issues" +license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception" +tags: ["org:ocamlpro" "org:typerex"] +dev-repo: "git+https://github.com/OCamlPro/ocp-indent.git" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +run-test: [ + ["dune" "runtest" "-p" name "-j" jobs] +] +depends: [ + "ocaml" + "dune" {>= "1.0"} + "cmdliner" {>= "1.0.0"} + "ocamlfind" + "base-bytes" +] +post-messages: [ + "This package requires additional configuration for use in editors. Install package 'user-setup', or manually: + +* for Emacs, add these lines to ~/.emacs: + (add-to-list 'load-path \"%{share}%/emacs/site-lisp\") + (require 'ocp-indent) + +* for Vim, add this line to ~/.vimrc: + set rtp^=\"%{share}%/ocp-indent/vim\" +" + {success & !user-setup:installed} +] +url { + src: "https://github.com/OCamlPro/ocp-indent/archive/1.8.1.tar.gz" + checksum: [ + "md5=70db6649a8c08a682ad63730c9752e31" + "sha512=565353de333dd44375366fff75e85a6256c3cd9ff52b3db79803141f975e77cda04dfe32f5e0f2d4c82c59be8f04e9c2bf4d066b113b2cdf267f4c3dcfa401da" + ] +} diff --git a/esy.lock/opam/ordering.3.15.2/opam b/esy.lock/opam/ordering.3.15.2/opam new file mode 100644 index 0000000..8b3cafe --- /dev/null +++ b/esy.lock/opam/ordering.3.15.2/opam @@ -0,0 +1,39 @@ +opam-version: "2.0" +synopsis: "Element ordering" +description: "Element ordering" +maintainer: ["Jane Street Group, LLC "] +authors: ["Jane Street Group, LLC "] +license: "MIT" +homepage: "https://github.com/ocaml/dune" +doc: "https://dune.readthedocs.io/" +bug-reports: "https://github.com/ocaml/dune/issues" +depends: [ + "dune" {>= "3.12"} + "ocaml" {>= "4.08.0"} + "odoc" {with-doc} +] +dev-repo: "git+https://github.com/ocaml/dune.git" +build: [ + ["dune" "subst"] {dev} + ["rm" "-rf" "vendor/csexp"] + ["rm" "-rf" "vendor/pp"] + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@doc" {with-doc} + ] +] +url { + src: + "https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz" + checksum: [ + "sha256=f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + "sha512=d752b8c09130cf3d564b3a524e3148783b581daa3f9a61d0f52bf4d6995ef73258e71877dbfd8b7516f9a4bac5ad973e80f4fed596df9446e704acc724aac55e" + ] +} +x-commit-hash: "c28817c416ac0b381f6a6938236419ab5d86d6e1" diff --git a/esy.lock/opam/pp.1.2.0/opam b/esy.lock/opam/pp.1.2.0/opam new file mode 100644 index 0000000..9f4fad2 --- /dev/null +++ b/esy.lock/opam/pp.1.2.0/opam @@ -0,0 +1,59 @@ +opam-version: "2.0" +synopsis: "Pretty-printing library" +description: """ + +This library provides a lean alternative to the Format [1] module of +the OCaml standard library. It aims to make it easy for users to do +the right thing. If you have tried Format before but find its API +complicated and difficult to use, then Pp might be a good choice for +you. + +Pp uses the same concepts of boxes and break hints, and the final +rendering is done to formatter from the Format module. However it +defines its own algebra which some might find easier to work with and +reason about. No previous knowledge is required to start using this +library, however the various guides for the Format module such as this +one [2] should be applicable to Pp as well. + +[1]: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Format.html +[2]: http://caml.inria.fr/resources/doc/guides/format.en.html +""" +maintainer: ["Jeremie Dimino "] +authors: [ + "Jane Street Group, LLC " + "Jeremie Dimino " +] +license: "MIT" +homepage: "https://github.com/ocaml-dune/pp" +doc: "https://ocaml-dune.github.io/pp/" +bug-reports: "https://github.com/ocaml-dune/pp/issues" +depends: [ + "dune" {>= "2.8"} + "ocaml" {>= "4.08.0"} + "ppx_expect" {with-test} + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/ocaml-dune/pp.git" +url { + src: + "https://github.com/ocaml-dune/pp/releases/download/1.2.0/pp-1.2.0.tbz" + checksum: [ + "sha256=a5e822573c55afb42db29ec56eacd1f2acd8f65cf2df2878e291de374ce6909c" + "sha512=912164c2aa7241d73f735dadfbefe8ed0138d241579d2e885440e068fac78eb9f0b3d782c2420e757e313168c1725daff6ab91800dd315b1e05288456998b40a" + ] +} +x-commit-hash: "83b68c740f21acdcfe54436355ab328372871357" diff --git a/esy.lock/opam/ppx_derivers.1.2.1/opam b/esy.lock/opam/ppx_derivers.1.2.1/opam new file mode 100644 index 0000000..484b265 --- /dev/null +++ b/esy.lock/opam/ppx_derivers.1.2.1/opam @@ -0,0 +1,23 @@ +opam-version: "2.0" +maintainer: "jeremie@dimino.org" +authors: ["Jérémie Dimino"] +license: "BSD-3-Clause" +homepage: "https://github.com/ocaml-ppx/ppx_derivers" +bug-reports: "https://github.com/ocaml-ppx/ppx_derivers/issues" +dev-repo: "git+https://github.com/ocaml-ppx/ppx_derivers.git" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" + "dune" +] +synopsis: "Shared [@@deriving] plugin registry" +description: """ +Ppx_derivers is a tiny package whose sole purpose is to allow +ppx_deriving and ppx_type_conv to inter-operate gracefully when linked +as part of the same ocaml-migrate-parsetree driver.""" +url { + src: "https://github.com/ocaml-ppx/ppx_derivers/archive/1.2.1.tar.gz" + checksum: "md5=5dc2bf130c1db3c731fe0fffc5648b41" +} diff --git a/esy.lock/opam/ppx_yojson_conv_lib.v0.16.0/opam b/esy.lock/opam/ppx_yojson_conv_lib.v0.16.0/opam new file mode 100644 index 0000000..c3e72b4 --- /dev/null +++ b/esy.lock/opam/ppx_yojson_conv_lib.v0.16.0/opam @@ -0,0 +1,24 @@ +opam-version: "2.0" +maintainer: "Jane Street developers" +authors: ["Jane Street Group, LLC"] +homepage: "https://github.com/janestreet/ppx_yojson_conv_lib" +bug-reports: "https://github.com/janestreet/ppx_yojson_conv_lib/issues" +dev-repo: "git+https://github.com/janestreet/ppx_yojson_conv_lib.git" +doc: "https://ocaml.janestreet.com/ocaml-core/latest/doc/ppx_yojson_conv_lib/index.html" +license: "MIT" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" {>= "4.14.0"} + "dune" {>= "2.0.0"} + "yojson" {>= "1.7.0"} +] +synopsis: "Runtime lib for ppx_yojson_conv" +description: " +Part of the Jane Street's PPX rewriters collection. +" +url { +src: "https://ocaml.janestreet.com/ocaml-core/v0.16/files/ppx_yojson_conv_lib-v0.16.0.tar.gz" +checksum: "sha256=557c43c88d365b4cbb514d809f1eecc54d7b9976b0669bc55b02169e6c86ec7d" +} diff --git a/esy.lock/opam/ppxlib.0.32.1/opam b/esy.lock/opam/ppxlib.0.32.1/opam new file mode 100644 index 0000000..0db44e2 --- /dev/null +++ b/esy.lock/opam/ppxlib.0.32.1/opam @@ -0,0 +1,63 @@ +opam-version: "2.0" +synopsis: "Standard infrastructure for ppx rewriters" +description: """ +Ppxlib is the standard infrastructure for ppx rewriters +and other programs that manipulate the in-memory representation of +OCaml programs, a.k.a the "Parsetree". + +It also comes bundled with two ppx rewriters that are commonly used to +write tools that manipulate and/or generate Parsetree values; +`ppxlib.metaquot` which allows to construct Parsetree values using the +OCaml syntax directly and `ppxlib.traverse` which provides various +ways of automatically traversing values of a given type, in particular +allowing to inject a complex structured value into generated code. +""" +maintainer: ["opensource@janestreet.com"] +authors: ["Jane Street Group, LLC "] +license: "MIT" +homepage: "https://github.com/ocaml-ppx/ppxlib" +doc: "https://ocaml-ppx.github.io/ppxlib/" +bug-reports: "https://github.com/ocaml-ppx/ppxlib/issues" +depends: [ + "dune" {>= "2.7"} + "ocaml" {>= "4.04.1" & < "5.3.0"} + "ocaml-compiler-libs" {>= "v0.11.0"} + "ppx_derivers" {>= "1.0"} + "sexplib0" {>= "v0.12"} + "sexplib0" {with-test & >= "v0.15"} + "stdlib-shims" + "ocamlfind" {with-test} + "re" {with-test & >= "1.9.0"} + "cinaps" {with-test & >= "v0.12.1"} + "odoc" {with-doc} +] +conflicts: [ + "ocaml-migrate-parsetree" {< "2.0.0"} + "ocaml-base-compiler" {= "5.1.0~alpha1"} + "ocaml-variants" {= "5.1.0~alpha1+options"} + "base-effects" +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/ocaml-ppx/ppxlib.git" +url { + src: + "https://github.com/ocaml-ppx/ppxlib/releases/download/0.32.1/ppxlib-0.32.1.tbz" + checksum: [ + "sha256=9dbad8bcb1c8b4f3df3f58bca60a5ed23d86531f0da34b4196c86bd585c09d7f" + "sha512=7b93b622b119478dde03adcf4993e73ea937c91c280e453ccee631c682d8589ecb31841f11d6a14966239954e22e000da8afbe25a0f089532c7210b698c52553" + ] +} +x-commit-hash: "cd138a752ae6f21ad649c531b3b2276f332b3bb0" diff --git a/esy.lock/opam/re.1.11.0/opam b/esy.lock/opam/re.1.11.0/opam new file mode 100644 index 0000000..303af00 --- /dev/null +++ b/esy.lock/opam/re.1.11.0/opam @@ -0,0 +1,46 @@ +opam-version: "2.0" + +maintainer: "rudi.grinberg@gmail.com" +authors: [ + "Jerome Vouillon" + "Thomas Gazagnaire" + "Anil Madhavapeddy" + "Rudi Grinberg" + "Gabriel Radanne" +] +license: "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception" +homepage: "https://github.com/ocaml/ocaml-re" +bug-reports: "https://github.com/ocaml/ocaml-re/issues" +dev-repo: "git+https://github.com/ocaml/ocaml-re.git" + +build: [ + ["dune" "subst"] {dev} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} +] + +depends: [ + "ocaml" {>= "4.03"} + "dune" {>= "2.0"} + "ounit" {with-test} + "seq" +] + +synopsis: "RE is a regular expression library for OCaml" +description: """ +Pure OCaml regular expressions with: +* Perl-style regular expressions (module Re.Perl) +* Posix extended regular expressions (module Re.Posix) +* Emacs-style regular expressions (module Re.Emacs) +* Shell-style file globbing (module Re.Glob) +* Compatibility layer for OCaml's built-in Str module (module Re.Str) +""" +url { + src: + "https://github.com/ocaml/ocaml-re/releases/download/1.11.0/re-1.11.0.tbz" + checksum: [ + "sha256=01fc244780c0f6be72ae796b1fb750f367de18624fd75d07ee79782ed6df8d4f" + "sha512=3e3712cc1266ec1f27620f3508ea2ebba338f4083b07d8a69dccee1facfdc1971a6c39f9deea664d2a62fd7f2cfd2eae816ca4c274acfadaee992a3befc4b757" + ] +} +x-commit-hash: "2dd38515c76c40299596d39f18d9b9a20f00d788" diff --git a/esy.lock/opam/reason.3.11.0/opam b/esy.lock/opam/reason.3.11.0/opam new file mode 100644 index 0000000..8ef3a86 --- /dev/null +++ b/esy.lock/opam/reason.3.11.0/opam @@ -0,0 +1,51 @@ +opam-version: "2.0" +synopsis: "Reason: Syntax & Toolchain for OCaml" +description: """ +Reason gives OCaml a new syntax that is remniscient of languages like +JavaScript. It's also the umbrella project for a set of tools for the OCaml & +JavaScript ecosystem.""" +maintainer: [ + "Jordan Walke " + "Antonio Nuno Monteiro " +] +authors: ["Jordan Walke "] +license: "MIT" +homepage: "https://reasonml.github.io/" +bug-reports: "https://github.com/reasonml/reason/issues" +depends: [ + "dune" {>= "2.9"} + "ocaml" {>= "4.03" & < "5.3"} + "ocamlfind" {build} + "dune-build-info" {>= "2.9.3"} + "menhir" {>= "20180523"} + "merlin-extend" {>= "0.6"} + "fix" + "ppx_derivers" + "ppxlib" {>= "0.28.0"} + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "--promote-install-files=false" + "@install" + "@doc" {with-doc} + ] + ["dune" "install" "-p" name "--create-install-files" name] +] +dev-repo: "git+https://github.com/reasonml/reason.git" +url { + src: + "https://github.com/reasonml/reason/releases/download/3.11.0/reason-3.11.0.tbz" + checksum: [ + "sha256=a58837f14a79f047c8eb99d5518aeb16ee64353574286cfd5b284c98a1a27250" + "sha512=28d6d1c3636e400614b1a7d8c78b0bbb5de143e259edf683139b75d2fd2013da8e1a6c58d11047e6853f1e559c387d233570665de0de646005197b5f4d6f4879" + ] +} +x-commit-hash: "3930092ac1cc04b7f3c62c71956592cf158ef8bb" diff --git a/esy.lock/opam/result.1.5/opam b/esy.lock/opam/result.1.5/opam new file mode 100644 index 0000000..6b7b68d --- /dev/null +++ b/esy.lock/opam/result.1.5/opam @@ -0,0 +1,22 @@ +opam-version: "2.0" +maintainer: "Jane Street developers" +authors: ["Jane Street Group, LLC"] +homepage: "https://github.com/janestreet/result" +dev-repo: "git+https://github.com/janestreet/result.git" +bug-reports: "https://github.com/janestreet/result/issues" +license: "BSD-3-Clause" +build: [["dune" "build" "-p" name "-j" jobs]] +depends: [ + "ocaml" + "dune" {>= "1.0"} +] +synopsis: "Compatibility Result module" +description: """ +Projects that want to use the new result type defined in OCaml >= 4.03 +while staying compatible with older version of OCaml should use the +Result module defined in this library.""" +url { + src: + "https://github.com/janestreet/result/releases/download/1.5/result-1.5.tbz" + checksum: "md5=1b82dec78849680b49ae9a8a365b831b" +} diff --git a/esy.lock/opam/seq.base/files/META.seq b/esy.lock/opam/seq.base/files/META.seq new file mode 100644 index 0000000..06b95ef --- /dev/null +++ b/esy.lock/opam/seq.base/files/META.seq @@ -0,0 +1,4 @@ +name="seq" +version="[distributed with OCaml 4.07 or above]" +description="dummy backward-compatibility package for iterators" +requires="" diff --git a/esy.lock/opam/seq.base/files/seq.install b/esy.lock/opam/seq.base/files/seq.install new file mode 100644 index 0000000..c4d7020 --- /dev/null +++ b/esy.lock/opam/seq.base/files/seq.install @@ -0,0 +1,3 @@ +lib:[ + "META.seq" {"META"} +] diff --git a/esy.lock/opam/seq.base/opam b/esy.lock/opam/seq.base/opam new file mode 100644 index 0000000..b33d8c7 --- /dev/null +++ b/esy.lock/opam/seq.base/opam @@ -0,0 +1,15 @@ +opam-version: "2.0" +maintainer: " " +authors: " " +homepage: " " +depends: [ + "ocaml" {>= "4.07.0"} +] +dev-repo: "git+https://github.com/ocaml/ocaml.git" +bug-reports: "https://caml.inria.fr/mantis/main_page.php" +synopsis: + "Compatibility package for OCaml's standard iterator type starting from 4.07." +extra-files: [ + ["seq.install" "md5=026b31e1df290373198373d5aaa26e42"] + ["META.seq" "md5=b33c8a1a6c7ed797816ce27df4855107"] +] diff --git a/esy.lock/opam/sexplib0.v0.16.0/opam b/esy.lock/opam/sexplib0.v0.16.0/opam new file mode 100644 index 0000000..d9c5f04 --- /dev/null +++ b/esy.lock/opam/sexplib0.v0.16.0/opam @@ -0,0 +1,26 @@ +opam-version: "2.0" +maintainer: "Jane Street developers" +authors: ["Jane Street Group, LLC"] +homepage: "https://github.com/janestreet/sexplib0" +bug-reports: "https://github.com/janestreet/sexplib0/issues" +dev-repo: "git+https://github.com/janestreet/sexplib0.git" +doc: "https://ocaml.janestreet.com/ocaml-core/latest/doc/sexplib0/index.html" +license: "MIT" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" {>= "4.08.0"} + "dune" {>= "2.0.0"} +] +synopsis: "Library containing the definition of S-expressions and some base converters" +description: " +Part of Jane Street's Core library +The Core suite of libraries is an industrial strength alternative to +OCaml's standard library that was developed by Jane Street, the +largest industrial user of OCaml. +" +url { +src: "https://ocaml.janestreet.com/ocaml-core/v0.16/files/sexplib0-v0.16.0.tar.gz" +checksum: "sha256=86dba26468194512f789f2fb709063515a9cb4e5c4461c021c239a369590701d" +} diff --git a/esy.lock/opam/spawn.v0.15.1/opam b/esy.lock/opam/spawn.v0.15.1/opam new file mode 100644 index 0000000..5be3a99 --- /dev/null +++ b/esy.lock/opam/spawn.v0.15.1/opam @@ -0,0 +1,56 @@ +opam-version: "2.0" +synopsis: "Spawning sub-processes" +description: """ +Spawn is a small library exposing only one functionality: spawning sub-process. + +It has three main goals: + +1. provide missing features of Unix.create_process such as providing a +working directory + +2. provide better errors when a system call fails in the +sub-process. For instance if a command is not found, you get a proper +[Unix.Unix_error] exception + +3. improve performance by using vfork when available. It is often +claimed that nowadays fork is as fast as vfork, however in practice +fork takes time proportional to the process memory while vfork is +constant time. In application using a lot of memory, vfork can be +thousands of times faster than fork. +""" +maintainer: ["Jane Street developers"] +authors: ["Jane Street Group, LLC"] +license: "MIT" +homepage: "https://github.com/janestreet/spawn" +doc: "https://janestreet.github.io/spawn/" +bug-reports: "https://github.com/janestreet/spawn/issues" +depends: [ + "dune" {>= "2.8"} + "ppx_expect" {with-test} + "ocaml" {>= "4.05"} + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/janestreet/spawn.git" +x-commit-hash: "13d279ebfa8c40d4bafe18cddfdff0de54b4eaff" +url { + src: + "https://github.com/janestreet/spawn/archive/v0.15.1.tar.gz" + checksum: [ + "sha256=9afdee314fab6c3fcd689ab6eb5608d6b78078e6dede3953a47debde06c19d50" + "sha512=efdb31d5ec5ea36d0bc80224d4ee04e46ce3428d1662870e6cebece92bc313d6eebee378802c0c059dd6e0cafea515308c31b7dfaf04a098eb4566583c1e9ed4" + ] +} diff --git a/esy.lock/opam/stdio.v0.16.0/opam b/esy.lock/opam/stdio.v0.16.0/opam new file mode 100644 index 0000000..bd23d60 --- /dev/null +++ b/esy.lock/opam/stdio.v0.16.0/opam @@ -0,0 +1,27 @@ +opam-version: "2.0" +maintainer: "Jane Street developers" +authors: ["Jane Street Group, LLC"] +homepage: "https://github.com/janestreet/stdio" +bug-reports: "https://github.com/janestreet/stdio/issues" +dev-repo: "git+https://github.com/janestreet/stdio.git" +doc: "https://ocaml.janestreet.com/ocaml-core/latest/doc/stdio/index.html" +license: "MIT" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" {>= "4.14.0"} + "base" {>= "v0.16" & < "v0.17"} + "dune" {>= "2.0.0"} +] +synopsis: "Standard IO library for OCaml" +description: " +Stdio implements simple input/output functionalities for OCaml. + +It re-exports the input/output functions of the OCaml standard +libraries using a more consistent API. +" +url { +src: "https://ocaml.janestreet.com/ocaml-core/v0.16/files/stdio-v0.16.0.tar.gz" +checksum: "sha256=61f0b75950614ac5378c6ec0d822cce6463402d919d5810b736fc46522b3a73e" +} diff --git a/esy.lock/opam/stdlib-shims.0.3.0/opam b/esy.lock/opam/stdlib-shims.0.3.0/opam new file mode 100644 index 0000000..8c96957 --- /dev/null +++ b/esy.lock/opam/stdlib-shims.0.3.0/opam @@ -0,0 +1,31 @@ +opam-version: "2.0" +maintainer: "The stdlib-shims programmers" +authors: "The stdlib-shims programmers" +homepage: "https://github.com/ocaml/stdlib-shims" +doc: "https://ocaml.github.io/stdlib-shims/" +dev-repo: "git+https://github.com/ocaml/stdlib-shims.git" +bug-reports: "https://github.com/ocaml/stdlib-shims/issues" +tags: ["stdlib" "compatibility" "org:ocaml"] +license: ["LGPL-2.1-only WITH OCaml-LGPL-linking-exception"] +depends: [ + "dune" + "ocaml" {>= "4.02.3"} +] +build: [ "dune" "build" "-p" name "-j" jobs ] +synopsis: "Backport some of the new stdlib features to older compiler" +description: """ +Backport some of the new stdlib features to older compiler, +such as the Stdlib module. + +This allows projects that require compatibility with older compiler to +use these new features in their code. +""" +x-commit-hash: "fb6815e5d745f07fd567c11671149de6ef2e74c8" +url { + src: + "https://github.com/ocaml/stdlib-shims/releases/download/0.3.0/stdlib-shims-0.3.0.tbz" + checksum: [ + "sha256=babf72d3917b86f707885f0c5528e36c63fccb698f4b46cf2bab5c7ccdd6d84a" + "sha512=1151d7edc8923516e9a36995a3f8938d323aaade759ad349ed15d6d8501db61ffbe63277e97c4d86149cf371306ac23df0f581ec7e02611f58335126e1870980" + ] +} diff --git a/esy.lock/opam/stdune.3.15.2/opam b/esy.lock/opam/stdune.3.15.2/opam new file mode 100644 index 0000000..72f39f8 --- /dev/null +++ b/esy.lock/opam/stdune.3.15.2/opam @@ -0,0 +1,45 @@ +opam-version: "2.0" +synopsis: "Dune's unstable standard library" +description: + "This library offers no backwards compatibility guarantees. Use at your own risk." +maintainer: ["Jane Street Group, LLC "] +authors: ["Jane Street Group, LLC "] +license: "MIT" +homepage: "https://github.com/ocaml/dune" +doc: "https://dune.readthedocs.io/" +bug-reports: "https://github.com/ocaml/dune/issues" +depends: [ + "dune" {>= "3.12"} + "ocaml" {>= "4.08.0"} + "base-unix" + "dyn" {= version} + "ordering" {= version} + "pp" {>= "1.2.0"} + "csexp" {>= "1.5.0"} + "odoc" {with-doc} +] +dev-repo: "git+https://github.com/ocaml/dune.git" +build: [ + ["dune" "subst"] {dev} + ["rm" "-rf" "vendor/csexp"] + ["rm" "-rf" "vendor/pp"] + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@doc" {with-doc} + ] +] +url { + src: + "https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz" + checksum: [ + "sha256=f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + "sha512=d752b8c09130cf3d564b3a524e3148783b581daa3f9a61d0f52bf4d6995ef73258e71877dbfd8b7516f9a4bac5ad973e80f4fed596df9446e704acc724aac55e" + ] +} +x-commit-hash: "c28817c416ac0b381f6a6938236419ab5d86d6e1" diff --git a/esy.lock/opam/topkg.1.0.7/opam b/esy.lock/opam/topkg.1.0.7/opam new file mode 100644 index 0000000..83fc06f --- /dev/null +++ b/esy.lock/opam/topkg.1.0.7/opam @@ -0,0 +1,47 @@ +opam-version: "2.0" +synopsis: "The transitory OCaml software packager" +description: """\ +Topkg is a packager for distributing OCaml software. It provides an +API to describe the files a package installs in a given build +configuration and to specify information about the package's +distribution, creation and publication procedures. + +The optional topkg-care package provides the `topkg` command line tool +which helps with various aspects of a package's life cycle: creating +and linting a distribution, releasing it on the WWW, publish its +documentation, add it to the OCaml opam repository, etc. + +Topkg is distributed under the ISC license and has **no** +dependencies. This is what your packages will need as a *build* +dependency. + +Topkg-care is distributed under the ISC license it depends on +[fmt][fmt], [logs][logs], [bos][bos], [cmdliner][cmdliner], +[webbrowser][webbrowser] and `opam-format`. + +[fmt]: http://erratique.ch/software/fmt +[logs]: http://erratique.ch/software/logs +[bos]: http://erratique.ch/software/bos +[cmdliner]: http://erratique.ch/software/cmdliner +[webbrowser]: http://erratique.ch/software/webbrowser + +Home page: http://erratique.ch/software/topkg""" +maintainer: "Daniel Bünzli " +authors: "The topkg programmers" +license: "ISC" +tags: ["packaging" "ocamlbuild" "org:erratique"] +homepage: "https://erratique.ch/software/topkg" +doc: "https://erratique.ch/software/topkg/doc" +bug-reports: "https://github.com/dbuenzli/topkg/issues" +depends: [ + "ocaml" {>= "4.05.0"} + "ocamlfind" {build & >= "1.6.1"} + "ocamlbuild" +] +build: ["ocaml" "pkg/pkg.ml" "build" "--pkg-name" name "--dev-pkg" "%{dev}%"] +dev-repo: "git+https://erratique.ch/repos/topkg.git" +url { + src: "https://erratique.ch/software/topkg/releases/topkg-1.0.7.tbz" + checksum: + "sha512=09e59f1759bf4db8471f02d0aefd8db602b44932a291c05c312b1423796e7a15d1598d3c62a0cec7f083eff8e410fac09363533dc4bd2120914bb9664efea535" +} \ No newline at end of file diff --git a/esy.lock/opam/uucp.15.1.0/opam b/esy.lock/opam/uucp.15.1.0/opam new file mode 100644 index 0000000..f3abfca --- /dev/null +++ b/esy.lock/opam/uucp.15.1.0/opam @@ -0,0 +1,51 @@ +opam-version: "2.0" +synopsis: "Unicode character properties for OCaml" +description: """\ +Uucp is an OCaml library providing efficient access to a selection of +character properties of the [Unicode character database]. + +Uucp is distributed under the ISC license. It has no dependency. + +Home page: + +[Unicode character database]: http://www.unicode.org/reports/tr44/""" +maintainer: "Daniel Bünzli " +authors: "The uucp programmers" +license: "ISC" +tags: ["unicode" "text" "character" "org:erratique"] +homepage: "https://erratique.ch/software/uucp" +doc: "https://erratique.ch/software/uucp/doc/" +bug-reports: "https://github.com/dbuenzli/uucp/issues" +depends: [ + "ocaml" {>= "4.14.0"} + "ocamlfind" {build} + "ocamlbuild" {build} + "topkg" {build & >= "1.0.3"} + "uucd" {with-test & dev & >= "15.1.0" & < "16.0.0"} + "uunf" {with-test} +] +depopts: ["uunf" "cmdliner"] +conflicts: [ + "uunf" {< "15.1.0" | >= "16.0.0"} + "cmdliner" {< "1.1.0"} +] +build: [ + "ocaml" + "pkg/pkg.ml" + "build" + "--dev-pkg" + "%{dev}%" + "--with-uunf" + "%{uunf:installed}%" + "--with-cmdliner" + "%{cmdliner:installed}%" +] +post-messages: + "If the build fails with \"ocamlopt.opt got signal and exited\", issue 'ulimit -s unlimited' and retry." + {failure & (arch = "ppc64" | arch = "arm64")} +dev-repo: "git+https://erratique.ch/repos/uucp.git" +url { + src: "https://erratique.ch/software/uucp/releases/uucp-15.1.0.tbz" + checksum: + "sha512=998f94fadb72357b15a3042a3d11c31b3e16f281822673f2defdd515cd1394d55de1817628be8bd5c030175f9e62c53630d4139a1c0253800f9fb898b0f11364" +} \ No newline at end of file diff --git a/esy.lock/opam/uuseg.15.1.0/opam b/esy.lock/opam/uuseg.15.1.0/opam new file mode 100644 index 0000000..c1a8720 --- /dev/null +++ b/esy.lock/opam/uuseg.15.1.0/opam @@ -0,0 +1,55 @@ +opam-version: "2.0" +synopsis: "Unicode text segmentation for OCaml" +description: """\ +Uuseg is an OCaml library for segmenting Unicode text. It implements +the locale independent [Unicode text segmentation algorithms][1] to +detect grapheme cluster, word and sentence boundaries and the [Unicode +line breaking algorithm][2] to detect line break opportunities. + +The library is independent from any IO mechanism or Unicode text data +structure and it can process text without a complete in-memory +representation. + +Uuseg is distributed under the ISC license. It depends on [Uucp]. + +[1]: http://www.unicode.org/reports/tr29/ +[2]: http://www.unicode.org/reports/tr14/ +[Uucp]: http://erratique.ch/software/uucp + +Homepage: """ +maintainer: "Daniel Bünzli " +authors: "The uuseg programmers" +license: "ISC" +tags: ["unicode" "text" "segmentation" "org:erratique"] +homepage: "https://erratique.ch/software/uuseg" +doc: "https://erratique.ch/software/uuseg/doc/" +bug-reports: "https://github.com/dbuenzli/uuseg/issues" +depends: [ + "ocaml" {>= "4.14.0"} + "ocamlfind" {build} + "ocamlbuild" {build} + "topkg" {build & >= "1.0.3"} + "uucp" {>= "15.1.0" & < "16.0.0"} +] +depopts: ["uutf" "cmdliner"] +conflicts: [ + "uutf" {< "1.0.0"} + "cmdliner" {< "1.1.0"} +] +build: [ + "ocaml" + "pkg/pkg.ml" + "build" + "--dev-pkg" + "%{dev}%" + "--with-uutf" + "%{uutf:installed}%" + "--with-cmdliner" + "%{cmdliner:installed}%" +] +dev-repo: "git+https://erratique.ch/repos/uuseg.git" +url { + src: "https://erratique.ch/software/uuseg/releases/uuseg-15.1.0.tbz" + checksum: + "sha512=1e9460dc5a856c985d40c61fd1560bdfdb8bbaf8d7430405814589b47d4a7f7869658d1e3198c7a9132412e9b4b85402ceb4bda5040da426b69e9aef4222a23a" +} \ No newline at end of file diff --git a/esy.lock/opam/uutf.1.0.3/opam b/esy.lock/opam/uutf.1.0.3/opam new file mode 100644 index 0000000..e96cc4a --- /dev/null +++ b/esy.lock/opam/uutf.1.0.3/opam @@ -0,0 +1,36 @@ +opam-version: "2.0" +synopsis: """Non-blocking streaming Unicode codec for OCaml""" +maintainer: ["Daniel Bünzli "] +authors: ["The uutf programmers"] +homepage: "https://erratique.ch/software/uutf" +doc: "https://erratique.ch/software/uutf/doc/" +dev-repo: "git+https://erratique.ch/repos/uutf.git" +bug-reports: "https://github.com/dbuenzli/uutf/issues" +license: ["ISC"] +tags: ["unicode" "text" "utf-8" "utf-16" "codec" "org:erratique"] +depends: ["ocaml" {>= "4.03.0"} + "ocamlfind" {build} + "ocamlbuild" {build} + "topkg" {build & >= "1.0.3"}] +depopts: ["cmdliner"] +conflicts: ["cmdliner" {< "0.9.8"}] +build: [["ocaml" "pkg/pkg.ml" "build" "--dev-pkg" "%{dev}%" + "--with-cmdliner" "%{cmdliner:installed}%"]] +url { + src: "https://erratique.ch/software/uutf/releases/uutf-1.0.3.tbz" + checksum: "sha512=50cc4486021da46fb08156e9daec0d57b4ca469b07309c508d5a9a41e9dbcf1f32dec2ed7be027326544453dcaf9c2534919395fd826dc7768efc6cc4bfcc9f8"} +description: """ +Uutf is a non-blocking streaming codec to decode and encode the UTF-8, +UTF-16, UTF-16LE and UTF-16BE encoding schemes. It can efficiently +work character by character without blocking on IO. Decoders perform +character position tracking and support newline normalization. + +Functions are also provided to fold over the characters of UTF encoded +OCaml string values and to directly encode characters in OCaml +Buffer.t values. **Note** that since OCaml 4.14, that functionality +can be found in the Stdlib and you are encouraged to migrate to it. + +Uutf has no dependency and is distributed under the ISC license. + +Home page: http://erratique.ch/software/uutf +Contact: Daniel Bünzli ``""" \ No newline at end of file diff --git a/esy.lock/opam/xdg.3.15.2/opam b/esy.lock/opam/xdg.3.15.2/opam new file mode 100644 index 0000000..9bd498c --- /dev/null +++ b/esy.lock/opam/xdg.3.15.2/opam @@ -0,0 +1,40 @@ +opam-version: "2.0" +synopsis: "XDG Base Directory Specification" +description: + "https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html" +maintainer: ["Jane Street Group, LLC "] +authors: ["Jane Street Group, LLC "] +license: "MIT" +homepage: "https://github.com/ocaml/dune" +doc: "https://dune.readthedocs.io/" +bug-reports: "https://github.com/ocaml/dune/issues" +depends: [ + "dune" {>= "3.12"} + "ocaml" {>= "4.08"} + "odoc" {with-doc} +] +dev-repo: "git+https://github.com/ocaml/dune.git" +build: [ + ["dune" "subst"] {dev} + ["rm" "-rf" "vendor/csexp"] + ["rm" "-rf" "vendor/pp"] + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@doc" {with-doc} + ] +] +url { + src: + "https://github.com/ocaml/dune/releases/download/3.15.2/dune-3.15.2.tbz" + checksum: [ + "sha256=f959980542ca85909b3f3f8e9be65c2b8a375f3a4e3bd83c7ad7a07f2e077933" + "sha512=d752b8c09130cf3d564b3a524e3148783b581daa3f9a61d0f52bf4d6995ef73258e71877dbfd8b7516f9a4bac5ad973e80f4fed596df9446e704acc724aac55e" + ] +} +x-commit-hash: "c28817c416ac0b381f6a6938236419ab5d86d6e1" diff --git a/esy.lock/opam/yojson.2.1.2/opam b/esy.lock/opam/yojson.2.1.2/opam new file mode 100644 index 0000000..df37a73 --- /dev/null +++ b/esy.lock/opam/yojson.2.1.2/opam @@ -0,0 +1,48 @@ +opam-version: "2.0" +synopsis: + "Yojson is an optimized parsing and printing library for the JSON format" +description: """ +Yojson is an optimized parsing and printing library for the JSON format. + +ydump is a pretty-printing command-line program provided with the +yojson package.""" +maintainer: [ + "paul-elliot@tarides.com" "nathan@tarides.com" "marek@tarides.com" +] +authors: ["Martin Jambon"] +license: "BSD-3-Clause" +homepage: "https://github.com/ocaml-community/yojson" +doc: "https://ocaml-community.github.io/yojson" +bug-reports: "https://github.com/ocaml-community/yojson/issues" +depends: [ + "dune" {>= "2.7"} + "ocaml" {>= "4.02.3"} + "cppo" {build} + "alcotest" {with-test & >= "0.8.5"} + "seq" {>= "0.2.2"} + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/ocaml-community/yojson.git" +url { + src: + "https://github.com/ocaml-community/yojson/releases/download/2.1.2/yojson-2.1.2.tbz" + checksum: [ + "sha256=59f2f1abbfc8a7ccbdbf608894e5c75e8a76006e34899254446f83e200dfb4f9" + "sha512=309cba7568dec51de20c7ab8df033258c275b8d58b0a36a66b26e673a3bc050cbd7e39ff8fe4796e89263e125bcc21e04dc36a394f3cc201956887eee1fb281a" + ] +} +x-commit-hash: "e51163ee04ad79408975545ec5fc3b7dc41f68eb" diff --git a/esy.lock/overrides/opam__s__dune_configurator_opam__c__3.15.2_opam_override/files/darwin.patch b/esy.lock/overrides/opam__s__dune_configurator_opam__c__3.15.2_opam_override/files/darwin.patch new file mode 100644 index 0000000..480861d --- /dev/null +++ b/esy.lock/overrides/opam__s__dune_configurator_opam__c__3.15.2_opam_override/files/darwin.patch @@ -0,0 +1,26 @@ +--- ./otherlibs/configurator/src/v1.ml ++++ ./otherlibs/configurator/src/v1.ml +@@ -696,13 +696,16 @@ + which c "brew" + >>= fun brew -> + let new_pkg_config_path = +- let prefix = String.trim (Process.run_capture_exn c ~dir brew [ "--prefix" ]) in +- let p = sprintf "%s/opt/%s/lib/pkgconfig" (quote_if_needed prefix) package in +- Option.some_if +- (match Sys.is_directory p with +- | s -> s +- | exception Sys_error _ -> false) +- p ++ try ++ let prefix = String.trim (Process.run_capture_exn c ~dir brew [ "--prefix" ]) in ++ let p = sprintf "%s/opt/%s/lib/pkgconfig" (quote_if_needed prefix) package in ++ Option.some_if ++ (match Sys.is_directory p with ++ | s -> s ++ | exception Sys_error _ -> false) ++ p ++ with ++ | _ -> None + in + new_pkg_config_path + >>| fun new_pkg_config_path -> diff --git a/esy.lock/overrides/opam__s__dune_configurator_opam__c__3.15.2_opam_override/package.json b/esy.lock/overrides/opam__s__dune_configurator_opam__c__3.15.2_opam_override/package.json new file mode 100644 index 0000000..a34fc43 --- /dev/null +++ b/esy.lock/overrides/opam__s__dune_configurator_opam__c__3.15.2_opam_override/package.json @@ -0,0 +1,27 @@ +{ + "build": [ + [ + "bash", + "-c", + "patch -p1 < darwin.patch" + ], + [ + "rm", + "-rf", + "vendor/csexp" + ], + [ + "rm", + "-rf", + "vendor/pp" + ], + [ + "dune", + "build", + "-p", + "dune-configurator", + "-j", + "4" + ] + ] +} diff --git a/esy.lock/overrides/opam__s__melange_opam__c__3.0.0_51_opam_override/files/0001-Fixes-Windows-build-error-Not-a-binary-file.patch b/esy.lock/overrides/opam__s__melange_opam__c__3.0.0_51_opam_override/files/0001-Fixes-Windows-build-error-Not-a-binary-file.patch new file mode 100644 index 0000000..8ea68a3 --- /dev/null +++ b/esy.lock/overrides/opam__s__melange_opam__c__3.0.0_51_opam_override/files/0001-Fixes-Windows-build-error-Not-a-binary-file.patch @@ -0,0 +1,34 @@ +From: Manas Jayanth <3097018+ManasJayanth@users.noreply.github.com> +Date: Sat, 11 May 2024 10:29:53 +0530 +Subject: [PATCH] Fixes Windows build error, "Not a binary file" + + +diff --git a/jscomp/core/gen/gen_traversal.ml b/jscomp/core/gen/gen_traversal.ml +index c2da52d68..5dfc343d7 100644 +--- a/jscomp/core/gen/gen_traversal.ml ++++ b/jscomp/core/gen/gen_traversal.ml +@@ -31,6 +31,7 @@ + | Record_fold -> Record_fold.make typedefs + in + let oc = stdout in ++ set_binary_mode_out oc true; + write_ast oc ~input_name:input new_ast + + let mode = + +diff --git a/jscomp/melstd/gen/build_reserved.ml b/jscomp/melstd/gen/build_reserved.ml +index 99ebb7b31..fc5cfd561 100644 +--- a/jscomp/melstd/gen/build_reserved.ml ++++ b/jscomp/melstd/gen/build_reserved.ml +@@ -241,6 +241,7 @@ + keywords_array :: binary_search + in + let oc = stdout in ++ set_binary_mode_out oc true; + write_ast oc ast; + close_out oc + + +-- +2.45.0.windows.1 + diff --git a/esy.lock/overrides/opam__s__melange_opam__c__3.0.0_51_opam_override/files/awk.patch b/esy.lock/overrides/opam__s__melange_opam__c__3.0.0_51_opam_override/files/awk.patch new file mode 100644 index 0000000..422cbcf --- /dev/null +++ b/esy.lock/overrides/opam__s__melange_opam__c__3.0.0_51_opam_override/files/awk.patch @@ -0,0 +1,33 @@ +--- ./jscomp/others/dune ++++ ./jscomp/others/dune +@@ -54,7 +54,7 @@ + (progn + (with-stdout-to + %{target} +- (run awk -f %{dep:expand_module_aliases_node.awk} %{deps}))))) ++ (bash "awk -f %{dep:expand_module_aliases_node.awk} %{deps}"))))) + + (library + (modes melange) + +--- ./jscomp/stdlib/dune ++++ ./jscomp/stdlib/dune +@@ -5,7 +5,7 @@ + (progn + (with-stdout-to + %{target}.awk +- (run awk -f %{dep:expand_module_aliases.awk} %{deps})) ++ (bash "awk -f %{dep:expand_module_aliases.awk} %{deps}")) + (run cppo -D=BS %{env:CPPO_FLAGS=} %{target}.awk -o %{target}.awk) + (with-stdout-to + %{target} +@@ -20,7 +20,7 @@ + (progn + (with-stdout-to + %{target}.awki +- (run awk -f %{dep:expand_module_aliases.awk} %{deps})) ++ (bash "awk -f %{dep:expand_module_aliases.awk} %{deps}")) + (run cppo -D=BS %{env:CPPO_FLAGS=} %{target}.awki -o %{target}.awki) + (with-stdout-to + %{target} + diff --git a/esy.lock/overrides/opam__s__melange_opam__c__3.0.0_51_opam_override/package.json b/esy.lock/overrides/opam__s__melange_opam__c__3.0.0_51_opam_override/package.json new file mode 100644 index 0000000..99de0e0 --- /dev/null +++ b/esy.lock/overrides/opam__s__melange_opam__c__3.0.0_51_opam_override/package.json @@ -0,0 +1,15 @@ +{ + "build": [ + [ + "bash", + "-c", + "#{os == 'windows' ? 'patch -p1 < ./awk.patch': 'true'}" + ], + [ + "bash", + "-c", + "#{os == 'windows' ? 'patch -p1 < ./0001-Fixes-Windows-build-error-Not-a-binary-file.patch': 'true'}" + ], + "dune build -p melange -j4" + ] +} diff --git a/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.3_opam_override/files/ocamlbuild-0.14.2.patch b/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.3_opam_override/files/ocamlbuild-0.14.2.patch new file mode 100644 index 0000000..e69de29 diff --git a/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.3_opam_override/files/winpatch.patch b/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.3_opam_override/files/winpatch.patch new file mode 100644 index 0000000..bba9929 --- /dev/null +++ b/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.3_opam_override/files/winpatch.patch @@ -0,0 +1,11 @@ +--- ./Makefile ++++ ./Makefile +@@ -271,7 +271,7 @@ + echo ' "ocamlbuild.byte" {"ocamlbuild.byte"}' >> ocamlbuild.install + ifeq ($(OCAML_NATIVE), true) + echo ' "ocamlbuild.native" {"ocamlbuild.native"}' >> ocamlbuild.install +- echo ' "ocamlbuild.native" {"ocamlbuild"}' >> ocamlbuild.install ++ echo " \"ocamlbuild.native\" {\"ocamlbuild${EXE}\"}" >> ocamlbuild.install + else + echo ' "ocamlbuild.byte" {"ocamlbuild"}' >> ocamlbuild.install + endif diff --git a/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.3_opam_override/package.json b/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.3_opam_override/package.json new file mode 100644 index 0000000..b57a42c --- /dev/null +++ b/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.3_opam_override/package.json @@ -0,0 +1,29 @@ +{ + "build": [ + [ + "bash", + "-c", + "#{os == 'windows' ? 'patch -p1 < winpatch.patch' : 'true'}" + ], + [ + "make", + "-f", + "configure.make", + "all", + "OCAMLBUILD_PREFIX=#{self.install}", + "OCAMLBUILD_BINDIR=#{self.bin}", + "OCAMLBUILD_LIBDIR=#{self.lib}", + "OCAMLBUILD_MANDIR=#{self.man}", + "OCAMLBUILD_NATIVE=true", + "OCAMLBUILD_NATIVE_TOOLS=true", + "EXE=#{os == 'windows' ? '.exe': ''}" + ], + [ + "make", + "check-if-preinstalled", + "all", + "EXE=#{os == 'windows' ? '.exe': ''}", + "opam-install" + ] + ] +} diff --git a/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.6_opam_override/files/findlib.patch b/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.6_opam_override/files/findlib.patch new file mode 100644 index 0000000..d545632 --- /dev/null +++ b/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.6_opam_override/files/findlib.patch @@ -0,0 +1,11 @@ +--- ./Makefile ++++ ./Makefile +@@ -55,7 +55,7 @@ + export USE_CYGPATH; \ + cat findlib.conf.in | \ + $(SH) tools/patch '@SITELIB@' '$(OCAML_SITELIB)' | \ +- $(SH) tools/patch '@FINDLIB_PATH@' '$(FINDLIB_PATH)' -p >findlib.conf ++ $(SH) tools/patch '@FINDLIB_PATH@' '$(FINDLIB_PATH)' >findlib.conf + if ./tools/cmd_from_same_dir ocamlc; then \ + echo 'ocamlc="ocamlc.opt"' >>findlib.conf; \ + fi diff --git a/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.6_opam_override/package.json b/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.6_opam_override/package.json new file mode 100644 index 0000000..bf169e5 --- /dev/null +++ b/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.6_opam_override/package.json @@ -0,0 +1,61 @@ +{ + "build": [ + [ + "bash", + "-c", + "#{os == 'windows' ? 'patch -p1 < findlib.patch' : 'true'}" + ], + [ + "./configure", + "-bindir", + "#{self.bin}", + "-sitelib", + "#{self.lib}", + "-mandir", + "#{self.man}", + "-config", + "#{self.lib}/findlib.conf", + "-no-custom", + "-no-topfind" + ], + [ + "make", + "all" + ], + [ + "make", + "opt" + ] + ], + "install": [ + [ + "make", + "install" + ], + [ + "install", + "-m", + "0755", + "ocaml-stub", + "#{self.bin}/ocaml" + ], + [ + "mkdir", + "-p", + "#{self.toplevel}" + ], + [ + "install", + "-m", + "0644", + "src/findlib/topfind", + "#{self.toplevel}/topfind" + ] + ], + "exportedEnv": { + "OCAML_TOPLEVEL_PATH": { + "val": "#{self.toplevel}", + "scope": "global" + } + } +} diff --git a/melange-node-modules/melange.belt/belt.js b/melange-node-modules/melange.belt/belt.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.belt/belt.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.belt/belt_Array.js b/melange-node-modules/melange.belt/belt_Array.js new file mode 100644 index 0000000..d63d44d --- /dev/null +++ b/melange-node-modules/melange.belt/belt_Array.js @@ -0,0 +1,764 @@ +// Generated by Melange + +import * as Caml from "melange.js/caml.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; +import * as Js__Js_math from "melange.js/js_math.js"; + +function get(arr, i) { + if (i >= 0 && i < arr.length) { + return Caml_option.some(arr[i]); + } + +} + +function getExn(arr, i) { + if (!(i >= 0 && i < arr.length)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/others/belt_Array.ml", + 29, + 2 + ], + Error: new Error() + }; + } + return arr[i]; +} + +function set(arr, i, v) { + if (i >= 0 && i < arr.length) { + arr[i] = v; + return true; + } else { + return false; + } +} + +function setExn(arr, i, v) { + if (!(i >= 0 && i < arr.length)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/others/belt_Array.ml", + 39, + 2 + ], + Error: new Error() + }; + } + arr[i] = v; +} + +function swapUnsafe(xs, i, j) { + var tmp = xs[i]; + xs[i] = xs[j]; + xs[j] = tmp; +} + +function shuffleInPlace(xs) { + var len = xs.length; + for(var i = 0; i < len; ++i){ + swapUnsafe(xs, i, Js__Js_math.random_int(i, len)); + } +} + +function shuffle(xs) { + var result = xs.slice(0); + shuffleInPlace(result); + return result; +} + +function reverseInPlace(xs) { + var len = xs.length; + var ofs = 0; + for(var i = 0 ,i_finish = len / 2 | 0; i < i_finish; ++i){ + swapUnsafe(xs, ofs + i | 0, ((ofs + len | 0) - i | 0) - 1 | 0); + } +} + +function reverse(xs) { + var len = xs.length; + var result = new Array(len); + for(var i = 0; i < len; ++i){ + result[i] = xs[(len - 1 | 0) - i | 0]; + } + return result; +} + +function make(l, f) { + if (l <= 0) { + return []; + } + var res = new Array(l); + for(var i = 0; i < l; ++i){ + res[i] = f; + } + return res; +} + +function makeByU(l, f) { + if (l <= 0) { + return []; + } + var res = new Array(l); + for(var i = 0; i < l; ++i){ + res[i] = f(i); + } + return res; +} + +function makeBy(l, f) { + return makeByU(l, Curry.__1(f)); +} + +function makeByAndShuffleU(l, f) { + var u = makeByU(l, f); + shuffleInPlace(u); + return u; +} + +function makeByAndShuffle(l, f) { + return makeByAndShuffleU(l, Curry.__1(f)); +} + +function range(start, finish) { + var cut = finish - start | 0; + if (cut < 0) { + return []; + } + var arr = new Array(cut + 1 | 0); + for(var i = 0; i <= cut; ++i){ + arr[i] = start + i | 0; + } + return arr; +} + +function rangeBy(start, finish, step) { + var cut = finish - start | 0; + if (cut < 0 || step <= 0) { + return []; + } + var nb = (cut / step | 0) + 1 | 0; + var arr = new Array(nb); + var cur = start; + for(var i = 0; i < nb; ++i){ + arr[i] = cur; + cur = cur + step | 0; + } + return arr; +} + +function zip(xs, ys) { + var lenx = xs.length; + var leny = ys.length; + var len = lenx < leny ? lenx : leny; + var s = new Array(len); + for(var i = 0; i < len; ++i){ + s[i] = [ + xs[i], + ys[i] + ]; + } + return s; +} + +function zipByU(xs, ys, f) { + var lenx = xs.length; + var leny = ys.length; + var len = lenx < leny ? lenx : leny; + var s = new Array(len); + for(var i = 0; i < len; ++i){ + s[i] = f(xs[i], ys[i]); + } + return s; +} + +function zipBy(xs, ys, f) { + return zipByU(xs, ys, Curry.__2(f)); +} + +function concat(a1, a2) { + var l1 = a1.length; + var l2 = a2.length; + var a1a2 = new Array(l1 + l2 | 0); + for(var i = 0; i < l1; ++i){ + a1a2[i] = a1[i]; + } + for(var i$1 = 0; i$1 < l2; ++i$1){ + a1a2[l1 + i$1 | 0] = a2[i$1]; + } + return a1a2; +} + +function concatMany(arrs) { + var lenArrs = arrs.length; + var totalLen = 0; + for(var i = 0; i < lenArrs; ++i){ + totalLen = totalLen + arrs[i].length | 0; + } + var result = new Array(totalLen); + totalLen = 0; + for(var j = 0; j < lenArrs; ++j){ + var cur = arrs[j]; + for(var k = 0 ,k_finish = cur.length; k < k_finish; ++k){ + result[totalLen] = cur[k]; + totalLen = totalLen + 1 | 0; + } + } + return result; +} + +function slice(a, offset, len) { + if (len <= 0) { + return []; + } + var lena = a.length; + var ofs = offset < 0 ? Caml.caml_int_max(lena + offset | 0, 0) : offset; + var hasLen = lena - ofs | 0; + var copyLength = hasLen < len ? hasLen : len; + if (copyLength <= 0) { + return []; + } + var result = new Array(copyLength); + for(var i = 0; i < copyLength; ++i){ + result[i] = a[ofs + i | 0]; + } + return result; +} + +function sliceToEnd(a, offset) { + var lena = a.length; + var ofs = offset < 0 ? Caml.caml_int_max(lena + offset | 0, 0) : offset; + var len = lena > ofs ? lena - ofs | 0 : 0; + var result = new Array(len); + for(var i = 0; i < len; ++i){ + result[i] = a[ofs + i | 0]; + } + return result; +} + +function fill(a, offset, len, v) { + if (len <= 0) { + return ; + } + var lena = a.length; + var ofs = offset < 0 ? Caml.caml_int_max(lena + offset | 0, 0) : offset; + var hasLen = lena - ofs | 0; + var fillLength = hasLen < len ? hasLen : len; + if (fillLength <= 0) { + return ; + } + for(var i = ofs ,i_finish = ofs + fillLength | 0; i < i_finish; ++i){ + a[i] = v; + } +} + +function blitUnsafe(a1, srcofs1, a2, srcofs2, blitLength) { + if (srcofs2 <= srcofs1) { + for(var j = 0; j < blitLength; ++j){ + a2[j + srcofs2 | 0] = a1[j + srcofs1 | 0]; + } + return ; + } + for(var j$1 = blitLength - 1 | 0; j$1 >= 0; --j$1){ + a2[j$1 + srcofs2 | 0] = a1[j$1 + srcofs1 | 0]; + } +} + +function blit(a1, ofs1, a2, ofs2, len) { + var lena1 = a1.length; + var lena2 = a2.length; + var srcofs1 = ofs1 < 0 ? Caml.caml_int_max(lena1 + ofs1 | 0, 0) : ofs1; + var srcofs2 = ofs2 < 0 ? Caml.caml_int_max(lena2 + ofs2 | 0, 0) : ofs2; + var blitLength = Caml.caml_int_min(len, Caml.caml_int_min(lena1 - srcofs1 | 0, lena2 - srcofs2 | 0)); + if (srcofs2 <= srcofs1) { + for(var j = 0; j < blitLength; ++j){ + a2[j + srcofs2 | 0] = a1[j + srcofs1 | 0]; + } + return ; + } + for(var j$1 = blitLength - 1 | 0; j$1 >= 0; --j$1){ + a2[j$1 + srcofs2 | 0] = a1[j$1 + srcofs1 | 0]; + } +} + +function forEachU(a, f) { + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + f(a[i]); + } +} + +function forEach(a, f) { + forEachU(a, Curry.__1(f)); +} + +function mapU(a, f) { + var l = a.length; + var r = new Array(l); + for(var i = 0; i < l; ++i){ + r[i] = f(a[i]); + } + return r; +} + +function map(a, f) { + return mapU(a, Curry.__1(f)); +} + +function flatMapU(a, f) { + return concatMany(mapU(a, f)); +} + +function flatMap(a, f) { + return concatMany(mapU(a, Curry.__1(f))); +} + +function getByU(a, p) { + var l = a.length; + var i = 0; + var r; + while(r === undefined && i < l) { + var v = a[i]; + if (p(v)) { + r = Caml_option.some(v); + } + i = i + 1 | 0; + }; + return r; +} + +function getBy(a, p) { + return getByU(a, Curry.__1(p)); +} + +function getIndexByU(a, p) { + var l = a.length; + var i = 0; + var r; + while(r === undefined && i < l) { + var v = a[i]; + if (p(v)) { + r = i; + } + i = i + 1 | 0; + }; + return r; +} + +function getIndexBy(a, p) { + return getIndexByU(a, Curry.__1(p)); +} + +function keepU(a, f) { + var l = a.length; + var r = new Array(l); + var j = 0; + for(var i = 0; i < l; ++i){ + var v = a[i]; + if (f(v)) { + r[j] = v; + j = j + 1 | 0; + } + + } + r.length = j; + return r; +} + +function keep(a, f) { + return keepU(a, Curry.__1(f)); +} + +function keepWithIndexU(a, f) { + var l = a.length; + var r = new Array(l); + var j = 0; + for(var i = 0; i < l; ++i){ + var v = a[i]; + if (f(v, i)) { + r[j] = v; + j = j + 1 | 0; + } + + } + r.length = j; + return r; +} + +function keepWithIndex(a, f) { + return keepWithIndexU(a, Curry.__2(f)); +} + +function keepMapU(a, f) { + var l = a.length; + var r = new Array(l); + var j = 0; + for(var i = 0; i < l; ++i){ + var v = a[i]; + var v$1 = f(v); + if (v$1 !== undefined) { + r[j] = Caml_option.valFromOption(v$1); + j = j + 1 | 0; + } + + } + r.length = j; + return r; +} + +function keepMap(a, f) { + return keepMapU(a, Curry.__1(f)); +} + +function forEachWithIndexU(a, f) { + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + f(i, a[i]); + } +} + +function forEachWithIndex(a, f) { + forEachWithIndexU(a, Curry.__2(f)); +} + +function mapWithIndexU(a, f) { + var l = a.length; + var r = new Array(l); + for(var i = 0; i < l; ++i){ + r[i] = f(i, a[i]); + } + return r; +} + +function mapWithIndex(a, f) { + return mapWithIndexU(a, Curry.__2(f)); +} + +function reduceU(a, x, f) { + var r = x; + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + r = f(r, a[i]); + } + return r; +} + +function reduce(a, x, f) { + return reduceU(a, x, Curry.__2(f)); +} + +function reduceReverseU(a, x, f) { + var r = x; + for(var i = a.length - 1 | 0; i >= 0; --i){ + r = f(r, a[i]); + } + return r; +} + +function reduceReverse(a, x, f) { + return reduceReverseU(a, x, Curry.__2(f)); +} + +function reduceReverse2U(a, b, x, f) { + var r = x; + var len = Caml.caml_int_min(a.length, b.length); + for(var i = len - 1 | 0; i >= 0; --i){ + r = f(r, a[i], b[i]); + } + return r; +} + +function reduceReverse2(a, b, x, f) { + return reduceReverse2U(a, b, x, Curry.__3(f)); +} + +function reduceWithIndexU(a, x, f) { + var r = x; + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + r = f(r, a[i], i); + } + return r; +} + +function reduceWithIndex(a, x, f) { + return reduceWithIndexU(a, x, Curry.__3(f)); +} + +function everyU(arr, b) { + var len = arr.length; + var _i = 0; + while(true) { + var i = _i; + if (i === len) { + return true; + } + if (!b(arr[i])) { + return false; + } + _i = i + 1 | 0; + continue ; + }; +} + +function every(arr, f) { + return everyU(arr, Curry.__1(f)); +} + +function someU(arr, b) { + var len = arr.length; + var _i = 0; + while(true) { + var i = _i; + if (i === len) { + return false; + } + if (b(arr[i])) { + return true; + } + _i = i + 1 | 0; + continue ; + }; +} + +function some(arr, f) { + return someU(arr, Curry.__1(f)); +} + +function everyAux2(arr1, arr2, _i, b, len) { + while(true) { + var i = _i; + if (i === len) { + return true; + } + if (!b(arr1[i], arr2[i])) { + return false; + } + _i = i + 1 | 0; + continue ; + }; +} + +function every2U(a, b, p) { + return everyAux2(a, b, 0, p, Caml.caml_int_min(a.length, b.length)); +} + +function every2(a, b, p) { + return every2U(a, b, Curry.__2(p)); +} + +function some2U(a, b, p) { + var _i = 0; + var len = Caml.caml_int_min(a.length, b.length); + while(true) { + var i = _i; + if (i === len) { + return false; + } + if (p(a[i], b[i])) { + return true; + } + _i = i + 1 | 0; + continue ; + }; +} + +function some2(a, b, p) { + return some2U(a, b, Curry.__2(p)); +} + +function eqU(a, b, p) { + var lena = a.length; + var lenb = b.length; + if (lena === lenb) { + return everyAux2(a, b, 0, p, lena); + } else { + return false; + } +} + +function eq(a, b, p) { + return eqU(a, b, Curry.__2(p)); +} + +function cmpU(a, b, p) { + var lena = a.length; + var lenb = b.length; + if (lena > lenb) { + return 1; + } else if (lena < lenb) { + return -1; + } else { + var _i = 0; + while(true) { + var i = _i; + if (i === lena) { + return 0; + } + var c = p(a[i], b[i]); + if (c !== 0) { + return c; + } + _i = i + 1 | 0; + continue ; + }; + } +} + +function cmp(a, b, p) { + return cmpU(a, b, Curry.__2(p)); +} + +function partitionU(a, f) { + var l = a.length; + var i = 0; + var j = 0; + var a1 = new Array(l); + var a2 = new Array(l); + for(var ii = 0; ii < l; ++ii){ + var v = a[ii]; + if (f(v)) { + a1[i] = v; + i = i + 1 | 0; + } else { + a2[j] = v; + j = j + 1 | 0; + } + } + a1.length = i; + a2.length = j; + return [ + a1, + a2 + ]; +} + +function partition(a, f) { + return partitionU(a, Curry.__1(f)); +} + +function unzip(a) { + var l = a.length; + var a1 = new Array(l); + var a2 = new Array(l); + for(var i = 0; i < l; ++i){ + var match = a[i]; + a1[i] = match[0]; + a2[i] = match[1]; + } + return [ + a1, + a2 + ]; +} + +function joinWithU(a, sep, toString) { + var l = a.length; + if (l === 0) { + return ""; + } + var lastIndex = l - 1 | 0; + var _i = 0; + var _res = ""; + while(true) { + var res = _res; + var i = _i; + if (i === lastIndex) { + return res + toString(a[i]); + } + _res = res + (toString(a[i]) + sep); + _i = i + 1 | 0; + continue ; + }; +} + +function joinWith(a, sep, toString) { + return joinWithU(a, sep, Curry.__1(toString)); +} + +function initU(n, f) { + var v = new Array(n); + for(var i = 0; i < n; ++i){ + v[i] = f(i); + } + return v; +} + +function init(n, f) { + return initU(n, Curry.__1(f)); +} + +export { + get , + getExn , + set , + setExn , + shuffleInPlace , + shuffle , + reverseInPlace , + reverse , + make , + range , + rangeBy , + makeByU , + makeBy , + makeByAndShuffleU , + makeByAndShuffle , + zip , + zipByU , + zipBy , + unzip , + concat , + concatMany , + slice , + sliceToEnd , + fill , + blit , + blitUnsafe , + forEachU , + forEach , + mapU , + map , + flatMapU , + flatMap , + getByU , + getBy , + getIndexByU , + getIndexBy , + keepU , + keep , + keepWithIndexU , + keepWithIndex , + keepMapU , + keepMap , + forEachWithIndexU , + forEachWithIndex , + mapWithIndexU , + mapWithIndex , + partitionU , + partition , + reduceU , + reduce , + reduceReverseU , + reduceReverse , + reduceReverse2U , + reduceReverse2 , + reduceWithIndexU , + reduceWithIndex , + joinWithU , + joinWith , + someU , + some , + everyU , + every , + every2U , + every2 , + some2U , + some2 , + cmpU , + cmp , + eqU , + eq , + initU , + init , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_Float.js b/melange-node-modules/melange.belt/belt_Float.js new file mode 100644 index 0000000..b2671d7 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_Float.js @@ -0,0 +1,16 @@ +// Generated by Melange + + +function fromString(i) { + var i$1 = parseFloat(i); + if (isNaN(i$1)) { + return ; + } else { + return i$1; + } +} + +export { + fromString , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_HashMap.js b/melange-node-modules/melange.belt/belt_HashMap.js new file mode 100644 index 0000000..840321f --- /dev/null +++ b/melange-node-modules/melange.belt/belt_HashMap.js @@ -0,0 +1,274 @@ +// Generated by Melange + +import * as Belt__Belt_internalBuckets from "./belt_internalBuckets.js"; +import * as Belt__Belt_internalBucketsType from "./belt_internalBucketsType.js"; +import * as Caml_option from "melange.js/caml_option.js"; + +function size(h) { + return h.size; +} + +function copyBucketReHash(hash, h_buckets, ndata_tail, _old_bucket) { + while(true) { + var old_bucket = _old_bucket; + if (old_bucket === undefined) { + return ; + } + var nidx = hash(old_bucket.key) & (h_buckets.length - 1 | 0); + var tail = ndata_tail[nidx]; + if (tail !== undefined) { + tail.next = old_bucket; + } else { + h_buckets[nidx] = old_bucket; + } + ndata_tail[nidx] = old_bucket; + _old_bucket = old_bucket.next; + continue ; + }; +} + +function replaceInBucket(eq, key, info, _cell) { + while(true) { + var cell = _cell; + if (eq(cell.key, key)) { + cell.value = info; + return false; + } + var cell$1 = cell.next; + if (cell$1 === undefined) { + return true; + } + _cell = cell$1; + continue ; + }; +} + +function set0(h, key, value, eq, hash) { + var h_buckets = h.buckets; + var buckets_len = h_buckets.length; + var i = hash(key) & (buckets_len - 1 | 0); + var l = h_buckets[i]; + if (l !== undefined) { + if (replaceInBucket(eq, key, value, l)) { + h_buckets[i] = { + key: key, + value: value, + next: l + }; + h.size = h.size + 1 | 0; + } + + } else { + h_buckets[i] = { + key: key, + value: value, + next: undefined + }; + h.size = h.size + 1 | 0; + } + if (h.size > (buckets_len << 1)) { + var odata = h.buckets; + var osize = odata.length; + var nsize = (osize << 1); + if (nsize < osize) { + return ; + } + var h_buckets$1 = new Array(nsize); + var ndata_tail = new Array(nsize); + h.buckets = h_buckets$1; + for(var i$1 = 0; i$1 < osize; ++i$1){ + copyBucketReHash(hash, h_buckets$1, ndata_tail, odata[i$1]); + } + for(var i$2 = 0; i$2 < nsize; ++i$2){ + var tail = ndata_tail[i$2]; + if (tail !== undefined) { + tail.next = undefined; + } + + } + return ; + } + +} + +function set(h, key, value) { + set0(h, key, value, h.eq, h.hash); +} + +function remove(h, key) { + var h_buckets = h.buckets; + var i = h.hash(key) & (h_buckets.length - 1 | 0); + var bucket = h_buckets[i]; + if (bucket === undefined) { + return ; + } + var eq = h.eq; + if (eq(bucket.key, key)) { + h_buckets[i] = bucket.next; + h.size = h.size - 1 | 0; + return ; + } else { + var _prec = bucket; + var _bucket = bucket.next; + while(true) { + var bucket$1 = _bucket; + var prec = _prec; + if (bucket$1 === undefined) { + return ; + } + var cell_next = bucket$1.next; + if (eq(bucket$1.key, key)) { + prec.next = cell_next; + h.size = h.size - 1 | 0; + return ; + } + _bucket = cell_next; + _prec = bucket$1; + continue ; + }; + } +} + +function get(h, key) { + var h_buckets = h.buckets; + var nid = h.hash(key) & (h_buckets.length - 1 | 0); + var cell1 = h_buckets[nid]; + if (cell1 === undefined) { + return ; + } + var eq = h.eq; + if (eq(key, cell1.key)) { + return Caml_option.some(cell1.value); + } + var cell2 = cell1.next; + if (cell2 === undefined) { + return ; + } + if (eq(key, cell2.key)) { + return Caml_option.some(cell2.value); + } + var cell3 = cell2.next; + if (cell3 !== undefined) { + if (eq(key, cell3.key)) { + return Caml_option.some(cell3.value); + } else { + var _buckets = cell3.next; + while(true) { + var buckets = _buckets; + if (buckets === undefined) { + return ; + } + if (eq(key, buckets.key)) { + return Caml_option.some(buckets.value); + } + _buckets = buckets.next; + continue ; + }; + } + } + +} + +function has(h, key) { + var h_buckets = h.buckets; + var nid = h.hash(key) & (h_buckets.length - 1 | 0); + var bucket = h_buckets[nid]; + if (bucket !== undefined) { + var _cell = bucket; + var eq = h.eq; + while(true) { + var cell = _cell; + if (eq(cell.key, key)) { + return true; + } + var nextCell = cell.next; + if (nextCell === undefined) { + return false; + } + _cell = nextCell; + continue ; + }; + } else { + return false; + } +} + +function make(hintSize, id) { + return Belt__Belt_internalBucketsType.make(id.hash, id.eq, hintSize); +} + +function fromArray(arr, id) { + var hash = id.hash; + var eq = id.eq; + var len = arr.length; + var v = Belt__Belt_internalBucketsType.make(hash, eq, len); + for(var i = 0; i < len; ++i){ + var match = arr[i]; + set0(v, match[0], match[1], eq, hash); + } + return v; +} + +function mergeMany(h, arr) { + var hash = h.hash; + var eq = h.eq; + var len = arr.length; + for(var i = 0; i < len; ++i){ + var match = arr[i]; + set0(h, match[0], match[1], eq, hash); + } +} + +var clear = Belt__Belt_internalBucketsType.clear; + +var isEmpty = Belt__Belt_internalBucketsType.isEmpty; + +var copy = Belt__Belt_internalBuckets.copy; + +var forEachU = Belt__Belt_internalBuckets.forEachU; + +var forEach = Belt__Belt_internalBuckets.forEach; + +var reduceU = Belt__Belt_internalBuckets.reduceU; + +var reduce = Belt__Belt_internalBuckets.reduce; + +var keepMapInPlaceU = Belt__Belt_internalBuckets.keepMapInPlaceU; + +var keepMapInPlace = Belt__Belt_internalBuckets.keepMapInPlace; + +var toArray = Belt__Belt_internalBuckets.toArray; + +var keysToArray = Belt__Belt_internalBuckets.keysToArray; + +var valuesToArray = Belt__Belt_internalBuckets.valuesToArray; + +var getBucketHistogram = Belt__Belt_internalBuckets.getBucketHistogram; + +var logStats = Belt__Belt_internalBuckets.logStats; + +export { + make , + clear , + isEmpty , + set , + copy , + get , + has , + remove , + forEachU , + forEach , + reduceU , + reduce , + keepMapInPlaceU , + keepMapInPlace , + size , + toArray , + keysToArray , + valuesToArray , + fromArray , + mergeMany , + getBucketHistogram , + logStats , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_HashMapInt.js b/melange-node-modules/melange.belt/belt_HashMapInt.js new file mode 100644 index 0000000..41fee53 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_HashMapInt.js @@ -0,0 +1,264 @@ +// Generated by Melange + +import * as Belt__Belt_internalBuckets from "./belt_internalBuckets.js"; +import * as Belt__Belt_internalBucketsType from "./belt_internalBucketsType.js"; +import * as Caml_hash_primitive from "melange.js/caml_hash_primitive.js"; +import * as Caml_option from "melange.js/caml_option.js"; + +function copyBucketReHash(h_buckets, ndata_tail, _old_bucket) { + while(true) { + var old_bucket = _old_bucket; + if (old_bucket === undefined) { + return ; + } + var nidx = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_int(0, old_bucket.key)) & (h_buckets.length - 1 | 0); + var tail = ndata_tail[nidx]; + if (tail !== undefined) { + tail.next = old_bucket; + } else { + h_buckets[nidx] = old_bucket; + } + ndata_tail[nidx] = old_bucket; + _old_bucket = old_bucket.next; + continue ; + }; +} + +function replaceInBucket(key, info, _cell) { + while(true) { + var cell = _cell; + if (cell.key === key) { + cell.value = info; + return false; + } + var cell$1 = cell.next; + if (cell$1 === undefined) { + return true; + } + _cell = cell$1; + continue ; + }; +} + +function set(h, key, value) { + var h_buckets = h.buckets; + var buckets_len = h_buckets.length; + var i = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_int(0, key)) & (buckets_len - 1 | 0); + var l = h_buckets[i]; + if (l !== undefined) { + if (replaceInBucket(key, value, l)) { + h_buckets[i] = { + key: key, + value: value, + next: l + }; + h.size = h.size + 1 | 0; + } + + } else { + h_buckets[i] = { + key: key, + value: value, + next: undefined + }; + h.size = h.size + 1 | 0; + } + if (h.size > (buckets_len << 1)) { + var odata = h.buckets; + var osize = odata.length; + var nsize = (osize << 1); + if (nsize < osize) { + return ; + } + var h_buckets$1 = new Array(nsize); + var ndata_tail = new Array(nsize); + h.buckets = h_buckets$1; + for(var i$1 = 0; i$1 < osize; ++i$1){ + copyBucketReHash(h_buckets$1, ndata_tail, odata[i$1]); + } + for(var i$2 = 0; i$2 < nsize; ++i$2){ + var tail = ndata_tail[i$2]; + if (tail !== undefined) { + tail.next = undefined; + } + + } + return ; + } + +} + +function remove(h, key) { + var h_buckets = h.buckets; + var i = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); + var bucket = h_buckets[i]; + if (bucket !== undefined) { + if (bucket.key === key) { + h_buckets[i] = bucket.next; + h.size = h.size - 1 | 0; + return ; + } else { + var _prec = bucket; + var _buckets = bucket.next; + while(true) { + var buckets = _buckets; + var prec = _prec; + if (buckets === undefined) { + return ; + } + var cell_next = buckets.next; + if (buckets.key === key) { + prec.next = cell_next; + h.size = h.size - 1 | 0; + return ; + } + _buckets = cell_next; + _prec = buckets; + continue ; + }; + } + } + +} + +function get(h, key) { + var h_buckets = h.buckets; + var nid = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); + var cell1 = h_buckets[nid]; + if (cell1 === undefined) { + return ; + } + if (key === cell1.key) { + return Caml_option.some(cell1.value); + } + var cell2 = cell1.next; + if (cell2 === undefined) { + return ; + } + if (key === cell2.key) { + return Caml_option.some(cell2.value); + } + var cell3 = cell2.next; + if (cell3 !== undefined) { + if (key === cell3.key) { + return Caml_option.some(cell3.value); + } else { + var _buckets = cell3.next; + while(true) { + var buckets = _buckets; + if (buckets === undefined) { + return ; + } + if (key === buckets.key) { + return Caml_option.some(buckets.value); + } + _buckets = buckets.next; + continue ; + }; + } + } + +} + +function has(h, key) { + var h_buckets = h.buckets; + var nid = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); + var bucket = h_buckets[nid]; + if (bucket !== undefined) { + var _cell = bucket; + while(true) { + var cell = _cell; + if (cell.key === key) { + return true; + } + var nextCell = cell.next; + if (nextCell === undefined) { + return false; + } + _cell = nextCell; + continue ; + }; + } else { + return false; + } +} + +function make(hintSize) { + return Belt__Belt_internalBucketsType.make(undefined, undefined, hintSize); +} + +function size(h) { + return h.size; +} + +function fromArray(arr) { + var len = arr.length; + var v = Belt__Belt_internalBucketsType.make(undefined, undefined, len); + for(var i = 0; i < len; ++i){ + var match = arr[i]; + set(v, match[0], match[1]); + } + return v; +} + +function mergeMany(h, arr) { + var len = arr.length; + for(var i = 0; i < len; ++i){ + var match = arr[i]; + set(h, match[0], match[1]); + } +} + +var clear = Belt__Belt_internalBucketsType.clear; + +var isEmpty = Belt__Belt_internalBucketsType.isEmpty; + +var copy = Belt__Belt_internalBuckets.copy; + +var forEachU = Belt__Belt_internalBuckets.forEachU; + +var forEach = Belt__Belt_internalBuckets.forEach; + +var reduceU = Belt__Belt_internalBuckets.reduceU; + +var reduce = Belt__Belt_internalBuckets.reduce; + +var keepMapInPlaceU = Belt__Belt_internalBuckets.keepMapInPlaceU; + +var keepMapInPlace = Belt__Belt_internalBuckets.keepMapInPlace; + +var toArray = Belt__Belt_internalBuckets.toArray; + +var keysToArray = Belt__Belt_internalBuckets.keysToArray; + +var valuesToArray = Belt__Belt_internalBuckets.valuesToArray; + +var getBucketHistogram = Belt__Belt_internalBuckets.getBucketHistogram; + +var logStats = Belt__Belt_internalBuckets.logStats; + +export { + make , + clear , + isEmpty , + set , + copy , + get , + has , + remove , + forEachU , + forEach , + reduceU , + reduce , + keepMapInPlaceU , + keepMapInPlace , + size , + toArray , + keysToArray , + valuesToArray , + fromArray , + mergeMany , + getBucketHistogram , + logStats , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_HashMapString.js b/melange-node-modules/melange.belt/belt_HashMapString.js new file mode 100644 index 0000000..d0e9b25 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_HashMapString.js @@ -0,0 +1,264 @@ +// Generated by Melange + +import * as Belt__Belt_internalBuckets from "./belt_internalBuckets.js"; +import * as Belt__Belt_internalBucketsType from "./belt_internalBucketsType.js"; +import * as Caml_hash_primitive from "melange.js/caml_hash_primitive.js"; +import * as Caml_option from "melange.js/caml_option.js"; + +function copyBucketReHash(h_buckets, ndata_tail, _old_bucket) { + while(true) { + var old_bucket = _old_bucket; + if (old_bucket === undefined) { + return ; + } + var nidx = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_string(0, old_bucket.key)) & (h_buckets.length - 1 | 0); + var tail = ndata_tail[nidx]; + if (tail !== undefined) { + tail.next = old_bucket; + } else { + h_buckets[nidx] = old_bucket; + } + ndata_tail[nidx] = old_bucket; + _old_bucket = old_bucket.next; + continue ; + }; +} + +function replaceInBucket(key, info, _cell) { + while(true) { + var cell = _cell; + if (cell.key === key) { + cell.value = info; + return false; + } + var cell$1 = cell.next; + if (cell$1 === undefined) { + return true; + } + _cell = cell$1; + continue ; + }; +} + +function set(h, key, value) { + var h_buckets = h.buckets; + var buckets_len = h_buckets.length; + var i = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_string(0, key)) & (buckets_len - 1 | 0); + var l = h_buckets[i]; + if (l !== undefined) { + if (replaceInBucket(key, value, l)) { + h_buckets[i] = { + key: key, + value: value, + next: l + }; + h.size = h.size + 1 | 0; + } + + } else { + h_buckets[i] = { + key: key, + value: value, + next: undefined + }; + h.size = h.size + 1 | 0; + } + if (h.size > (buckets_len << 1)) { + var odata = h.buckets; + var osize = odata.length; + var nsize = (osize << 1); + if (nsize < osize) { + return ; + } + var h_buckets$1 = new Array(nsize); + var ndata_tail = new Array(nsize); + h.buckets = h_buckets$1; + for(var i$1 = 0; i$1 < osize; ++i$1){ + copyBucketReHash(h_buckets$1, ndata_tail, odata[i$1]); + } + for(var i$2 = 0; i$2 < nsize; ++i$2){ + var tail = ndata_tail[i$2]; + if (tail !== undefined) { + tail.next = undefined; + } + + } + return ; + } + +} + +function remove(h, key) { + var h_buckets = h.buckets; + var i = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); + var bucket = h_buckets[i]; + if (bucket !== undefined) { + if (bucket.key === key) { + h_buckets[i] = bucket.next; + h.size = h.size - 1 | 0; + return ; + } else { + var _prec = bucket; + var _buckets = bucket.next; + while(true) { + var buckets = _buckets; + var prec = _prec; + if (buckets === undefined) { + return ; + } + var cell_next = buckets.next; + if (buckets.key === key) { + prec.next = cell_next; + h.size = h.size - 1 | 0; + return ; + } + _buckets = cell_next; + _prec = buckets; + continue ; + }; + } + } + +} + +function get(h, key) { + var h_buckets = h.buckets; + var nid = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); + var cell1 = h_buckets[nid]; + if (cell1 === undefined) { + return ; + } + if (key === cell1.key) { + return Caml_option.some(cell1.value); + } + var cell2 = cell1.next; + if (cell2 === undefined) { + return ; + } + if (key === cell2.key) { + return Caml_option.some(cell2.value); + } + var cell3 = cell2.next; + if (cell3 !== undefined) { + if (key === cell3.key) { + return Caml_option.some(cell3.value); + } else { + var _buckets = cell3.next; + while(true) { + var buckets = _buckets; + if (buckets === undefined) { + return ; + } + if (key === buckets.key) { + return Caml_option.some(buckets.value); + } + _buckets = buckets.next; + continue ; + }; + } + } + +} + +function has(h, key) { + var h_buckets = h.buckets; + var nid = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); + var bucket = h_buckets[nid]; + if (bucket !== undefined) { + var _cell = bucket; + while(true) { + var cell = _cell; + if (cell.key === key) { + return true; + } + var nextCell = cell.next; + if (nextCell === undefined) { + return false; + } + _cell = nextCell; + continue ; + }; + } else { + return false; + } +} + +function make(hintSize) { + return Belt__Belt_internalBucketsType.make(undefined, undefined, hintSize); +} + +function size(h) { + return h.size; +} + +function fromArray(arr) { + var len = arr.length; + var v = Belt__Belt_internalBucketsType.make(undefined, undefined, len); + for(var i = 0; i < len; ++i){ + var match = arr[i]; + set(v, match[0], match[1]); + } + return v; +} + +function mergeMany(h, arr) { + var len = arr.length; + for(var i = 0; i < len; ++i){ + var match = arr[i]; + set(h, match[0], match[1]); + } +} + +var clear = Belt__Belt_internalBucketsType.clear; + +var isEmpty = Belt__Belt_internalBucketsType.isEmpty; + +var copy = Belt__Belt_internalBuckets.copy; + +var forEachU = Belt__Belt_internalBuckets.forEachU; + +var forEach = Belt__Belt_internalBuckets.forEach; + +var reduceU = Belt__Belt_internalBuckets.reduceU; + +var reduce = Belt__Belt_internalBuckets.reduce; + +var keepMapInPlaceU = Belt__Belt_internalBuckets.keepMapInPlaceU; + +var keepMapInPlace = Belt__Belt_internalBuckets.keepMapInPlace; + +var toArray = Belt__Belt_internalBuckets.toArray; + +var keysToArray = Belt__Belt_internalBuckets.keysToArray; + +var valuesToArray = Belt__Belt_internalBuckets.valuesToArray; + +var getBucketHistogram = Belt__Belt_internalBuckets.getBucketHistogram; + +var logStats = Belt__Belt_internalBuckets.logStats; + +export { + make , + clear , + isEmpty , + set , + copy , + get , + has , + remove , + forEachU , + forEach , + reduceU , + reduce , + keepMapInPlaceU , + keepMapInPlace , + size , + toArray , + keysToArray , + valuesToArray , + fromArray , + mergeMany , + getBucketHistogram , + logStats , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_HashSet.js b/melange-node-modules/melange.belt/belt_HashSet.js new file mode 100644 index 0000000..89c0496 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_HashSet.js @@ -0,0 +1,216 @@ +// Generated by Melange + +import * as Belt__Belt_internalBucketsType from "./belt_internalBucketsType.js"; +import * as Belt__Belt_internalSetBuckets from "./belt_internalSetBuckets.js"; + +function copyBucket(hash, h_buckets, ndata_tail, _old_bucket) { + while(true) { + var old_bucket = _old_bucket; + if (old_bucket === undefined) { + return ; + } + var nidx = hash(old_bucket.key) & (h_buckets.length - 1 | 0); + var tail = ndata_tail[nidx]; + if (tail !== undefined) { + tail.next = old_bucket; + } else { + h_buckets[nidx] = old_bucket; + } + ndata_tail[nidx] = old_bucket; + _old_bucket = old_bucket.next; + continue ; + }; +} + +function remove(h, key) { + var eq = h.eq; + var h_buckets = h.buckets; + var i = h.hash(key) & (h_buckets.length - 1 | 0); + var l = h_buckets[i]; + if (l === undefined) { + return ; + } + var next_cell = l.next; + if (eq(l.key, key)) { + h.size = h.size - 1 | 0; + h_buckets[i] = next_cell; + return ; + } else if (next_cell !== undefined) { + var _prec = l; + var _cell = next_cell; + while(true) { + var cell = _cell; + var prec = _prec; + var cell_next = cell.next; + if (eq(cell.key, key)) { + prec.next = cell_next; + h.size = h.size - 1 | 0; + return ; + } + if (cell_next === undefined) { + return ; + } + _cell = cell_next; + _prec = cell; + continue ; + }; + } else { + return ; + } +} + +function addBucket(h, key, _cell, eq) { + while(true) { + var cell = _cell; + if (eq(cell.key, key)) { + return ; + } + var n = cell.next; + if (n !== undefined) { + _cell = n; + continue ; + } + h.size = h.size + 1 | 0; + cell.next = { + key: key, + next: undefined + }; + return ; + }; +} + +function add0(h, key, hash, eq) { + var h_buckets = h.buckets; + var buckets_len = h_buckets.length; + var i = hash(key) & (buckets_len - 1 | 0); + var l = h_buckets[i]; + if (l !== undefined) { + addBucket(h, key, l, eq); + } else { + h.size = h.size + 1 | 0; + h_buckets[i] = { + key: key, + next: undefined + }; + } + if (h.size > (buckets_len << 1)) { + var odata = h.buckets; + var osize = odata.length; + var nsize = (osize << 1); + if (nsize < osize) { + return ; + } + var h_buckets$1 = new Array(nsize); + var ndata_tail = new Array(nsize); + h.buckets = h_buckets$1; + for(var i$1 = 0; i$1 < osize; ++i$1){ + copyBucket(hash, h_buckets$1, ndata_tail, odata[i$1]); + } + for(var i$2 = 0; i$2 < nsize; ++i$2){ + var tail = ndata_tail[i$2]; + if (tail !== undefined) { + tail.next = undefined; + } + + } + return ; + } + +} + +function add(h, key) { + add0(h, key, h.hash, h.eq); +} + +function has(h, key) { + var eq = h.eq; + var h_buckets = h.buckets; + var nid = h.hash(key) & (h_buckets.length - 1 | 0); + var bucket = h_buckets[nid]; + if (bucket !== undefined) { + var _cell = bucket; + while(true) { + var cell = _cell; + if (eq(cell.key, key)) { + return true; + } + var nextCell = cell.next; + if (nextCell === undefined) { + return false; + } + _cell = nextCell; + continue ; + }; + } else { + return false; + } +} + +function make(hintSize, id) { + return Belt__Belt_internalBucketsType.make(id.hash, id.eq, hintSize); +} + +function size(h) { + return h.size; +} + +function fromArray(arr, id) { + var eq = id.eq; + var hash = id.hash; + var len = arr.length; + var v = Belt__Belt_internalBucketsType.make(hash, eq, len); + for(var i = 0; i < len; ++i){ + add0(v, arr[i], hash, eq); + } + return v; +} + +function mergeMany(h, arr) { + var eq = h.eq; + var hash = h.hash; + var len = arr.length; + for(var i = 0; i < len; ++i){ + add0(h, arr[i], hash, eq); + } +} + +var clear = Belt__Belt_internalBucketsType.clear; + +var isEmpty = Belt__Belt_internalBucketsType.isEmpty; + +var copy = Belt__Belt_internalSetBuckets.copy; + +var forEachU = Belt__Belt_internalSetBuckets.forEachU; + +var forEach = Belt__Belt_internalSetBuckets.forEach; + +var reduceU = Belt__Belt_internalSetBuckets.reduceU; + +var reduce = Belt__Belt_internalSetBuckets.reduce; + +var logStats = Belt__Belt_internalSetBuckets.logStats; + +var toArray = Belt__Belt_internalSetBuckets.toArray; + +var getBucketHistogram = Belt__Belt_internalSetBuckets.getBucketHistogram; + +export { + make , + clear , + isEmpty , + add , + copy , + has , + remove , + forEachU , + forEach , + reduceU , + reduce , + size , + logStats , + toArray , + fromArray , + mergeMany , + getBucketHistogram , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_HashSetInt.js b/melange-node-modules/melange.belt/belt_HashSetInt.js new file mode 100644 index 0000000..ed23a24 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_HashSetInt.js @@ -0,0 +1,207 @@ +// Generated by Melange + +import * as Belt__Belt_internalBucketsType from "./belt_internalBucketsType.js"; +import * as Belt__Belt_internalSetBuckets from "./belt_internalSetBuckets.js"; +import * as Caml_hash_primitive from "melange.js/caml_hash_primitive.js"; + +function copyBucket(h_buckets, ndata_tail, _old_bucket) { + while(true) { + var old_bucket = _old_bucket; + if (old_bucket === undefined) { + return ; + } + var nidx = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_int(0, old_bucket.key)) & (h_buckets.length - 1 | 0); + var tail = ndata_tail[nidx]; + if (tail !== undefined) { + tail.next = old_bucket; + } else { + h_buckets[nidx] = old_bucket; + } + ndata_tail[nidx] = old_bucket; + _old_bucket = old_bucket.next; + continue ; + }; +} + +function remove(h, key) { + var h_buckets = h.buckets; + var i = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); + var l = h_buckets[i]; + if (l === undefined) { + return ; + } + var next_cell = l.next; + if (l.key === key) { + h.size = h.size - 1 | 0; + h_buckets[i] = next_cell; + return ; + } else if (next_cell !== undefined) { + var _prec = l; + var _cell = next_cell; + while(true) { + var cell = _cell; + var prec = _prec; + var cell_next = cell.next; + if (cell.key === key) { + prec.next = cell_next; + h.size = h.size - 1 | 0; + return ; + } + if (cell_next === undefined) { + return ; + } + _cell = cell_next; + _prec = cell; + continue ; + }; + } else { + return ; + } +} + +function addBucket(h, key, _cell) { + while(true) { + var cell = _cell; + if (cell.key === key) { + return ; + } + var n = cell.next; + if (n !== undefined) { + _cell = n; + continue ; + } + h.size = h.size + 1 | 0; + cell.next = { + key: key, + next: undefined + }; + return ; + }; +} + +function add(h, key) { + var h_buckets = h.buckets; + var buckets_len = h_buckets.length; + var i = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_int(0, key)) & (buckets_len - 1 | 0); + var l = h_buckets[i]; + if (l !== undefined) { + addBucket(h, key, l); + } else { + h_buckets[i] = { + key: key, + next: undefined + }; + h.size = h.size + 1 | 0; + } + if (h.size > (buckets_len << 1)) { + var odata = h.buckets; + var osize = odata.length; + var nsize = (osize << 1); + if (nsize < osize) { + return ; + } + var h_buckets$1 = new Array(nsize); + var ndata_tail = new Array(nsize); + h.buckets = h_buckets$1; + for(var i$1 = 0; i$1 < osize; ++i$1){ + copyBucket(h_buckets$1, ndata_tail, odata[i$1]); + } + for(var i$2 = 0; i$2 < nsize; ++i$2){ + var tail = ndata_tail[i$2]; + if (tail !== undefined) { + tail.next = undefined; + } + + } + return ; + } + +} + +function has(h, key) { + var h_buckets = h.buckets; + var nid = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_int(0, key)) & (h_buckets.length - 1 | 0); + var bucket = h_buckets[nid]; + if (bucket !== undefined) { + var _cell = bucket; + while(true) { + var cell = _cell; + if (cell.key === key) { + return true; + } + var nextCell = cell.next; + if (nextCell === undefined) { + return false; + } + _cell = nextCell; + continue ; + }; + } else { + return false; + } +} + +function make(hintSize) { + return Belt__Belt_internalBucketsType.make(undefined, undefined, hintSize); +} + +function size(h) { + return h.size; +} + +function fromArray(arr) { + var len = arr.length; + var v = Belt__Belt_internalBucketsType.make(undefined, undefined, len); + for(var i = 0; i < len; ++i){ + add(v, arr[i]); + } + return v; +} + +function mergeMany(h, arr) { + var len = arr.length; + for(var i = 0; i < len; ++i){ + add(h, arr[i]); + } +} + +var clear = Belt__Belt_internalBucketsType.clear; + +var isEmpty = Belt__Belt_internalBucketsType.isEmpty; + +var copy = Belt__Belt_internalSetBuckets.copy; + +var forEachU = Belt__Belt_internalSetBuckets.forEachU; + +var forEach = Belt__Belt_internalSetBuckets.forEach; + +var reduceU = Belt__Belt_internalSetBuckets.reduceU; + +var reduce = Belt__Belt_internalSetBuckets.reduce; + +var logStats = Belt__Belt_internalSetBuckets.logStats; + +var toArray = Belt__Belt_internalSetBuckets.toArray; + +var getBucketHistogram = Belt__Belt_internalSetBuckets.getBucketHistogram; + +export { + make , + clear , + isEmpty , + add , + copy , + has , + remove , + forEachU , + forEach , + reduceU , + reduce , + size , + logStats , + toArray , + fromArray , + mergeMany , + getBucketHistogram , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_HashSetString.js b/melange-node-modules/melange.belt/belt_HashSetString.js new file mode 100644 index 0000000..129ad95 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_HashSetString.js @@ -0,0 +1,207 @@ +// Generated by Melange + +import * as Belt__Belt_internalBucketsType from "./belt_internalBucketsType.js"; +import * as Belt__Belt_internalSetBuckets from "./belt_internalSetBuckets.js"; +import * as Caml_hash_primitive from "melange.js/caml_hash_primitive.js"; + +function copyBucket(h_buckets, ndata_tail, _old_bucket) { + while(true) { + var old_bucket = _old_bucket; + if (old_bucket === undefined) { + return ; + } + var nidx = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_string(0, old_bucket.key)) & (h_buckets.length - 1 | 0); + var tail = ndata_tail[nidx]; + if (tail !== undefined) { + tail.next = old_bucket; + } else { + h_buckets[nidx] = old_bucket; + } + ndata_tail[nidx] = old_bucket; + _old_bucket = old_bucket.next; + continue ; + }; +} + +function remove(h, key) { + var h_buckets = h.buckets; + var i = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); + var l = h_buckets[i]; + if (l === undefined) { + return ; + } + var next_cell = l.next; + if (l.key === key) { + h.size = h.size - 1 | 0; + h_buckets[i] = next_cell; + return ; + } else if (next_cell !== undefined) { + var _prec = l; + var _cell = next_cell; + while(true) { + var cell = _cell; + var prec = _prec; + var cell_next = cell.next; + if (cell.key === key) { + prec.next = cell_next; + h.size = h.size - 1 | 0; + return ; + } + if (cell_next === undefined) { + return ; + } + _cell = cell_next; + _prec = cell; + continue ; + }; + } else { + return ; + } +} + +function addBucket(h, key, _cell) { + while(true) { + var cell = _cell; + if (cell.key === key) { + return ; + } + var n = cell.next; + if (n !== undefined) { + _cell = n; + continue ; + } + h.size = h.size + 1 | 0; + cell.next = { + key: key, + next: undefined + }; + return ; + }; +} + +function add(h, key) { + var h_buckets = h.buckets; + var buckets_len = h_buckets.length; + var i = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_string(0, key)) & (buckets_len - 1 | 0); + var l = h_buckets[i]; + if (l !== undefined) { + addBucket(h, key, l); + } else { + h_buckets[i] = { + key: key, + next: undefined + }; + h.size = h.size + 1 | 0; + } + if (h.size > (buckets_len << 1)) { + var odata = h.buckets; + var osize = odata.length; + var nsize = (osize << 1); + if (nsize < osize) { + return ; + } + var h_buckets$1 = new Array(nsize); + var ndata_tail = new Array(nsize); + h.buckets = h_buckets$1; + for(var i$1 = 0; i$1 < osize; ++i$1){ + copyBucket(h_buckets$1, ndata_tail, odata[i$1]); + } + for(var i$2 = 0; i$2 < nsize; ++i$2){ + var tail = ndata_tail[i$2]; + if (tail !== undefined) { + tail.next = undefined; + } + + } + return ; + } + +} + +function has(h, key) { + var h_buckets = h.buckets; + var nid = Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_string(0, key)) & (h_buckets.length - 1 | 0); + var bucket = h_buckets[nid]; + if (bucket !== undefined) { + var _cell = bucket; + while(true) { + var cell = _cell; + if (cell.key === key) { + return true; + } + var nextCell = cell.next; + if (nextCell === undefined) { + return false; + } + _cell = nextCell; + continue ; + }; + } else { + return false; + } +} + +function make(hintSize) { + return Belt__Belt_internalBucketsType.make(undefined, undefined, hintSize); +} + +function size(h) { + return h.size; +} + +function fromArray(arr) { + var len = arr.length; + var v = Belt__Belt_internalBucketsType.make(undefined, undefined, len); + for(var i = 0; i < len; ++i){ + add(v, arr[i]); + } + return v; +} + +function mergeMany(h, arr) { + var len = arr.length; + for(var i = 0; i < len; ++i){ + add(h, arr[i]); + } +} + +var clear = Belt__Belt_internalBucketsType.clear; + +var isEmpty = Belt__Belt_internalBucketsType.isEmpty; + +var copy = Belt__Belt_internalSetBuckets.copy; + +var forEachU = Belt__Belt_internalSetBuckets.forEachU; + +var forEach = Belt__Belt_internalSetBuckets.forEach; + +var reduceU = Belt__Belt_internalSetBuckets.reduceU; + +var reduce = Belt__Belt_internalSetBuckets.reduce; + +var logStats = Belt__Belt_internalSetBuckets.logStats; + +var toArray = Belt__Belt_internalSetBuckets.toArray; + +var getBucketHistogram = Belt__Belt_internalSetBuckets.getBucketHistogram; + +export { + make , + clear , + isEmpty , + add , + copy , + has , + remove , + forEachU , + forEach , + reduceU , + reduce , + size , + logStats , + toArray , + fromArray , + mergeMany , + getBucketHistogram , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_Id.js b/melange-node-modules/melange.belt/belt_Id.js new file mode 100644 index 0000000..dc22372 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_Id.js @@ -0,0 +1,71 @@ +// Generated by Melange + +import * as Curry from "melange.js/curry.js"; + +function MakeComparableU(M) { + return M; +} + +function MakeComparable(M) { + var cmp = M.cmp; + var cmp$1 = Curry.__2(cmp); + return { + cmp: cmp$1 + }; +} + +function comparableU(cmp) { + return { + cmp: cmp + }; +} + +function comparable(cmp) { + var cmp$1 = Curry.__2(cmp); + return { + cmp: cmp$1 + }; +} + +function MakeHashableU(M) { + return M; +} + +function MakeHashable(M) { + var hash = M.hash; + var hash$1 = Curry.__1(hash); + var eq = M.eq; + var eq$1 = Curry.__2(eq); + return { + hash: hash$1, + eq: eq$1 + }; +} + +function hashableU(hash, eq) { + return { + hash: hash, + eq: eq + }; +} + +function hashable(hash, eq) { + var hash$1 = Curry.__1(hash); + var eq$1 = Curry.__2(eq); + return { + hash: hash$1, + eq: eq$1 + }; +} + +export { + MakeComparableU , + MakeComparable , + comparableU , + comparable , + MakeHashableU , + MakeHashable , + hashableU , + hashable , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_Int.js b/melange-node-modules/melange.belt/belt_Int.js new file mode 100644 index 0000000..819f04d --- /dev/null +++ b/melange-node-modules/melange.belt/belt_Int.js @@ -0,0 +1,16 @@ +// Generated by Melange + + +function fromString(i) { + var i$1 = parseInt(i, 10); + if (isNaN(i$1)) { + return ; + } else { + return i$1; + } +} + +export { + fromString , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_List.js b/melange-node-modules/melange.belt/belt_List.js new file mode 100644 index 0000000..3bca9e1 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_List.js @@ -0,0 +1,1512 @@ +// Generated by Melange + +import * as Belt__Belt_Array from "./belt_Array.js"; +import * as Belt__Belt_SortArray from "./belt_SortArray.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function head(x) { + if (x) { + return Caml_option.some(x.hd); + } + +} + +function headExn(x) { + if (x) { + return x.hd; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; +} + +function tail(x) { + if (x) { + return x.tl; + } + +} + +function tailExn(x) { + if (x) { + return x.tl; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; +} + +function add(xs, x) { + return { + hd: x, + tl: xs + }; +} + +function get(x, n) { + if (n < 0) { + return ; + } else { + var _x = x; + var _n = n; + while(true) { + var n$1 = _n; + var x$1 = _x; + if (!x$1) { + return ; + } + if (n$1 === 0) { + return Caml_option.some(x$1.hd); + } + _n = n$1 - 1 | 0; + _x = x$1.tl; + continue ; + }; + } +} + +function getExn(x, n) { + if (n < 0) { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + var _x = x; + var _n = n; + while(true) { + var n$1 = _n; + var x$1 = _x; + if (x$1) { + if (n$1 === 0) { + return x$1.hd; + } + _n = n$1 - 1 | 0; + _x = x$1.tl; + continue ; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + }; +} + +function partitionAux(p, _cell, _precX, _precY) { + while(true) { + var precY = _precY; + var precX = _precX; + var cell = _cell; + if (!cell) { + return ; + } + var t = cell.tl; + var h = cell.hd; + var next = { + hd: h, + tl: /* [] */0 + }; + if (p(h)) { + precX.tl = next; + _precX = next; + _cell = t; + continue ; + } + precY.tl = next; + _precY = next; + _cell = t; + continue ; + }; +} + +function splitAux(_cell, _precX, _precY) { + while(true) { + var precY = _precY; + var precX = _precX; + var cell = _cell; + if (!cell) { + return ; + } + var match = cell.hd; + var nextA = { + hd: match[0], + tl: /* [] */0 + }; + var nextB = { + hd: match[1], + tl: /* [] */0 + }; + precX.tl = nextA; + precY.tl = nextB; + _precY = nextB; + _precX = nextA; + _cell = cell.tl; + continue ; + }; +} + +function copyAuxCont(_cellX, _prec) { + while(true) { + var prec = _prec; + var cellX = _cellX; + if (!cellX) { + return prec; + } + var next = { + hd: cellX.hd, + tl: /* [] */0 + }; + prec.tl = next; + _prec = next; + _cellX = cellX.tl; + continue ; + }; +} + +function copyAuxWitFilter(f, _cellX, _prec) { + while(true) { + var prec = _prec; + var cellX = _cellX; + if (!cellX) { + return ; + } + var t = cellX.tl; + var h = cellX.hd; + if (f(h)) { + var next = { + hd: h, + tl: /* [] */0 + }; + prec.tl = next; + _prec = next; + _cellX = t; + continue ; + } + _cellX = t; + continue ; + }; +} + +function copyAuxWithFilterIndex(f, _cellX, _prec, _i) { + while(true) { + var i = _i; + var prec = _prec; + var cellX = _cellX; + if (!cellX) { + return ; + } + var t = cellX.tl; + var h = cellX.hd; + if (f(h, i)) { + var next = { + hd: h, + tl: /* [] */0 + }; + prec.tl = next; + _i = i + 1 | 0; + _prec = next; + _cellX = t; + continue ; + } + _i = i + 1 | 0; + _cellX = t; + continue ; + }; +} + +function copyAuxWitFilterMap(f, _cellX, _prec) { + while(true) { + var prec = _prec; + var cellX = _cellX; + if (!cellX) { + return ; + } + var t = cellX.tl; + var h = f(cellX.hd); + if (h !== undefined) { + var next = { + hd: Caml_option.valFromOption(h), + tl: /* [] */0 + }; + prec.tl = next; + _prec = next; + _cellX = t; + continue ; + } + _cellX = t; + continue ; + }; +} + +function removeAssocAuxWithMap(_cellX, x, _prec, f) { + while(true) { + var prec = _prec; + var cellX = _cellX; + if (!cellX) { + return false; + } + var t = cellX.tl; + var h = cellX.hd; + if (f(h[0], x)) { + prec.tl = t; + return true; + } + var next = { + hd: h, + tl: /* [] */0 + }; + prec.tl = next; + _prec = next; + _cellX = t; + continue ; + }; +} + +function setAssocAuxWithMap(_cellX, x, k, _prec, eq) { + while(true) { + var prec = _prec; + var cellX = _cellX; + if (!cellX) { + return false; + } + var t = cellX.tl; + var h = cellX.hd; + if (eq(h[0], x)) { + prec.tl = { + hd: [ + x, + k + ], + tl: t + }; + return true; + } + var next = { + hd: h, + tl: /* [] */0 + }; + prec.tl = next; + _prec = next; + _cellX = t; + continue ; + }; +} + +function copyAuxWithMap(_cellX, _prec, f) { + while(true) { + var prec = _prec; + var cellX = _cellX; + if (!cellX) { + return ; + } + var next = { + hd: f(cellX.hd), + tl: /* [] */0 + }; + prec.tl = next; + _prec = next; + _cellX = cellX.tl; + continue ; + }; +} + +function zipAux(_cellX, _cellY, _prec) { + while(true) { + var prec = _prec; + var cellY = _cellY; + var cellX = _cellX; + if (!cellX) { + return ; + } + if (!cellY) { + return ; + } + var next = { + hd: [ + cellX.hd, + cellY.hd + ], + tl: /* [] */0 + }; + prec.tl = next; + _prec = next; + _cellY = cellY.tl; + _cellX = cellX.tl; + continue ; + }; +} + +function copyAuxWithMap2(f, _cellX, _cellY, _prec) { + while(true) { + var prec = _prec; + var cellY = _cellY; + var cellX = _cellX; + if (!cellX) { + return ; + } + if (!cellY) { + return ; + } + var next = { + hd: f(cellX.hd, cellY.hd), + tl: /* [] */0 + }; + prec.tl = next; + _prec = next; + _cellY = cellY.tl; + _cellX = cellX.tl; + continue ; + }; +} + +function copyAuxWithMapI(f, _i, _cellX, _prec) { + while(true) { + var prec = _prec; + var cellX = _cellX; + var i = _i; + if (!cellX) { + return ; + } + var next = { + hd: f(i, cellX.hd), + tl: /* [] */0 + }; + prec.tl = next; + _prec = next; + _cellX = cellX.tl; + _i = i + 1 | 0; + continue ; + }; +} + +function takeAux(_n, _cell, _prec) { + while(true) { + var prec = _prec; + var cell = _cell; + var n = _n; + if (n === 0) { + return true; + } + if (!cell) { + return false; + } + var cell$1 = { + hd: cell.hd, + tl: /* [] */0 + }; + prec.tl = cell$1; + _prec = cell$1; + _cell = cell.tl; + _n = n - 1 | 0; + continue ; + }; +} + +function splitAtAux(_n, _cell, _prec) { + while(true) { + var prec = _prec; + var cell = _cell; + var n = _n; + if (n === 0) { + return cell; + } + if (!cell) { + return ; + } + var cell$1 = { + hd: cell.hd, + tl: /* [] */0 + }; + prec.tl = cell$1; + _prec = cell$1; + _cell = cell.tl; + _n = n - 1 | 0; + continue ; + }; +} + +function take(lst, n) { + if (n < 0) { + return ; + } + if (n === 0) { + return /* [] */0; + } + if (!lst) { + return ; + } + var cell = { + hd: lst.hd, + tl: /* [] */0 + }; + var has = takeAux(n - 1 | 0, lst.tl, cell); + if (has) { + return cell; + } + +} + +function drop(lst, n) { + if (n < 0) { + return ; + } else { + var _l = lst; + var _n = n; + while(true) { + var n$1 = _n; + var l = _l; + if (n$1 === 0) { + return l; + } + if (!l) { + return ; + } + _n = n$1 - 1 | 0; + _l = l.tl; + continue ; + }; + } +} + +function splitAt(lst, n) { + if (n < 0) { + return ; + } + if (n === 0) { + return [ + /* [] */0, + lst + ]; + } + if (!lst) { + return ; + } + var cell = { + hd: lst.hd, + tl: /* [] */0 + }; + var rest = splitAtAux(n - 1 | 0, lst.tl, cell); + if (rest !== undefined) { + return [ + cell, + rest + ]; + } + +} + +function concat(xs, ys) { + if (!xs) { + return ys; + } + var cell = { + hd: xs.hd, + tl: /* [] */0 + }; + copyAuxCont(xs.tl, cell).tl = ys; + return cell; +} + +function mapU(xs, f) { + if (!xs) { + return /* [] */0; + } + var cell = { + hd: f(xs.hd), + tl: /* [] */0 + }; + copyAuxWithMap(xs.tl, cell, f); + return cell; +} + +function map(xs, f) { + return mapU(xs, Curry.__1(f)); +} + +function zipByU(l1, l2, f) { + if (!l1) { + return /* [] */0; + } + if (!l2) { + return /* [] */0; + } + var cell = { + hd: f(l1.hd, l2.hd), + tl: /* [] */0 + }; + copyAuxWithMap2(f, l1.tl, l2.tl, cell); + return cell; +} + +function zipBy(l1, l2, f) { + return zipByU(l1, l2, Curry.__2(f)); +} + +function mapWithIndexU(xs, f) { + if (!xs) { + return /* [] */0; + } + var cell = { + hd: f(0, xs.hd), + tl: /* [] */0 + }; + copyAuxWithMapI(f, 1, xs.tl, cell); + return cell; +} + +function mapWithIndex(xs, f) { + return mapWithIndexU(xs, Curry.__2(f)); +} + +function makeByU(n, f) { + if (n <= 0) { + return /* [] */0; + } + var headX = { + hd: f(0), + tl: /* [] */0 + }; + var cur = headX; + var i = 1; + while(i < n) { + var v = { + hd: f(i), + tl: /* [] */0 + }; + cur.tl = v; + cur = v; + i = i + 1 | 0; + }; + return headX; +} + +function makeBy(n, f) { + return makeByU(n, Curry.__1(f)); +} + +function make(n, v) { + if (n <= 0) { + return /* [] */0; + } + var headX = { + hd: v, + tl: /* [] */0 + }; + var cur = headX; + var i = 1; + while(i < n) { + var v$1 = { + hd: v, + tl: /* [] */0 + }; + cur.tl = v$1; + cur = v$1; + i = i + 1 | 0; + }; + return headX; +} + +function length(xs) { + var _x = xs; + var _acc = 0; + while(true) { + var acc = _acc; + var x = _x; + if (!x) { + return acc; + } + _acc = acc + 1 | 0; + _x = x.tl; + continue ; + }; +} + +function fillAux(arr, _i, _x) { + while(true) { + var x = _x; + var i = _i; + if (!x) { + return ; + } + arr[i] = x.hd; + _x = x.tl; + _i = i + 1 | 0; + continue ; + }; +} + +function fromArray(a) { + var _i = a.length - 1 | 0; + var _res = /* [] */0; + while(true) { + var res = _res; + var i = _i; + if (i < 0) { + return res; + } + _res = { + hd: a[i], + tl: res + }; + _i = i - 1 | 0; + continue ; + }; +} + +function toArray(x) { + var len = length(x); + var arr = new Array(len); + fillAux(arr, 0, x); + return arr; +} + +function shuffle(xs) { + var v = toArray(xs); + Belt__Belt_Array.shuffleInPlace(v); + return fromArray(v); +} + +function reverseConcat(_l1, _l2) { + while(true) { + var l2 = _l2; + var l1 = _l1; + if (!l1) { + return l2; + } + _l2 = { + hd: l1.hd, + tl: l2 + }; + _l1 = l1.tl; + continue ; + }; +} + +function reverse(l) { + return reverseConcat(l, /* [] */0); +} + +function flattenAux(_prec, _xs) { + while(true) { + var xs = _xs; + var prec = _prec; + if (xs) { + _xs = xs.tl; + _prec = copyAuxCont(xs.hd, prec); + continue ; + } + prec.tl = /* [] */0; + return ; + }; +} + +function flatten(_xs) { + while(true) { + var xs = _xs; + if (!xs) { + return /* [] */0; + } + var match = xs.hd; + if (match) { + var cell = { + hd: match.hd, + tl: /* [] */0 + }; + flattenAux(copyAuxCont(match.tl, cell), xs.tl); + return cell; + } + _xs = xs.tl; + continue ; + }; +} + +function concatMany(xs) { + var len = xs.length; + if (len === 1) { + return xs[0]; + } + if (!len) { + return /* [] */0; + } + var len$1 = xs.length; + var v = xs[len$1 - 1 | 0]; + for(var i = len$1 - 2 | 0; i >= 0; --i){ + v = concat(xs[i], v); + } + return v; +} + +function mapReverseU(l, f) { + var _accu = /* [] */0; + var _xs = l; + while(true) { + var xs = _xs; + var accu = _accu; + if (!xs) { + return accu; + } + _xs = xs.tl; + _accu = { + hd: f(xs.hd), + tl: accu + }; + continue ; + }; +} + +function mapReverse(l, f) { + return mapReverseU(l, Curry.__1(f)); +} + +function forEachU(_xs, f) { + while(true) { + var xs = _xs; + if (!xs) { + return ; + } + f(xs.hd); + _xs = xs.tl; + continue ; + }; +} + +function forEach(xs, f) { + forEachU(xs, Curry.__1(f)); +} + +function forEachWithIndexU(l, f) { + var _xs = l; + var _i = 0; + while(true) { + var i = _i; + var xs = _xs; + if (!xs) { + return ; + } + f(i, xs.hd); + _i = i + 1 | 0; + _xs = xs.tl; + continue ; + }; +} + +function forEachWithIndex(l, f) { + forEachWithIndexU(l, Curry.__2(f)); +} + +function reduceU(_l, _accu, f) { + while(true) { + var accu = _accu; + var l = _l; + if (!l) { + return accu; + } + _accu = f(accu, l.hd); + _l = l.tl; + continue ; + }; +} + +function reduce(l, accu, f) { + return reduceU(l, accu, Curry.__2(f)); +} + +function reduceReverseUnsafeU(l, accu, f) { + if (l) { + return f(reduceReverseUnsafeU(l.tl, accu, f), l.hd); + } else { + return accu; + } +} + +function reduceReverseU(l, acc, f) { + var len = length(l); + if (len < 1000) { + return reduceReverseUnsafeU(l, acc, f); + } else { + return Belt__Belt_Array.reduceReverseU(toArray(l), acc, f); + } +} + +function reduceReverse(l, accu, f) { + return reduceReverseU(l, accu, Curry.__2(f)); +} + +function reduceWithIndexU(l, acc, f) { + var _l = l; + var _acc = acc; + var _i = 0; + while(true) { + var i = _i; + var acc$1 = _acc; + var l$1 = _l; + if (!l$1) { + return acc$1; + } + _i = i + 1 | 0; + _acc = f(acc$1, l$1.hd, i); + _l = l$1.tl; + continue ; + }; +} + +function reduceWithIndex(l, acc, f) { + return reduceWithIndexU(l, acc, Curry.__3(f)); +} + +function mapReverse2U(l1, l2, f) { + var _l1 = l1; + var _l2 = l2; + var _accu = /* [] */0; + while(true) { + var accu = _accu; + var l2$1 = _l2; + var l1$1 = _l1; + if (!l1$1) { + return accu; + } + if (!l2$1) { + return accu; + } + _accu = { + hd: f(l1$1.hd, l2$1.hd), + tl: accu + }; + _l2 = l2$1.tl; + _l1 = l1$1.tl; + continue ; + }; +} + +function mapReverse2(l1, l2, f) { + return mapReverse2U(l1, l2, Curry.__2(f)); +} + +function forEach2U(_l1, _l2, f) { + while(true) { + var l2 = _l2; + var l1 = _l1; + if (!l1) { + return ; + } + if (!l2) { + return ; + } + f(l1.hd, l2.hd); + _l2 = l2.tl; + _l1 = l1.tl; + continue ; + }; +} + +function forEach2(l1, l2, f) { + forEach2U(l1, l2, Curry.__2(f)); +} + +function reduce2U(_l1, _l2, _accu, f) { + while(true) { + var accu = _accu; + var l2 = _l2; + var l1 = _l1; + if (!l1) { + return accu; + } + if (!l2) { + return accu; + } + _accu = f(accu, l1.hd, l2.hd); + _l2 = l2.tl; + _l1 = l1.tl; + continue ; + }; +} + +function reduce2(l1, l2, acc, f) { + return reduce2U(l1, l2, acc, Curry.__3(f)); +} + +function reduceReverse2UnsafeU(l1, l2, accu, f) { + if (l1 && l2) { + return f(reduceReverse2UnsafeU(l1.tl, l2.tl, accu, f), l1.hd, l2.hd); + } else { + return accu; + } +} + +function reduceReverse2U(l1, l2, acc, f) { + var len = length(l1); + if (len < 1000) { + return reduceReverse2UnsafeU(l1, l2, acc, f); + } else { + return Belt__Belt_Array.reduceReverse2U(toArray(l1), toArray(l2), acc, f); + } +} + +function reduceReverse2(l1, l2, acc, f) { + return reduceReverse2U(l1, l2, acc, Curry.__3(f)); +} + +function everyU(_xs, p) { + while(true) { + var xs = _xs; + if (!xs) { + return true; + } + if (!p(xs.hd)) { + return false; + } + _xs = xs.tl; + continue ; + }; +} + +function every(xs, p) { + return everyU(xs, Curry.__1(p)); +} + +function someU(_xs, p) { + while(true) { + var xs = _xs; + if (!xs) { + return false; + } + if (p(xs.hd)) { + return true; + } + _xs = xs.tl; + continue ; + }; +} + +function some(xs, p) { + return someU(xs, Curry.__1(p)); +} + +function every2U(_l1, _l2, p) { + while(true) { + var l2 = _l2; + var l1 = _l1; + if (!l1) { + return true; + } + if (!l2) { + return true; + } + if (!p(l1.hd, l2.hd)) { + return false; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue ; + }; +} + +function every2(l1, l2, p) { + return every2U(l1, l2, Curry.__2(p)); +} + +function cmpByLength(_l1, _l2) { + while(true) { + var l2 = _l2; + var l1 = _l1; + if (!l1) { + if (l2) { + return -1; + } else { + return 0; + } + } + if (!l2) { + return 1; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue ; + }; +} + +function cmpU(_l1, _l2, p) { + while(true) { + var l2 = _l2; + var l1 = _l1; + if (!l1) { + if (l2) { + return -1; + } else { + return 0; + } + } + if (!l2) { + return 1; + } + var c = p(l1.hd, l2.hd); + if (c !== 0) { + return c; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue ; + }; +} + +function cmp(l1, l2, f) { + return cmpU(l1, l2, Curry.__2(f)); +} + +function eqU(_l1, _l2, p) { + while(true) { + var l2 = _l2; + var l1 = _l1; + if (!l1) { + if (l2) { + return false; + } else { + return true; + } + } + if (!l2) { + return false; + } + if (!p(l1.hd, l2.hd)) { + return false; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue ; + }; +} + +function eq(l1, l2, f) { + return eqU(l1, l2, Curry.__2(f)); +} + +function some2U(_l1, _l2, p) { + while(true) { + var l2 = _l2; + var l1 = _l1; + if (!l1) { + return false; + } + if (!l2) { + return false; + } + if (p(l1.hd, l2.hd)) { + return true; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue ; + }; +} + +function some2(l1, l2, p) { + return some2U(l1, l2, Curry.__2(p)); +} + +function hasU(_xs, x, eq) { + while(true) { + var xs = _xs; + if (!xs) { + return false; + } + if (eq(xs.hd, x)) { + return true; + } + _xs = xs.tl; + continue ; + }; +} + +function has(xs, x, eq) { + return hasU(xs, x, Curry.__2(eq)); +} + +function getAssocU(_xs, x, eq) { + while(true) { + var xs = _xs; + if (!xs) { + return ; + } + var match = xs.hd; + if (eq(match[0], x)) { + return Caml_option.some(match[1]); + } + _xs = xs.tl; + continue ; + }; +} + +function getAssoc(xs, x, eq) { + return getAssocU(xs, x, Curry.__2(eq)); +} + +function hasAssocU(_xs, x, eq) { + while(true) { + var xs = _xs; + if (!xs) { + return false; + } + if (eq(xs.hd[0], x)) { + return true; + } + _xs = xs.tl; + continue ; + }; +} + +function hasAssoc(xs, x, eq) { + return hasAssocU(xs, x, Curry.__2(eq)); +} + +function removeAssocU(xs, x, eq) { + if (!xs) { + return /* [] */0; + } + var l = xs.tl; + var pair = xs.hd; + if (eq(pair[0], x)) { + return l; + } + var cell = { + hd: pair, + tl: /* [] */0 + }; + var removed = removeAssocAuxWithMap(l, x, cell, eq); + if (removed) { + return cell; + } else { + return xs; + } +} + +function removeAssoc(xs, x, eq) { + return removeAssocU(xs, x, Curry.__2(eq)); +} + +function setAssocU(xs, x, k, eq) { + if (!xs) { + return { + hd: [ + x, + k + ], + tl: /* [] */0 + }; + } + var l = xs.tl; + var pair = xs.hd; + if (eq(pair[0], x)) { + return { + hd: [ + x, + k + ], + tl: l + }; + } + var cell = { + hd: pair, + tl: /* [] */0 + }; + var replaced = setAssocAuxWithMap(l, x, k, cell, eq); + if (replaced) { + return cell; + } else { + return { + hd: [ + x, + k + ], + tl: xs + }; + } +} + +function setAssoc(xs, x, k, eq) { + return setAssocU(xs, x, k, Curry.__2(eq)); +} + +function sortU(xs, cmp) { + var arr = toArray(xs); + Belt__Belt_SortArray.stableSortInPlaceByU(arr, cmp); + return fromArray(arr); +} + +function sort(xs, cmp) { + return sortU(xs, Curry.__2(cmp)); +} + +function getByU(_xs, p) { + while(true) { + var xs = _xs; + if (!xs) { + return ; + } + var x = xs.hd; + if (p(x)) { + return Caml_option.some(x); + } + _xs = xs.tl; + continue ; + }; +} + +function getBy(xs, p) { + return getByU(xs, Curry.__1(p)); +} + +function keepU(_xs, p) { + while(true) { + var xs = _xs; + if (!xs) { + return /* [] */0; + } + var t = xs.tl; + var h = xs.hd; + if (p(h)) { + var cell = { + hd: h, + tl: /* [] */0 + }; + copyAuxWitFilter(p, t, cell); + return cell; + } + _xs = t; + continue ; + }; +} + +function keep(xs, p) { + return keepU(xs, Curry.__1(p)); +} + +function keepWithIndexU(xs, p) { + var _xs = xs; + var _i = 0; + while(true) { + var i = _i; + var xs$1 = _xs; + if (!xs$1) { + return /* [] */0; + } + var t = xs$1.tl; + var h = xs$1.hd; + if (p(h, i)) { + var cell = { + hd: h, + tl: /* [] */0 + }; + copyAuxWithFilterIndex(p, t, cell, i + 1 | 0); + return cell; + } + _i = i + 1 | 0; + _xs = t; + continue ; + }; +} + +function keepWithIndex(xs, p) { + return keepWithIndexU(xs, Curry.__2(p)); +} + +function keepMapU(_xs, p) { + while(true) { + var xs = _xs; + if (!xs) { + return /* [] */0; + } + var t = xs.tl; + var h = p(xs.hd); + if (h !== undefined) { + var cell = { + hd: Caml_option.valFromOption(h), + tl: /* [] */0 + }; + copyAuxWitFilterMap(p, t, cell); + return cell; + } + _xs = t; + continue ; + }; +} + +function keepMap(xs, p) { + return keepMapU(xs, Curry.__1(p)); +} + +function partitionU(l, p) { + if (!l) { + return [ + /* [] */0, + /* [] */0 + ]; + } + var h = l.hd; + var nextX = { + hd: h, + tl: /* [] */0 + }; + var nextY = { + hd: h, + tl: /* [] */0 + }; + var b = p(h); + partitionAux(p, l.tl, nextX, nextY); + if (b) { + return [ + nextX, + nextY.tl + ]; + } else { + return [ + nextX.tl, + nextY + ]; + } +} + +function partition(l, p) { + return partitionU(l, Curry.__1(p)); +} + +function unzip(xs) { + if (!xs) { + return [ + /* [] */0, + /* [] */0 + ]; + } + var match = xs.hd; + var cellX = { + hd: match[0], + tl: /* [] */0 + }; + var cellY = { + hd: match[1], + tl: /* [] */0 + }; + splitAux(xs.tl, cellX, cellY); + return [ + cellX, + cellY + ]; +} + +function zip(l1, l2) { + if (!l1) { + return /* [] */0; + } + if (!l2) { + return /* [] */0; + } + var cell = { + hd: [ + l1.hd, + l2.hd + ], + tl: /* [] */0 + }; + zipAux(l1.tl, l2.tl, cell); + return cell; +} + +var size = length; + +var filter = keep; + +var filterWithIndex = keepWithIndex; + +export { + length , + size , + head , + headExn , + tail , + tailExn , + add , + get , + getExn , + make , + makeByU , + makeBy , + shuffle , + drop , + take , + splitAt , + concat , + concatMany , + reverseConcat , + flatten , + mapU , + map , + zip , + zipByU , + zipBy , + mapWithIndexU , + mapWithIndex , + fromArray , + toArray , + reverse , + mapReverseU , + mapReverse , + forEachU , + forEach , + forEachWithIndexU , + forEachWithIndex , + reduceU , + reduce , + reduceWithIndexU , + reduceWithIndex , + reduceReverseU , + reduceReverse , + mapReverse2U , + mapReverse2 , + forEach2U , + forEach2 , + reduce2U , + reduce2 , + reduceReverse2U , + reduceReverse2 , + everyU , + every , + someU , + some , + every2U , + every2 , + some2U , + some2 , + cmpByLength , + cmpU , + cmp , + eqU , + eq , + hasU , + has , + getByU , + getBy , + keepU , + keep , + filter , + keepWithIndexU , + keepWithIndex , + filterWithIndex , + keepMapU , + keepMap , + partitionU , + partition , + unzip , + getAssocU , + getAssoc , + hasAssocU , + hasAssoc , + removeAssocU , + removeAssoc , + setAssocU , + setAssoc , + sortU , + sort , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_Map.js b/melange-node-modules/melange.belt/belt_Map.js new file mode 100644 index 0000000..a2e683d --- /dev/null +++ b/melange-node-modules/melange.belt/belt_Map.js @@ -0,0 +1,367 @@ +// Generated by Melange + +import * as Belt__Belt_MapDict from "./belt_MapDict.js"; +import * as Curry from "melange.js/curry.js"; + +function fromArray(data, id) { + var cmp = id.cmp; + return { + cmp: cmp, + data: Belt__Belt_MapDict.fromArray(data, cmp) + }; +} + +function remove(m, x) { + var odata = m.data; + var cmp = m.cmp; + var newData = Belt__Belt_MapDict.remove(odata, x, cmp); + if (newData === odata) { + return m; + } else { + return { + cmp: cmp, + data: newData + }; + } +} + +function removeMany(m, x) { + var cmp = m.cmp; + var newData = Belt__Belt_MapDict.removeMany(m.data, x, cmp); + return { + cmp: cmp, + data: newData + }; +} + +function set(m, key, d) { + var cmp = m.cmp; + return { + cmp: cmp, + data: Belt__Belt_MapDict.set(m.data, key, d, cmp) + }; +} + +function mergeMany(m, e) { + var cmp = m.cmp; + return { + cmp: cmp, + data: Belt__Belt_MapDict.mergeMany(m.data, e, cmp) + }; +} + +function updateU(m, key, f) { + var cmp = m.cmp; + return { + cmp: cmp, + data: Belt__Belt_MapDict.updateU(m.data, key, f, cmp) + }; +} + +function update(m, key, f) { + return updateU(m, key, Curry.__1(f)); +} + +function split(m, x) { + var cmp = m.cmp; + var match = Belt__Belt_MapDict.split(m.data, x, cmp); + var match$1 = match[0]; + return [ + [ + { + cmp: cmp, + data: match$1[0] + }, + { + cmp: cmp, + data: match$1[1] + } + ], + match[1] + ]; +} + +function mergeU(s1, s2, f) { + var cmp = s1.cmp; + return { + cmp: cmp, + data: Belt__Belt_MapDict.mergeU(s1.data, s2.data, f, cmp) + }; +} + +function merge(s1, s2, f) { + return mergeU(s1, s2, Curry.__3(f)); +} + +function make(id) { + return { + cmp: id.cmp, + data: undefined + }; +} + +function isEmpty(map) { + return Belt__Belt_MapDict.isEmpty(map.data); +} + +function findFirstByU(m, f) { + return Belt__Belt_MapDict.findFirstByU(m.data, f); +} + +function findFirstBy(m, f) { + return Belt__Belt_MapDict.findFirstByU(m.data, Curry.__2(f)); +} + +function forEachU(m, f) { + Belt__Belt_MapDict.forEachU(m.data, f); +} + +function forEach(m, f) { + Belt__Belt_MapDict.forEachU(m.data, Curry.__2(f)); +} + +function reduceU(m, acc, f) { + return Belt__Belt_MapDict.reduceU(m.data, acc, f); +} + +function reduce(m, acc, f) { + return reduceU(m, acc, Curry.__3(f)); +} + +function everyU(m, f) { + return Belt__Belt_MapDict.everyU(m.data, f); +} + +function every(m, f) { + return Belt__Belt_MapDict.everyU(m.data, Curry.__2(f)); +} + +function someU(m, f) { + return Belt__Belt_MapDict.someU(m.data, f); +} + +function some(m, f) { + return Belt__Belt_MapDict.someU(m.data, Curry.__2(f)); +} + +function keepU(m, f) { + return { + cmp: m.cmp, + data: Belt__Belt_MapDict.keepU(m.data, f) + }; +} + +function keep(m, f) { + return keepU(m, Curry.__2(f)); +} + +function partitionU(m, p) { + var cmp = m.cmp; + var match = Belt__Belt_MapDict.partitionU(m.data, p); + return [ + { + cmp: cmp, + data: match[0] + }, + { + cmp: cmp, + data: match[1] + } + ]; +} + +function partition(m, p) { + return partitionU(m, Curry.__2(p)); +} + +function mapU(m, f) { + return { + cmp: m.cmp, + data: Belt__Belt_MapDict.mapU(m.data, f) + }; +} + +function map(m, f) { + return mapU(m, Curry.__1(f)); +} + +function mapWithKeyU(m, f) { + return { + cmp: m.cmp, + data: Belt__Belt_MapDict.mapWithKeyU(m.data, f) + }; +} + +function mapWithKey(m, f) { + return mapWithKeyU(m, Curry.__2(f)); +} + +function size(map) { + return Belt__Belt_MapDict.size(map.data); +} + +function toList(map) { + return Belt__Belt_MapDict.toList(map.data); +} + +function toArray(m) { + return Belt__Belt_MapDict.toArray(m.data); +} + +function keysToArray(m) { + return Belt__Belt_MapDict.keysToArray(m.data); +} + +function valuesToArray(m) { + return Belt__Belt_MapDict.valuesToArray(m.data); +} + +function minKey(m) { + return Belt__Belt_MapDict.minKey(m.data); +} + +function minKeyUndefined(m) { + return Belt__Belt_MapDict.minKeyUndefined(m.data); +} + +function maxKey(m) { + return Belt__Belt_MapDict.maxKey(m.data); +} + +function maxKeyUndefined(m) { + return Belt__Belt_MapDict.maxKeyUndefined(m.data); +} + +function minimum(m) { + return Belt__Belt_MapDict.minimum(m.data); +} + +function minUndefined(m) { + return Belt__Belt_MapDict.minUndefined(m.data); +} + +function maximum(m) { + return Belt__Belt_MapDict.maximum(m.data); +} + +function maxUndefined(m) { + return Belt__Belt_MapDict.maxUndefined(m.data); +} + +function get(map, x) { + return Belt__Belt_MapDict.get(map.data, x, map.cmp); +} + +function getUndefined(map, x) { + return Belt__Belt_MapDict.getUndefined(map.data, x, map.cmp); +} + +function getWithDefault(map, x, def) { + return Belt__Belt_MapDict.getWithDefault(map.data, x, def, map.cmp); +} + +function getExn(map, x) { + return Belt__Belt_MapDict.getExn(map.data, x, map.cmp); +} + +function has(map, x) { + return Belt__Belt_MapDict.has(map.data, x, map.cmp); +} + +function checkInvariantInternal(m) { + Belt__Belt_MapDict.checkInvariantInternal(m.data); +} + +function eqU(m1, m2, veq) { + return Belt__Belt_MapDict.eqU(m1.data, m2.data, m1.cmp, veq); +} + +function eq(m1, m2, veq) { + return eqU(m1, m2, Curry.__2(veq)); +} + +function cmpU(m1, m2, vcmp) { + return Belt__Belt_MapDict.cmpU(m1.data, m2.data, m1.cmp, vcmp); +} + +function cmp(m1, m2, vcmp) { + return cmpU(m1, m2, Curry.__2(vcmp)); +} + +function getData(m) { + return m.data; +} + +function getId(m) { + var cmp = m.cmp; + return { + cmp: cmp + }; +} + +function packIdData(id, data) { + return { + cmp: id.cmp, + data: data + }; +} + +export { + make , + isEmpty , + has , + cmpU , + cmp , + eqU , + eq , + findFirstByU , + findFirstBy , + forEachU , + forEach , + reduceU , + reduce , + everyU , + every , + someU , + some , + size , + toArray , + toList , + fromArray , + keysToArray , + valuesToArray , + minKey , + minKeyUndefined , + maxKey , + maxKeyUndefined , + minimum , + minUndefined , + maximum , + maxUndefined , + get , + getUndefined , + getWithDefault , + getExn , + remove , + removeMany , + set , + updateU , + update , + mergeMany , + mergeU , + merge , + keepU , + keep , + partitionU , + partition , + split , + mapU , + map , + mapWithKeyU , + mapWithKey , + getData , + getId , + packIdData , + checkInvariantInternal , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_MapDict.js b/melange-node-modules/melange.belt/belt_MapDict.js new file mode 100644 index 0000000..50447c2 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_MapDict.js @@ -0,0 +1,423 @@ +// Generated by Melange + +import * as Belt__Belt_internalAVLtree from "./belt_internalAVLtree.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function set(t, newK, newD, cmp) { + if (t === undefined) { + return Belt__Belt_internalAVLtree.singleton(newK, newD); + } + var n = Caml_option.valFromOption(t); + var k = n.k; + var c = cmp(newK, k); + if (c === 0) { + return Belt__Belt_internalAVLtree.updateValue(n, newD); + } + var l = n.l; + var r = n.r; + var v = n.v; + if (c < 0) { + return Belt__Belt_internalAVLtree.bal(set(l, newK, newD, cmp), k, v, r); + } else { + return Belt__Belt_internalAVLtree.bal(l, k, v, set(r, newK, newD, cmp)); + } +} + +function updateU(t, newK, f, cmp) { + if (t !== undefined) { + var n = Caml_option.valFromOption(t); + var k = n.k; + var c = cmp(newK, k); + if (c === 0) { + var newD = f(Caml_option.some(n.v)); + if (newD !== undefined) { + return Belt__Belt_internalAVLtree.updateValue(n, Caml_option.valFromOption(newD)); + } + var l = n.l; + var r = n.r; + if (l === undefined) { + return r; + } + if (r === undefined) { + return l; + } + var rn = Caml_option.valFromOption(r); + var kr = { + contents: rn.k + }; + var vr = { + contents: rn.v + }; + var r$1 = Belt__Belt_internalAVLtree.removeMinAuxWithRef(rn, kr, vr); + return Belt__Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); + } + var l$1 = n.l; + var r$2 = n.r; + var v = n.v; + if (c < 0) { + var ll = updateU(l$1, newK, f, cmp); + if (l$1 === ll) { + return t; + } else { + return Belt__Belt_internalAVLtree.bal(ll, k, v, r$2); + } + } + var rr = updateU(r$2, newK, f, cmp); + if (r$2 === rr) { + return t; + } else { + return Belt__Belt_internalAVLtree.bal(l$1, k, v, rr); + } + } + var newD$1 = f(undefined); + if (newD$1 !== undefined) { + return Belt__Belt_internalAVLtree.singleton(newK, Caml_option.valFromOption(newD$1)); + } else { + return t; + } +} + +function update(t, newK, f, cmp) { + return updateU(t, newK, Curry.__1(f), cmp); +} + +function removeAux0(n, x, cmp) { + var v = n.k; + var l = n.l; + var r = n.r; + var c = cmp(x, v); + if (c === 0) { + if (l === undefined) { + return r; + } + if (r === undefined) { + return l; + } + var rn = Caml_option.valFromOption(r); + var kr = { + contents: rn.k + }; + var vr = { + contents: rn.v + }; + var r$1 = Belt__Belt_internalAVLtree.removeMinAuxWithRef(rn, kr, vr); + return Belt__Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); + } + if (c < 0) { + if (l === undefined) { + return n; + } + var ll = removeAux0(Caml_option.valFromOption(l), x, cmp); + if (ll === l) { + return n; + } else { + return Belt__Belt_internalAVLtree.bal(ll, v, n.v, r); + } + } + if (r === undefined) { + return n; + } + var rr = removeAux0(Caml_option.valFromOption(r), x, cmp); + if (rr === r) { + return n; + } else { + return Belt__Belt_internalAVLtree.bal(l, v, n.v, rr); + } +} + +function remove(n, x, cmp) { + if (n !== undefined) { + return removeAux0(n, x, cmp); + } + +} + +function mergeMany(h, arr, cmp) { + var len = arr.length; + var v = h; + for(var i = 0; i < len; ++i){ + var match = arr[i]; + v = set(v, match[0], match[1], cmp); + } + return v; +} + +function splitAuxPivot(n, x, pres, cmp) { + var v = n.k; + var d = n.v; + var l = n.l; + var r = n.r; + var c = cmp(x, v); + if (c === 0) { + pres.contents = Caml_option.some(d); + return [ + l, + r + ]; + } + if (c < 0) { + if (l === undefined) { + return [ + undefined, + n + ]; + } + var match = splitAuxPivot(Caml_option.valFromOption(l), x, pres, cmp); + return [ + match[0], + Belt__Belt_internalAVLtree.join(match[1], v, d, r) + ]; + } + if (r === undefined) { + return [ + n, + undefined + ]; + } + var match$1 = splitAuxPivot(Caml_option.valFromOption(r), x, pres, cmp); + return [ + Belt__Belt_internalAVLtree.join(l, v, d, match$1[0]), + match$1[1] + ]; +} + +function split(n, x, cmp) { + if (n === undefined) { + return [ + [ + undefined, + undefined + ], + undefined + ]; + } + var pres = { + contents: undefined + }; + var v = splitAuxPivot(n, x, pres, cmp); + return [ + v, + pres.contents + ]; +} + +function mergeU(s1, s2, f, cmp) { + if (s1 === undefined) { + if (s2 !== undefined) { + return Belt__Belt_internalAVLtree.keepMapU(s2, (function (k, v) { + return f(k, undefined, Caml_option.some(v)); + })); + } else { + return ; + } + } + var s1n = Caml_option.valFromOption(s1); + if (s2 === undefined) { + return Belt__Belt_internalAVLtree.keepMapU(s1, (function (k, v) { + return f(k, Caml_option.some(v), undefined); + })); + } + var s2n = Caml_option.valFromOption(s2); + if (s1n.h >= s2n.h) { + var v1 = s1n.k; + var d1 = s1n.v; + var l1 = s1n.l; + var r1 = s1n.r; + var d2 = { + contents: undefined + }; + var match = splitAuxPivot(s2n, v1, d2, cmp); + var d2$1 = d2.contents; + var newLeft = mergeU(l1, match[0], f, cmp); + var newD = f(v1, Caml_option.some(d1), d2$1); + var newRight = mergeU(r1, match[1], f, cmp); + return Belt__Belt_internalAVLtree.concatOrJoin(newLeft, v1, newD, newRight); + } + var v2 = s2n.k; + var d2$2 = s2n.v; + var l2 = s2n.l; + var r2 = s2n.r; + var d1$1 = { + contents: undefined + }; + var match$1 = splitAuxPivot(s1n, v2, d1$1, cmp); + var d1$2 = d1$1.contents; + var newLeft$1 = mergeU(match$1[0], l2, f, cmp); + var newD$1 = f(v2, d1$2, Caml_option.some(d2$2)); + var newRight$1 = mergeU(match$1[1], r2, f, cmp); + return Belt__Belt_internalAVLtree.concatOrJoin(newLeft$1, v2, newD$1, newRight$1); +} + +function merge(s1, s2, f, cmp) { + return mergeU(s1, s2, Curry.__3(f), cmp); +} + +function removeMany(t, keys, cmp) { + var len = keys.length; + if (t !== undefined) { + var _t = t; + var _i = 0; + while(true) { + var i = _i; + var t$1 = _t; + if (i >= len) { + return t$1; + } + var ele = keys[i]; + var u = removeAux0(t$1, ele, cmp); + if (u === undefined) { + return u; + } + _i = i + 1 | 0; + _t = Caml_option.valFromOption(u); + continue ; + }; + } + +} + +var empty; + +var isEmpty = Belt__Belt_internalAVLtree.isEmpty; + +var has = Belt__Belt_internalAVLtree.has; + +var cmpU = Belt__Belt_internalAVLtree.cmpU; + +var cmp = Belt__Belt_internalAVLtree.cmp; + +var eqU = Belt__Belt_internalAVLtree.eqU; + +var eq = Belt__Belt_internalAVLtree.eq; + +var findFirstByU = Belt__Belt_internalAVLtree.findFirstByU; + +var findFirstBy = Belt__Belt_internalAVLtree.findFirstBy; + +var forEachU = Belt__Belt_internalAVLtree.forEachU; + +var forEach = Belt__Belt_internalAVLtree.forEach; + +var reduceU = Belt__Belt_internalAVLtree.reduceU; + +var reduce = Belt__Belt_internalAVLtree.reduce; + +var everyU = Belt__Belt_internalAVLtree.everyU; + +var every = Belt__Belt_internalAVLtree.every; + +var someU = Belt__Belt_internalAVLtree.someU; + +var some = Belt__Belt_internalAVLtree.some; + +var size = Belt__Belt_internalAVLtree.size; + +var toList = Belt__Belt_internalAVLtree.toList; + +var toArray = Belt__Belt_internalAVLtree.toArray; + +var fromArray = Belt__Belt_internalAVLtree.fromArray; + +var keysToArray = Belt__Belt_internalAVLtree.keysToArray; + +var valuesToArray = Belt__Belt_internalAVLtree.valuesToArray; + +var minKey = Belt__Belt_internalAVLtree.minKey; + +var minKeyUndefined = Belt__Belt_internalAVLtree.minKeyUndefined; + +var maxKey = Belt__Belt_internalAVLtree.maxKey; + +var maxKeyUndefined = Belt__Belt_internalAVLtree.maxKeyUndefined; + +var minimum = Belt__Belt_internalAVLtree.minimum; + +var minUndefined = Belt__Belt_internalAVLtree.minUndefined; + +var maximum = Belt__Belt_internalAVLtree.maximum; + +var maxUndefined = Belt__Belt_internalAVLtree.maxUndefined; + +var get = Belt__Belt_internalAVLtree.get; + +var getUndefined = Belt__Belt_internalAVLtree.getUndefined; + +var getWithDefault = Belt__Belt_internalAVLtree.getWithDefault; + +var getExn = Belt__Belt_internalAVLtree.getExn; + +var checkInvariantInternal = Belt__Belt_internalAVLtree.checkInvariantInternal; + +var keepU = Belt__Belt_internalAVLtree.keepSharedU; + +var keep = Belt__Belt_internalAVLtree.keepShared; + +var partitionU = Belt__Belt_internalAVLtree.partitionSharedU; + +var partition = Belt__Belt_internalAVLtree.partitionShared; + +var mapU = Belt__Belt_internalAVLtree.mapU; + +var map = Belt__Belt_internalAVLtree.map; + +var mapWithKeyU = Belt__Belt_internalAVLtree.mapWithKeyU; + +var mapWithKey = Belt__Belt_internalAVLtree.mapWithKey; + +export { + empty , + isEmpty , + has , + cmpU , + cmp , + eqU , + eq , + findFirstByU , + findFirstBy , + forEachU , + forEach , + reduceU , + reduce , + everyU , + every , + someU , + some , + size , + toList , + toArray , + fromArray , + keysToArray , + valuesToArray , + minKey , + minKeyUndefined , + maxKey , + maxKeyUndefined , + minimum , + minUndefined , + maximum , + maxUndefined , + get , + getUndefined , + getWithDefault , + getExn , + checkInvariantInternal , + remove , + removeMany , + set , + updateU , + update , + mergeU , + merge , + mergeMany , + keepU , + keep , + partitionU , + partition , + split , + mapU , + map , + mapWithKeyU , + mapWithKey , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_MapInt.js b/melange-node-modules/melange.belt/belt_MapInt.js new file mode 100644 index 0000000..5fd87aa --- /dev/null +++ b/melange-node-modules/melange.belt/belt_MapInt.js @@ -0,0 +1,311 @@ +// Generated by Melange + +import * as Belt__Belt_internalAVLtree from "./belt_internalAVLtree.js"; +import * as Belt__Belt_internalMapInt from "./belt_internalMapInt.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function set(t, newK, newD) { + if (t === undefined) { + return Belt__Belt_internalAVLtree.singleton(newK, newD); + } + var n = Caml_option.valFromOption(t); + var k = n.k; + if (newK === k) { + return Belt__Belt_internalAVLtree.updateValue(n, newD); + } + var v = n.v; + if (newK < k) { + return Belt__Belt_internalAVLtree.bal(set(n.l, newK, newD), k, v, n.r); + } else { + return Belt__Belt_internalAVLtree.bal(n.l, k, v, set(n.r, newK, newD)); + } +} + +function updateU(t, x, f) { + if (t !== undefined) { + var n = Caml_option.valFromOption(t); + var k = n.k; + if (x === k) { + var data = f(Caml_option.some(n.v)); + if (data !== undefined) { + return Belt__Belt_internalAVLtree.updateValue(n, Caml_option.valFromOption(data)); + } + var l = n.l; + var r = n.r; + if (l === undefined) { + return r; + } + if (r === undefined) { + return l; + } + var rn = Caml_option.valFromOption(r); + var kr = { + contents: rn.k + }; + var vr = { + contents: rn.v + }; + var r$1 = Belt__Belt_internalAVLtree.removeMinAuxWithRef(rn, kr, vr); + return Belt__Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); + } + var v = n.v; + var l$1 = n.l; + var r$2 = n.r; + if (x < k) { + var ll = updateU(l$1, x, f); + if (l$1 === ll) { + return t; + } else { + return Belt__Belt_internalAVLtree.bal(ll, k, v, r$2); + } + } + var rr = updateU(r$2, x, f); + if (r$2 === rr) { + return t; + } else { + return Belt__Belt_internalAVLtree.bal(l$1, k, v, rr); + } + } + var data$1 = f(undefined); + if (data$1 !== undefined) { + return Belt__Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); + } else { + return t; + } +} + +function update(t, x, f) { + return updateU(t, x, Curry.__1(f)); +} + +function removeAux(n, x) { + var v = n.k; + var l = n.l; + var r = n.r; + if (x === v) { + if (l === undefined) { + return r; + } + if (r === undefined) { + return l; + } + var rn = Caml_option.valFromOption(r); + var kr = { + contents: rn.k + }; + var vr = { + contents: rn.v + }; + var r$1 = Belt__Belt_internalAVLtree.removeMinAuxWithRef(rn, kr, vr); + return Belt__Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); + } + if (x < v) { + if (l === undefined) { + return n; + } + var ll = removeAux(Caml_option.valFromOption(l), x); + if (ll === l) { + return n; + } else { + return Belt__Belt_internalAVLtree.bal(ll, v, n.v, r); + } + } + if (r === undefined) { + return n; + } + var rr = removeAux(Caml_option.valFromOption(r), x); + return Belt__Belt_internalAVLtree.bal(l, v, n.v, rr); +} + +function remove(n, x) { + if (n !== undefined) { + return removeAux(n, x); + } + +} + +function removeMany(t, keys) { + var len = keys.length; + if (t !== undefined) { + var _t = t; + var _i = 0; + while(true) { + var i = _i; + var t$1 = _t; + if (i >= len) { + return t$1; + } + var ele = keys[i]; + var u = removeAux(t$1, ele); + if (u === undefined) { + return u; + } + _i = i + 1 | 0; + _t = Caml_option.valFromOption(u); + continue ; + }; + } + +} + +function mergeMany(h, arr) { + var len = arr.length; + var v = h; + for(var i = 0; i < len; ++i){ + var match = arr[i]; + v = set(v, match[0], match[1]); + } + return v; +} + +var empty; + +var isEmpty = Belt__Belt_internalAVLtree.isEmpty; + +var has = Belt__Belt_internalMapInt.has; + +var cmpU = Belt__Belt_internalMapInt.cmpU; + +var cmp = Belt__Belt_internalMapInt.cmp; + +var eqU = Belt__Belt_internalMapInt.eqU; + +var eq = Belt__Belt_internalMapInt.eq; + +var findFirstByU = Belt__Belt_internalAVLtree.findFirstByU; + +var findFirstBy = Belt__Belt_internalAVLtree.findFirstBy; + +var forEachU = Belt__Belt_internalAVLtree.forEachU; + +var forEach = Belt__Belt_internalAVLtree.forEach; + +var reduceU = Belt__Belt_internalAVLtree.reduceU; + +var reduce = Belt__Belt_internalAVLtree.reduce; + +var everyU = Belt__Belt_internalAVLtree.everyU; + +var every = Belt__Belt_internalAVLtree.every; + +var someU = Belt__Belt_internalAVLtree.someU; + +var some = Belt__Belt_internalAVLtree.some; + +var size = Belt__Belt_internalAVLtree.size; + +var toList = Belt__Belt_internalAVLtree.toList; + +var toArray = Belt__Belt_internalAVLtree.toArray; + +var fromArray = Belt__Belt_internalMapInt.fromArray; + +var keysToArray = Belt__Belt_internalAVLtree.keysToArray; + +var valuesToArray = Belt__Belt_internalAVLtree.valuesToArray; + +var minKey = Belt__Belt_internalAVLtree.minKey; + +var minKeyUndefined = Belt__Belt_internalAVLtree.minKeyUndefined; + +var maxKey = Belt__Belt_internalAVLtree.maxKey; + +var maxKeyUndefined = Belt__Belt_internalAVLtree.maxKeyUndefined; + +var minimum = Belt__Belt_internalAVLtree.minimum; + +var minUndefined = Belt__Belt_internalAVLtree.minUndefined; + +var maximum = Belt__Belt_internalAVLtree.maximum; + +var maxUndefined = Belt__Belt_internalAVLtree.maxUndefined; + +var get = Belt__Belt_internalMapInt.get; + +var getUndefined = Belt__Belt_internalMapInt.getUndefined; + +var getWithDefault = Belt__Belt_internalMapInt.getWithDefault; + +var getExn = Belt__Belt_internalMapInt.getExn; + +var checkInvariantInternal = Belt__Belt_internalAVLtree.checkInvariantInternal; + +var mergeU = Belt__Belt_internalMapInt.mergeU; + +var merge = Belt__Belt_internalMapInt.merge; + +var keepU = Belt__Belt_internalAVLtree.keepSharedU; + +var keep = Belt__Belt_internalAVLtree.keepShared; + +var partitionU = Belt__Belt_internalAVLtree.partitionSharedU; + +var partition = Belt__Belt_internalAVLtree.partitionShared; + +var split = Belt__Belt_internalMapInt.split; + +var mapU = Belt__Belt_internalAVLtree.mapU; + +var map = Belt__Belt_internalAVLtree.map; + +var mapWithKeyU = Belt__Belt_internalAVLtree.mapWithKeyU; + +var mapWithKey = Belt__Belt_internalAVLtree.mapWithKey; + +export { + empty , + isEmpty , + has , + cmpU , + cmp , + eqU , + eq , + findFirstByU , + findFirstBy , + forEachU , + forEach , + reduceU , + reduce , + everyU , + every , + someU , + some , + size , + toList , + toArray , + fromArray , + keysToArray , + valuesToArray , + minKey , + minKeyUndefined , + maxKey , + maxKeyUndefined , + minimum , + minUndefined , + maximum , + maxUndefined , + get , + getUndefined , + getWithDefault , + getExn , + checkInvariantInternal , + remove , + removeMany , + set , + updateU , + update , + mergeU , + merge , + mergeMany , + keepU , + keep , + partitionU , + partition , + split , + mapU , + map , + mapWithKeyU , + mapWithKey , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_MapString.js b/melange-node-modules/melange.belt/belt_MapString.js new file mode 100644 index 0000000..a554feb --- /dev/null +++ b/melange-node-modules/melange.belt/belt_MapString.js @@ -0,0 +1,311 @@ +// Generated by Melange + +import * as Belt__Belt_internalAVLtree from "./belt_internalAVLtree.js"; +import * as Belt__Belt_internalMapString from "./belt_internalMapString.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function set(t, newK, newD) { + if (t === undefined) { + return Belt__Belt_internalAVLtree.singleton(newK, newD); + } + var n = Caml_option.valFromOption(t); + var k = n.k; + if (newK === k) { + return Belt__Belt_internalAVLtree.updateValue(n, newD); + } + var v = n.v; + if (newK < k) { + return Belt__Belt_internalAVLtree.bal(set(n.l, newK, newD), k, v, n.r); + } else { + return Belt__Belt_internalAVLtree.bal(n.l, k, v, set(n.r, newK, newD)); + } +} + +function updateU(t, x, f) { + if (t !== undefined) { + var n = Caml_option.valFromOption(t); + var k = n.k; + if (x === k) { + var data = f(Caml_option.some(n.v)); + if (data !== undefined) { + return Belt__Belt_internalAVLtree.updateValue(n, Caml_option.valFromOption(data)); + } + var l = n.l; + var r = n.r; + if (l === undefined) { + return r; + } + if (r === undefined) { + return l; + } + var rn = Caml_option.valFromOption(r); + var kr = { + contents: rn.k + }; + var vr = { + contents: rn.v + }; + var r$1 = Belt__Belt_internalAVLtree.removeMinAuxWithRef(rn, kr, vr); + return Belt__Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); + } + var v = n.v; + var l$1 = n.l; + var r$2 = n.r; + if (x < k) { + var ll = updateU(l$1, x, f); + if (l$1 === ll) { + return t; + } else { + return Belt__Belt_internalAVLtree.bal(ll, k, v, r$2); + } + } + var rr = updateU(r$2, x, f); + if (r$2 === rr) { + return t; + } else { + return Belt__Belt_internalAVLtree.bal(l$1, k, v, rr); + } + } + var data$1 = f(undefined); + if (data$1 !== undefined) { + return Belt__Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); + } else { + return t; + } +} + +function update(t, x, f) { + return updateU(t, x, Curry.__1(f)); +} + +function removeAux(n, x) { + var v = n.k; + var l = n.l; + var r = n.r; + if (x === v) { + if (l === undefined) { + return r; + } + if (r === undefined) { + return l; + } + var rn = Caml_option.valFromOption(r); + var kr = { + contents: rn.k + }; + var vr = { + contents: rn.v + }; + var r$1 = Belt__Belt_internalAVLtree.removeMinAuxWithRef(rn, kr, vr); + return Belt__Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); + } + if (x < v) { + if (l === undefined) { + return n; + } + var ll = removeAux(Caml_option.valFromOption(l), x); + if (ll === l) { + return n; + } else { + return Belt__Belt_internalAVLtree.bal(ll, v, n.v, r); + } + } + if (r === undefined) { + return n; + } + var rr = removeAux(Caml_option.valFromOption(r), x); + return Belt__Belt_internalAVLtree.bal(l, v, n.v, rr); +} + +function remove(n, x) { + if (n !== undefined) { + return removeAux(n, x); + } + +} + +function removeMany(t, keys) { + var len = keys.length; + if (t !== undefined) { + var _t = t; + var _i = 0; + while(true) { + var i = _i; + var t$1 = _t; + if (i >= len) { + return t$1; + } + var ele = keys[i]; + var u = removeAux(t$1, ele); + if (u === undefined) { + return u; + } + _i = i + 1 | 0; + _t = Caml_option.valFromOption(u); + continue ; + }; + } + +} + +function mergeMany(h, arr) { + var len = arr.length; + var v = h; + for(var i = 0; i < len; ++i){ + var match = arr[i]; + v = set(v, match[0], match[1]); + } + return v; +} + +var empty; + +var isEmpty = Belt__Belt_internalAVLtree.isEmpty; + +var has = Belt__Belt_internalMapString.has; + +var cmpU = Belt__Belt_internalMapString.cmpU; + +var cmp = Belt__Belt_internalMapString.cmp; + +var eqU = Belt__Belt_internalMapString.eqU; + +var eq = Belt__Belt_internalMapString.eq; + +var findFirstByU = Belt__Belt_internalAVLtree.findFirstByU; + +var findFirstBy = Belt__Belt_internalAVLtree.findFirstBy; + +var forEachU = Belt__Belt_internalAVLtree.forEachU; + +var forEach = Belt__Belt_internalAVLtree.forEach; + +var reduceU = Belt__Belt_internalAVLtree.reduceU; + +var reduce = Belt__Belt_internalAVLtree.reduce; + +var everyU = Belt__Belt_internalAVLtree.everyU; + +var every = Belt__Belt_internalAVLtree.every; + +var someU = Belt__Belt_internalAVLtree.someU; + +var some = Belt__Belt_internalAVLtree.some; + +var size = Belt__Belt_internalAVLtree.size; + +var toList = Belt__Belt_internalAVLtree.toList; + +var toArray = Belt__Belt_internalAVLtree.toArray; + +var fromArray = Belt__Belt_internalMapString.fromArray; + +var keysToArray = Belt__Belt_internalAVLtree.keysToArray; + +var valuesToArray = Belt__Belt_internalAVLtree.valuesToArray; + +var minKey = Belt__Belt_internalAVLtree.minKey; + +var minKeyUndefined = Belt__Belt_internalAVLtree.minKeyUndefined; + +var maxKey = Belt__Belt_internalAVLtree.maxKey; + +var maxKeyUndefined = Belt__Belt_internalAVLtree.maxKeyUndefined; + +var minimum = Belt__Belt_internalAVLtree.minimum; + +var minUndefined = Belt__Belt_internalAVLtree.minUndefined; + +var maximum = Belt__Belt_internalAVLtree.maximum; + +var maxUndefined = Belt__Belt_internalAVLtree.maxUndefined; + +var get = Belt__Belt_internalMapString.get; + +var getUndefined = Belt__Belt_internalMapString.getUndefined; + +var getWithDefault = Belt__Belt_internalMapString.getWithDefault; + +var getExn = Belt__Belt_internalMapString.getExn; + +var checkInvariantInternal = Belt__Belt_internalAVLtree.checkInvariantInternal; + +var mergeU = Belt__Belt_internalMapString.mergeU; + +var merge = Belt__Belt_internalMapString.merge; + +var keepU = Belt__Belt_internalAVLtree.keepSharedU; + +var keep = Belt__Belt_internalAVLtree.keepShared; + +var partitionU = Belt__Belt_internalAVLtree.partitionSharedU; + +var partition = Belt__Belt_internalAVLtree.partitionShared; + +var split = Belt__Belt_internalMapString.split; + +var mapU = Belt__Belt_internalAVLtree.mapU; + +var map = Belt__Belt_internalAVLtree.map; + +var mapWithKeyU = Belt__Belt_internalAVLtree.mapWithKeyU; + +var mapWithKey = Belt__Belt_internalAVLtree.mapWithKey; + +export { + empty , + isEmpty , + has , + cmpU , + cmp , + eqU , + eq , + findFirstByU , + findFirstBy , + forEachU , + forEach , + reduceU , + reduce , + everyU , + every , + someU , + some , + size , + toList , + toArray , + fromArray , + keysToArray , + valuesToArray , + minKey , + minKeyUndefined , + maxKey , + maxKeyUndefined , + minimum , + minUndefined , + maximum , + maxUndefined , + get , + getUndefined , + getWithDefault , + getExn , + checkInvariantInternal , + remove , + removeMany , + set , + updateU , + update , + mergeU , + merge , + mergeMany , + keepU , + keep , + partitionU , + partition , + split , + mapU , + map , + mapWithKeyU , + mapWithKey , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_MutableMap.js b/melange-node-modules/melange.belt/belt_MutableMap.js new file mode 100644 index 0000000..4f393ed --- /dev/null +++ b/melange-node-modules/melange.belt/belt_MutableMap.js @@ -0,0 +1,390 @@ +// Generated by Melange + +import * as Belt__Belt_internalAVLtree from "./belt_internalAVLtree.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function removeMutateAux(nt, x, cmp) { + var k = nt.k; + var c = cmp(x, k); + if (c === 0) { + var l = nt.l; + var r = nt.r; + if (l !== undefined) { + if (r !== undefined) { + nt.r = Belt__Belt_internalAVLtree.removeMinAuxWithRootMutate(nt, Caml_option.valFromOption(r)); + return Belt__Belt_internalAVLtree.balMutate(nt); + } else { + return l; + } + } else if (r !== undefined) { + return r; + } else { + return l; + } + } + if (c < 0) { + var l$1 = nt.l; + if (l$1 !== undefined) { + nt.l = removeMutateAux(Caml_option.valFromOption(l$1), x, cmp); + return Belt__Belt_internalAVLtree.balMutate(nt); + } else { + return nt; + } + } + var r$1 = nt.r; + if (r$1 !== undefined) { + nt.r = removeMutateAux(Caml_option.valFromOption(r$1), x, cmp); + return Belt__Belt_internalAVLtree.balMutate(nt); + } else { + return nt; + } +} + +function remove(d, k) { + var oldRoot = d.data; + if (oldRoot === undefined) { + return ; + } + var newRoot = removeMutateAux(Caml_option.valFromOption(oldRoot), k, d.cmp); + if (newRoot !== oldRoot) { + d.data = newRoot; + return ; + } + +} + +function removeArrayMutateAux(_t, xs, _i, len, cmp) { + while(true) { + var i = _i; + var t = _t; + if (i >= len) { + return t; + } + var ele = xs[i]; + var u = removeMutateAux(t, ele, cmp); + if (u === undefined) { + return ; + } + _i = i + 1 | 0; + _t = Caml_option.valFromOption(u); + continue ; + }; +} + +function removeMany(d, xs) { + var oldRoot = d.data; + if (oldRoot === undefined) { + return ; + } + var len = xs.length; + var newRoot = removeArrayMutateAux(Caml_option.valFromOption(oldRoot), xs, 0, len, d.cmp); + if (newRoot !== oldRoot) { + d.data = newRoot; + return ; + } + +} + +function updateDone(t, x, f, cmp) { + if (t !== undefined) { + var nt = Caml_option.valFromOption(t); + var k = nt.k; + var c = cmp(x, k); + if (c === 0) { + var data = f(Caml_option.some(nt.v)); + if (data !== undefined) { + nt.v = Caml_option.valFromOption(data); + return nt; + } + var l = nt.l; + var r = nt.r; + if (l !== undefined) { + if (r !== undefined) { + nt.r = Belt__Belt_internalAVLtree.removeMinAuxWithRootMutate(nt, Caml_option.valFromOption(r)); + return Belt__Belt_internalAVLtree.balMutate(nt); + } else { + return l; + } + } else if (r !== undefined) { + return r; + } else { + return l; + } + } + if (c < 0) { + nt.l = updateDone(nt.l, x, f, cmp); + } else { + nt.r = updateDone(nt.r, x, f, cmp); + } + return Belt__Belt_internalAVLtree.balMutate(nt); + } + var data$1 = f(undefined); + if (data$1 !== undefined) { + return Belt__Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); + } else { + return t; + } +} + +function updateU(t, x, f) { + var oldRoot = t.data; + var newRoot = updateDone(oldRoot, x, f, t.cmp); + if (newRoot !== oldRoot) { + t.data = newRoot; + return ; + } + +} + +function update(t, x, f) { + updateU(t, x, Curry.__1(f)); +} + +function make(id) { + return { + cmp: id.cmp, + data: undefined + }; +} + +function clear(m) { + m.data = undefined; +} + +function isEmpty(d) { + var x = d.data; + return x === undefined; +} + +function minKey(m) { + return Belt__Belt_internalAVLtree.minKey(m.data); +} + +function minKeyUndefined(m) { + return Belt__Belt_internalAVLtree.minKeyUndefined(m.data); +} + +function maxKey(m) { + return Belt__Belt_internalAVLtree.maxKey(m.data); +} + +function maxKeyUndefined(m) { + return Belt__Belt_internalAVLtree.maxKeyUndefined(m.data); +} + +function minimum(m) { + return Belt__Belt_internalAVLtree.minimum(m.data); +} + +function minUndefined(m) { + return Belt__Belt_internalAVLtree.minUndefined(m.data); +} + +function maximum(m) { + return Belt__Belt_internalAVLtree.maximum(m.data); +} + +function maxUndefined(m) { + return Belt__Belt_internalAVLtree.maxUndefined(m.data); +} + +function forEachU(d, f) { + Belt__Belt_internalAVLtree.forEachU(d.data, f); +} + +function forEach(d, f) { + Belt__Belt_internalAVLtree.forEachU(d.data, Curry.__2(f)); +} + +function reduceU(d, acc, cb) { + return Belt__Belt_internalAVLtree.reduceU(d.data, acc, cb); +} + +function reduce(d, acc, cb) { + return reduceU(d, acc, Curry.__3(cb)); +} + +function everyU(d, p) { + return Belt__Belt_internalAVLtree.everyU(d.data, p); +} + +function every(d, p) { + return Belt__Belt_internalAVLtree.everyU(d.data, Curry.__2(p)); +} + +function someU(d, p) { + return Belt__Belt_internalAVLtree.someU(d.data, p); +} + +function some(d, p) { + return Belt__Belt_internalAVLtree.someU(d.data, Curry.__2(p)); +} + +function size(d) { + return Belt__Belt_internalAVLtree.size(d.data); +} + +function toList(d) { + return Belt__Belt_internalAVLtree.toList(d.data); +} + +function toArray(d) { + return Belt__Belt_internalAVLtree.toArray(d.data); +} + +function keysToArray(d) { + return Belt__Belt_internalAVLtree.keysToArray(d.data); +} + +function valuesToArray(d) { + return Belt__Belt_internalAVLtree.valuesToArray(d.data); +} + +function checkInvariantInternal(d) { + Belt__Belt_internalAVLtree.checkInvariantInternal(d.data); +} + +function cmpU(m1, m2, cmp) { + return Belt__Belt_internalAVLtree.cmpU(m1.data, m2.data, m1.cmp, cmp); +} + +function cmp(m1, m2, cmp$1) { + return cmpU(m1, m2, Curry.__2(cmp$1)); +} + +function eqU(m1, m2, cmp) { + return Belt__Belt_internalAVLtree.eqU(m1.data, m2.data, m1.cmp, cmp); +} + +function eq(m1, m2, cmp) { + return eqU(m1, m2, Curry.__2(cmp)); +} + +function mapU(m, f) { + return { + cmp: m.cmp, + data: Belt__Belt_internalAVLtree.mapU(m.data, f) + }; +} + +function map(m, f) { + return mapU(m, Curry.__1(f)); +} + +function mapWithKeyU(m, f) { + return { + cmp: m.cmp, + data: Belt__Belt_internalAVLtree.mapWithKeyU(m.data, f) + }; +} + +function mapWithKey(m, f) { + return mapWithKeyU(m, Curry.__2(f)); +} + +function get(m, x) { + return Belt__Belt_internalAVLtree.get(m.data, x, m.cmp); +} + +function getUndefined(m, x) { + return Belt__Belt_internalAVLtree.getUndefined(m.data, x, m.cmp); +} + +function getWithDefault(m, x, def) { + return Belt__Belt_internalAVLtree.getWithDefault(m.data, x, def, m.cmp); +} + +function getExn(m, x) { + return Belt__Belt_internalAVLtree.getExn(m.data, x, m.cmp); +} + +function has(m, x) { + return Belt__Belt_internalAVLtree.has(m.data, x, m.cmp); +} + +function fromArray(data, id) { + var cmp = id.cmp; + return { + cmp: cmp, + data: Belt__Belt_internalAVLtree.fromArray(data, cmp) + }; +} + +function set(m, e, v) { + var oldRoot = m.data; + var newRoot = Belt__Belt_internalAVLtree.updateMutate(oldRoot, e, v, m.cmp); + if (newRoot !== oldRoot) { + m.data = newRoot; + return ; + } + +} + +function mergeManyAux(t, xs, cmp) { + var v = t; + for(var i = 0 ,i_finish = xs.length; i < i_finish; ++i){ + var match = xs[i]; + v = Belt__Belt_internalAVLtree.updateMutate(v, match[0], match[1], cmp); + } + return v; +} + +function mergeMany(d, xs) { + var oldRoot = d.data; + var newRoot = mergeManyAux(oldRoot, xs, d.cmp); + if (newRoot !== oldRoot) { + d.data = newRoot; + return ; + } + +} + +export { + make , + clear , + isEmpty , + has , + cmpU , + cmp , + eqU , + eq , + forEachU , + forEach , + reduceU , + reduce , + everyU , + every , + someU , + some , + size , + toList , + toArray , + fromArray , + keysToArray , + valuesToArray , + minKey , + minKeyUndefined , + maxKey , + maxKeyUndefined , + minimum , + minUndefined , + maximum , + maxUndefined , + get , + getUndefined , + getWithDefault , + getExn , + checkInvariantInternal , + remove , + removeMany , + set , + updateU , + update , + mergeMany , + mapU , + map , + mapWithKeyU , + mapWithKey , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_MutableMapInt.js b/melange-node-modules/melange.belt/belt_MutableMapInt.js new file mode 100644 index 0000000..7166a8d --- /dev/null +++ b/melange-node-modules/melange.belt/belt_MutableMapInt.js @@ -0,0 +1,363 @@ +// Generated by Melange + +import * as Belt__Belt_internalAVLtree from "./belt_internalAVLtree.js"; +import * as Belt__Belt_internalMapInt from "./belt_internalMapInt.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function make(param) { + return { + data: undefined + }; +} + +function isEmpty(m) { + var x = m.data; + return x === undefined; +} + +function clear(m) { + m.data = undefined; +} + +function minKeyUndefined(m) { + return Belt__Belt_internalAVLtree.minKeyUndefined(m.data); +} + +function minKey(m) { + return Belt__Belt_internalAVLtree.minKey(m.data); +} + +function maxKeyUndefined(m) { + return Belt__Belt_internalAVLtree.maxKeyUndefined(m.data); +} + +function maxKey(m) { + return Belt__Belt_internalAVLtree.maxKey(m.data); +} + +function minimum(m) { + return Belt__Belt_internalAVLtree.minimum(m.data); +} + +function minUndefined(m) { + return Belt__Belt_internalAVLtree.minUndefined(m.data); +} + +function maximum(m) { + return Belt__Belt_internalAVLtree.maximum(m.data); +} + +function maxUndefined(m) { + return Belt__Belt_internalAVLtree.maxUndefined(m.data); +} + +function set(m, k, v) { + var old_data = m.data; + var v$1 = Belt__Belt_internalMapInt.addMutate(old_data, k, v); + if (v$1 !== old_data) { + m.data = v$1; + return ; + } + +} + +function forEachU(d, f) { + Belt__Belt_internalAVLtree.forEachU(d.data, f); +} + +function forEach(d, f) { + Belt__Belt_internalAVLtree.forEachU(d.data, Curry.__2(f)); +} + +function mapU(d, f) { + return { + data: Belt__Belt_internalAVLtree.mapU(d.data, f) + }; +} + +function map(d, f) { + return mapU(d, Curry.__1(f)); +} + +function mapWithKeyU(d, f) { + return { + data: Belt__Belt_internalAVLtree.mapWithKeyU(d.data, f) + }; +} + +function mapWithKey(d, f) { + return mapWithKeyU(d, Curry.__2(f)); +} + +function reduceU(d, acc, f) { + return Belt__Belt_internalAVLtree.reduceU(d.data, acc, f); +} + +function reduce(d, acc, f) { + return reduceU(d, acc, Curry.__3(f)); +} + +function everyU(d, f) { + return Belt__Belt_internalAVLtree.everyU(d.data, f); +} + +function every(d, f) { + return Belt__Belt_internalAVLtree.everyU(d.data, Curry.__2(f)); +} + +function someU(d, f) { + return Belt__Belt_internalAVLtree.someU(d.data, f); +} + +function some(d, f) { + return Belt__Belt_internalAVLtree.someU(d.data, Curry.__2(f)); +} + +function size(d) { + return Belt__Belt_internalAVLtree.size(d.data); +} + +function toList(d) { + return Belt__Belt_internalAVLtree.toList(d.data); +} + +function toArray(d) { + return Belt__Belt_internalAVLtree.toArray(d.data); +} + +function keysToArray(d) { + return Belt__Belt_internalAVLtree.keysToArray(d.data); +} + +function valuesToArray(d) { + return Belt__Belt_internalAVLtree.valuesToArray(d.data); +} + +function checkInvariantInternal(d) { + Belt__Belt_internalAVLtree.checkInvariantInternal(d.data); +} + +function has(d, v) { + return Belt__Belt_internalMapInt.has(d.data, v); +} + +function removeMutateAux(nt, x) { + var k = nt.k; + if (x === k) { + var l = nt.l; + var r = nt.r; + if (l !== undefined) { + if (r !== undefined) { + nt.r = Belt__Belt_internalAVLtree.removeMinAuxWithRootMutate(nt, Caml_option.valFromOption(r)); + return Belt__Belt_internalAVLtree.balMutate(nt); + } else { + return l; + } + } else { + return r; + } + } + if (x < k) { + var l$1 = nt.l; + if (l$1 !== undefined) { + nt.l = removeMutateAux(Caml_option.valFromOption(l$1), x); + return Belt__Belt_internalAVLtree.balMutate(nt); + } else { + return nt; + } + } + var r$1 = nt.r; + if (r$1 !== undefined) { + nt.r = removeMutateAux(Caml_option.valFromOption(r$1), x); + return Belt__Belt_internalAVLtree.balMutate(nt); + } else { + return nt; + } +} + +function remove(d, v) { + var oldRoot = d.data; + if (oldRoot === undefined) { + return ; + } + var newRoot = removeMutateAux(Caml_option.valFromOption(oldRoot), v); + if (newRoot !== oldRoot) { + d.data = newRoot; + return ; + } + +} + +function updateDone(t, x, f) { + if (t !== undefined) { + var nt = Caml_option.valFromOption(t); + var k = nt.k; + if (k === x) { + var data = f(Caml_option.some(nt.v)); + if (data !== undefined) { + nt.v = Caml_option.valFromOption(data); + return nt; + } + var l = nt.l; + var r = nt.r; + if (l !== undefined) { + if (r !== undefined) { + nt.r = Belt__Belt_internalAVLtree.removeMinAuxWithRootMutate(nt, Caml_option.valFromOption(r)); + return Belt__Belt_internalAVLtree.balMutate(nt); + } else { + return l; + } + } else { + return r; + } + } + var l$1 = nt.l; + var r$1 = nt.r; + if (x < k) { + var ll = updateDone(l$1, x, f); + nt.l = ll; + } else { + nt.r = updateDone(r$1, x, f); + } + return Belt__Belt_internalAVLtree.balMutate(nt); + } + var data$1 = f(undefined); + if (data$1 !== undefined) { + return Belt__Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); + } else { + return t; + } +} + +function updateU(t, x, f) { + var oldRoot = t.data; + var newRoot = updateDone(oldRoot, x, f); + if (newRoot !== oldRoot) { + t.data = newRoot; + return ; + } + +} + +function update(t, x, f) { + updateU(t, x, Curry.__1(f)); +} + +function removeArrayMutateAux(_t, xs, _i, len) { + while(true) { + var i = _i; + var t = _t; + if (i >= len) { + return t; + } + var ele = xs[i]; + var u = removeMutateAux(t, ele); + if (u === undefined) { + return ; + } + _i = i + 1 | 0; + _t = Caml_option.valFromOption(u); + continue ; + }; +} + +function removeMany(d, xs) { + var oldRoot = d.data; + if (oldRoot === undefined) { + return ; + } + var len = xs.length; + var newRoot = removeArrayMutateAux(Caml_option.valFromOption(oldRoot), xs, 0, len); + if (newRoot !== oldRoot) { + d.data = newRoot; + return ; + } + +} + +function fromArray(xs) { + return { + data: Belt__Belt_internalMapInt.fromArray(xs) + }; +} + +function cmpU(d0, d1, f) { + return Belt__Belt_internalMapInt.cmpU(d0.data, d1.data, f); +} + +function cmp(d0, d1, f) { + return cmpU(d0, d1, Curry.__2(f)); +} + +function eqU(d0, d1, f) { + return Belt__Belt_internalMapInt.eqU(d0.data, d1.data, f); +} + +function eq(d0, d1, f) { + return eqU(d0, d1, Curry.__2(f)); +} + +function get(d, x) { + return Belt__Belt_internalMapInt.get(d.data, x); +} + +function getUndefined(d, x) { + return Belt__Belt_internalMapInt.getUndefined(d.data, x); +} + +function getWithDefault(d, x, def) { + return Belt__Belt_internalMapInt.getWithDefault(d.data, x, def); +} + +function getExn(d, x) { + return Belt__Belt_internalMapInt.getExn(d.data, x); +} + +export { + make , + clear , + isEmpty , + has , + cmpU , + cmp , + eqU , + eq , + forEachU , + forEach , + reduceU , + reduce , + everyU , + every , + someU , + some , + size , + toList , + toArray , + fromArray , + keysToArray , + valuesToArray , + minKey , + minKeyUndefined , + maxKey , + maxKeyUndefined , + minimum , + minUndefined , + maximum , + maxUndefined , + get , + getUndefined , + getWithDefault , + getExn , + checkInvariantInternal , + remove , + removeMany , + set , + updateU , + update , + mapU , + map , + mapWithKeyU , + mapWithKey , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_MutableMapString.js b/melange-node-modules/melange.belt/belt_MutableMapString.js new file mode 100644 index 0000000..9b7a8f3 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_MutableMapString.js @@ -0,0 +1,363 @@ +// Generated by Melange + +import * as Belt__Belt_internalAVLtree from "./belt_internalAVLtree.js"; +import * as Belt__Belt_internalMapString from "./belt_internalMapString.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function make(param) { + return { + data: undefined + }; +} + +function isEmpty(m) { + var x = m.data; + return x === undefined; +} + +function clear(m) { + m.data = undefined; +} + +function minKeyUndefined(m) { + return Belt__Belt_internalAVLtree.minKeyUndefined(m.data); +} + +function minKey(m) { + return Belt__Belt_internalAVLtree.minKey(m.data); +} + +function maxKeyUndefined(m) { + return Belt__Belt_internalAVLtree.maxKeyUndefined(m.data); +} + +function maxKey(m) { + return Belt__Belt_internalAVLtree.maxKey(m.data); +} + +function minimum(m) { + return Belt__Belt_internalAVLtree.minimum(m.data); +} + +function minUndefined(m) { + return Belt__Belt_internalAVLtree.minUndefined(m.data); +} + +function maximum(m) { + return Belt__Belt_internalAVLtree.maximum(m.data); +} + +function maxUndefined(m) { + return Belt__Belt_internalAVLtree.maxUndefined(m.data); +} + +function set(m, k, v) { + var old_data = m.data; + var v$1 = Belt__Belt_internalMapString.addMutate(old_data, k, v); + if (v$1 !== old_data) { + m.data = v$1; + return ; + } + +} + +function forEachU(d, f) { + Belt__Belt_internalAVLtree.forEachU(d.data, f); +} + +function forEach(d, f) { + Belt__Belt_internalAVLtree.forEachU(d.data, Curry.__2(f)); +} + +function mapU(d, f) { + return { + data: Belt__Belt_internalAVLtree.mapU(d.data, f) + }; +} + +function map(d, f) { + return mapU(d, Curry.__1(f)); +} + +function mapWithKeyU(d, f) { + return { + data: Belt__Belt_internalAVLtree.mapWithKeyU(d.data, f) + }; +} + +function mapWithKey(d, f) { + return mapWithKeyU(d, Curry.__2(f)); +} + +function reduceU(d, acc, f) { + return Belt__Belt_internalAVLtree.reduceU(d.data, acc, f); +} + +function reduce(d, acc, f) { + return reduceU(d, acc, Curry.__3(f)); +} + +function everyU(d, f) { + return Belt__Belt_internalAVLtree.everyU(d.data, f); +} + +function every(d, f) { + return Belt__Belt_internalAVLtree.everyU(d.data, Curry.__2(f)); +} + +function someU(d, f) { + return Belt__Belt_internalAVLtree.someU(d.data, f); +} + +function some(d, f) { + return Belt__Belt_internalAVLtree.someU(d.data, Curry.__2(f)); +} + +function size(d) { + return Belt__Belt_internalAVLtree.size(d.data); +} + +function toList(d) { + return Belt__Belt_internalAVLtree.toList(d.data); +} + +function toArray(d) { + return Belt__Belt_internalAVLtree.toArray(d.data); +} + +function keysToArray(d) { + return Belt__Belt_internalAVLtree.keysToArray(d.data); +} + +function valuesToArray(d) { + return Belt__Belt_internalAVLtree.valuesToArray(d.data); +} + +function checkInvariantInternal(d) { + Belt__Belt_internalAVLtree.checkInvariantInternal(d.data); +} + +function has(d, v) { + return Belt__Belt_internalMapString.has(d.data, v); +} + +function removeMutateAux(nt, x) { + var k = nt.k; + if (x === k) { + var l = nt.l; + var r = nt.r; + if (l !== undefined) { + if (r !== undefined) { + nt.r = Belt__Belt_internalAVLtree.removeMinAuxWithRootMutate(nt, Caml_option.valFromOption(r)); + return Belt__Belt_internalAVLtree.balMutate(nt); + } else { + return l; + } + } else { + return r; + } + } + if (x < k) { + var l$1 = nt.l; + if (l$1 !== undefined) { + nt.l = removeMutateAux(Caml_option.valFromOption(l$1), x); + return Belt__Belt_internalAVLtree.balMutate(nt); + } else { + return nt; + } + } + var r$1 = nt.r; + if (r$1 !== undefined) { + nt.r = removeMutateAux(Caml_option.valFromOption(r$1), x); + return Belt__Belt_internalAVLtree.balMutate(nt); + } else { + return nt; + } +} + +function remove(d, v) { + var oldRoot = d.data; + if (oldRoot === undefined) { + return ; + } + var newRoot = removeMutateAux(Caml_option.valFromOption(oldRoot), v); + if (newRoot !== oldRoot) { + d.data = newRoot; + return ; + } + +} + +function updateDone(t, x, f) { + if (t !== undefined) { + var nt = Caml_option.valFromOption(t); + var k = nt.k; + if (k === x) { + var data = f(Caml_option.some(nt.v)); + if (data !== undefined) { + nt.v = Caml_option.valFromOption(data); + return nt; + } + var l = nt.l; + var r = nt.r; + if (l !== undefined) { + if (r !== undefined) { + nt.r = Belt__Belt_internalAVLtree.removeMinAuxWithRootMutate(nt, Caml_option.valFromOption(r)); + return Belt__Belt_internalAVLtree.balMutate(nt); + } else { + return l; + } + } else { + return r; + } + } + var l$1 = nt.l; + var r$1 = nt.r; + if (x < k) { + var ll = updateDone(l$1, x, f); + nt.l = ll; + } else { + nt.r = updateDone(r$1, x, f); + } + return Belt__Belt_internalAVLtree.balMutate(nt); + } + var data$1 = f(undefined); + if (data$1 !== undefined) { + return Belt__Belt_internalAVLtree.singleton(x, Caml_option.valFromOption(data$1)); + } else { + return t; + } +} + +function updateU(t, x, f) { + var oldRoot = t.data; + var newRoot = updateDone(oldRoot, x, f); + if (newRoot !== oldRoot) { + t.data = newRoot; + return ; + } + +} + +function update(t, x, f) { + updateU(t, x, Curry.__1(f)); +} + +function removeArrayMutateAux(_t, xs, _i, len) { + while(true) { + var i = _i; + var t = _t; + if (i >= len) { + return t; + } + var ele = xs[i]; + var u = removeMutateAux(t, ele); + if (u === undefined) { + return ; + } + _i = i + 1 | 0; + _t = Caml_option.valFromOption(u); + continue ; + }; +} + +function removeMany(d, xs) { + var oldRoot = d.data; + if (oldRoot === undefined) { + return ; + } + var len = xs.length; + var newRoot = removeArrayMutateAux(Caml_option.valFromOption(oldRoot), xs, 0, len); + if (newRoot !== oldRoot) { + d.data = newRoot; + return ; + } + +} + +function fromArray(xs) { + return { + data: Belt__Belt_internalMapString.fromArray(xs) + }; +} + +function cmpU(d0, d1, f) { + return Belt__Belt_internalMapString.cmpU(d0.data, d1.data, f); +} + +function cmp(d0, d1, f) { + return cmpU(d0, d1, Curry.__2(f)); +} + +function eqU(d0, d1, f) { + return Belt__Belt_internalMapString.eqU(d0.data, d1.data, f); +} + +function eq(d0, d1, f) { + return eqU(d0, d1, Curry.__2(f)); +} + +function get(d, x) { + return Belt__Belt_internalMapString.get(d.data, x); +} + +function getUndefined(d, x) { + return Belt__Belt_internalMapString.getUndefined(d.data, x); +} + +function getWithDefault(d, x, def) { + return Belt__Belt_internalMapString.getWithDefault(d.data, x, def); +} + +function getExn(d, x) { + return Belt__Belt_internalMapString.getExn(d.data, x); +} + +export { + make , + clear , + isEmpty , + has , + cmpU , + cmp , + eqU , + eq , + forEachU , + forEach , + reduceU , + reduce , + everyU , + every , + someU , + some , + size , + toList , + toArray , + fromArray , + keysToArray , + valuesToArray , + minKey , + minKeyUndefined , + maxKey , + maxKeyUndefined , + minimum , + minUndefined , + maximum , + maxUndefined , + get , + getUndefined , + getWithDefault , + getExn , + checkInvariantInternal , + remove , + removeMany , + set , + updateU , + update , + mapU , + map , + mapWithKeyU , + mapWithKey , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_MutableQueue.js b/melange-node-modules/melange.belt/belt_MutableQueue.js new file mode 100644 index 0000000..45931e1 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_MutableQueue.js @@ -0,0 +1,307 @@ +// Generated by Melange + +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function make(param) { + return { + length: 0, + first: undefined, + last: undefined + }; +} + +function clear(q) { + q.length = 0; + q.first = undefined; + q.last = undefined; +} + +function add(q, x) { + var cell = { + content: x, + next: undefined + }; + var last = q.last; + if (last !== undefined) { + q.length = q.length + 1 | 0; + Caml_option.valFromOption(last).next = cell; + q.last = cell; + } else { + q.length = 1; + q.first = cell; + q.last = cell; + } +} + +function peek(q) { + var v = q.first; + if (v !== undefined) { + return Caml_option.some(Caml_option.valFromOption(v).content); + } + +} + +function peekUndefined(q) { + var v = q.first; + if (v !== undefined) { + return Caml_option.valFromOption(v).content; + } + +} + +function peekExn(q) { + var v = q.first; + if (v !== undefined) { + return Caml_option.valFromOption(v).content; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; +} + +function pop(q) { + var x = q.first; + if (x === undefined) { + return ; + } + var x$1 = Caml_option.valFromOption(x); + var next = x$1.next; + if (next === undefined) { + clear(q); + return Caml_option.some(x$1.content); + } else { + q.length = q.length - 1 | 0; + q.first = next; + return Caml_option.some(x$1.content); + } +} + +function popExn(q) { + var x = q.first; + if (x !== undefined) { + var x$1 = Caml_option.valFromOption(x); + var next = x$1.next; + if (next === undefined) { + clear(q); + return x$1.content; + } else { + q.length = q.length - 1 | 0; + q.first = next; + return x$1.content; + } + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; +} + +function popUndefined(q) { + var x = q.first; + if (x === undefined) { + return ; + } + var x$1 = Caml_option.valFromOption(x); + var next = x$1.next; + if (next === undefined) { + clear(q); + return x$1.content; + } else { + q.length = q.length - 1 | 0; + q.first = next; + return x$1.content; + } +} + +function copy(q) { + var qRes = { + length: q.length, + first: undefined, + last: undefined + }; + var _prev; + var _cell = q.first; + while(true) { + var cell = _cell; + var prev = _prev; + if (cell !== undefined) { + var x = Caml_option.valFromOption(cell); + var content = x.content; + var res = { + content: content, + next: undefined + }; + if (prev !== undefined) { + Caml_option.valFromOption(prev).next = res; + } else { + qRes.first = res; + } + _cell = x.next; + _prev = res; + continue ; + } + qRes.last = prev; + return qRes; + }; +} + +function mapU(q, f) { + var qRes = { + length: q.length, + first: undefined, + last: undefined + }; + var _prev; + var _cell = q.first; + while(true) { + var cell = _cell; + var prev = _prev; + if (cell !== undefined) { + var x = Caml_option.valFromOption(cell); + var content = f(x.content); + var res = { + content: content, + next: undefined + }; + if (prev !== undefined) { + Caml_option.valFromOption(prev).next = res; + } else { + qRes.first = res; + } + _cell = x.next; + _prev = res; + continue ; + } + qRes.last = prev; + return qRes; + }; +} + +function map(q, f) { + return mapU(q, Curry.__1(f)); +} + +function isEmpty(q) { + return q.length === 0; +} + +function size(q) { + return q.length; +} + +function forEachU(q, f) { + var _cell = q.first; + while(true) { + var cell = _cell; + if (cell === undefined) { + return ; + } + var x = Caml_option.valFromOption(cell); + f(x.content); + _cell = x.next; + continue ; + }; +} + +function forEach(q, f) { + forEachU(q, Curry.__1(f)); +} + +function reduceU(q, accu, f) { + var _accu = accu; + var _cell = q.first; + while(true) { + var cell = _cell; + var accu$1 = _accu; + if (cell === undefined) { + return accu$1; + } + var x = Caml_option.valFromOption(cell); + var accu$2 = f(accu$1, x.content); + _cell = x.next; + _accu = accu$2; + continue ; + }; +} + +function reduce(q, accu, f) { + return reduceU(q, accu, Curry.__2(f)); +} + +function transfer(q1, q2) { + if (q1.length <= 0) { + return ; + } + var l = q2.last; + if (l !== undefined) { + q2.length = q2.length + q1.length | 0; + Caml_option.valFromOption(l).next = q1.first; + q2.last = q1.last; + return clear(q1); + } else { + q2.length = q1.length; + q2.first = q1.first; + q2.last = q1.last; + return clear(q1); + } +} + +function fillAux(_i, arr, _cell) { + while(true) { + var cell = _cell; + var i = _i; + if (cell === undefined) { + return ; + } + var x = Caml_option.valFromOption(cell); + arr[i] = x.content; + _cell = x.next; + _i = i + 1 | 0; + continue ; + }; +} + +function toArray(x) { + var v = new Array(x.length); + fillAux(0, v, x.first); + return v; +} + +function fromArray(arr) { + var q = { + length: 0, + first: undefined, + last: undefined + }; + for(var i = 0 ,i_finish = arr.length; i < i_finish; ++i){ + add(q, arr[i]); + } + return q; +} + +export { + make , + clear , + isEmpty , + fromArray , + add , + peek , + peekUndefined , + peekExn , + pop , + popUndefined , + popExn , + copy , + size , + mapU , + map , + forEachU , + forEach , + reduceU , + reduce , + transfer , + toArray , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_MutableSet.js b/melange-node-modules/melange.belt/belt_MutableSet.js new file mode 100644 index 0000000..1e3e916 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_MutableSet.js @@ -0,0 +1,540 @@ +// Generated by Melange + +import * as Belt__Belt_SortArray from "./belt_SortArray.js"; +import * as Belt__Belt_internalAVLset from "./belt_internalAVLset.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function remove0(nt, x, cmp) { + var k = nt.v; + var c = cmp(x, k); + if (c === 0) { + var l = nt.l; + var r = nt.r; + if (l !== undefined) { + if (r !== undefined) { + nt.r = Belt__Belt_internalAVLset.removeMinAuxWithRootMutate(nt, Caml_option.valFromOption(r)); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return l; + } + } else { + return r; + } + } + if (c < 0) { + var l$1 = nt.l; + if (l$1 !== undefined) { + nt.l = remove0(Caml_option.valFromOption(l$1), x, cmp); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return nt; + } + } + var r$1 = nt.r; + if (r$1 !== undefined) { + nt.r = remove0(Caml_option.valFromOption(r$1), x, cmp); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return nt; + } +} + +function remove(d, v) { + var oldRoot = d.data; + if (oldRoot === undefined) { + return ; + } + var newRoot = remove0(Caml_option.valFromOption(oldRoot), v, d.cmp); + if (newRoot !== oldRoot) { + d.data = newRoot; + return ; + } + +} + +function removeMany0(_t, xs, _i, len, cmp) { + while(true) { + var i = _i; + var t = _t; + if (i >= len) { + return t; + } + var ele = xs[i]; + var u = remove0(t, ele, cmp); + if (u === undefined) { + return ; + } + _i = i + 1 | 0; + _t = Caml_option.valFromOption(u); + continue ; + }; +} + +function removeMany(d, xs) { + var oldRoot = d.data; + if (oldRoot === undefined) { + return ; + } + var len = xs.length; + d.data = removeMany0(Caml_option.valFromOption(oldRoot), xs, 0, len, d.cmp); +} + +function removeCheck0(nt, x, removed, cmp) { + var k = nt.v; + var c = cmp(x, k); + if (c === 0) { + removed.contents = true; + var l = nt.l; + var r = nt.r; + if (l !== undefined) { + if (r !== undefined) { + nt.r = Belt__Belt_internalAVLset.removeMinAuxWithRootMutate(nt, Caml_option.valFromOption(r)); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return l; + } + } else { + return r; + } + } + if (c < 0) { + var l$1 = nt.l; + if (l$1 !== undefined) { + nt.l = removeCheck0(Caml_option.valFromOption(l$1), x, removed, cmp); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return nt; + } + } + var r$1 = nt.r; + if (r$1 !== undefined) { + nt.r = removeCheck0(Caml_option.valFromOption(r$1), x, removed, cmp); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return nt; + } +} + +function removeCheck(d, v) { + var oldRoot = d.data; + if (oldRoot === undefined) { + return false; + } + var removed = { + contents: false + }; + var newRoot = removeCheck0(Caml_option.valFromOption(oldRoot), v, removed, d.cmp); + if (newRoot !== oldRoot) { + d.data = newRoot; + } + return removed.contents; +} + +function addCheck0(t, x, added, cmp) { + if (t !== undefined) { + var nt = Caml_option.valFromOption(t); + var k = nt.v; + var c = cmp(x, k); + if (c === 0) { + return t; + } + var l = nt.l; + var r = nt.r; + if (c < 0) { + var ll = addCheck0(l, x, added, cmp); + nt.l = ll; + } else { + nt.r = addCheck0(r, x, added, cmp); + } + return Belt__Belt_internalAVLset.balMutate(nt); + } + added.contents = true; + return Belt__Belt_internalAVLset.singleton(x); +} + +function addCheck(m, e) { + var oldRoot = m.data; + var added = { + contents: false + }; + var newRoot = addCheck0(oldRoot, e, added, m.cmp); + if (newRoot !== oldRoot) { + m.data = newRoot; + } + return added.contents; +} + +function add(m, e) { + var oldRoot = m.data; + var newRoot = Belt__Belt_internalAVLset.addMutate(m.cmp, oldRoot, e); + if (newRoot !== oldRoot) { + m.data = newRoot; + return ; + } + +} + +function addArrayMutate(t, xs, cmp) { + var v = t; + for(var i = 0 ,i_finish = xs.length; i < i_finish; ++i){ + v = Belt__Belt_internalAVLset.addMutate(cmp, v, xs[i]); + } + return v; +} + +function mergeMany(d, xs) { + d.data = addArrayMutate(d.data, xs, d.cmp); +} + +function make(id) { + return { + cmp: id.cmp, + data: undefined + }; +} + +function isEmpty(d) { + var n = d.data; + return n === undefined; +} + +function minimum(d) { + return Belt__Belt_internalAVLset.minimum(d.data); +} + +function minUndefined(d) { + return Belt__Belt_internalAVLset.minUndefined(d.data); +} + +function maximum(d) { + return Belt__Belt_internalAVLset.maximum(d.data); +} + +function maxUndefined(d) { + return Belt__Belt_internalAVLset.maxUndefined(d.data); +} + +function forEachU(d, f) { + Belt__Belt_internalAVLset.forEachU(d.data, f); +} + +function forEach(d, f) { + Belt__Belt_internalAVLset.forEachU(d.data, Curry.__1(f)); +} + +function reduceU(d, acc, cb) { + return Belt__Belt_internalAVLset.reduceU(d.data, acc, cb); +} + +function reduce(d, acc, cb) { + return reduceU(d, acc, Curry.__2(cb)); +} + +function everyU(d, p) { + return Belt__Belt_internalAVLset.everyU(d.data, p); +} + +function every(d, p) { + return Belt__Belt_internalAVLset.everyU(d.data, Curry.__1(p)); +} + +function someU(d, p) { + return Belt__Belt_internalAVLset.someU(d.data, p); +} + +function some(d, p) { + return Belt__Belt_internalAVLset.someU(d.data, Curry.__1(p)); +} + +function size(d) { + return Belt__Belt_internalAVLset.size(d.data); +} + +function toList(d) { + return Belt__Belt_internalAVLset.toList(d.data); +} + +function toArray(d) { + return Belt__Belt_internalAVLset.toArray(d.data); +} + +function fromSortedArrayUnsafe(xs, id) { + return { + cmp: id.cmp, + data: Belt__Belt_internalAVLset.fromSortedArrayUnsafe(xs) + }; +} + +function checkInvariantInternal(d) { + Belt__Belt_internalAVLset.checkInvariantInternal(d.data); +} + +function fromArray(data, id) { + var cmp = id.cmp; + return { + cmp: cmp, + data: Belt__Belt_internalAVLset.fromArray(data, cmp) + }; +} + +function cmp(d0, d1) { + return Belt__Belt_internalAVLset.cmp(d0.data, d1.data, d0.cmp); +} + +function eq(d0, d1) { + return Belt__Belt_internalAVLset.eq(d0.data, d1.data, d0.cmp); +} + +function get(d, x) { + return Belt__Belt_internalAVLset.get(d.data, x, d.cmp); +} + +function getUndefined(d, x) { + return Belt__Belt_internalAVLset.getUndefined(d.data, x, d.cmp); +} + +function getExn(d, x) { + return Belt__Belt_internalAVLset.getExn(d.data, x, d.cmp); +} + +function split(d, key) { + var arr = Belt__Belt_internalAVLset.toArray(d.data); + var cmp = d.cmp; + var i = Belt__Belt_SortArray.binarySearchByU(arr, key, cmp); + var len = arr.length; + if (i >= 0) { + return [ + [ + { + cmp: cmp, + data: Belt__Belt_internalAVLset.fromSortedArrayAux(arr, 0, i) + }, + { + cmp: cmp, + data: Belt__Belt_internalAVLset.fromSortedArrayAux(arr, i + 1 | 0, (len - i | 0) - 1 | 0) + } + ], + true + ]; + } + var next = (-i | 0) - 1 | 0; + return [ + [ + { + cmp: cmp, + data: Belt__Belt_internalAVLset.fromSortedArrayAux(arr, 0, next) + }, + { + cmp: cmp, + data: Belt__Belt_internalAVLset.fromSortedArrayAux(arr, next, len - next | 0) + } + ], + false + ]; +} + +function keepU(d, p) { + return { + cmp: d.cmp, + data: Belt__Belt_internalAVLset.keepCopyU(d.data, p) + }; +} + +function keep(d, p) { + return keepU(d, Curry.__1(p)); +} + +function partitionU(d, p) { + var cmp = d.cmp; + var match = Belt__Belt_internalAVLset.partitionCopyU(d.data, p); + return [ + { + cmp: cmp, + data: match[0] + }, + { + cmp: cmp, + data: match[1] + } + ]; +} + +function partition(d, p) { + return partitionU(d, Curry.__1(p)); +} + +function subset(a, b) { + return Belt__Belt_internalAVLset.subset(a.data, b.data, a.cmp); +} + +function intersect(a, b) { + var cmp = a.cmp; + var match = a.data; + var match$1 = b.data; + if (match === undefined) { + return { + cmp: cmp, + data: undefined + }; + } + if (match$1 === undefined) { + return { + cmp: cmp, + data: undefined + }; + } + var datab0 = Caml_option.valFromOption(match$1); + var dataa0 = Caml_option.valFromOption(match); + var sizea = Belt__Belt_internalAVLset.lengthNode(dataa0); + var sizeb = Belt__Belt_internalAVLset.lengthNode(datab0); + var totalSize = sizea + sizeb | 0; + var tmp = new Array(totalSize); + Belt__Belt_internalAVLset.fillArray(dataa0, 0, tmp); + Belt__Belt_internalAVLset.fillArray(datab0, sizea, tmp); + if (cmp(tmp[sizea - 1 | 0], tmp[sizea]) < 0 || cmp(tmp[totalSize - 1 | 0], tmp[0]) < 0) { + return { + cmp: cmp, + data: undefined + }; + } + var tmp2 = new Array(sizea < sizeb ? sizea : sizeb); + var k = Belt__Belt_SortArray.intersectU(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0, cmp); + return { + cmp: cmp, + data: Belt__Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) + }; +} + +function diff(a, b) { + var cmp = a.cmp; + var dataa = a.data; + var match = b.data; + if (dataa === undefined) { + return { + cmp: cmp, + data: undefined + }; + } + if (match === undefined) { + return { + cmp: cmp, + data: Belt__Belt_internalAVLset.copy(dataa) + }; + } + var datab0 = Caml_option.valFromOption(match); + var dataa0 = Caml_option.valFromOption(dataa); + var sizea = Belt__Belt_internalAVLset.lengthNode(dataa0); + var sizeb = Belt__Belt_internalAVLset.lengthNode(datab0); + var totalSize = sizea + sizeb | 0; + var tmp = new Array(totalSize); + Belt__Belt_internalAVLset.fillArray(dataa0, 0, tmp); + Belt__Belt_internalAVLset.fillArray(datab0, sizea, tmp); + if (cmp(tmp[sizea - 1 | 0], tmp[sizea]) < 0 || cmp(tmp[totalSize - 1 | 0], tmp[0]) < 0) { + return { + cmp: cmp, + data: Belt__Belt_internalAVLset.copy(dataa) + }; + } + var tmp2 = new Array(sizea); + var k = Belt__Belt_SortArray.diffU(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0, cmp); + return { + cmp: cmp, + data: Belt__Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) + }; +} + +function union(a, b) { + var cmp = a.cmp; + var dataa = a.data; + var datab = b.data; + if (dataa === undefined) { + return { + cmp: cmp, + data: Belt__Belt_internalAVLset.copy(datab) + }; + } + if (datab === undefined) { + return { + cmp: cmp, + data: Belt__Belt_internalAVLset.copy(dataa) + }; + } + var datab0 = Caml_option.valFromOption(datab); + var dataa0 = Caml_option.valFromOption(dataa); + var sizea = Belt__Belt_internalAVLset.lengthNode(dataa0); + var sizeb = Belt__Belt_internalAVLset.lengthNode(datab0); + var totalSize = sizea + sizeb | 0; + var tmp = new Array(totalSize); + Belt__Belt_internalAVLset.fillArray(dataa0, 0, tmp); + Belt__Belt_internalAVLset.fillArray(datab0, sizea, tmp); + if (cmp(tmp[sizea - 1 | 0], tmp[sizea]) < 0) { + return { + cmp: cmp, + data: Belt__Belt_internalAVLset.fromSortedArrayAux(tmp, 0, totalSize) + }; + } + var tmp2 = new Array(totalSize); + var k = Belt__Belt_SortArray.unionU(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0, cmp); + return { + cmp: cmp, + data: Belt__Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) + }; +} + +function has(d, x) { + return Belt__Belt_internalAVLset.has(d.data, x, d.cmp); +} + +function copy(d) { + return { + cmp: d.cmp, + data: Belt__Belt_internalAVLset.copy(d.data) + }; +} + +export { + make , + fromArray , + fromSortedArrayUnsafe , + copy , + isEmpty , + has , + add , + addCheck , + mergeMany , + remove , + removeCheck , + removeMany , + union , + intersect , + diff , + subset , + cmp , + eq , + forEachU , + forEach , + reduceU , + reduce , + everyU , + every , + someU , + some , + keepU , + keep , + partitionU , + partition , + size , + toList , + toArray , + minimum , + minUndefined , + maximum , + maxUndefined , + get , + getUndefined , + getExn , + split , + checkInvariantInternal , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_MutableSetInt.js b/melange-node-modules/melange.belt/belt_MutableSetInt.js new file mode 100644 index 0000000..5a1be6b --- /dev/null +++ b/melange-node-modules/melange.belt/belt_MutableSetInt.js @@ -0,0 +1,508 @@ +// Generated by Melange + +import * as Belt__Belt_SortArrayInt from "./belt_SortArrayInt.js"; +import * as Belt__Belt_internalAVLset from "./belt_internalAVLset.js"; +import * as Belt__Belt_internalSetInt from "./belt_internalSetInt.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function remove0(nt, x) { + var k = nt.v; + if (x === k) { + var l = nt.l; + var r = nt.r; + if (l !== undefined) { + if (r !== undefined) { + nt.r = Belt__Belt_internalAVLset.removeMinAuxWithRootMutate(nt, r); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return l; + } + } else { + return r; + } + } + if (x < k) { + var l$1 = nt.l; + if (l$1 !== undefined) { + nt.l = remove0(l$1, x); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return nt; + } + } + var r$1 = nt.r; + if (r$1 !== undefined) { + nt.r = remove0(r$1, x); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return nt; + } +} + +function remove(d, v) { + var oldRoot = d.data; + if (oldRoot === undefined) { + return ; + } + var newRoot = remove0(Caml_option.valFromOption(oldRoot), v); + if (newRoot !== oldRoot) { + d.data = newRoot; + return ; + } + +} + +function removeMany0(_t, xs, _i, len) { + while(true) { + var i = _i; + var t = _t; + if (i >= len) { + return t; + } + var ele = xs[i]; + var u = remove0(t, ele); + if (u === undefined) { + return ; + } + _i = i + 1 | 0; + _t = u; + continue ; + }; +} + +function removeMany(d, xs) { + var oldRoot = d.data; + if (oldRoot === undefined) { + return ; + } + var len = xs.length; + d.data = removeMany0(Caml_option.valFromOption(oldRoot), xs, 0, len); +} + +function removeCheck0(nt, x, removed) { + var k = nt.v; + if (x === k) { + removed.contents = true; + var l = nt.l; + var r = nt.r; + if (l !== undefined) { + if (r !== undefined) { + nt.r = Belt__Belt_internalAVLset.removeMinAuxWithRootMutate(nt, r); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return l; + } + } else { + return r; + } + } + if (x < k) { + var l$1 = nt.l; + if (l$1 !== undefined) { + nt.l = removeCheck0(l$1, x, removed); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return nt; + } + } + var r$1 = nt.r; + if (r$1 !== undefined) { + nt.r = removeCheck0(r$1, x, removed); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return nt; + } +} + +function removeCheck(d, v) { + var oldRoot = d.data; + if (oldRoot === undefined) { + return false; + } + var removed = { + contents: false + }; + var newRoot = removeCheck0(Caml_option.valFromOption(oldRoot), v, removed); + if (newRoot !== oldRoot) { + d.data = newRoot; + } + return removed.contents; +} + +function addCheck0(t, x, added) { + if (t !== undefined) { + var k = t.v; + if (x === k) { + return t; + } + var l = t.l; + var r = t.r; + if (x < k) { + var ll = addCheck0(l, x, added); + t.l = ll; + } else { + t.r = addCheck0(r, x, added); + } + return Belt__Belt_internalAVLset.balMutate(t); + } + added.contents = true; + return Belt__Belt_internalAVLset.singleton(x); +} + +function addCheck(m, e) { + var oldRoot = m.data; + var added = { + contents: false + }; + var newRoot = addCheck0(oldRoot, e, added); + if (newRoot !== oldRoot) { + m.data = newRoot; + } + return added.contents; +} + +function add(d, k) { + var oldRoot = d.data; + var v = Belt__Belt_internalSetInt.addMutate(oldRoot, k); + if (v !== oldRoot) { + d.data = v; + return ; + } + +} + +function addArrayMutate(t, xs) { + var v = t; + for(var i = 0 ,i_finish = xs.length; i < i_finish; ++i){ + v = Belt__Belt_internalSetInt.addMutate(v, xs[i]); + } + return v; +} + +function mergeMany(d, arr) { + d.data = addArrayMutate(d.data, arr); +} + +function make(param) { + return { + data: undefined + }; +} + +function isEmpty(d) { + var n = d.data; + return n === undefined; +} + +function minimum(d) { + return Belt__Belt_internalAVLset.minimum(d.data); +} + +function minUndefined(d) { + return Belt__Belt_internalAVLset.minUndefined(d.data); +} + +function maximum(d) { + return Belt__Belt_internalAVLset.maximum(d.data); +} + +function maxUndefined(d) { + return Belt__Belt_internalAVLset.maxUndefined(d.data); +} + +function forEachU(d, f) { + Belt__Belt_internalAVLset.forEachU(d.data, f); +} + +function forEach(d, f) { + Belt__Belt_internalAVLset.forEachU(d.data, Curry.__1(f)); +} + +function reduceU(d, acc, cb) { + return Belt__Belt_internalAVLset.reduceU(d.data, acc, cb); +} + +function reduce(d, acc, cb) { + return reduceU(d, acc, Curry.__2(cb)); +} + +function everyU(d, p) { + return Belt__Belt_internalAVLset.everyU(d.data, p); +} + +function every(d, p) { + return Belt__Belt_internalAVLset.everyU(d.data, Curry.__1(p)); +} + +function someU(d, p) { + return Belt__Belt_internalAVLset.someU(d.data, p); +} + +function some(d, p) { + return Belt__Belt_internalAVLset.someU(d.data, Curry.__1(p)); +} + +function size(d) { + return Belt__Belt_internalAVLset.size(d.data); +} + +function toList(d) { + return Belt__Belt_internalAVLset.toList(d.data); +} + +function toArray(d) { + return Belt__Belt_internalAVLset.toArray(d.data); +} + +function fromSortedArrayUnsafe(xs) { + return { + data: Belt__Belt_internalAVLset.fromSortedArrayUnsafe(xs) + }; +} + +function checkInvariantInternal(d) { + Belt__Belt_internalAVLset.checkInvariantInternal(d.data); +} + +function fromArray(xs) { + return { + data: Belt__Belt_internalSetInt.fromArray(xs) + }; +} + +function cmp(d0, d1) { + return Belt__Belt_internalSetInt.cmp(d0.data, d1.data); +} + +function eq(d0, d1) { + return Belt__Belt_internalSetInt.eq(d0.data, d1.data); +} + +function get(d, x) { + return Belt__Belt_internalSetInt.get(d.data, x); +} + +function getUndefined(d, x) { + return Belt__Belt_internalSetInt.getUndefined(d.data, x); +} + +function getExn(d, x) { + return Belt__Belt_internalSetInt.getExn(d.data, x); +} + +function split(d, key) { + var arr = Belt__Belt_internalAVLset.toArray(d.data); + var i = Belt__Belt_SortArrayInt.binarySearch(arr, key); + var len = arr.length; + if (i >= 0) { + return [ + [ + { + data: Belt__Belt_internalAVLset.fromSortedArrayAux(arr, 0, i) + }, + { + data: Belt__Belt_internalAVLset.fromSortedArrayAux(arr, i + 1 | 0, (len - i | 0) - 1 | 0) + } + ], + true + ]; + } + var next = (-i | 0) - 1 | 0; + return [ + [ + { + data: Belt__Belt_internalAVLset.fromSortedArrayAux(arr, 0, next) + }, + { + data: Belt__Belt_internalAVLset.fromSortedArrayAux(arr, next, len - next | 0) + } + ], + false + ]; +} + +function keepU(d, p) { + return { + data: Belt__Belt_internalAVLset.keepCopyU(d.data, p) + }; +} + +function keep(d, p) { + return keepU(d, Curry.__1(p)); +} + +function partitionU(d, p) { + var match = Belt__Belt_internalAVLset.partitionCopyU(d.data, p); + return [ + { + data: match[0] + }, + { + data: match[1] + } + ]; +} + +function partition(d, p) { + return partitionU(d, Curry.__1(p)); +} + +function subset(a, b) { + return Belt__Belt_internalSetInt.subset(a.data, b.data); +} + +function intersect(dataa, datab) { + var dataa$1 = dataa.data; + var datab$1 = datab.data; + if (dataa$1 === undefined) { + return { + data: undefined + }; + } + if (datab$1 === undefined) { + return { + data: undefined + }; + } + var datab0 = Caml_option.valFromOption(datab$1); + var dataa0 = Caml_option.valFromOption(dataa$1); + var sizea = Belt__Belt_internalAVLset.lengthNode(dataa0); + var sizeb = Belt__Belt_internalAVLset.lengthNode(datab0); + var totalSize = sizea + sizeb | 0; + var tmp = new Array(totalSize); + Belt__Belt_internalAVLset.fillArray(dataa0, 0, tmp); + Belt__Belt_internalAVLset.fillArray(datab0, sizea, tmp); + if (tmp[sizea - 1 | 0] < tmp[sizea] || tmp[totalSize - 1 | 0] < tmp[0]) { + return { + data: undefined + }; + } + var tmp2 = new Array(sizea < sizeb ? sizea : sizeb); + var k = Belt__Belt_SortArrayInt.intersect(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); + return { + data: Belt__Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) + }; +} + +function diff(dataa, datab) { + var dataa$1 = dataa.data; + var datab$1 = datab.data; + if (dataa$1 === undefined) { + return { + data: undefined + }; + } + if (datab$1 === undefined) { + return { + data: Belt__Belt_internalAVLset.copy(dataa$1) + }; + } + var datab0 = Caml_option.valFromOption(datab$1); + var dataa0 = Caml_option.valFromOption(dataa$1); + var sizea = Belt__Belt_internalAVLset.lengthNode(dataa0); + var sizeb = Belt__Belt_internalAVLset.lengthNode(datab0); + var totalSize = sizea + sizeb | 0; + var tmp = new Array(totalSize); + Belt__Belt_internalAVLset.fillArray(dataa0, 0, tmp); + Belt__Belt_internalAVLset.fillArray(datab0, sizea, tmp); + if (tmp[sizea - 1 | 0] < tmp[sizea] || tmp[totalSize - 1 | 0] < tmp[0]) { + return { + data: Belt__Belt_internalAVLset.copy(dataa$1) + }; + } + var tmp2 = new Array(sizea); + var k = Belt__Belt_SortArrayInt.diff(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); + return { + data: Belt__Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) + }; +} + +function union(dataa, datab) { + var dataa$1 = dataa.data; + var datab$1 = datab.data; + if (dataa$1 === undefined) { + return { + data: Belt__Belt_internalAVLset.copy(datab$1) + }; + } + if (datab$1 === undefined) { + return { + data: Belt__Belt_internalAVLset.copy(dataa$1) + }; + } + var datab0 = Caml_option.valFromOption(datab$1); + var dataa0 = Caml_option.valFromOption(dataa$1); + var sizea = Belt__Belt_internalAVLset.lengthNode(dataa0); + var sizeb = Belt__Belt_internalAVLset.lengthNode(datab0); + var totalSize = sizea + sizeb | 0; + var tmp = new Array(totalSize); + Belt__Belt_internalAVLset.fillArray(dataa0, 0, tmp); + Belt__Belt_internalAVLset.fillArray(datab0, sizea, tmp); + if (tmp[sizea - 1 | 0] < tmp[sizea]) { + return { + data: Belt__Belt_internalAVLset.fromSortedArrayAux(tmp, 0, totalSize) + }; + } + var tmp2 = new Array(totalSize); + var k = Belt__Belt_SortArrayInt.union(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); + return { + data: Belt__Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) + }; +} + +function has(d, x) { + return Belt__Belt_internalSetInt.has(d.data, x); +} + +function copy(d) { + return { + data: Belt__Belt_internalAVLset.copy(d.data) + }; +} + +export { + make , + fromArray , + fromSortedArrayUnsafe , + copy , + isEmpty , + has , + add , + addCheck , + mergeMany , + remove , + removeCheck , + removeMany , + union , + intersect , + diff , + subset , + cmp , + eq , + forEachU , + forEach , + reduceU , + reduce , + everyU , + every , + someU , + some , + keepU , + keep , + partitionU , + partition , + size , + toList , + toArray , + minimum , + minUndefined , + maximum , + maxUndefined , + get , + getUndefined , + getExn , + split , + checkInvariantInternal , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_MutableSetString.js b/melange-node-modules/melange.belt/belt_MutableSetString.js new file mode 100644 index 0000000..ba4a7a3 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_MutableSetString.js @@ -0,0 +1,508 @@ +// Generated by Melange + +import * as Belt__Belt_SortArrayString from "./belt_SortArrayString.js"; +import * as Belt__Belt_internalAVLset from "./belt_internalAVLset.js"; +import * as Belt__Belt_internalSetString from "./belt_internalSetString.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function remove0(nt, x) { + var k = nt.v; + if (x === k) { + var l = nt.l; + var r = nt.r; + if (l !== undefined) { + if (r !== undefined) { + nt.r = Belt__Belt_internalAVLset.removeMinAuxWithRootMutate(nt, r); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return l; + } + } else { + return r; + } + } + if (x < k) { + var l$1 = nt.l; + if (l$1 !== undefined) { + nt.l = remove0(l$1, x); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return nt; + } + } + var r$1 = nt.r; + if (r$1 !== undefined) { + nt.r = remove0(r$1, x); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return nt; + } +} + +function remove(d, v) { + var oldRoot = d.data; + if (oldRoot === undefined) { + return ; + } + var newRoot = remove0(Caml_option.valFromOption(oldRoot), v); + if (newRoot !== oldRoot) { + d.data = newRoot; + return ; + } + +} + +function removeMany0(_t, xs, _i, len) { + while(true) { + var i = _i; + var t = _t; + if (i >= len) { + return t; + } + var ele = xs[i]; + var u = remove0(t, ele); + if (u === undefined) { + return ; + } + _i = i + 1 | 0; + _t = u; + continue ; + }; +} + +function removeMany(d, xs) { + var oldRoot = d.data; + if (oldRoot === undefined) { + return ; + } + var len = xs.length; + d.data = removeMany0(Caml_option.valFromOption(oldRoot), xs, 0, len); +} + +function removeCheck0(nt, x, removed) { + var k = nt.v; + if (x === k) { + removed.contents = true; + var l = nt.l; + var r = nt.r; + if (l !== undefined) { + if (r !== undefined) { + nt.r = Belt__Belt_internalAVLset.removeMinAuxWithRootMutate(nt, r); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return l; + } + } else { + return r; + } + } + if (x < k) { + var l$1 = nt.l; + if (l$1 !== undefined) { + nt.l = removeCheck0(l$1, x, removed); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return nt; + } + } + var r$1 = nt.r; + if (r$1 !== undefined) { + nt.r = removeCheck0(r$1, x, removed); + return Belt__Belt_internalAVLset.balMutate(nt); + } else { + return nt; + } +} + +function removeCheck(d, v) { + var oldRoot = d.data; + if (oldRoot === undefined) { + return false; + } + var removed = { + contents: false + }; + var newRoot = removeCheck0(Caml_option.valFromOption(oldRoot), v, removed); + if (newRoot !== oldRoot) { + d.data = newRoot; + } + return removed.contents; +} + +function addCheck0(t, x, added) { + if (t !== undefined) { + var k = t.v; + if (x === k) { + return t; + } + var l = t.l; + var r = t.r; + if (x < k) { + var ll = addCheck0(l, x, added); + t.l = ll; + } else { + t.r = addCheck0(r, x, added); + } + return Belt__Belt_internalAVLset.balMutate(t); + } + added.contents = true; + return Belt__Belt_internalAVLset.singleton(x); +} + +function addCheck(m, e) { + var oldRoot = m.data; + var added = { + contents: false + }; + var newRoot = addCheck0(oldRoot, e, added); + if (newRoot !== oldRoot) { + m.data = newRoot; + } + return added.contents; +} + +function add(d, k) { + var oldRoot = d.data; + var v = Belt__Belt_internalSetString.addMutate(oldRoot, k); + if (v !== oldRoot) { + d.data = v; + return ; + } + +} + +function addArrayMutate(t, xs) { + var v = t; + for(var i = 0 ,i_finish = xs.length; i < i_finish; ++i){ + v = Belt__Belt_internalSetString.addMutate(v, xs[i]); + } + return v; +} + +function mergeMany(d, arr) { + d.data = addArrayMutate(d.data, arr); +} + +function make(param) { + return { + data: undefined + }; +} + +function isEmpty(d) { + var n = d.data; + return n === undefined; +} + +function minimum(d) { + return Belt__Belt_internalAVLset.minimum(d.data); +} + +function minUndefined(d) { + return Belt__Belt_internalAVLset.minUndefined(d.data); +} + +function maximum(d) { + return Belt__Belt_internalAVLset.maximum(d.data); +} + +function maxUndefined(d) { + return Belt__Belt_internalAVLset.maxUndefined(d.data); +} + +function forEachU(d, f) { + Belt__Belt_internalAVLset.forEachU(d.data, f); +} + +function forEach(d, f) { + Belt__Belt_internalAVLset.forEachU(d.data, Curry.__1(f)); +} + +function reduceU(d, acc, cb) { + return Belt__Belt_internalAVLset.reduceU(d.data, acc, cb); +} + +function reduce(d, acc, cb) { + return reduceU(d, acc, Curry.__2(cb)); +} + +function everyU(d, p) { + return Belt__Belt_internalAVLset.everyU(d.data, p); +} + +function every(d, p) { + return Belt__Belt_internalAVLset.everyU(d.data, Curry.__1(p)); +} + +function someU(d, p) { + return Belt__Belt_internalAVLset.someU(d.data, p); +} + +function some(d, p) { + return Belt__Belt_internalAVLset.someU(d.data, Curry.__1(p)); +} + +function size(d) { + return Belt__Belt_internalAVLset.size(d.data); +} + +function toList(d) { + return Belt__Belt_internalAVLset.toList(d.data); +} + +function toArray(d) { + return Belt__Belt_internalAVLset.toArray(d.data); +} + +function fromSortedArrayUnsafe(xs) { + return { + data: Belt__Belt_internalAVLset.fromSortedArrayUnsafe(xs) + }; +} + +function checkInvariantInternal(d) { + Belt__Belt_internalAVLset.checkInvariantInternal(d.data); +} + +function fromArray(xs) { + return { + data: Belt__Belt_internalSetString.fromArray(xs) + }; +} + +function cmp(d0, d1) { + return Belt__Belt_internalSetString.cmp(d0.data, d1.data); +} + +function eq(d0, d1) { + return Belt__Belt_internalSetString.eq(d0.data, d1.data); +} + +function get(d, x) { + return Belt__Belt_internalSetString.get(d.data, x); +} + +function getUndefined(d, x) { + return Belt__Belt_internalSetString.getUndefined(d.data, x); +} + +function getExn(d, x) { + return Belt__Belt_internalSetString.getExn(d.data, x); +} + +function split(d, key) { + var arr = Belt__Belt_internalAVLset.toArray(d.data); + var i = Belt__Belt_SortArrayString.binarySearch(arr, key); + var len = arr.length; + if (i >= 0) { + return [ + [ + { + data: Belt__Belt_internalAVLset.fromSortedArrayAux(arr, 0, i) + }, + { + data: Belt__Belt_internalAVLset.fromSortedArrayAux(arr, i + 1 | 0, (len - i | 0) - 1 | 0) + } + ], + true + ]; + } + var next = (-i | 0) - 1 | 0; + return [ + [ + { + data: Belt__Belt_internalAVLset.fromSortedArrayAux(arr, 0, next) + }, + { + data: Belt__Belt_internalAVLset.fromSortedArrayAux(arr, next, len - next | 0) + } + ], + false + ]; +} + +function keepU(d, p) { + return { + data: Belt__Belt_internalAVLset.keepCopyU(d.data, p) + }; +} + +function keep(d, p) { + return keepU(d, Curry.__1(p)); +} + +function partitionU(d, p) { + var match = Belt__Belt_internalAVLset.partitionCopyU(d.data, p); + return [ + { + data: match[0] + }, + { + data: match[1] + } + ]; +} + +function partition(d, p) { + return partitionU(d, Curry.__1(p)); +} + +function subset(a, b) { + return Belt__Belt_internalSetString.subset(a.data, b.data); +} + +function intersect(dataa, datab) { + var dataa$1 = dataa.data; + var datab$1 = datab.data; + if (dataa$1 === undefined) { + return { + data: undefined + }; + } + if (datab$1 === undefined) { + return { + data: undefined + }; + } + var datab0 = Caml_option.valFromOption(datab$1); + var dataa0 = Caml_option.valFromOption(dataa$1); + var sizea = Belt__Belt_internalAVLset.lengthNode(dataa0); + var sizeb = Belt__Belt_internalAVLset.lengthNode(datab0); + var totalSize = sizea + sizeb | 0; + var tmp = new Array(totalSize); + Belt__Belt_internalAVLset.fillArray(dataa0, 0, tmp); + Belt__Belt_internalAVLset.fillArray(datab0, sizea, tmp); + if (tmp[sizea - 1 | 0] < tmp[sizea] || tmp[totalSize - 1 | 0] < tmp[0]) { + return { + data: undefined + }; + } + var tmp2 = new Array(sizea < sizeb ? sizea : sizeb); + var k = Belt__Belt_SortArrayString.intersect(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); + return { + data: Belt__Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) + }; +} + +function diff(dataa, datab) { + var dataa$1 = dataa.data; + var datab$1 = datab.data; + if (dataa$1 === undefined) { + return { + data: undefined + }; + } + if (datab$1 === undefined) { + return { + data: Belt__Belt_internalAVLset.copy(dataa$1) + }; + } + var datab0 = Caml_option.valFromOption(datab$1); + var dataa0 = Caml_option.valFromOption(dataa$1); + var sizea = Belt__Belt_internalAVLset.lengthNode(dataa0); + var sizeb = Belt__Belt_internalAVLset.lengthNode(datab0); + var totalSize = sizea + sizeb | 0; + var tmp = new Array(totalSize); + Belt__Belt_internalAVLset.fillArray(dataa0, 0, tmp); + Belt__Belt_internalAVLset.fillArray(datab0, sizea, tmp); + if (tmp[sizea - 1 | 0] < tmp[sizea] || tmp[totalSize - 1 | 0] < tmp[0]) { + return { + data: Belt__Belt_internalAVLset.copy(dataa$1) + }; + } + var tmp2 = new Array(sizea); + var k = Belt__Belt_SortArrayString.diff(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); + return { + data: Belt__Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) + }; +} + +function union(dataa, datab) { + var dataa$1 = dataa.data; + var datab$1 = datab.data; + if (dataa$1 === undefined) { + return { + data: Belt__Belt_internalAVLset.copy(datab$1) + }; + } + if (datab$1 === undefined) { + return { + data: Belt__Belt_internalAVLset.copy(dataa$1) + }; + } + var datab0 = Caml_option.valFromOption(datab$1); + var dataa0 = Caml_option.valFromOption(dataa$1); + var sizea = Belt__Belt_internalAVLset.lengthNode(dataa0); + var sizeb = Belt__Belt_internalAVLset.lengthNode(datab0); + var totalSize = sizea + sizeb | 0; + var tmp = new Array(totalSize); + Belt__Belt_internalAVLset.fillArray(dataa0, 0, tmp); + Belt__Belt_internalAVLset.fillArray(datab0, sizea, tmp); + if (tmp[sizea - 1 | 0] < tmp[sizea]) { + return { + data: Belt__Belt_internalAVLset.fromSortedArrayAux(tmp, 0, totalSize) + }; + } + var tmp2 = new Array(totalSize); + var k = Belt__Belt_SortArrayString.union(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); + return { + data: Belt__Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) + }; +} + +function has(d, x) { + return Belt__Belt_internalSetString.has(d.data, x); +} + +function copy(d) { + return { + data: Belt__Belt_internalAVLset.copy(d.data) + }; +} + +export { + make , + fromArray , + fromSortedArrayUnsafe , + copy , + isEmpty , + has , + add , + addCheck , + mergeMany , + remove , + removeCheck , + removeMany , + union , + intersect , + diff , + subset , + cmp , + eq , + forEachU , + forEach , + reduceU , + reduce , + everyU , + every , + someU , + some , + keepU , + keep , + partitionU , + partition , + size , + toList , + toArray , + minimum , + minUndefined , + maximum , + maxUndefined , + get , + getUndefined , + getExn , + split , + checkInvariantInternal , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_MutableStack.js b/melange-node-modules/melange.belt/belt_MutableStack.js new file mode 100644 index 0000000..bb27c9b --- /dev/null +++ b/melange-node-modules/melange.belt/belt_MutableStack.js @@ -0,0 +1,141 @@ +// Generated by Melange + +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function make(param) { + return { + root: undefined + }; +} + +function clear(s) { + s.root = undefined; +} + +function copy(s) { + return { + root: s.root + }; +} + +function push(s, x) { + s.root = { + head: x, + tail: s.root + }; +} + +function topUndefined(s) { + var x = s.root; + if (x !== undefined) { + return Caml_option.valFromOption(x).head; + } + +} + +function top(s) { + var x = s.root; + if (x !== undefined) { + return Caml_option.some(Caml_option.valFromOption(x).head); + } + +} + +function isEmpty(s) { + return s.root === undefined; +} + +function popUndefined(s) { + var x = s.root; + if (x === undefined) { + return ; + } + var x$1 = Caml_option.valFromOption(x); + s.root = x$1.tail; + return x$1.head; +} + +function pop(s) { + var x = s.root; + if (x === undefined) { + return ; + } + var x$1 = Caml_option.valFromOption(x); + s.root = x$1.tail; + return Caml_option.some(x$1.head); +} + +function size(s) { + var x = s.root; + if (x !== undefined) { + var _x = Caml_option.valFromOption(x); + var _acc = 0; + while(true) { + var acc = _acc; + var x$1 = _x; + var x$2 = x$1.tail; + if (x$2 === undefined) { + return acc + 1 | 0; + } + _acc = acc + 1 | 0; + _x = Caml_option.valFromOption(x$2); + continue ; + }; + } else { + return 0; + } +} + +function forEachU(s, f) { + var _s = s.root; + while(true) { + var s$1 = _s; + if (s$1 === undefined) { + return ; + } + var x = Caml_option.valFromOption(s$1); + f(x.head); + _s = x.tail; + continue ; + }; +} + +function forEach(s, f) { + forEachU(s, Curry.__1(f)); +} + +function dynamicPopIterU(s, f) { + while(true) { + var match = s.root; + if (match === undefined) { + return ; + } + var match$1 = Caml_option.valFromOption(match); + s.root = match$1.tail; + f(match$1.head); + continue ; + }; +} + +function dynamicPopIter(s, f) { + dynamicPopIterU(s, Curry.__1(f)); +} + +export { + make , + clear , + copy , + push , + popUndefined , + pop , + topUndefined , + top , + isEmpty , + size , + forEachU , + forEach , + dynamicPopIterU , + dynamicPopIter , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_Option.js b/melange-node-modules/melange.belt/belt_Option.js new file mode 100644 index 0000000..888a3e7 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_Option.js @@ -0,0 +1,151 @@ +// Generated by Melange + +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function keepU(opt, p) { + if (opt !== undefined && p(Caml_option.valFromOption(opt))) { + return opt; + } + +} + +function keep(opt, p) { + return keepU(opt, Curry.__1(p)); +} + +function forEachU(opt, f) { + if (opt !== undefined) { + return f(Caml_option.valFromOption(opt)); + } + +} + +function forEach(opt, f) { + forEachU(opt, Curry.__1(f)); +} + +function getExn(param) { + if (param !== undefined) { + return Caml_option.valFromOption(param); + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; +} + +function mapWithDefaultU(opt, $$default, f) { + if (opt !== undefined) { + return f(Caml_option.valFromOption(opt)); + } else { + return $$default; + } +} + +function mapWithDefault(opt, $$default, f) { + return mapWithDefaultU(opt, $$default, Curry.__1(f)); +} + +function mapU(opt, f) { + if (opt !== undefined) { + return Caml_option.some(f(Caml_option.valFromOption(opt))); + } + +} + +function map(opt, f) { + return mapU(opt, Curry.__1(f)); +} + +function flatMapU(opt, f) { + if (opt !== undefined) { + return f(Caml_option.valFromOption(opt)); + } + +} + +function flatMap(opt, f) { + return flatMapU(opt, Curry.__1(f)); +} + +function getWithDefault(opt, $$default) { + if (opt !== undefined) { + return Caml_option.valFromOption(opt); + } else { + return $$default; + } +} + +function orElse(opt, other) { + if (opt !== undefined) { + return opt; + } else { + return other; + } +} + +function isSome(param) { + return param !== undefined; +} + +function isNone(x) { + return x === undefined; +} + +function eqU(a, b, f) { + if (a !== undefined) { + if (b !== undefined) { + return f(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); + } else { + return false; + } + } else { + return b === undefined; + } +} + +function eq(a, b, f) { + return eqU(a, b, Curry.__2(f)); +} + +function cmpU(a, b, f) { + if (a !== undefined) { + if (b !== undefined) { + return f(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); + } else { + return 1; + } + } else if (b !== undefined) { + return -1; + } else { + return 0; + } +} + +function cmp(a, b, f) { + return cmpU(a, b, Curry.__2(f)); +} + +export { + keepU , + keep , + forEachU , + forEach , + getExn , + mapWithDefaultU , + mapWithDefault , + mapU , + map , + flatMapU , + flatMap , + getWithDefault , + orElse , + isSome , + isNone , + eqU , + eq , + cmpU , + cmp , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_Range.js b/melange-node-modules/melange.belt/belt_Range.js new file mode 100644 index 0000000..f8106a1 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_Range.js @@ -0,0 +1,109 @@ +// Generated by Melange + +import * as Curry from "melange.js/curry.js"; + +function forEachU(s, f, action) { + for(var i = s; i <= f; ++i){ + action(i); + } +} + +function forEach(s, f, action) { + forEachU(s, f, Curry.__1(action)); +} + +function everyU(_s, f, p) { + while(true) { + var s = _s; + if (s > f) { + return true; + } + if (!p(s)) { + return false; + } + _s = s + 1 | 0; + continue ; + }; +} + +function every(s, f, p) { + return everyU(s, f, Curry.__1(p)); +} + +function everyByU(s, f, step, p) { + if (step > 0) { + var _s = s; + while(true) { + var s$1 = _s; + if (s$1 > f) { + return true; + } + if (!p(s$1)) { + return false; + } + _s = s$1 + step | 0; + continue ; + }; + } else { + return true; + } +} + +function everyBy(s, f, step, p) { + return everyByU(s, f, step, Curry.__1(p)); +} + +function someU(_s, f, p) { + while(true) { + var s = _s; + if (s > f) { + return false; + } + if (p(s)) { + return true; + } + _s = s + 1 | 0; + continue ; + }; +} + +function some(s, f, p) { + return someU(s, f, Curry.__1(p)); +} + +function someByU(s, f, step, p) { + if (step > 0) { + var _s = s; + while(true) { + var s$1 = _s; + if (s$1 > f) { + return false; + } + if (p(s$1)) { + return true; + } + _s = s$1 + step | 0; + continue ; + }; + } else { + return false; + } +} + +function someBy(s, f, step, p) { + return someByU(s, f, step, Curry.__1(p)); +} + +export { + forEachU , + forEach , + everyU , + every , + everyByU , + everyBy , + someU , + some , + someByU , + someBy , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_Result.js b/melange-node-modules/melange.belt/belt_Result.js new file mode 100644 index 0000000..9959ab2 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_Result.js @@ -0,0 +1,136 @@ +// Generated by Melange + +import * as Curry from "melange.js/curry.js"; + +function getExn(param) { + if (param.TAG === /* Ok */0) { + return param._0; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; +} + +function mapWithDefaultU(opt, $$default, f) { + if (opt.TAG === /* Ok */0) { + return f(opt._0); + } else { + return $$default; + } +} + +function mapWithDefault(opt, $$default, f) { + return mapWithDefaultU(opt, $$default, Curry.__1(f)); +} + +function mapU(opt, f) { + if (opt.TAG === /* Ok */0) { + return { + TAG: /* Ok */0, + _0: f(opt._0) + }; + } else { + return { + TAG: /* Error */1, + _0: opt._0 + }; + } +} + +function map(opt, f) { + return mapU(opt, Curry.__1(f)); +} + +function flatMapU(opt, f) { + if (opt.TAG === /* Ok */0) { + return f(opt._0); + } else { + return { + TAG: /* Error */1, + _0: opt._0 + }; + } +} + +function flatMap(opt, f) { + return flatMapU(opt, Curry.__1(f)); +} + +function getWithDefault(opt, $$default) { + if (opt.TAG === /* Ok */0) { + return opt._0; + } else { + return $$default; + } +} + +function isOk(param) { + if (param.TAG === /* Ok */0) { + return true; + } else { + return false; + } +} + +function isError(param) { + if (param.TAG === /* Ok */0) { + return false; + } else { + return true; + } +} + +function eqU(a, b, f) { + if (a.TAG === /* Ok */0) { + if (b.TAG === /* Ok */0) { + return f(a._0, b._0); + } else { + return false; + } + } else if (b.TAG === /* Ok */0) { + return false; + } else { + return true; + } +} + +function eq(a, b, f) { + return eqU(a, b, Curry.__2(f)); +} + +function cmpU(a, b, f) { + if (a.TAG === /* Ok */0) { + if (b.TAG === /* Ok */0) { + return f(a._0, b._0); + } else { + return 1; + } + } else if (b.TAG === /* Ok */0) { + return -1; + } else { + return 0; + } +} + +function cmp(a, b, f) { + return cmpU(a, b, Curry.__2(f)); +} + +export { + getExn , + mapWithDefaultU , + mapWithDefault , + mapU , + map , + flatMapU , + flatMap , + getWithDefault , + isOk , + isError , + eqU , + eq , + cmpU , + cmp , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_Set.js b/melange-node-modules/melange.belt/belt_Set.js new file mode 100644 index 0000000..b103e49 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_Set.js @@ -0,0 +1,305 @@ +// Generated by Melange + +import * as Belt__Belt_SetDict from "./belt_SetDict.js"; +import * as Curry from "melange.js/curry.js"; + +function fromArray(data, id) { + var cmp = id.cmp; + return { + cmp: cmp, + data: Belt__Belt_SetDict.fromArray(data, cmp) + }; +} + +function remove(m, e) { + var data = m.data; + var cmp = m.cmp; + var newData = Belt__Belt_SetDict.remove(data, e, cmp); + if (newData === data) { + return m; + } else { + return { + cmp: cmp, + data: newData + }; + } +} + +function add(m, e) { + var data = m.data; + var cmp = m.cmp; + var newData = Belt__Belt_SetDict.add(data, e, cmp); + if (newData === data) { + return m; + } else { + return { + cmp: cmp, + data: newData + }; + } +} + +function mergeMany(m, e) { + var cmp = m.cmp; + return { + cmp: cmp, + data: Belt__Belt_SetDict.mergeMany(m.data, e, cmp) + }; +} + +function removeMany(m, e) { + var cmp = m.cmp; + return { + cmp: cmp, + data: Belt__Belt_SetDict.removeMany(m.data, e, cmp) + }; +} + +function union(m, n) { + var cmp = m.cmp; + return { + cmp: cmp, + data: Belt__Belt_SetDict.union(m.data, n.data, cmp) + }; +} + +function intersect(m, n) { + var cmp = m.cmp; + return { + cmp: cmp, + data: Belt__Belt_SetDict.intersect(m.data, n.data, cmp) + }; +} + +function diff(m, n) { + var cmp = m.cmp; + return { + cmp: cmp, + data: Belt__Belt_SetDict.diff(m.data, n.data, cmp) + }; +} + +function subset(m, n) { + var cmp = m.cmp; + return Belt__Belt_SetDict.subset(m.data, n.data, cmp); +} + +function split(m, e) { + var cmp = m.cmp; + var match = Belt__Belt_SetDict.split(m.data, e, cmp); + var match$1 = match[0]; + return [ + [ + { + cmp: cmp, + data: match$1[0] + }, + { + cmp: cmp, + data: match$1[1] + } + ], + match[1] + ]; +} + +function make(id) { + return { + cmp: id.cmp, + data: undefined + }; +} + +function isEmpty(m) { + return Belt__Belt_SetDict.isEmpty(m.data); +} + +function cmp(m, n) { + var cmp$1 = m.cmp; + return Belt__Belt_SetDict.cmp(m.data, n.data, cmp$1); +} + +function eq(m, n) { + return Belt__Belt_SetDict.eq(m.data, n.data, m.cmp); +} + +function forEachU(m, f) { + Belt__Belt_SetDict.forEachU(m.data, f); +} + +function forEach(m, f) { + Belt__Belt_SetDict.forEachU(m.data, Curry.__1(f)); +} + +function reduceU(m, acc, f) { + return Belt__Belt_SetDict.reduceU(m.data, acc, f); +} + +function reduce(m, acc, f) { + return reduceU(m, acc, Curry.__2(f)); +} + +function everyU(m, f) { + return Belt__Belt_SetDict.everyU(m.data, f); +} + +function every(m, f) { + return Belt__Belt_SetDict.everyU(m.data, Curry.__1(f)); +} + +function someU(m, f) { + return Belt__Belt_SetDict.someU(m.data, f); +} + +function some(m, f) { + return Belt__Belt_SetDict.someU(m.data, Curry.__1(f)); +} + +function keepU(m, f) { + return { + cmp: m.cmp, + data: Belt__Belt_SetDict.keepU(m.data, f) + }; +} + +function keep(m, f) { + return keepU(m, Curry.__1(f)); +} + +function partitionU(m, f) { + var match = Belt__Belt_SetDict.partitionU(m.data, f); + var cmp = m.cmp; + return [ + { + cmp: cmp, + data: match[0] + }, + { + cmp: cmp, + data: match[1] + } + ]; +} + +function partition(m, f) { + return partitionU(m, Curry.__1(f)); +} + +function size(m) { + return Belt__Belt_SetDict.size(m.data); +} + +function toList(m) { + return Belt__Belt_SetDict.toList(m.data); +} + +function toArray(m) { + return Belt__Belt_SetDict.toArray(m.data); +} + +function minimum(m) { + return Belt__Belt_SetDict.minimum(m.data); +} + +function minUndefined(m) { + return Belt__Belt_SetDict.minUndefined(m.data); +} + +function maximum(m) { + return Belt__Belt_SetDict.maximum(m.data); +} + +function maxUndefined(m) { + return Belt__Belt_SetDict.maxUndefined(m.data); +} + +function get(m, e) { + return Belt__Belt_SetDict.get(m.data, e, m.cmp); +} + +function getUndefined(m, e) { + return Belt__Belt_SetDict.getUndefined(m.data, e, m.cmp); +} + +function getExn(m, e) { + return Belt__Belt_SetDict.getExn(m.data, e, m.cmp); +} + +function has(m, e) { + return Belt__Belt_SetDict.has(m.data, e, m.cmp); +} + +function fromSortedArrayUnsafe(xs, id) { + return { + cmp: id.cmp, + data: Belt__Belt_SetDict.fromSortedArrayUnsafe(xs) + }; +} + +function getData(m) { + return m.data; +} + +function getId(m) { + var cmp = m.cmp; + return { + cmp: cmp + }; +} + +function packIdData(id, data) { + return { + cmp: id.cmp, + data: data + }; +} + +function checkInvariantInternal(d) { + Belt__Belt_SetDict.checkInvariantInternal(d.data); +} + +export { + make , + fromArray , + fromSortedArrayUnsafe , + isEmpty , + has , + add , + mergeMany , + remove , + removeMany , + union , + intersect , + diff , + subset , + cmp , + eq , + forEachU , + forEach , + reduceU , + reduce , + everyU , + every , + someU , + some , + keepU , + keep , + partitionU , + partition , + size , + toArray , + toList , + minimum , + minUndefined , + maximum , + maxUndefined , + get , + getUndefined , + getExn , + split , + checkInvariantInternal , + getData , + getId , + packIdData , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_SetDict.js b/melange-node-modules/melange.belt/belt_SetDict.js new file mode 100644 index 0000000..ea4110e --- /dev/null +++ b/melange-node-modules/melange.belt/belt_SetDict.js @@ -0,0 +1,370 @@ +// Generated by Melange + +import * as Belt__Belt_internalAVLset from "./belt_internalAVLset.js"; +import * as Caml_option from "melange.js/caml_option.js"; + +function add(t, x, cmp) { + if (t === undefined) { + return Belt__Belt_internalAVLset.singleton(x); + } + var nt = Caml_option.valFromOption(t); + var k = nt.v; + var c = cmp(x, k); + if (c === 0) { + return t; + } + var l = nt.l; + var r = nt.r; + if (c < 0) { + var ll = add(l, x, cmp); + if (ll === l) { + return t; + } else { + return Belt__Belt_internalAVLset.bal(ll, k, r); + } + } + var rr = add(r, x, cmp); + if (rr === r) { + return t; + } else { + return Belt__Belt_internalAVLset.bal(l, k, rr); + } +} + +function remove(t, x, cmp) { + if (t === undefined) { + return t; + } + var n = Caml_option.valFromOption(t); + var v = n.v; + var l = n.l; + var r = n.r; + var c = cmp(x, v); + if (c === 0) { + if (l === undefined) { + return r; + } + if (r === undefined) { + return l; + } + var rn = Caml_option.valFromOption(r); + var v$1 = { + contents: rn.v + }; + var r$1 = Belt__Belt_internalAVLset.removeMinAuxWithRef(rn, v$1); + return Belt__Belt_internalAVLset.bal(l, v$1.contents, r$1); + } + if (c < 0) { + var ll = remove(l, x, cmp); + if (ll === l) { + return t; + } else { + return Belt__Belt_internalAVLset.bal(ll, v, r); + } + } + var rr = remove(r, x, cmp); + if (rr === r) { + return t; + } else { + return Belt__Belt_internalAVLset.bal(l, v, rr); + } +} + +function mergeMany(h, arr, cmp) { + var len = arr.length; + var v = h; + for(var i = 0; i < len; ++i){ + var key = arr[i]; + v = add(v, key, cmp); + } + return v; +} + +function removeMany(h, arr, cmp) { + var len = arr.length; + var v = h; + for(var i = 0; i < len; ++i){ + var key = arr[i]; + v = remove(v, key, cmp); + } + return v; +} + +function splitAuxNoPivot(cmp, n, x) { + var v = n.v; + var l = n.l; + var r = n.r; + var c = cmp(x, v); + if (c === 0) { + return [ + l, + r + ]; + } + if (c < 0) { + if (l === undefined) { + return [ + undefined, + n + ]; + } + var match = splitAuxNoPivot(cmp, Caml_option.valFromOption(l), x); + return [ + match[0], + Belt__Belt_internalAVLset.joinShared(match[1], v, r) + ]; + } + if (r === undefined) { + return [ + n, + undefined + ]; + } + var match$1 = splitAuxNoPivot(cmp, Caml_option.valFromOption(r), x); + return [ + Belt__Belt_internalAVLset.joinShared(l, v, match$1[0]), + match$1[1] + ]; +} + +function splitAuxPivot(cmp, n, x, pres) { + var v = n.v; + var l = n.l; + var r = n.r; + var c = cmp(x, v); + if (c === 0) { + pres.contents = true; + return [ + l, + r + ]; + } + if (c < 0) { + if (l === undefined) { + return [ + undefined, + n + ]; + } + var match = splitAuxPivot(cmp, Caml_option.valFromOption(l), x, pres); + return [ + match[0], + Belt__Belt_internalAVLset.joinShared(match[1], v, r) + ]; + } + if (r === undefined) { + return [ + n, + undefined + ]; + } + var match$1 = splitAuxPivot(cmp, Caml_option.valFromOption(r), x, pres); + return [ + Belt__Belt_internalAVLset.joinShared(l, v, match$1[0]), + match$1[1] + ]; +} + +function split(t, x, cmp) { + if (t === undefined) { + return [ + [ + undefined, + undefined + ], + false + ]; + } + var pres = { + contents: false + }; + var v = splitAuxPivot(cmp, Caml_option.valFromOption(t), x, pres); + return [ + v, + pres.contents + ]; +} + +function union(s1, s2, cmp) { + if (s1 === undefined) { + return s2; + } + if (s2 === undefined) { + return s1; + } + var n2 = Caml_option.valFromOption(s2); + var n1 = Caml_option.valFromOption(s1); + var h1 = n1.h; + var h2 = n2.h; + if (h1 >= h2) { + if (h2 === 1) { + return add(s1, n2.v, cmp); + } + var v1 = n1.v; + var l1 = n1.l; + var r1 = n1.r; + var match = splitAuxNoPivot(cmp, n2, v1); + return Belt__Belt_internalAVLset.joinShared(union(l1, match[0], cmp), v1, union(r1, match[1], cmp)); + } + if (h1 === 1) { + return add(s2, n1.v, cmp); + } + var v2 = n2.v; + var l2 = n2.l; + var r2 = n2.r; + var match$1 = splitAuxNoPivot(cmp, n1, v2); + return Belt__Belt_internalAVLset.joinShared(union(match$1[0], l2, cmp), v2, union(match$1[1], r2, cmp)); +} + +function intersect(s1, s2, cmp) { + if (s1 === undefined) { + return ; + } + if (s2 === undefined) { + return ; + } + var n1 = Caml_option.valFromOption(s1); + var v1 = n1.v; + var l1 = n1.l; + var r1 = n1.r; + var pres = { + contents: false + }; + var match = splitAuxPivot(cmp, Caml_option.valFromOption(s2), v1, pres); + var ll = intersect(l1, match[0], cmp); + var rr = intersect(r1, match[1], cmp); + if (pres.contents) { + return Belt__Belt_internalAVLset.joinShared(ll, v1, rr); + } else { + return Belt__Belt_internalAVLset.concatShared(ll, rr); + } +} + +function diff(s1, s2, cmp) { + if (s1 === undefined) { + return s1; + } + if (s2 === undefined) { + return s1; + } + var n1 = Caml_option.valFromOption(s1); + var v1 = n1.v; + var l1 = n1.l; + var r1 = n1.r; + var pres = { + contents: false + }; + var match = splitAuxPivot(cmp, Caml_option.valFromOption(s2), v1, pres); + var ll = diff(l1, match[0], cmp); + var rr = diff(r1, match[1], cmp); + if (pres.contents) { + return Belt__Belt_internalAVLset.concatShared(ll, rr); + } else { + return Belt__Belt_internalAVLset.joinShared(ll, v1, rr); + } +} + +var empty; + +var fromArray = Belt__Belt_internalAVLset.fromArray; + +var fromSortedArrayUnsafe = Belt__Belt_internalAVLset.fromSortedArrayUnsafe; + +var isEmpty = Belt__Belt_internalAVLset.isEmpty; + +var has = Belt__Belt_internalAVLset.has; + +var subset = Belt__Belt_internalAVLset.subset; + +var cmp = Belt__Belt_internalAVLset.cmp; + +var eq = Belt__Belt_internalAVLset.eq; + +var forEachU = Belt__Belt_internalAVLset.forEachU; + +var forEach = Belt__Belt_internalAVLset.forEach; + +var reduceU = Belt__Belt_internalAVLset.reduceU; + +var reduce = Belt__Belt_internalAVLset.reduce; + +var everyU = Belt__Belt_internalAVLset.everyU; + +var every = Belt__Belt_internalAVLset.every; + +var someU = Belt__Belt_internalAVLset.someU; + +var some = Belt__Belt_internalAVLset.some; + +var keepU = Belt__Belt_internalAVLset.keepSharedU; + +var keep = Belt__Belt_internalAVLset.keepShared; + +var partitionU = Belt__Belt_internalAVLset.partitionSharedU; + +var partition = Belt__Belt_internalAVLset.partitionShared; + +var size = Belt__Belt_internalAVLset.size; + +var toList = Belt__Belt_internalAVLset.toList; + +var toArray = Belt__Belt_internalAVLset.toArray; + +var minimum = Belt__Belt_internalAVLset.minimum; + +var minUndefined = Belt__Belt_internalAVLset.minUndefined; + +var maximum = Belt__Belt_internalAVLset.maximum; + +var maxUndefined = Belt__Belt_internalAVLset.maxUndefined; + +var get = Belt__Belt_internalAVLset.get; + +var getUndefined = Belt__Belt_internalAVLset.getUndefined; + +var getExn = Belt__Belt_internalAVLset.getExn; + +var checkInvariantInternal = Belt__Belt_internalAVLset.checkInvariantInternal; + +export { + empty , + fromArray , + fromSortedArrayUnsafe , + isEmpty , + has , + add , + mergeMany , + remove , + removeMany , + union , + intersect , + diff , + subset , + cmp , + eq , + forEachU , + forEach , + reduceU , + reduce , + everyU , + every , + someU , + some , + keepU , + keep , + partitionU , + partition , + size , + toList , + toArray , + minimum , + minUndefined , + maximum , + maxUndefined , + get , + getUndefined , + getExn , + split , + checkInvariantInternal , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_SetInt.js b/melange-node-modules/melange.belt/belt_SetInt.js new file mode 100644 index 0000000..2c99abc --- /dev/null +++ b/melange-node-modules/melange.belt/belt_SetInt.js @@ -0,0 +1,366 @@ +// Generated by Melange + +import * as Belt__Belt_internalAVLset from "./belt_internalAVLset.js"; +import * as Belt__Belt_internalSetInt from "./belt_internalSetInt.js"; +import * as Caml_option from "melange.js/caml_option.js"; + +function add(t, x) { + if (t === undefined) { + return Belt__Belt_internalAVLset.singleton(x); + } + var nt = Caml_option.valFromOption(t); + var v = nt.v; + if (x === v) { + return t; + } + var l = nt.l; + var r = nt.r; + if (x < v) { + var ll = add(l, x); + if (ll === l) { + return t; + } else { + return Belt__Belt_internalAVLset.bal(ll, v, r); + } + } + var rr = add(r, x); + if (rr === r) { + return t; + } else { + return Belt__Belt_internalAVLset.bal(l, v, rr); + } +} + +function mergeMany(h, arr) { + var len = arr.length; + var v = h; + for(var i = 0; i < len; ++i){ + var key = arr[i]; + v = add(v, key); + } + return v; +} + +function remove(t, x) { + if (t === undefined) { + return t; + } + var n = Caml_option.valFromOption(t); + var v = n.v; + var l = n.l; + var r = n.r; + if (x === v) { + if (l === undefined) { + return r; + } + if (r === undefined) { + return l; + } + var v$1 = { + contents: r.v + }; + var r$1 = Belt__Belt_internalAVLset.removeMinAuxWithRef(r, v$1); + return Belt__Belt_internalAVLset.bal(l, v$1.contents, r$1); + } + if (x < v) { + var ll = remove(l, x); + if (ll === l) { + return t; + } else { + return Belt__Belt_internalAVLset.bal(ll, v, r); + } + } + var rr = remove(r, x); + if (rr === r) { + return t; + } else { + return Belt__Belt_internalAVLset.bal(l, v, rr); + } +} + +function removeMany(h, arr) { + var len = arr.length; + var v = h; + for(var i = 0; i < len; ++i){ + var key = arr[i]; + v = remove(v, key); + } + return v; +} + +function splitAuxNoPivot(n, x) { + var v = n.v; + var l = n.l; + var r = n.r; + if (x === v) { + return [ + l, + r + ]; + } + if (x < v) { + if (l === undefined) { + return [ + undefined, + n + ]; + } + var match = splitAuxNoPivot(l, x); + return [ + match[0], + Belt__Belt_internalAVLset.joinShared(match[1], v, r) + ]; + } + if (r === undefined) { + return [ + n, + undefined + ]; + } + var match$1 = splitAuxNoPivot(r, x); + return [ + Belt__Belt_internalAVLset.joinShared(l, v, match$1[0]), + match$1[1] + ]; +} + +function splitAuxPivot(n, x, pres) { + var v = n.v; + var l = n.l; + var r = n.r; + if (x === v) { + pres.contents = true; + return [ + l, + r + ]; + } + if (x < v) { + if (l === undefined) { + return [ + undefined, + n + ]; + } + var match = splitAuxPivot(l, x, pres); + return [ + match[0], + Belt__Belt_internalAVLset.joinShared(match[1], v, r) + ]; + } + if (r === undefined) { + return [ + n, + undefined + ]; + } + var match$1 = splitAuxPivot(r, x, pres); + return [ + Belt__Belt_internalAVLset.joinShared(l, v, match$1[0]), + match$1[1] + ]; +} + +function split(t, x) { + if (t === undefined) { + return [ + [ + undefined, + undefined + ], + false + ]; + } + var pres = { + contents: false + }; + var v = splitAuxPivot(Caml_option.valFromOption(t), x, pres); + return [ + v, + pres.contents + ]; +} + +function union(s1, s2) { + if (s1 === undefined) { + return s2; + } + if (s2 === undefined) { + return s1; + } + var n2 = Caml_option.valFromOption(s2); + var n1 = Caml_option.valFromOption(s1); + var h1 = n1.h; + var h2 = n2.h; + if (h1 >= h2) { + if (h2 === 1) { + return add(s1, n2.v); + } + var v1 = n1.v; + var l1 = n1.l; + var r1 = n1.r; + var match = splitAuxNoPivot(n2, v1); + return Belt__Belt_internalAVLset.joinShared(union(l1, match[0]), v1, union(r1, match[1])); + } + if (h1 === 1) { + return add(s2, n1.v); + } + var v2 = n2.v; + var l2 = n2.l; + var r2 = n2.r; + var match$1 = splitAuxNoPivot(n1, v2); + return Belt__Belt_internalAVLset.joinShared(union(match$1[0], l2), v2, union(match$1[1], r2)); +} + +function intersect(s1, s2) { + if (s1 === undefined) { + return ; + } + if (s2 === undefined) { + return ; + } + var n1 = Caml_option.valFromOption(s1); + var v1 = n1.v; + var l1 = n1.l; + var r1 = n1.r; + var pres = { + contents: false + }; + var match = splitAuxPivot(Caml_option.valFromOption(s2), v1, pres); + var ll = intersect(l1, match[0]); + var rr = intersect(r1, match[1]); + if (pres.contents) { + return Belt__Belt_internalAVLset.joinShared(ll, v1, rr); + } else { + return Belt__Belt_internalAVLset.concatShared(ll, rr); + } +} + +function diff(s1, s2) { + if (s1 === undefined) { + return s1; + } + if (s2 === undefined) { + return s1; + } + var n1 = Caml_option.valFromOption(s1); + var v1 = n1.v; + var l1 = n1.l; + var r1 = n1.r; + var pres = { + contents: false + }; + var match = splitAuxPivot(Caml_option.valFromOption(s2), v1, pres); + var ll = diff(l1, match[0]); + var rr = diff(r1, match[1]); + if (pres.contents) { + return Belt__Belt_internalAVLset.concatShared(ll, rr); + } else { + return Belt__Belt_internalAVLset.joinShared(ll, v1, rr); + } +} + +var empty; + +var fromArray = Belt__Belt_internalSetInt.fromArray; + +var fromSortedArrayUnsafe = Belt__Belt_internalAVLset.fromSortedArrayUnsafe; + +var isEmpty = Belt__Belt_internalAVLset.isEmpty; + +var has = Belt__Belt_internalSetInt.has; + +var subset = Belt__Belt_internalSetInt.subset; + +var cmp = Belt__Belt_internalSetInt.cmp; + +var eq = Belt__Belt_internalSetInt.eq; + +var forEachU = Belt__Belt_internalAVLset.forEachU; + +var forEach = Belt__Belt_internalAVLset.forEach; + +var reduceU = Belt__Belt_internalAVLset.reduceU; + +var reduce = Belt__Belt_internalAVLset.reduce; + +var everyU = Belt__Belt_internalAVLset.everyU; + +var every = Belt__Belt_internalAVLset.every; + +var someU = Belt__Belt_internalAVLset.someU; + +var some = Belt__Belt_internalAVLset.some; + +var keepU = Belt__Belt_internalAVLset.keepSharedU; + +var keep = Belt__Belt_internalAVLset.keepShared; + +var partitionU = Belt__Belt_internalAVLset.partitionSharedU; + +var partition = Belt__Belt_internalAVLset.partitionShared; + +var size = Belt__Belt_internalAVLset.size; + +var toList = Belt__Belt_internalAVLset.toList; + +var toArray = Belt__Belt_internalAVLset.toArray; + +var minimum = Belt__Belt_internalAVLset.minimum; + +var minUndefined = Belt__Belt_internalAVLset.minUndefined; + +var maximum = Belt__Belt_internalAVLset.maximum; + +var maxUndefined = Belt__Belt_internalAVLset.maxUndefined; + +var get = Belt__Belt_internalSetInt.get; + +var getUndefined = Belt__Belt_internalSetInt.getUndefined; + +var getExn = Belt__Belt_internalSetInt.getExn; + +var checkInvariantInternal = Belt__Belt_internalAVLset.checkInvariantInternal; + +export { + empty , + fromArray , + fromSortedArrayUnsafe , + isEmpty , + has , + add , + mergeMany , + remove , + removeMany , + union , + intersect , + diff , + subset , + cmp , + eq , + forEachU , + forEach , + reduceU , + reduce , + everyU , + every , + someU , + some , + keepU , + keep , + partitionU , + partition , + size , + toList , + toArray , + minimum , + minUndefined , + maximum , + maxUndefined , + get , + getUndefined , + getExn , + split , + checkInvariantInternal , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_SetString.js b/melange-node-modules/melange.belt/belt_SetString.js new file mode 100644 index 0000000..247b7e9 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_SetString.js @@ -0,0 +1,366 @@ +// Generated by Melange + +import * as Belt__Belt_internalAVLset from "./belt_internalAVLset.js"; +import * as Belt__Belt_internalSetString from "./belt_internalSetString.js"; +import * as Caml_option from "melange.js/caml_option.js"; + +function add(t, x) { + if (t === undefined) { + return Belt__Belt_internalAVLset.singleton(x); + } + var nt = Caml_option.valFromOption(t); + var v = nt.v; + if (x === v) { + return t; + } + var l = nt.l; + var r = nt.r; + if (x < v) { + var ll = add(l, x); + if (ll === l) { + return t; + } else { + return Belt__Belt_internalAVLset.bal(ll, v, r); + } + } + var rr = add(r, x); + if (rr === r) { + return t; + } else { + return Belt__Belt_internalAVLset.bal(l, v, rr); + } +} + +function mergeMany(h, arr) { + var len = arr.length; + var v = h; + for(var i = 0; i < len; ++i){ + var key = arr[i]; + v = add(v, key); + } + return v; +} + +function remove(t, x) { + if (t === undefined) { + return t; + } + var n = Caml_option.valFromOption(t); + var v = n.v; + var l = n.l; + var r = n.r; + if (x === v) { + if (l === undefined) { + return r; + } + if (r === undefined) { + return l; + } + var v$1 = { + contents: r.v + }; + var r$1 = Belt__Belt_internalAVLset.removeMinAuxWithRef(r, v$1); + return Belt__Belt_internalAVLset.bal(l, v$1.contents, r$1); + } + if (x < v) { + var ll = remove(l, x); + if (ll === l) { + return t; + } else { + return Belt__Belt_internalAVLset.bal(ll, v, r); + } + } + var rr = remove(r, x); + if (rr === r) { + return t; + } else { + return Belt__Belt_internalAVLset.bal(l, v, rr); + } +} + +function removeMany(h, arr) { + var len = arr.length; + var v = h; + for(var i = 0; i < len; ++i){ + var key = arr[i]; + v = remove(v, key); + } + return v; +} + +function splitAuxNoPivot(n, x) { + var v = n.v; + var l = n.l; + var r = n.r; + if (x === v) { + return [ + l, + r + ]; + } + if (x < v) { + if (l === undefined) { + return [ + undefined, + n + ]; + } + var match = splitAuxNoPivot(l, x); + return [ + match[0], + Belt__Belt_internalAVLset.joinShared(match[1], v, r) + ]; + } + if (r === undefined) { + return [ + n, + undefined + ]; + } + var match$1 = splitAuxNoPivot(r, x); + return [ + Belt__Belt_internalAVLset.joinShared(l, v, match$1[0]), + match$1[1] + ]; +} + +function splitAuxPivot(n, x, pres) { + var v = n.v; + var l = n.l; + var r = n.r; + if (x === v) { + pres.contents = true; + return [ + l, + r + ]; + } + if (x < v) { + if (l === undefined) { + return [ + undefined, + n + ]; + } + var match = splitAuxPivot(l, x, pres); + return [ + match[0], + Belt__Belt_internalAVLset.joinShared(match[1], v, r) + ]; + } + if (r === undefined) { + return [ + n, + undefined + ]; + } + var match$1 = splitAuxPivot(r, x, pres); + return [ + Belt__Belt_internalAVLset.joinShared(l, v, match$1[0]), + match$1[1] + ]; +} + +function split(t, x) { + if (t === undefined) { + return [ + [ + undefined, + undefined + ], + false + ]; + } + var pres = { + contents: false + }; + var v = splitAuxPivot(Caml_option.valFromOption(t), x, pres); + return [ + v, + pres.contents + ]; +} + +function union(s1, s2) { + if (s1 === undefined) { + return s2; + } + if (s2 === undefined) { + return s1; + } + var n2 = Caml_option.valFromOption(s2); + var n1 = Caml_option.valFromOption(s1); + var h1 = n1.h; + var h2 = n2.h; + if (h1 >= h2) { + if (h2 === 1) { + return add(s1, n2.v); + } + var v1 = n1.v; + var l1 = n1.l; + var r1 = n1.r; + var match = splitAuxNoPivot(n2, v1); + return Belt__Belt_internalAVLset.joinShared(union(l1, match[0]), v1, union(r1, match[1])); + } + if (h1 === 1) { + return add(s2, n1.v); + } + var v2 = n2.v; + var l2 = n2.l; + var r2 = n2.r; + var match$1 = splitAuxNoPivot(n1, v2); + return Belt__Belt_internalAVLset.joinShared(union(match$1[0], l2), v2, union(match$1[1], r2)); +} + +function intersect(s1, s2) { + if (s1 === undefined) { + return ; + } + if (s2 === undefined) { + return ; + } + var n1 = Caml_option.valFromOption(s1); + var v1 = n1.v; + var l1 = n1.l; + var r1 = n1.r; + var pres = { + contents: false + }; + var match = splitAuxPivot(Caml_option.valFromOption(s2), v1, pres); + var ll = intersect(l1, match[0]); + var rr = intersect(r1, match[1]); + if (pres.contents) { + return Belt__Belt_internalAVLset.joinShared(ll, v1, rr); + } else { + return Belt__Belt_internalAVLset.concatShared(ll, rr); + } +} + +function diff(s1, s2) { + if (s1 === undefined) { + return s1; + } + if (s2 === undefined) { + return s1; + } + var n1 = Caml_option.valFromOption(s1); + var v1 = n1.v; + var l1 = n1.l; + var r1 = n1.r; + var pres = { + contents: false + }; + var match = splitAuxPivot(Caml_option.valFromOption(s2), v1, pres); + var ll = diff(l1, match[0]); + var rr = diff(r1, match[1]); + if (pres.contents) { + return Belt__Belt_internalAVLset.concatShared(ll, rr); + } else { + return Belt__Belt_internalAVLset.joinShared(ll, v1, rr); + } +} + +var empty; + +var fromArray = Belt__Belt_internalSetString.fromArray; + +var fromSortedArrayUnsafe = Belt__Belt_internalAVLset.fromSortedArrayUnsafe; + +var isEmpty = Belt__Belt_internalAVLset.isEmpty; + +var has = Belt__Belt_internalSetString.has; + +var subset = Belt__Belt_internalSetString.subset; + +var cmp = Belt__Belt_internalSetString.cmp; + +var eq = Belt__Belt_internalSetString.eq; + +var forEachU = Belt__Belt_internalAVLset.forEachU; + +var forEach = Belt__Belt_internalAVLset.forEach; + +var reduceU = Belt__Belt_internalAVLset.reduceU; + +var reduce = Belt__Belt_internalAVLset.reduce; + +var everyU = Belt__Belt_internalAVLset.everyU; + +var every = Belt__Belt_internalAVLset.every; + +var someU = Belt__Belt_internalAVLset.someU; + +var some = Belt__Belt_internalAVLset.some; + +var keepU = Belt__Belt_internalAVLset.keepSharedU; + +var keep = Belt__Belt_internalAVLset.keepShared; + +var partitionU = Belt__Belt_internalAVLset.partitionSharedU; + +var partition = Belt__Belt_internalAVLset.partitionShared; + +var size = Belt__Belt_internalAVLset.size; + +var toList = Belt__Belt_internalAVLset.toList; + +var toArray = Belt__Belt_internalAVLset.toArray; + +var minimum = Belt__Belt_internalAVLset.minimum; + +var minUndefined = Belt__Belt_internalAVLset.minUndefined; + +var maximum = Belt__Belt_internalAVLset.maximum; + +var maxUndefined = Belt__Belt_internalAVLset.maxUndefined; + +var get = Belt__Belt_internalSetString.get; + +var getUndefined = Belt__Belt_internalSetString.getUndefined; + +var getExn = Belt__Belt_internalSetString.getExn; + +var checkInvariantInternal = Belt__Belt_internalAVLset.checkInvariantInternal; + +export { + empty , + fromArray , + fromSortedArrayUnsafe , + isEmpty , + has , + add , + mergeMany , + remove , + removeMany , + union , + intersect , + diff , + subset , + cmp , + eq , + forEachU , + forEach , + reduceU , + reduce , + everyU , + every , + someU , + some , + keepU , + keep , + partitionU , + partition , + size , + toList , + toArray , + minimum , + minUndefined , + maximum , + maxUndefined , + get , + getUndefined , + getExn , + split , + checkInvariantInternal , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_SortArray.js b/melange-node-modules/melange.belt/belt_SortArray.js new file mode 100644 index 0000000..f177a80 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_SortArray.js @@ -0,0 +1,421 @@ +// Generated by Melange + +import * as Belt__Belt_Array from "./belt_Array.js"; +import * as Curry from "melange.js/curry.js"; + +function sortedLengthAuxMore(xs, _prec, _acc, len, lt) { + while(true) { + var acc = _acc; + var prec = _prec; + if (acc >= len) { + return acc; + } + var v = xs[acc]; + if (!lt(v, prec)) { + return acc; + } + _acc = acc + 1 | 0; + _prec = v; + continue ; + }; +} + +function strictlySortedLengthU(xs, lt) { + var len = xs.length; + if (len === 0 || len === 1) { + return len; + } + var x0 = xs[0]; + var x1 = xs[1]; + if (lt(x0, x1)) { + var _prec = x1; + var _acc = 2; + while(true) { + var acc = _acc; + var prec = _prec; + if (acc >= len) { + return acc; + } + var v = xs[acc]; + if (!lt(prec, v)) { + return acc; + } + _acc = acc + 1 | 0; + _prec = v; + continue ; + }; + } else if (lt(x1, x0)) { + return -sortedLengthAuxMore(xs, x1, 2, len, lt) | 0; + } else { + return 1; + } +} + +function strictlySortedLength(xs, lt) { + return strictlySortedLengthU(xs, Curry.__2(lt)); +} + +function isSortedU(a, cmp) { + var len = a.length; + if (len === 0) { + return true; + } else { + var _i = 0; + var last_bound = len - 1 | 0; + while(true) { + var i = _i; + if (i === last_bound) { + return true; + } + if (cmp(a[i], a[i + 1 | 0]) > 0) { + return false; + } + _i = i + 1 | 0; + continue ; + }; + } +} + +function isSorted(a, cmp) { + return isSortedU(a, Curry.__2(cmp)); +} + +function merge(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { + var src1r = src1ofs + src1len | 0; + var src2r = src2ofs + src2len | 0; + var _i1 = src1ofs; + var _s1 = src[src1ofs]; + var _i2 = src2ofs; + var _s2 = src2[src2ofs]; + var _d = dstofs; + while(true) { + var d = _d; + var s2 = _s2; + var i2 = _i2; + var s1 = _s1; + var i1 = _i1; + if (cmp(s1, s2) <= 0) { + dst[d] = s1; + var i1$1 = i1 + 1 | 0; + if (i1$1 >= src1r) { + return Belt__Belt_Array.blitUnsafe(src2, i2, dst, d + 1 | 0, src2r - i2 | 0); + } + _d = d + 1 | 0; + _s1 = src[i1$1]; + _i1 = i1$1; + continue ; + } + dst[d] = s2; + var i2$1 = i2 + 1 | 0; + if (i2$1 >= src2r) { + return Belt__Belt_Array.blitUnsafe(src, i1, dst, d + 1 | 0, src1r - i1 | 0); + } + _d = d + 1 | 0; + _s2 = src2[i2$1]; + _i2 = i2$1; + continue ; + }; +} + +function unionU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { + var src1r = src1ofs + src1len | 0; + var src2r = src2ofs + src2len | 0; + var _i1 = src1ofs; + var _s1 = src[src1ofs]; + var _i2 = src2ofs; + var _s2 = src2[src2ofs]; + var _d = dstofs; + while(true) { + var d = _d; + var s2 = _s2; + var i2 = _i2; + var s1 = _s1; + var i1 = _i1; + var c = cmp(s1, s2); + if (c < 0) { + dst[d] = s1; + var i1$1 = i1 + 1 | 0; + var d$1 = d + 1 | 0; + if (i1$1 < src1r) { + _d = d$1; + _s1 = src[i1$1]; + _i1 = i1$1; + continue ; + } + Belt__Belt_Array.blitUnsafe(src2, i2, dst, d$1, src2r - i2 | 0); + return (d$1 + src2r | 0) - i2 | 0; + } + if (c === 0) { + dst[d] = s1; + var i1$2 = i1 + 1 | 0; + var i2$1 = i2 + 1 | 0; + var d$2 = d + 1 | 0; + if (!(i1$2 < src1r && i2$1 < src2r)) { + if (i1$2 === src1r) { + Belt__Belt_Array.blitUnsafe(src2, i2$1, dst, d$2, src2r - i2$1 | 0); + return (d$2 + src2r | 0) - i2$1 | 0; + } else { + Belt__Belt_Array.blitUnsafe(src, i1$2, dst, d$2, src1r - i1$2 | 0); + return (d$2 + src1r | 0) - i1$2 | 0; + } + } + _d = d$2; + _s2 = src2[i2$1]; + _i2 = i2$1; + _s1 = src[i1$2]; + _i1 = i1$2; + continue ; + } + dst[d] = s2; + var i2$2 = i2 + 1 | 0; + var d$3 = d + 1 | 0; + if (i2$2 < src2r) { + _d = d$3; + _s2 = src2[i2$2]; + _i2 = i2$2; + continue ; + } + Belt__Belt_Array.blitUnsafe(src, i1, dst, d$3, src1r - i1 | 0); + return (d$3 + src1r | 0) - i1 | 0; + }; +} + +function union(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { + return unionU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, Curry.__2(cmp)); +} + +function intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { + var src1r = src1ofs + src1len | 0; + var src2r = src2ofs + src2len | 0; + var _i1 = src1ofs; + var _s1 = src[src1ofs]; + var _i2 = src2ofs; + var _s2 = src2[src2ofs]; + var _d = dstofs; + while(true) { + var d = _d; + var s2 = _s2; + var i2 = _i2; + var s1 = _s1; + var i1 = _i1; + var c = cmp(s1, s2); + if (c < 0) { + var i1$1 = i1 + 1 | 0; + if (i1$1 >= src1r) { + return d; + } + _s1 = src[i1$1]; + _i1 = i1$1; + continue ; + } + if (c === 0) { + dst[d] = s1; + var i1$2 = i1 + 1 | 0; + var i2$1 = i2 + 1 | 0; + var d$1 = d + 1 | 0; + if (!(i1$2 < src1r && i2$1 < src2r)) { + return d$1; + } + _d = d$1; + _s2 = src2[i2$1]; + _i2 = i2$1; + _s1 = src[i1$2]; + _i1 = i1$2; + continue ; + } + var i2$2 = i2 + 1 | 0; + if (i2$2 >= src2r) { + return d; + } + _s2 = src2[i2$2]; + _i2 = i2$2; + continue ; + }; +} + +function intersect(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { + return intersectU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, Curry.__2(cmp)); +} + +function diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { + var src1r = src1ofs + src1len | 0; + var src2r = src2ofs + src2len | 0; + var _i1 = src1ofs; + var _s1 = src[src1ofs]; + var _i2 = src2ofs; + var _s2 = src2[src2ofs]; + var _d = dstofs; + while(true) { + var d = _d; + var s2 = _s2; + var i2 = _i2; + var s1 = _s1; + var i1 = _i1; + var c = cmp(s1, s2); + if (c < 0) { + dst[d] = s1; + var d$1 = d + 1 | 0; + var i1$1 = i1 + 1 | 0; + if (i1$1 >= src1r) { + return d$1; + } + _d = d$1; + _s1 = src[i1$1]; + _i1 = i1$1; + continue ; + } + if (c === 0) { + var i1$2 = i1 + 1 | 0; + var i2$1 = i2 + 1 | 0; + if (!(i1$2 < src1r && i2$1 < src2r)) { + if (i1$2 === src1r) { + return d; + } else { + Belt__Belt_Array.blitUnsafe(src, i1$2, dst, d, src1r - i1$2 | 0); + return (d + src1r | 0) - i1$2 | 0; + } + } + _s2 = src2[i2$1]; + _i2 = i2$1; + _s1 = src[i1$2]; + _i1 = i1$2; + continue ; + } + var i2$2 = i2 + 1 | 0; + if (i2$2 < src2r) { + _s2 = src2[i2$2]; + _i2 = i2$2; + continue ; + } + Belt__Belt_Array.blitUnsafe(src, i1, dst, d, src1r - i1 | 0); + return (d + src1r | 0) - i1 | 0; + }; +} + +function diff(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) { + return diffU(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, Curry.__2(cmp)); +} + +function insertionSort(src, srcofs, dst, dstofs, len, cmp) { + for(var i = 0; i < len; ++i){ + var e = src[srcofs + i | 0]; + var j = (dstofs + i | 0) - 1 | 0; + while(j >= dstofs && cmp(dst[j], e) > 0) { + dst[j + 1 | 0] = dst[j]; + j = j - 1 | 0; + }; + dst[j + 1 | 0] = e; + } +} + +function sortTo(src, srcofs, dst, dstofs, len, cmp) { + if (len <= 5) { + return insertionSort(src, srcofs, dst, dstofs, len, cmp); + } + var l1 = len / 2 | 0; + var l2 = len - l1 | 0; + sortTo(src, srcofs + l1 | 0, dst, dstofs + l1 | 0, l2, cmp); + sortTo(src, srcofs, src, srcofs + l2 | 0, l1, cmp); + merge(src, srcofs + l2 | 0, l1, dst, dstofs + l1 | 0, l2, dst, dstofs, cmp); +} + +function stableSortInPlaceByU(a, cmp) { + var l = a.length; + if (l <= 5) { + return insertionSort(a, 0, a, 0, l, cmp); + } + var l1 = l / 2 | 0; + var l2 = l - l1 | 0; + var t = new Array(l2); + sortTo(a, l1, t, 0, l2, cmp); + sortTo(a, 0, a, l2, l1, cmp); + merge(a, l2, l1, t, 0, l2, a, 0, cmp); +} + +function stableSortInPlaceBy(a, cmp) { + stableSortInPlaceByU(a, Curry.__2(cmp)); +} + +function stableSortByU(a, cmp) { + var b = a.slice(0); + stableSortInPlaceByU(b, cmp); + return b; +} + +function stableSortBy(a, cmp) { + return stableSortByU(a, Curry.__2(cmp)); +} + +function binarySearchByU(sorted, key, cmp) { + var len = sorted.length; + if (len === 0) { + return -1; + } + var lo = sorted[0]; + var c = cmp(key, lo); + if (c < 0) { + return -1; + } + var hi = sorted[len - 1 | 0]; + var c2 = cmp(key, hi); + if (c2 > 0) { + return -(len + 1 | 0) | 0; + } else { + var _lo = 0; + var _hi = len - 1 | 0; + while(true) { + var hi$1 = _hi; + var lo$1 = _lo; + var mid = (lo$1 + hi$1 | 0) / 2 | 0; + var midVal = sorted[mid]; + var c$1 = cmp(key, midVal); + if (c$1 === 0) { + return mid; + } + if (c$1 < 0) { + if (hi$1 === mid) { + if (cmp(sorted[lo$1], key) === 0) { + return lo$1; + } else { + return -(hi$1 + 1 | 0) | 0; + } + } + _hi = mid; + continue ; + } + if (lo$1 === mid) { + if (cmp(sorted[hi$1], key) === 0) { + return hi$1; + } else { + return -(hi$1 + 1 | 0) | 0; + } + } + _lo = mid; + continue ; + }; + } +} + +function binarySearchBy(sorted, key, cmp) { + return binarySearchByU(sorted, key, Curry.__2(cmp)); +} + +export { + strictlySortedLengthU , + strictlySortedLength , + isSortedU , + isSorted , + stableSortInPlaceByU , + stableSortInPlaceBy , + stableSortByU , + stableSortBy , + binarySearchByU , + binarySearchBy , + unionU , + union , + intersectU , + intersect , + diffU , + diff , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_SortArrayInt.js b/melange-node-modules/melange.belt/belt_SortArrayInt.js new file mode 100644 index 0000000..fe87368 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_SortArrayInt.js @@ -0,0 +1,374 @@ +// Generated by Melange + +import * as Belt__Belt_Array from "./belt_Array.js"; + +function sortedLengthAuxMore(xs, _prec, _acc, len) { + while(true) { + var acc = _acc; + var prec = _prec; + if (acc >= len) { + return acc; + } + var v = xs[acc]; + if (prec <= v) { + return acc; + } + _acc = acc + 1 | 0; + _prec = v; + continue ; + }; +} + +function strictlySortedLength(xs) { + var len = xs.length; + if (len === 0 || len === 1) { + return len; + } + var x0 = xs[0]; + var x1 = xs[1]; + if (x0 < x1) { + var _prec = x1; + var _acc = 2; + while(true) { + var acc = _acc; + var prec = _prec; + if (acc >= len) { + return acc; + } + var v = xs[acc]; + if (prec >= v) { + return acc; + } + _acc = acc + 1 | 0; + _prec = v; + continue ; + }; + } else if (x0 > x1) { + return -sortedLengthAuxMore(xs, x1, 2, len) | 0; + } else { + return 1; + } +} + +function isSorted(a) { + var len = a.length; + if (len === 0) { + return true; + } else { + var _i = 0; + var last_bound = len - 1 | 0; + while(true) { + var i = _i; + if (i === last_bound) { + return true; + } + if (a[i] > a[i + 1 | 0]) { + return false; + } + _i = i + 1 | 0; + continue ; + }; + } +} + +function merge(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { + var src1r = src1ofs + src1len | 0; + var src2r = src2ofs + src2len | 0; + var _i1 = src1ofs; + var _s1 = src[src1ofs]; + var _i2 = src2ofs; + var _s2 = src2[src2ofs]; + var _d = dstofs; + while(true) { + var d = _d; + var s2 = _s2; + var i2 = _i2; + var s1 = _s1; + var i1 = _i1; + if (s1 <= s2) { + dst[d] = s1; + var i1$1 = i1 + 1 | 0; + if (i1$1 >= src1r) { + return Belt__Belt_Array.blitUnsafe(src2, i2, dst, d + 1 | 0, src2r - i2 | 0); + } + _d = d + 1 | 0; + _s1 = src[i1$1]; + _i1 = i1$1; + continue ; + } + dst[d] = s2; + var i2$1 = i2 + 1 | 0; + if (i2$1 >= src2r) { + return Belt__Belt_Array.blitUnsafe(src, i1, dst, d + 1 | 0, src1r - i1 | 0); + } + _d = d + 1 | 0; + _s2 = src2[i2$1]; + _i2 = i2$1; + continue ; + }; +} + +function union(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { + var src1r = src1ofs + src1len | 0; + var src2r = src2ofs + src2len | 0; + var _i1 = src1ofs; + var _s1 = src[src1ofs]; + var _i2 = src2ofs; + var _s2 = src2[src2ofs]; + var _d = dstofs; + while(true) { + var d = _d; + var s2 = _s2; + var i2 = _i2; + var s1 = _s1; + var i1 = _i1; + if (s1 < s2) { + dst[d] = s1; + var i1$1 = i1 + 1 | 0; + var d$1 = d + 1 | 0; + if (i1$1 < src1r) { + _d = d$1; + _s1 = src[i1$1]; + _i1 = i1$1; + continue ; + } + Belt__Belt_Array.blitUnsafe(src2, i2, dst, d$1, src2r - i2 | 0); + return (d$1 + src2r | 0) - i2 | 0; + } + if (s1 === s2) { + dst[d] = s1; + var i1$2 = i1 + 1 | 0; + var i2$1 = i2 + 1 | 0; + var d$2 = d + 1 | 0; + if (!(i1$2 < src1r && i2$1 < src2r)) { + if (i1$2 === src1r) { + Belt__Belt_Array.blitUnsafe(src2, i2$1, dst, d$2, src2r - i2$1 | 0); + return (d$2 + src2r | 0) - i2$1 | 0; + } else { + Belt__Belt_Array.blitUnsafe(src, i1$2, dst, d$2, src1r - i1$2 | 0); + return (d$2 + src1r | 0) - i1$2 | 0; + } + } + _d = d$2; + _s2 = src2[i2$1]; + _i2 = i2$1; + _s1 = src[i1$2]; + _i1 = i1$2; + continue ; + } + dst[d] = s2; + var i2$2 = i2 + 1 | 0; + var d$3 = d + 1 | 0; + if (i2$2 < src2r) { + _d = d$3; + _s2 = src2[i2$2]; + _i2 = i2$2; + continue ; + } + Belt__Belt_Array.blitUnsafe(src, i1, dst, d$3, src1r - i1 | 0); + return (d$3 + src1r | 0) - i1 | 0; + }; +} + +function intersect(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { + var src1r = src1ofs + src1len | 0; + var src2r = src2ofs + src2len | 0; + var _i1 = src1ofs; + var _s1 = src[src1ofs]; + var _i2 = src2ofs; + var _s2 = src2[src2ofs]; + var _d = dstofs; + while(true) { + var d = _d; + var s2 = _s2; + var i2 = _i2; + var s1 = _s1; + var i1 = _i1; + if (s1 < s2) { + var i1$1 = i1 + 1 | 0; + if (i1$1 >= src1r) { + return d; + } + _s1 = src[i1$1]; + _i1 = i1$1; + continue ; + } + if (s1 === s2) { + dst[d] = s1; + var i1$2 = i1 + 1 | 0; + var i2$1 = i2 + 1 | 0; + var d$1 = d + 1 | 0; + if (!(i1$2 < src1r && i2$1 < src2r)) { + return d$1; + } + _d = d$1; + _s2 = src2[i2$1]; + _i2 = i2$1; + _s1 = src[i1$2]; + _i1 = i1$2; + continue ; + } + var i2$2 = i2 + 1 | 0; + if (i2$2 >= src2r) { + return d; + } + _s2 = src2[i2$2]; + _i2 = i2$2; + continue ; + }; +} + +function diff(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { + var src1r = src1ofs + src1len | 0; + var src2r = src2ofs + src2len | 0; + var _i1 = src1ofs; + var _s1 = src[src1ofs]; + var _i2 = src2ofs; + var _s2 = src2[src2ofs]; + var _d = dstofs; + while(true) { + var d = _d; + var s2 = _s2; + var i2 = _i2; + var s1 = _s1; + var i1 = _i1; + if (s1 < s2) { + dst[d] = s1; + var d$1 = d + 1 | 0; + var i1$1 = i1 + 1 | 0; + if (i1$1 >= src1r) { + return d$1; + } + _d = d$1; + _s1 = src[i1$1]; + _i1 = i1$1; + continue ; + } + if (s1 === s2) { + var i1$2 = i1 + 1 | 0; + var i2$1 = i2 + 1 | 0; + if (!(i1$2 < src1r && i2$1 < src2r)) { + if (i1$2 === src1r) { + return d; + } else { + Belt__Belt_Array.blitUnsafe(src, i1$2, dst, d, src1r - i1$2 | 0); + return (d + src1r | 0) - i1$2 | 0; + } + } + _s2 = src2[i2$1]; + _i2 = i2$1; + _s1 = src[i1$2]; + _i1 = i1$2; + continue ; + } + var i2$2 = i2 + 1 | 0; + if (i2$2 < src2r) { + _s2 = src2[i2$2]; + _i2 = i2$2; + continue ; + } + Belt__Belt_Array.blitUnsafe(src, i1, dst, d, src1r - i1 | 0); + return (d + src1r | 0) - i1 | 0; + }; +} + +function insertionSort(src, srcofs, dst, dstofs, len) { + for(var i = 0; i < len; ++i){ + var e = src[srcofs + i | 0]; + var j = (dstofs + i | 0) - 1 | 0; + while(j >= dstofs && dst[j] > e) { + dst[j + 1 | 0] = dst[j]; + j = j - 1 | 0; + }; + dst[j + 1 | 0] = e; + } +} + +function sortTo(src, srcofs, dst, dstofs, len) { + if (len <= 5) { + return insertionSort(src, srcofs, dst, dstofs, len); + } + var l1 = len / 2 | 0; + var l2 = len - l1 | 0; + sortTo(src, srcofs + l1 | 0, dst, dstofs + l1 | 0, l2); + sortTo(src, srcofs, src, srcofs + l2 | 0, l1); + merge(src, srcofs + l2 | 0, l1, dst, dstofs + l1 | 0, l2, dst, dstofs); +} + +function stableSortInPlace(a) { + var l = a.length; + if (l <= 5) { + return insertionSort(a, 0, a, 0, l); + } + var l1 = l / 2 | 0; + var l2 = l - l1 | 0; + var t = new Array(l2); + sortTo(a, l1, t, 0, l2); + sortTo(a, 0, a, l2, l1); + merge(a, l2, l1, t, 0, l2, a, 0); +} + +function stableSort(a) { + var b = a.slice(0); + stableSortInPlace(b); + return b; +} + +function binarySearch(sorted, key) { + var len = sorted.length; + if (len === 0) { + return -1; + } + var lo = sorted[0]; + if (key < lo) { + return -1; + } + var hi = sorted[len - 1 | 0]; + if (key > hi) { + return -(len + 1 | 0) | 0; + } else { + var _lo = 0; + var _hi = len - 1 | 0; + while(true) { + var hi$1 = _hi; + var lo$1 = _lo; + var mid = (lo$1 + hi$1 | 0) / 2 | 0; + var midVal = sorted[mid]; + if (key === midVal) { + return mid; + } + if (key < midVal) { + if (hi$1 === mid) { + if (sorted[lo$1] === key) { + return lo$1; + } else { + return -(hi$1 + 1 | 0) | 0; + } + } + _hi = mid; + continue ; + } + if (lo$1 === mid) { + if (sorted[hi$1] === key) { + return hi$1; + } else { + return -(hi$1 + 1 | 0) | 0; + } + } + _lo = mid; + continue ; + }; + } +} + +export { + strictlySortedLength , + isSorted , + stableSortInPlace , + stableSort , + binarySearch , + union , + intersect , + diff , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_SortArrayString.js b/melange-node-modules/melange.belt/belt_SortArrayString.js new file mode 100644 index 0000000..fe87368 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_SortArrayString.js @@ -0,0 +1,374 @@ +// Generated by Melange + +import * as Belt__Belt_Array from "./belt_Array.js"; + +function sortedLengthAuxMore(xs, _prec, _acc, len) { + while(true) { + var acc = _acc; + var prec = _prec; + if (acc >= len) { + return acc; + } + var v = xs[acc]; + if (prec <= v) { + return acc; + } + _acc = acc + 1 | 0; + _prec = v; + continue ; + }; +} + +function strictlySortedLength(xs) { + var len = xs.length; + if (len === 0 || len === 1) { + return len; + } + var x0 = xs[0]; + var x1 = xs[1]; + if (x0 < x1) { + var _prec = x1; + var _acc = 2; + while(true) { + var acc = _acc; + var prec = _prec; + if (acc >= len) { + return acc; + } + var v = xs[acc]; + if (prec >= v) { + return acc; + } + _acc = acc + 1 | 0; + _prec = v; + continue ; + }; + } else if (x0 > x1) { + return -sortedLengthAuxMore(xs, x1, 2, len) | 0; + } else { + return 1; + } +} + +function isSorted(a) { + var len = a.length; + if (len === 0) { + return true; + } else { + var _i = 0; + var last_bound = len - 1 | 0; + while(true) { + var i = _i; + if (i === last_bound) { + return true; + } + if (a[i] > a[i + 1 | 0]) { + return false; + } + _i = i + 1 | 0; + continue ; + }; + } +} + +function merge(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { + var src1r = src1ofs + src1len | 0; + var src2r = src2ofs + src2len | 0; + var _i1 = src1ofs; + var _s1 = src[src1ofs]; + var _i2 = src2ofs; + var _s2 = src2[src2ofs]; + var _d = dstofs; + while(true) { + var d = _d; + var s2 = _s2; + var i2 = _i2; + var s1 = _s1; + var i1 = _i1; + if (s1 <= s2) { + dst[d] = s1; + var i1$1 = i1 + 1 | 0; + if (i1$1 >= src1r) { + return Belt__Belt_Array.blitUnsafe(src2, i2, dst, d + 1 | 0, src2r - i2 | 0); + } + _d = d + 1 | 0; + _s1 = src[i1$1]; + _i1 = i1$1; + continue ; + } + dst[d] = s2; + var i2$1 = i2 + 1 | 0; + if (i2$1 >= src2r) { + return Belt__Belt_Array.blitUnsafe(src, i1, dst, d + 1 | 0, src1r - i1 | 0); + } + _d = d + 1 | 0; + _s2 = src2[i2$1]; + _i2 = i2$1; + continue ; + }; +} + +function union(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { + var src1r = src1ofs + src1len | 0; + var src2r = src2ofs + src2len | 0; + var _i1 = src1ofs; + var _s1 = src[src1ofs]; + var _i2 = src2ofs; + var _s2 = src2[src2ofs]; + var _d = dstofs; + while(true) { + var d = _d; + var s2 = _s2; + var i2 = _i2; + var s1 = _s1; + var i1 = _i1; + if (s1 < s2) { + dst[d] = s1; + var i1$1 = i1 + 1 | 0; + var d$1 = d + 1 | 0; + if (i1$1 < src1r) { + _d = d$1; + _s1 = src[i1$1]; + _i1 = i1$1; + continue ; + } + Belt__Belt_Array.blitUnsafe(src2, i2, dst, d$1, src2r - i2 | 0); + return (d$1 + src2r | 0) - i2 | 0; + } + if (s1 === s2) { + dst[d] = s1; + var i1$2 = i1 + 1 | 0; + var i2$1 = i2 + 1 | 0; + var d$2 = d + 1 | 0; + if (!(i1$2 < src1r && i2$1 < src2r)) { + if (i1$2 === src1r) { + Belt__Belt_Array.blitUnsafe(src2, i2$1, dst, d$2, src2r - i2$1 | 0); + return (d$2 + src2r | 0) - i2$1 | 0; + } else { + Belt__Belt_Array.blitUnsafe(src, i1$2, dst, d$2, src1r - i1$2 | 0); + return (d$2 + src1r | 0) - i1$2 | 0; + } + } + _d = d$2; + _s2 = src2[i2$1]; + _i2 = i2$1; + _s1 = src[i1$2]; + _i1 = i1$2; + continue ; + } + dst[d] = s2; + var i2$2 = i2 + 1 | 0; + var d$3 = d + 1 | 0; + if (i2$2 < src2r) { + _d = d$3; + _s2 = src2[i2$2]; + _i2 = i2$2; + continue ; + } + Belt__Belt_Array.blitUnsafe(src, i1, dst, d$3, src1r - i1 | 0); + return (d$3 + src1r | 0) - i1 | 0; + }; +} + +function intersect(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { + var src1r = src1ofs + src1len | 0; + var src2r = src2ofs + src2len | 0; + var _i1 = src1ofs; + var _s1 = src[src1ofs]; + var _i2 = src2ofs; + var _s2 = src2[src2ofs]; + var _d = dstofs; + while(true) { + var d = _d; + var s2 = _s2; + var i2 = _i2; + var s1 = _s1; + var i1 = _i1; + if (s1 < s2) { + var i1$1 = i1 + 1 | 0; + if (i1$1 >= src1r) { + return d; + } + _s1 = src[i1$1]; + _i1 = i1$1; + continue ; + } + if (s1 === s2) { + dst[d] = s1; + var i1$2 = i1 + 1 | 0; + var i2$1 = i2 + 1 | 0; + var d$1 = d + 1 | 0; + if (!(i1$2 < src1r && i2$1 < src2r)) { + return d$1; + } + _d = d$1; + _s2 = src2[i2$1]; + _i2 = i2$1; + _s1 = src[i1$2]; + _i1 = i1$2; + continue ; + } + var i2$2 = i2 + 1 | 0; + if (i2$2 >= src2r) { + return d; + } + _s2 = src2[i2$2]; + _i2 = i2$2; + continue ; + }; +} + +function diff(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { + var src1r = src1ofs + src1len | 0; + var src2r = src2ofs + src2len | 0; + var _i1 = src1ofs; + var _s1 = src[src1ofs]; + var _i2 = src2ofs; + var _s2 = src2[src2ofs]; + var _d = dstofs; + while(true) { + var d = _d; + var s2 = _s2; + var i2 = _i2; + var s1 = _s1; + var i1 = _i1; + if (s1 < s2) { + dst[d] = s1; + var d$1 = d + 1 | 0; + var i1$1 = i1 + 1 | 0; + if (i1$1 >= src1r) { + return d$1; + } + _d = d$1; + _s1 = src[i1$1]; + _i1 = i1$1; + continue ; + } + if (s1 === s2) { + var i1$2 = i1 + 1 | 0; + var i2$1 = i2 + 1 | 0; + if (!(i1$2 < src1r && i2$1 < src2r)) { + if (i1$2 === src1r) { + return d; + } else { + Belt__Belt_Array.blitUnsafe(src, i1$2, dst, d, src1r - i1$2 | 0); + return (d + src1r | 0) - i1$2 | 0; + } + } + _s2 = src2[i2$1]; + _i2 = i2$1; + _s1 = src[i1$2]; + _i1 = i1$2; + continue ; + } + var i2$2 = i2 + 1 | 0; + if (i2$2 < src2r) { + _s2 = src2[i2$2]; + _i2 = i2$2; + continue ; + } + Belt__Belt_Array.blitUnsafe(src, i1, dst, d, src1r - i1 | 0); + return (d + src1r | 0) - i1 | 0; + }; +} + +function insertionSort(src, srcofs, dst, dstofs, len) { + for(var i = 0; i < len; ++i){ + var e = src[srcofs + i | 0]; + var j = (dstofs + i | 0) - 1 | 0; + while(j >= dstofs && dst[j] > e) { + dst[j + 1 | 0] = dst[j]; + j = j - 1 | 0; + }; + dst[j + 1 | 0] = e; + } +} + +function sortTo(src, srcofs, dst, dstofs, len) { + if (len <= 5) { + return insertionSort(src, srcofs, dst, dstofs, len); + } + var l1 = len / 2 | 0; + var l2 = len - l1 | 0; + sortTo(src, srcofs + l1 | 0, dst, dstofs + l1 | 0, l2); + sortTo(src, srcofs, src, srcofs + l2 | 0, l1); + merge(src, srcofs + l2 | 0, l1, dst, dstofs + l1 | 0, l2, dst, dstofs); +} + +function stableSortInPlace(a) { + var l = a.length; + if (l <= 5) { + return insertionSort(a, 0, a, 0, l); + } + var l1 = l / 2 | 0; + var l2 = l - l1 | 0; + var t = new Array(l2); + sortTo(a, l1, t, 0, l2); + sortTo(a, 0, a, l2, l1); + merge(a, l2, l1, t, 0, l2, a, 0); +} + +function stableSort(a) { + var b = a.slice(0); + stableSortInPlace(b); + return b; +} + +function binarySearch(sorted, key) { + var len = sorted.length; + if (len === 0) { + return -1; + } + var lo = sorted[0]; + if (key < lo) { + return -1; + } + var hi = sorted[len - 1 | 0]; + if (key > hi) { + return -(len + 1 | 0) | 0; + } else { + var _lo = 0; + var _hi = len - 1 | 0; + while(true) { + var hi$1 = _hi; + var lo$1 = _lo; + var mid = (lo$1 + hi$1 | 0) / 2 | 0; + var midVal = sorted[mid]; + if (key === midVal) { + return mid; + } + if (key < midVal) { + if (hi$1 === mid) { + if (sorted[lo$1] === key) { + return lo$1; + } else { + return -(hi$1 + 1 | 0) | 0; + } + } + _hi = mid; + continue ; + } + if (lo$1 === mid) { + if (sorted[hi$1] === key) { + return hi$1; + } else { + return -(hi$1 + 1 | 0) | 0; + } + } + _lo = mid; + continue ; + }; + } +} + +export { + strictlySortedLength , + isSorted , + stableSortInPlace , + stableSort , + binarySearch , + union , + intersect , + diff , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt__.js b/melange-node-modules/melange.belt/belt__.js new file mode 100644 index 0000000..40fe058 --- /dev/null +++ b/melange-node-modules/melange.belt/belt__.js @@ -0,0 +1,9 @@ +// Generated by Melange + + +var Belt__ = {}; + +export { + Belt__ , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_internalAVLset.js b/melange-node-modules/melange.belt/belt_internalAVLset.js new file mode 100644 index 0000000..38522ce --- /dev/null +++ b/melange-node-modules/melange.belt/belt_internalAVLset.js @@ -0,0 +1,965 @@ +// Generated by Melange + +import * as Belt__Belt_SortArray from "./belt_SortArray.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function copy(n) { + if (n === undefined) { + return n; + } + var n$1 = Caml_option.valFromOption(n); + return { + v: n$1.v, + h: n$1.h, + l: copy(n$1.l), + r: copy(n$1.r) + }; +} + +function create(l, v, r) { + var hl = l !== undefined ? Caml_option.valFromOption(l).h : 0; + var hr = r !== undefined ? Caml_option.valFromOption(r).h : 0; + return { + v: v, + h: ( + hl >= hr ? hl : hr + ) + 1 | 0, + l: l, + r: r + }; +} + +function singleton(x) { + return { + v: x, + h: 1, + l: undefined, + r: undefined + }; +} + +function heightGe(l, r) { + if (r !== undefined) { + if (l !== undefined) { + return l.h >= r.h; + } else { + return false; + } + } else { + return true; + } +} + +function bal(l, v, r) { + var hl = l !== undefined ? Caml_option.valFromOption(l).h : 0; + var hr = r !== undefined ? Caml_option.valFromOption(r).h : 0; + if (hl > (hr + 2 | 0)) { + var l$1 = Caml_option.valFromOption(l); + var ll = l$1.l; + var lr = l$1.r; + if (heightGe(ll, lr)) { + return create(ll, l$1.v, create(lr, v, r)); + } + var lr$1 = Caml_option.valFromOption(lr); + return create(create(ll, l$1.v, lr$1.l), lr$1.v, create(lr$1.r, v, r)); + } + if (hr <= (hl + 2 | 0)) { + return { + v: v, + h: ( + hl >= hr ? hl : hr + ) + 1 | 0, + l: l, + r: r + }; + } + var r$1 = Caml_option.valFromOption(r); + var rl = r$1.l; + var rr = r$1.r; + if (heightGe(rr, rl)) { + return create(create(l, v, rl), r$1.v, rr); + } + var rl$1 = Caml_option.valFromOption(rl); + return create(create(l, v, rl$1.l), rl$1.v, create(rl$1.r, r$1.v, rr)); +} + +function min0Aux(_n) { + while(true) { + var n = _n; + var n$1 = n.l; + if (n$1 === undefined) { + return n.v; + } + _n = Caml_option.valFromOption(n$1); + continue ; + }; +} + +function minimum(n) { + if (n !== undefined) { + return Caml_option.some(min0Aux(n)); + } + +} + +function minUndefined(n) { + if (n !== undefined) { + return min0Aux(n); + } + +} + +function max0Aux(_n) { + while(true) { + var n = _n; + var n$1 = n.r; + if (n$1 === undefined) { + return n.v; + } + _n = Caml_option.valFromOption(n$1); + continue ; + }; +} + +function maximum(n) { + if (n !== undefined) { + return Caml_option.some(max0Aux(n)); + } + +} + +function maxUndefined(n) { + if (n !== undefined) { + return max0Aux(n); + } + +} + +function removeMinAuxWithRef(n, v) { + var ln = n.l; + if (ln !== undefined) { + return bal(removeMinAuxWithRef(Caml_option.valFromOption(ln), v), n.v, n.r); + } else { + v.contents = n.v; + return n.r; + } +} + +function isEmpty(n) { + return n === undefined; +} + +function stackAllLeft(_v, _s) { + while(true) { + var s = _s; + var v = _v; + if (v === undefined) { + return s; + } + var x = Caml_option.valFromOption(v); + _s = { + hd: x, + tl: s + }; + _v = x.l; + continue ; + }; +} + +function forEachU(_n, f) { + while(true) { + var n = _n; + if (n === undefined) { + return ; + } + var n$1 = Caml_option.valFromOption(n); + forEachU(n$1.l, f); + f(n$1.v); + _n = n$1.r; + continue ; + }; +} + +function forEach(n, f) { + forEachU(n, Curry.__1(f)); +} + +function reduceU(_s, _accu, f) { + while(true) { + var accu = _accu; + var s = _s; + if (s === undefined) { + return accu; + } + var n = Caml_option.valFromOption(s); + _accu = f(reduceU(n.l, accu, f), n.v); + _s = n.r; + continue ; + }; +} + +function reduce(s, accu, f) { + return reduceU(s, accu, Curry.__2(f)); +} + +function everyU(_n, p) { + while(true) { + var n = _n; + if (n === undefined) { + return true; + } + var n$1 = Caml_option.valFromOption(n); + if (!p(n$1.v)) { + return false; + } + if (!everyU(n$1.l, p)) { + return false; + } + _n = n$1.r; + continue ; + }; +} + +function every(n, p) { + return everyU(n, Curry.__1(p)); +} + +function someU(_n, p) { + while(true) { + var n = _n; + if (n === undefined) { + return false; + } + var n$1 = Caml_option.valFromOption(n); + if (p(n$1.v)) { + return true; + } + if (someU(n$1.l, p)) { + return true; + } + _n = n$1.r; + continue ; + }; +} + +function some(n, p) { + return someU(n, Curry.__1(p)); +} + +function addMinElement(n, v) { + if (n === undefined) { + return singleton(v); + } + var n$1 = Caml_option.valFromOption(n); + return bal(addMinElement(n$1.l, v), n$1.v, n$1.r); +} + +function addMaxElement(n, v) { + if (n === undefined) { + return singleton(v); + } + var n$1 = Caml_option.valFromOption(n); + return bal(n$1.l, n$1.v, addMaxElement(n$1.r, v)); +} + +function joinShared(ln, v, rn) { + if (ln === undefined) { + return addMinElement(rn, v); + } + if (rn === undefined) { + return addMaxElement(ln, v); + } + var r = Caml_option.valFromOption(rn); + var l = Caml_option.valFromOption(ln); + var lh = l.h; + var rh = r.h; + if (lh > (rh + 2 | 0)) { + return bal(l.l, l.v, joinShared(l.r, v, rn)); + } else if (rh > (lh + 2 | 0)) { + return bal(joinShared(ln, v, r.l), r.v, r.r); + } else { + return create(ln, v, rn); + } +} + +function concatShared(t1, t2) { + if (t1 === undefined) { + return t2; + } + if (t2 === undefined) { + return t1; + } + var t2n = Caml_option.valFromOption(t2); + var v = { + contents: t2n.v + }; + var t2r = removeMinAuxWithRef(t2n, v); + return joinShared(t1, v.contents, t2r); +} + +function partitionSharedU(n, p) { + if (n === undefined) { + return [ + undefined, + undefined + ]; + } + var n$1 = Caml_option.valFromOption(n); + var value = n$1.v; + var match = partitionSharedU(n$1.l, p); + var lf = match[1]; + var lt = match[0]; + var pv = p(value); + var match$1 = partitionSharedU(n$1.r, p); + var rf = match$1[1]; + var rt = match$1[0]; + if (pv) { + return [ + joinShared(lt, value, rt), + concatShared(lf, rf) + ]; + } else { + return [ + concatShared(lt, rt), + joinShared(lf, value, rf) + ]; + } +} + +function partitionShared(n, p) { + return partitionSharedU(n, Curry.__1(p)); +} + +function lengthNode(n) { + var l = n.l; + var r = n.r; + var sizeL = l !== undefined ? lengthNode(Caml_option.valFromOption(l)) : 0; + var sizeR = r !== undefined ? lengthNode(Caml_option.valFromOption(r)) : 0; + return (1 + sizeL | 0) + sizeR | 0; +} + +function size(n) { + if (n !== undefined) { + return lengthNode(n); + } else { + return 0; + } +} + +function toListAux(_n, _accu) { + while(true) { + var accu = _accu; + var n = _n; + if (n === undefined) { + return accu; + } + var n$1 = Caml_option.valFromOption(n); + _accu = { + hd: n$1.v, + tl: toListAux(n$1.r, accu) + }; + _n = n$1.l; + continue ; + }; +} + +function toList(s) { + return toListAux(s, /* [] */0); +} + +function checkInvariantInternal(_v) { + while(true) { + var v = _v; + if (v === undefined) { + return ; + } + var n = Caml_option.valFromOption(v); + var l = n.l; + var r = n.r; + var diff = ( + l !== undefined ? Caml_option.valFromOption(l).h : 0 + ) - ( + r !== undefined ? Caml_option.valFromOption(r).h : 0 + ) | 0; + if (!(diff <= 2 && diff >= -2)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/others/belt_internalAVLset.ml", + 244, + 6 + ], + Error: new Error() + }; + } + checkInvariantInternal(l); + _v = r; + continue ; + }; +} + +function fillArray(_n, _i, arr) { + while(true) { + var i = _i; + var n = _n; + var v = n.v; + var l = n.l; + var r = n.r; + var next = l !== undefined ? fillArray(Caml_option.valFromOption(l), i, arr) : i; + arr[next] = v; + var rnext = next + 1 | 0; + if (r === undefined) { + return rnext; + } + _i = rnext; + _n = Caml_option.valFromOption(r); + continue ; + }; +} + +function fillArrayWithPartition(_n, cursor, arr, p) { + while(true) { + var n = _n; + var v = n.v; + var l = n.l; + var r = n.r; + if (l !== undefined) { + fillArrayWithPartition(Caml_option.valFromOption(l), cursor, arr, p); + } + if (p(v)) { + var c = cursor.forward; + arr[c] = v; + cursor.forward = c + 1 | 0; + } else { + var c$1 = cursor.backward; + arr[c$1] = v; + cursor.backward = c$1 - 1 | 0; + } + if (r === undefined) { + return ; + } + _n = Caml_option.valFromOption(r); + continue ; + }; +} + +function fillArrayWithFilter(_n, _i, arr, p) { + while(true) { + var i = _i; + var n = _n; + var v = n.v; + var l = n.l; + var r = n.r; + var next = l !== undefined ? fillArrayWithFilter(Caml_option.valFromOption(l), i, arr, p) : i; + var rnext = p(v) ? (arr[next] = v, next + 1 | 0) : next; + if (r === undefined) { + return rnext; + } + _i = rnext; + _n = Caml_option.valFromOption(r); + continue ; + }; +} + +function toArray(n) { + if (n === undefined) { + return []; + } + var size = lengthNode(n); + var v = new Array(size); + fillArray(n, 0, v); + return v; +} + +function fromSortedArrayRevAux(arr, off, len) { + switch (len) { + case 0 : + return ; + case 1 : + return singleton(arr[off]); + case 2 : + var x0 = arr[off]; + var x1 = arr[off - 1 | 0]; + return { + v: x1, + h: 2, + l: singleton(x0), + r: undefined + }; + case 3 : + var x0$1 = arr[off]; + var x1$1 = arr[off - 1 | 0]; + var x2 = arr[off - 2 | 0]; + return { + v: x1$1, + h: 2, + l: singleton(x0$1), + r: singleton(x2) + }; + default: + var nl = len / 2 | 0; + var left = fromSortedArrayRevAux(arr, off, nl); + var mid = arr[off - nl | 0]; + var right = fromSortedArrayRevAux(arr, (off - nl | 0) - 1 | 0, (len - nl | 0) - 1 | 0); + return create(left, mid, right); + } +} + +function fromSortedArrayAux(arr, off, len) { + switch (len) { + case 0 : + return ; + case 1 : + return singleton(arr[off]); + case 2 : + var x0 = arr[off]; + var x1 = arr[off + 1 | 0]; + return { + v: x1, + h: 2, + l: singleton(x0), + r: undefined + }; + case 3 : + var x0$1 = arr[off]; + var x1$1 = arr[off + 1 | 0]; + var x2 = arr[off + 2 | 0]; + return { + v: x1$1, + h: 2, + l: singleton(x0$1), + r: singleton(x2) + }; + default: + var nl = len / 2 | 0; + var left = fromSortedArrayAux(arr, off, nl); + var mid = arr[off + nl | 0]; + var right = fromSortedArrayAux(arr, (off + nl | 0) + 1 | 0, (len - nl | 0) - 1 | 0); + return create(left, mid, right); + } +} + +function fromSortedArrayUnsafe(arr) { + return fromSortedArrayAux(arr, 0, arr.length); +} + +function keepSharedU(n, p) { + if (n === undefined) { + return ; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.v; + var l = n$1.l; + var r = n$1.r; + var newL = keepSharedU(l, p); + var pv = p(v); + var newR = keepSharedU(r, p); + if (pv) { + if (l === newL && r === newR) { + return n$1; + } else { + return joinShared(newL, v, newR); + } + } else { + return concatShared(newL, newR); + } +} + +function keepShared(n, p) { + return keepSharedU(n, Curry.__1(p)); +} + +function keepCopyU(n, p) { + if (n === undefined) { + return ; + } + var size = lengthNode(n); + var v = new Array(size); + var last = fillArrayWithFilter(n, 0, v, p); + return fromSortedArrayAux(v, 0, last); +} + +function keepCopy(n, p) { + return keepCopyU(n, Curry.__1(p)); +} + +function partitionCopyU(n, p) { + if (n === undefined) { + return [ + undefined, + undefined + ]; + } + var size = lengthNode(n); + var v = new Array(size); + var backward = size - 1 | 0; + var cursor = { + forward: 0, + backward: backward + }; + fillArrayWithPartition(n, cursor, v, p); + var forwardLen = cursor.forward; + return [ + fromSortedArrayAux(v, 0, forwardLen), + fromSortedArrayRevAux(v, backward, size - forwardLen | 0) + ]; +} + +function partitionCopy(n, p) { + return partitionCopyU(n, Curry.__1(p)); +} + +function has(_t, x, cmp) { + while(true) { + var t = _t; + if (t === undefined) { + return false; + } + var n = Caml_option.valFromOption(t); + var v = n.v; + var c = cmp(x, v); + if (c === 0) { + return true; + } + _t = c < 0 ? n.l : n.r; + continue ; + }; +} + +function cmp(s1, s2, cmp$1) { + var len1 = size(s1); + var len2 = size(s2); + if (len1 === len2) { + var _e1 = stackAllLeft(s1, /* [] */0); + var _e2 = stackAllLeft(s2, /* [] */0); + while(true) { + var e2 = _e2; + var e1 = _e1; + if (!e1) { + return 0; + } + if (!e2) { + return 0; + } + var h2 = e2.hd; + var h1 = e1.hd; + var c = cmp$1(h1.v, h2.v); + if (c !== 0) { + return c; + } + _e2 = stackAllLeft(h2.r, e2.tl); + _e1 = stackAllLeft(h1.r, e1.tl); + continue ; + }; + } else if (len1 < len2) { + return -1; + } else { + return 1; + } +} + +function eq(s1, s2, c) { + return cmp(s1, s2, c) === 0; +} + +function subset(_s1, _s2, cmp) { + while(true) { + var s2 = _s2; + var s1 = _s1; + if (s1 === undefined) { + return true; + } + if (s2 === undefined) { + return false; + } + var t2 = Caml_option.valFromOption(s2); + var t1 = Caml_option.valFromOption(s1); + var v1 = t1.v; + var l1 = t1.l; + var r1 = t1.r; + var v2 = t2.v; + var l2 = t2.l; + var r2 = t2.r; + var c = cmp(v1, v2); + if (c === 0) { + if (!subset(l1, l2, cmp)) { + return false; + } + _s2 = r2; + _s1 = r1; + continue ; + } + if (c < 0) { + if (!subset(create(l1, v1, undefined), l2, cmp)) { + return false; + } + _s1 = r1; + continue ; + } + if (!subset(create(undefined, v1, r1), r2, cmp)) { + return false; + } + _s1 = l1; + continue ; + }; +} + +function get(_n, x, cmp) { + while(true) { + var n = _n; + if (n === undefined) { + return ; + } + var t = Caml_option.valFromOption(n); + var v = t.v; + var c = cmp(x, v); + if (c === 0) { + return Caml_option.some(v); + } + _n = c < 0 ? t.l : t.r; + continue ; + }; +} + +function getUndefined(_n, x, cmp) { + while(true) { + var n = _n; + if (n === undefined) { + return ; + } + var t = Caml_option.valFromOption(n); + var v = t.v; + var c = cmp(x, v); + if (c === 0) { + return v; + } + _n = c < 0 ? t.l : t.r; + continue ; + }; +} + +function getExn(_n, x, cmp) { + while(true) { + var n = _n; + if (n !== undefined) { + var t = Caml_option.valFromOption(n); + var v = t.v; + var c = cmp(x, v); + if (c === 0) { + return v; + } + _n = c < 0 ? t.l : t.r; + continue ; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + }; +} + +function rotateWithLeftChild(k2) { + var k1 = k2.l; + var k1$1 = Caml_option.valFromOption(k1); + k2.l = k1$1.r; + k1$1.r = k2; + var n = k2.l; + var hlk2 = n !== undefined ? Caml_option.valFromOption(n).h : 0; + var n$1 = k2.r; + var hrk2 = n$1 !== undefined ? Caml_option.valFromOption(n$1).h : 0; + k2.h = ( + hlk2 > hrk2 ? hlk2 : hrk2 + ) + 1 | 0; + var n$2 = k1$1.l; + var hlk1 = n$2 !== undefined ? Caml_option.valFromOption(n$2).h : 0; + var hk2 = k2.h; + k1$1.h = ( + hlk1 > hk2 ? hlk1 : hk2 + ) + 1 | 0; + return k1$1; +} + +function rotateWithRightChild(k1) { + var k2 = k1.r; + var k2$1 = Caml_option.valFromOption(k2); + k1.r = k2$1.l; + k2$1.l = k1; + var n = k1.l; + var hlk1 = n !== undefined ? Caml_option.valFromOption(n).h : 0; + var n$1 = k1.r; + var hrk1 = n$1 !== undefined ? Caml_option.valFromOption(n$1).h : 0; + k1.h = ( + hlk1 > hrk1 ? hlk1 : hrk1 + ) + 1 | 0; + var n$2 = k2$1.r; + var hrk2 = n$2 !== undefined ? Caml_option.valFromOption(n$2).h : 0; + var hk1 = k1.h; + k2$1.h = ( + hrk2 > hk1 ? hrk2 : hk1 + ) + 1 | 0; + return k2$1; +} + +function doubleWithLeftChild(k3) { + var k3l = k3.l; + var v = rotateWithRightChild(Caml_option.valFromOption(k3l)); + k3.l = v; + return rotateWithLeftChild(k3); +} + +function doubleWithRightChild(k2) { + var k2r = k2.r; + var v = rotateWithLeftChild(Caml_option.valFromOption(k2r)); + k2.r = v; + return rotateWithRightChild(k2); +} + +function heightUpdateMutate(t) { + var n = t.l; + var hlt = n !== undefined ? Caml_option.valFromOption(n).h : 0; + var n$1 = t.r; + var hrt = n$1 !== undefined ? Caml_option.valFromOption(n$1).h : 0; + t.h = ( + hlt > hrt ? hlt : hrt + ) + 1 | 0; + return t; +} + +function balMutate(nt) { + var l = nt.l; + var r = nt.r; + var hl = l !== undefined ? Caml_option.valFromOption(l).h : 0; + var hr = r !== undefined ? Caml_option.valFromOption(r).h : 0; + if (hl > (2 + hr | 0)) { + var match = Caml_option.valFromOption(l); + var ll = match.l; + var lr = match.r; + if (heightGe(ll, lr)) { + return heightUpdateMutate(rotateWithLeftChild(nt)); + } else { + return heightUpdateMutate(doubleWithLeftChild(nt)); + } + } + if (hr > (2 + hl | 0)) { + var match$1 = Caml_option.valFromOption(r); + var rl = match$1.l; + var rr = match$1.r; + if (heightGe(rr, rl)) { + return heightUpdateMutate(rotateWithRightChild(nt)); + } else { + return heightUpdateMutate(doubleWithRightChild(nt)); + } + } + nt.h = ( + hl > hr ? hl : hr + ) + 1 | 0; + return nt; +} + +function addMutate(cmp, t, x) { + if (t === undefined) { + return singleton(x); + } + var nt = Caml_option.valFromOption(t); + var k = nt.v; + var c = cmp(x, k); + if (c === 0) { + return t; + } + var l = nt.l; + var r = nt.r; + if (c < 0) { + var ll = addMutate(cmp, l, x); + nt.l = ll; + } else { + nt.r = addMutate(cmp, r, x); + } + return balMutate(nt); +} + +function fromArray(xs, cmp) { + var len = xs.length; + if (len === 0) { + return ; + } + var next = Belt__Belt_SortArray.strictlySortedLengthU(xs, (function (x, y) { + return cmp(x, y) < 0; + })); + var result; + if (next >= 0) { + result = fromSortedArrayAux(xs, 0, next); + } else { + next = -next | 0; + result = fromSortedArrayRevAux(xs, next - 1 | 0, next); + } + for(var i = next; i < len; ++i){ + result = addMutate(cmp, result, xs[i]); + } + return result; +} + +function removeMinAuxWithRootMutate(nt, n) { + var ln = n.l; + var rn = n.r; + if (ln !== undefined) { + n.l = removeMinAuxWithRootMutate(nt, Caml_option.valFromOption(ln)); + return balMutate(n); + } else { + nt.v = n.v; + return rn; + } +} + +export { + copy , + create , + bal , + singleton , + minimum , + minUndefined , + maximum , + maxUndefined , + removeMinAuxWithRef , + isEmpty , + stackAllLeft , + forEachU , + forEach , + reduceU , + reduce , + everyU , + every , + someU , + some , + joinShared , + concatShared , + keepSharedU , + keepShared , + keepCopyU , + keepCopy , + partitionSharedU , + partitionShared , + partitionCopyU , + partitionCopy , + lengthNode , + size , + toList , + checkInvariantInternal , + fillArray , + toArray , + fromSortedArrayAux , + fromSortedArrayRevAux , + fromSortedArrayUnsafe , + has , + cmp , + eq , + subset , + get , + getUndefined , + getExn , + fromArray , + addMutate , + balMutate , + removeMinAuxWithRootMutate , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_internalAVLtree.js b/melange-node-modules/melange.belt/belt_internalAVLtree.js new file mode 100644 index 0000000..5c7974a --- /dev/null +++ b/melange-node-modules/melange.belt/belt_internalAVLtree.js @@ -0,0 +1,1173 @@ +// Generated by Melange + +import * as Belt__Belt_SortArray from "./belt_SortArray.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function treeHeight(n) { + if (n !== undefined) { + return Caml_option.valFromOption(n).h; + } else { + return 0; + } +} + +function copy(n) { + if (n === undefined) { + return n; + } + var n$1 = Caml_option.valFromOption(n); + return { + k: n$1.k, + v: n$1.v, + h: n$1.h, + l: copy(n$1.l), + r: copy(n$1.r) + }; +} + +function create(l, x, d, r) { + var hl = treeHeight(l); + var hr = treeHeight(r); + return { + k: x, + v: d, + h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0, + l: l, + r: r + }; +} + +function singleton(x, d) { + return { + k: x, + v: d, + h: 1, + l: undefined, + r: undefined + }; +} + +function heightGe(l, r) { + if (r !== undefined) { + if (l !== undefined) { + return l.h >= r.h; + } else { + return false; + } + } else { + return true; + } +} + +function updateValue(n, newValue) { + if (n.v === newValue) { + return n; + } else { + return { + k: n.k, + v: newValue, + h: n.h, + l: n.l, + r: n.r + }; + } +} + +function bal(l, x, d, r) { + var hl = l !== undefined ? Caml_option.valFromOption(l).h : 0; + var hr = r !== undefined ? Caml_option.valFromOption(r).h : 0; + if (hl > (hr + 2 | 0)) { + var ll = l.l; + var lr = l.r; + if (treeHeight(ll) >= treeHeight(lr)) { + return create(ll, l.k, l.v, create(lr, x, d, r)); + } + var lr$1 = Caml_option.valFromOption(lr); + return create(create(ll, l.k, l.v, lr$1.l), lr$1.k, lr$1.v, create(lr$1.r, x, d, r)); + } + if (hr <= (hl + 2 | 0)) { + return { + k: x, + v: d, + h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0, + l: l, + r: r + }; + } + var r$1 = Caml_option.valFromOption(r); + var rl = r$1.l; + var rr = r$1.r; + if (treeHeight(rr) >= treeHeight(rl)) { + return create(create(l, x, d, rl), r$1.k, r$1.v, rr); + } + var rl$1 = Caml_option.valFromOption(rl); + return create(create(l, x, d, rl$1.l), rl$1.k, rl$1.v, create(rl$1.r, r$1.k, r$1.v, rr)); +} + +function minKey0Aux(_n) { + while(true) { + var n = _n; + var n$1 = n.l; + if (n$1 === undefined) { + return n.k; + } + _n = Caml_option.valFromOption(n$1); + continue ; + }; +} + +function minKey(n) { + if (n !== undefined) { + return Caml_option.some(minKey0Aux(n)); + } + +} + +function minKeyUndefined(n) { + if (n !== undefined) { + return minKey0Aux(n); + } + +} + +function maxKey0Aux(_n) { + while(true) { + var n = _n; + var n$1 = n.r; + if (n$1 === undefined) { + return n.k; + } + _n = Caml_option.valFromOption(n$1); + continue ; + }; +} + +function maxKey(n) { + if (n !== undefined) { + return Caml_option.some(maxKey0Aux(n)); + } + +} + +function maxKeyUndefined(n) { + if (n !== undefined) { + return maxKey0Aux(n); + } + +} + +function minKV0Aux(_n) { + while(true) { + var n = _n; + var n$1 = n.l; + if (n$1 === undefined) { + return [ + n.k, + n.v + ]; + } + _n = Caml_option.valFromOption(n$1); + continue ; + }; +} + +function minimum(n) { + if (n !== undefined) { + return minKV0Aux(n); + } + +} + +function minUndefined(n) { + if (n !== undefined) { + return minKV0Aux(n); + } + +} + +function maxKV0Aux(_n) { + while(true) { + var n = _n; + var n$1 = n.r; + if (n$1 === undefined) { + return [ + n.k, + n.v + ]; + } + _n = Caml_option.valFromOption(n$1); + continue ; + }; +} + +function maximum(n) { + if (n !== undefined) { + return maxKV0Aux(n); + } + +} + +function maxUndefined(n) { + if (n !== undefined) { + return maxKV0Aux(n); + } + +} + +function removeMinAuxWithRef(n, kr, vr) { + var ln = n.l; + if (ln !== undefined) { + return bal(removeMinAuxWithRef(Caml_option.valFromOption(ln), kr, vr), n.k, n.v, n.r); + } else { + kr.contents = n.k; + vr.contents = n.v; + return n.r; + } +} + +function isEmpty(x) { + return x === undefined; +} + +function stackAllLeft(_v, _s) { + while(true) { + var s = _s; + var v = _v; + if (v === undefined) { + return s; + } + var x = Caml_option.valFromOption(v); + _s = { + hd: x, + tl: s + }; + _v = x.l; + continue ; + }; +} + +function findFirstByU(n, p) { + if (n === undefined) { + return ; + } + var n$1 = Caml_option.valFromOption(n); + var left = findFirstByU(n$1.l, p); + if (left !== undefined) { + return left; + } + var v = n$1.k; + var d = n$1.v; + var pvd = p(v, d); + if (pvd) { + return [ + v, + d + ]; + } + var right = findFirstByU(n$1.r, p); + if (right !== undefined) { + return right; + } + +} + +function findFirstBy(n, p) { + return findFirstByU(n, Curry.__2(p)); +} + +function forEachU(_n, f) { + while(true) { + var n = _n; + if (n === undefined) { + return ; + } + var n$1 = Caml_option.valFromOption(n); + forEachU(n$1.l, f); + f(n$1.k, n$1.v); + _n = n$1.r; + continue ; + }; +} + +function forEach(n, f) { + forEachU(n, Curry.__2(f)); +} + +function mapU(n, f) { + if (n === undefined) { + return ; + } + var n$1 = Caml_option.valFromOption(n); + var newLeft = mapU(n$1.l, f); + var newD = f(n$1.v); + var newRight = mapU(n$1.r, f); + return { + k: n$1.k, + v: newD, + h: n$1.h, + l: newLeft, + r: newRight + }; +} + +function map(n, f) { + return mapU(n, Curry.__1(f)); +} + +function mapWithKeyU(n, f) { + if (n === undefined) { + return ; + } + var n$1 = Caml_option.valFromOption(n); + var key = n$1.k; + var newLeft = mapWithKeyU(n$1.l, f); + var newD = f(key, n$1.v); + var newRight = mapWithKeyU(n$1.r, f); + return { + k: key, + v: newD, + h: n$1.h, + l: newLeft, + r: newRight + }; +} + +function mapWithKey(n, f) { + return mapWithKeyU(n, Curry.__2(f)); +} + +function reduceU(_m, _accu, f) { + while(true) { + var accu = _accu; + var m = _m; + if (m === undefined) { + return accu; + } + var n = Caml_option.valFromOption(m); + var v = n.k; + var d = n.v; + var l = n.l; + var r = n.r; + _accu = f(reduceU(l, accu, f), v, d); + _m = r; + continue ; + }; +} + +function reduce(m, accu, f) { + return reduceU(m, accu, Curry.__3(f)); +} + +function everyU(_n, p) { + while(true) { + var n = _n; + if (n === undefined) { + return true; + } + var n$1 = Caml_option.valFromOption(n); + if (!p(n$1.k, n$1.v)) { + return false; + } + if (!everyU(n$1.l, p)) { + return false; + } + _n = n$1.r; + continue ; + }; +} + +function every(n, p) { + return everyU(n, Curry.__2(p)); +} + +function someU(_n, p) { + while(true) { + var n = _n; + if (n === undefined) { + return false; + } + var n$1 = Caml_option.valFromOption(n); + if (p(n$1.k, n$1.v)) { + return true; + } + if (someU(n$1.l, p)) { + return true; + } + _n = n$1.r; + continue ; + }; +} + +function some(n, p) { + return someU(n, Curry.__2(p)); +} + +function addMinElement(n, k, v) { + if (n === undefined) { + return singleton(k, v); + } + var n$1 = Caml_option.valFromOption(n); + return bal(addMinElement(n$1.l, k, v), n$1.k, n$1.v, n$1.r); +} + +function addMaxElement(n, k, v) { + if (n === undefined) { + return singleton(k, v); + } + var n$1 = Caml_option.valFromOption(n); + return bal(n$1.l, n$1.k, n$1.v, addMaxElement(n$1.r, k, v)); +} + +function join(ln, v, d, rn) { + if (ln === undefined) { + return addMinElement(rn, v, d); + } + if (rn === undefined) { + return addMaxElement(ln, v, d); + } + var r = Caml_option.valFromOption(rn); + var l = Caml_option.valFromOption(ln); + var lv = l.k; + var ld = l.v; + var lh = l.h; + var ll = l.l; + var lr = l.r; + var rv = r.k; + var rd = r.v; + var rh = r.h; + var rl = r.l; + var rr = r.r; + if (lh > (rh + 2 | 0)) { + return bal(ll, lv, ld, join(lr, v, d, rn)); + } else if (rh > (lh + 2 | 0)) { + return bal(join(ln, v, d, rl), rv, rd, rr); + } else { + return create(ln, v, d, rn); + } +} + +function concat(t1, t2) { + if (t1 === undefined) { + return t2; + } + if (t2 === undefined) { + return t1; + } + var t2n = Caml_option.valFromOption(t2); + var kr = { + contents: t2n.k + }; + var vr = { + contents: t2n.v + }; + var t2r = removeMinAuxWithRef(t2n, kr, vr); + return join(t1, kr.contents, vr.contents, t2r); +} + +function concatOrJoin(t1, v, d, t2) { + if (d !== undefined) { + return join(t1, v, Caml_option.valFromOption(d), t2); + } else { + return concat(t1, t2); + } +} + +function keepSharedU(n, p) { + if (n === undefined) { + return ; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + var d = n$1.v; + var newLeft = keepSharedU(n$1.l, p); + var pvd = p(v, d); + var newRight = keepSharedU(n$1.r, p); + if (pvd) { + return join(newLeft, v, d, newRight); + } else { + return concat(newLeft, newRight); + } +} + +function keepShared(n, p) { + return keepSharedU(n, Curry.__2(p)); +} + +function keepMapU(n, p) { + if (n === undefined) { + return ; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + var d = n$1.v; + var newLeft = keepMapU(n$1.l, p); + var pvd = p(v, d); + var newRight = keepMapU(n$1.r, p); + if (pvd !== undefined) { + return join(newLeft, v, Caml_option.valFromOption(pvd), newRight); + } else { + return concat(newLeft, newRight); + } +} + +function keepMap(n, p) { + return keepMapU(n, Curry.__2(p)); +} + +function partitionSharedU(n, p) { + if (n === undefined) { + return [ + undefined, + undefined + ]; + } + var n$1 = Caml_option.valFromOption(n); + var key = n$1.k; + var value = n$1.v; + var match = partitionSharedU(n$1.l, p); + var lf = match[1]; + var lt = match[0]; + var pvd = p(key, value); + var match$1 = partitionSharedU(n$1.r, p); + var rf = match$1[1]; + var rt = match$1[0]; + if (pvd) { + return [ + join(lt, key, value, rt), + concat(lf, rf) + ]; + } else { + return [ + concat(lt, rt), + join(lf, key, value, rf) + ]; + } +} + +function partitionShared(n, p) { + return partitionSharedU(n, Curry.__2(p)); +} + +function lengthNode(n) { + var l = n.l; + var r = n.r; + var sizeL = l !== undefined ? lengthNode(Caml_option.valFromOption(l)) : 0; + var sizeR = r !== undefined ? lengthNode(Caml_option.valFromOption(r)) : 0; + return (1 + sizeL | 0) + sizeR | 0; +} + +function size(n) { + if (n !== undefined) { + return lengthNode(n); + } else { + return 0; + } +} + +function toListAux(_n, _accu) { + while(true) { + var accu = _accu; + var n = _n; + if (n === undefined) { + return accu; + } + var n$1 = Caml_option.valFromOption(n); + var k = n$1.k; + var v = n$1.v; + var l = n$1.l; + var r = n$1.r; + _accu = { + hd: [ + k, + v + ], + tl: toListAux(r, accu) + }; + _n = l; + continue ; + }; +} + +function toList(s) { + return toListAux(s, /* [] */0); +} + +function checkInvariantInternal(_v) { + while(true) { + var v = _v; + if (v === undefined) { + return ; + } + var n = Caml_option.valFromOption(v); + var l = n.l; + var r = n.r; + var diff = treeHeight(l) - treeHeight(r) | 0; + if (!(diff <= 2 && diff >= -2)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/others/belt_internalAVLtree.ml", + 360, + 6 + ], + Error: new Error() + }; + } + checkInvariantInternal(l); + _v = r; + continue ; + }; +} + +function fillArrayKey(_n, _i, arr) { + while(true) { + var i = _i; + var n = _n; + var v = n.k; + var l = n.l; + var r = n.r; + var next = l !== undefined ? fillArrayKey(Caml_option.valFromOption(l), i, arr) : i; + arr[next] = v; + var rnext = next + 1 | 0; + if (r === undefined) { + return rnext; + } + _i = rnext; + _n = Caml_option.valFromOption(r); + continue ; + }; +} + +function fillArrayValue(_n, _i, arr) { + while(true) { + var i = _i; + var n = _n; + var l = n.l; + var r = n.r; + var next = l !== undefined ? fillArrayValue(Caml_option.valFromOption(l), i, arr) : i; + arr[next] = n.v; + var rnext = next + 1 | 0; + if (r === undefined) { + return rnext; + } + _i = rnext; + _n = Caml_option.valFromOption(r); + continue ; + }; +} + +function fillArray(_n, _i, arr) { + while(true) { + var i = _i; + var n = _n; + var l = n.l; + var v = n.k; + var r = n.r; + var next = l !== undefined ? fillArray(Caml_option.valFromOption(l), i, arr) : i; + arr[next] = [ + v, + n.v + ]; + var rnext = next + 1 | 0; + if (r === undefined) { + return rnext; + } + _i = rnext; + _n = Caml_option.valFromOption(r); + continue ; + }; +} + +function toArray(n) { + if (n === undefined) { + return []; + } + var size = lengthNode(n); + var v = new Array(size); + fillArray(n, 0, v); + return v; +} + +function keysToArray(n) { + if (n === undefined) { + return []; + } + var size = lengthNode(n); + var v = new Array(size); + fillArrayKey(n, 0, v); + return v; +} + +function valuesToArray(n) { + if (n === undefined) { + return []; + } + var size = lengthNode(n); + var v = new Array(size); + fillArrayValue(n, 0, v); + return v; +} + +function fromSortedArrayRevAux(arr, off, len) { + switch (len) { + case 0 : + return ; + case 1 : + var match = arr[off]; + return singleton(match[0], match[1]); + case 2 : + var match_0 = arr[off]; + var match_1 = arr[off - 1 | 0]; + var match$1 = match_1; + var match$2 = match_0; + return { + k: match$1[0], + v: match$1[1], + h: 2, + l: singleton(match$2[0], match$2[1]), + r: undefined + }; + case 3 : + var match_0$1 = arr[off]; + var match_1$1 = arr[off - 1 | 0]; + var match_2 = arr[off - 2 | 0]; + var match$3 = match_2; + var match$4 = match_1$1; + var match$5 = match_0$1; + return { + k: match$4[0], + v: match$4[1], + h: 2, + l: singleton(match$5[0], match$5[1]), + r: singleton(match$3[0], match$3[1]) + }; + default: + var nl = len / 2 | 0; + var left = fromSortedArrayRevAux(arr, off, nl); + var match$6 = arr[off - nl | 0]; + var right = fromSortedArrayRevAux(arr, (off - nl | 0) - 1 | 0, (len - nl | 0) - 1 | 0); + return create(left, match$6[0], match$6[1], right); + } +} + +function fromSortedArrayAux(arr, off, len) { + switch (len) { + case 0 : + return ; + case 1 : + var match = arr[off]; + return singleton(match[0], match[1]); + case 2 : + var match_0 = arr[off]; + var match_1 = arr[off + 1 | 0]; + var match$1 = match_1; + var match$2 = match_0; + return { + k: match$1[0], + v: match$1[1], + h: 2, + l: singleton(match$2[0], match$2[1]), + r: undefined + }; + case 3 : + var match_0$1 = arr[off]; + var match_1$1 = arr[off + 1 | 0]; + var match_2 = arr[off + 2 | 0]; + var match$3 = match_2; + var match$4 = match_1$1; + var match$5 = match_0$1; + return { + k: match$4[0], + v: match$4[1], + h: 2, + l: singleton(match$5[0], match$5[1]), + r: singleton(match$3[0], match$3[1]) + }; + default: + var nl = len / 2 | 0; + var left = fromSortedArrayAux(arr, off, nl); + var match$6 = arr[off + nl | 0]; + var right = fromSortedArrayAux(arr, (off + nl | 0) + 1 | 0, (len - nl | 0) - 1 | 0); + return create(left, match$6[0], match$6[1], right); + } +} + +function fromSortedArrayUnsafe(arr) { + return fromSortedArrayAux(arr, 0, arr.length); +} + +function cmpU(s1, s2, kcmp, vcmp) { + var len1 = size(s1); + var len2 = size(s2); + if (len1 === len2) { + var _e1 = stackAllLeft(s1, /* [] */0); + var _e2 = stackAllLeft(s2, /* [] */0); + while(true) { + var e2 = _e2; + var e1 = _e1; + if (!e1) { + return 0; + } + if (!e2) { + return 0; + } + var h2 = e2.hd; + var h1 = e1.hd; + var c = kcmp(h1.k, h2.k); + if (c !== 0) { + return c; + } + var cx = vcmp(h1.v, h2.v); + if (cx !== 0) { + return cx; + } + _e2 = stackAllLeft(h2.r, e2.tl); + _e1 = stackAllLeft(h1.r, e1.tl); + continue ; + }; + } else if (len1 < len2) { + return -1; + } else { + return 1; + } +} + +function cmp(s1, s2, kcmp, vcmp) { + return cmpU(s1, s2, kcmp, Curry.__2(vcmp)); +} + +function eqU(s1, s2, kcmp, veq) { + var len1 = size(s1); + var len2 = size(s2); + if (len1 === len2) { + var _e1 = stackAllLeft(s1, /* [] */0); + var _e2 = stackAllLeft(s2, /* [] */0); + while(true) { + var e2 = _e2; + var e1 = _e1; + if (!e1) { + return true; + } + if (!e2) { + return true; + } + var h2 = e2.hd; + var h1 = e1.hd; + if (!(kcmp(h1.k, h2.k) === 0 && veq(h1.v, h2.v))) { + return false; + } + _e2 = stackAllLeft(h2.r, e2.tl); + _e1 = stackAllLeft(h1.r, e1.tl); + continue ; + }; + } else { + return false; + } +} + +function eq(s1, s2, kcmp, veq) { + return eqU(s1, s2, kcmp, Curry.__2(veq)); +} + +function get(_n, x, cmp) { + while(true) { + var n = _n; + if (n === undefined) { + return ; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + var c = cmp(x, v); + if (c === 0) { + return Caml_option.some(n$1.v); + } + _n = c < 0 ? n$1.l : n$1.r; + continue ; + }; +} + +function getUndefined(_n, x, cmp) { + while(true) { + var n = _n; + if (n === undefined) { + return ; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + var c = cmp(x, v); + if (c === 0) { + return n$1.v; + } + _n = c < 0 ? n$1.l : n$1.r; + continue ; + }; +} + +function getExn(_n, x, cmp) { + while(true) { + var n = _n; + if (n !== undefined) { + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + var c = cmp(x, v); + if (c === 0) { + return n$1.v; + } + _n = c < 0 ? n$1.l : n$1.r; + continue ; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + }; +} + +function getWithDefault(_n, x, def, cmp) { + while(true) { + var n = _n; + if (n === undefined) { + return def; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + var c = cmp(x, v); + if (c === 0) { + return n$1.v; + } + _n = c < 0 ? n$1.l : n$1.r; + continue ; + }; +} + +function has(_n, x, cmp) { + while(true) { + var n = _n; + if (n === undefined) { + return false; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + var c = cmp(x, v); + if (c === 0) { + return true; + } + _n = c < 0 ? n$1.l : n$1.r; + continue ; + }; +} + +function rotateWithLeftChild(k2) { + var k1 = k2.l; + var k1$1 = Caml_option.valFromOption(k1); + k2.l = k1$1.r; + k1$1.r = k2; + var hlk2 = treeHeight(k2.l); + var hrk2 = treeHeight(k2.r); + k2.h = ( + hlk2 > hrk2 ? hlk2 : hrk2 + ) + 1 | 0; + var hlk1 = treeHeight(k1$1.l); + var hk2 = k2.h; + k1$1.h = ( + hlk1 > hk2 ? hlk1 : hk2 + ) + 1 | 0; + return k1$1; +} + +function rotateWithRightChild(k1) { + var k2 = k1.r; + var k2$1 = Caml_option.valFromOption(k2); + k1.r = k2$1.l; + k2$1.l = k1; + var hlk1 = treeHeight(k1.l); + var hrk1 = treeHeight(k1.r); + k1.h = ( + hlk1 > hrk1 ? hlk1 : hrk1 + ) + 1 | 0; + var hrk2 = treeHeight(k2$1.r); + var hk1 = k1.h; + k2$1.h = ( + hrk2 > hk1 ? hrk2 : hk1 + ) + 1 | 0; + return k2$1; +} + +function doubleWithLeftChild(k3) { + var x = k3.l; + var v = rotateWithRightChild(Caml_option.valFromOption(x)); + k3.l = v; + return rotateWithLeftChild(k3); +} + +function doubleWithRightChild(k2) { + var x = k2.r; + var v = rotateWithLeftChild(Caml_option.valFromOption(x)); + k2.r = v; + return rotateWithRightChild(k2); +} + +function heightUpdateMutate(t) { + var hlt = treeHeight(t.l); + var hrt = treeHeight(t.r); + t.h = ( + hlt > hrt ? hlt : hrt + ) + 1 | 0; + return t; +} + +function balMutate(nt) { + var l = nt.l; + var r = nt.r; + var hl = treeHeight(l); + var hr = treeHeight(r); + if (hl > (2 + hr | 0)) { + var match = Caml_option.valFromOption(l); + var ll = match.l; + var lr = match.r; + if (heightGe(ll, lr)) { + return heightUpdateMutate(rotateWithLeftChild(nt)); + } else { + return heightUpdateMutate(doubleWithLeftChild(nt)); + } + } + if (hr > (2 + hl | 0)) { + var match$1 = Caml_option.valFromOption(r); + var rl = match$1.l; + var rr = match$1.r; + if (heightGe(rr, rl)) { + return heightUpdateMutate(rotateWithRightChild(nt)); + } else { + return heightUpdateMutate(doubleWithRightChild(nt)); + } + } + nt.h = ( + hl > hr ? hl : hr + ) + 1 | 0; + return nt; +} + +function updateMutate(t, x, data, cmp) { + if (t === undefined) { + return singleton(x, data); + } + var nt = Caml_option.valFromOption(t); + var k = nt.k; + var c = cmp(x, k); + if (c === 0) { + nt.v = data; + return nt; + } + var l = nt.l; + var r = nt.r; + if (c < 0) { + var ll = updateMutate(l, x, data, cmp); + nt.l = ll; + } else { + nt.r = updateMutate(r, x, data, cmp); + } + return balMutate(nt); +} + +function fromArray(xs, cmp) { + var len = xs.length; + if (len === 0) { + return ; + } + var next = Belt__Belt_SortArray.strictlySortedLengthU(xs, (function (param, param$1) { + return cmp(param[0], param$1[0]) < 0; + })); + var result; + if (next >= 0) { + result = fromSortedArrayAux(xs, 0, next); + } else { + next = -next | 0; + result = fromSortedArrayRevAux(xs, next - 1 | 0, next); + } + for(var i = next; i < len; ++i){ + var match = xs[i]; + result = updateMutate(result, match[0], match[1], cmp); + } + return result; +} + +function removeMinAuxWithRootMutate(nt, n) { + var rn = n.r; + var ln = n.l; + if (ln !== undefined) { + n.l = removeMinAuxWithRootMutate(nt, Caml_option.valFromOption(ln)); + return balMutate(n); + } else { + nt.k = n.k; + nt.v = n.v; + return rn; + } +} + +export { + copy , + create , + bal , + singleton , + updateValue , + minKey , + minKeyUndefined , + maxKey , + maxKeyUndefined , + minimum , + minUndefined , + maximum , + maxUndefined , + removeMinAuxWithRef , + isEmpty , + stackAllLeft , + findFirstByU , + findFirstBy , + forEachU , + forEach , + mapU , + map , + mapWithKeyU , + mapWithKey , + reduceU , + reduce , + everyU , + every , + someU , + some , + join , + concat , + concatOrJoin , + keepSharedU , + keepShared , + keepMapU , + keepMap , + partitionSharedU , + partitionShared , + lengthNode , + size , + toList , + checkInvariantInternal , + fillArray , + toArray , + keysToArray , + valuesToArray , + fromSortedArrayAux , + fromSortedArrayRevAux , + fromSortedArrayUnsafe , + cmpU , + cmp , + eqU , + eq , + get , + getUndefined , + getWithDefault , + getExn , + has , + fromArray , + updateMutate , + balMutate , + removeMinAuxWithRootMutate , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_internalBuckets.js b/melange-node-modules/melange.belt/belt_internalBuckets.js new file mode 100644 index 0000000..27a19c8 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_internalBuckets.js @@ -0,0 +1,284 @@ +// Generated by Melange + +import * as Belt__Belt_Array from "./belt_Array.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function copyAuxCont(_c, _prec) { + while(true) { + var prec = _prec; + var c = _c; + if (c === undefined) { + return ; + } + var ncopy = { + key: c.key, + value: c.value, + next: undefined + }; + prec.next = ncopy; + _prec = ncopy; + _c = c.next; + continue ; + }; +} + +function copyBucket(c) { + if (c === undefined) { + return c; + } + var head = { + key: c.key, + value: c.value, + next: undefined + }; + copyAuxCont(c.next, head); + return head; +} + +function copyBuckets(buckets) { + var len = buckets.length; + var newBuckets = new Array(len); + for(var i = 0; i < len; ++i){ + newBuckets[i] = copyBucket(buckets[i]); + } + return newBuckets; +} + +function copy(x) { + return { + size: x.size, + buckets: copyBuckets(x.buckets), + hash: x.hash, + eq: x.eq + }; +} + +function bucketLength(_accu, _buckets) { + while(true) { + var buckets = _buckets; + var accu = _accu; + if (buckets === undefined) { + return accu; + } + _buckets = buckets.next; + _accu = accu + 1 | 0; + continue ; + }; +} + +function do_bucket_iter(f, _buckets) { + while(true) { + var buckets = _buckets; + if (buckets === undefined) { + return ; + } + f(buckets.key, buckets.value); + _buckets = buckets.next; + continue ; + }; +} + +function forEachU(h, f) { + var d = h.buckets; + for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ + do_bucket_iter(f, d[i]); + } +} + +function forEach(h, f) { + forEachU(h, Curry.__2(f)); +} + +function do_bucket_fold(f, _b, _accu) { + while(true) { + var accu = _accu; + var b = _b; + if (b === undefined) { + return accu; + } + _accu = f(accu, b.key, b.value); + _b = b.next; + continue ; + }; +} + +function reduceU(h, init, f) { + var d = h.buckets; + var accu = init; + for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ + accu = do_bucket_fold(f, d[i], accu); + } + return accu; +} + +function reduce(h, init, f) { + return reduceU(h, init, Curry.__3(f)); +} + +function getMaxBucketLength(h) { + return Belt__Belt_Array.reduceU(h.buckets, 0, (function (m, b) { + var len = bucketLength(0, b); + if (m > len) { + return m; + } else { + return len; + } + })); +} + +function getBucketHistogram(h) { + var mbl = getMaxBucketLength(h); + var histo = Belt__Belt_Array.makeByU(mbl + 1 | 0, (function (param) { + return 0; + })); + Belt__Belt_Array.forEachU(h.buckets, (function (b) { + var l = bucketLength(0, b); + histo[l] = histo[l] + 1 | 0; + })); + return histo; +} + +function logStats(h) { + var histogram = getBucketHistogram(h); + console.log({ + bindings: h.size, + buckets: h.buckets.length, + histogram: histogram + }); +} + +function filterMapInplaceBucket(f, h, i, _prec, _cell) { + while(true) { + var cell = _cell; + var prec = _prec; + var n = cell.next; + var data = f(cell.key, cell.value); + if (data !== undefined) { + if (prec !== undefined) { + cell.next = cell; + } else { + h.buckets[i] = cell; + } + cell.value = Caml_option.valFromOption(data); + if (n === undefined) { + cell.next = n; + return ; + } + _cell = n; + _prec = cell; + continue ; + } + h.size = h.size - 1 | 0; + if (n === undefined) { + if (prec !== undefined) { + prec.next = n; + } else { + h.buckets[i] = prec; + } + return ; + } + _cell = n; + continue ; + }; +} + +function keepMapInPlaceU(h, f) { + var h_buckets = h.buckets; + for(var i = 0 ,i_finish = h_buckets.length; i < i_finish; ++i){ + var v = h_buckets[i]; + if (v !== undefined) { + filterMapInplaceBucket(f, h, i, undefined, v); + } + + } +} + +function keepMapInPlace(h, f) { + keepMapInPlaceU(h, Curry.__2(f)); +} + +function fillArray(_i, arr, _cell) { + while(true) { + var cell = _cell; + var i = _i; + arr[i] = [ + cell.key, + cell.value + ]; + var v = cell.next; + if (v === undefined) { + return i + 1 | 0; + } + _cell = v; + _i = i + 1 | 0; + continue ; + }; +} + +function fillArrayMap(_i, arr, _cell, f) { + while(true) { + var cell = _cell; + var i = _i; + arr[i] = f(cell); + var v = cell.next; + if (v === undefined) { + return i + 1 | 0; + } + _cell = v; + _i = i + 1 | 0; + continue ; + }; +} + +function linear(h, f) { + var d = h.buckets; + var current = 0; + var arr = new Array(h.size); + for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ + var cell = d[i]; + if (cell !== undefined) { + current = fillArrayMap(current, arr, cell, f); + } + + } + return arr; +} + +function keysToArray(h) { + return linear(h, (function (x) { + return x.key; + })); +} + +function valuesToArray(h) { + return linear(h, (function (x) { + return x.value; + })); +} + +function toArray(h) { + return linear(h, (function (x) { + return [ + x.key, + x.value + ]; + })); +} + +export { + copy , + forEachU , + forEach , + reduceU , + reduce , + logStats , + keepMapInPlaceU , + keepMapInPlace , + fillArray , + keysToArray , + valuesToArray , + toArray , + getBucketHistogram , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_internalBucketsType.js b/melange-node-modules/melange.belt/belt_internalBucketsType.js new file mode 100644 index 0000000..f89805a --- /dev/null +++ b/melange-node-modules/melange.belt/belt_internalBucketsType.js @@ -0,0 +1,49 @@ +// Generated by Melange + + +function power_2_above(_x, n) { + while(true) { + var x = _x; + if (x >= n) { + return x; + } + if ((x << 1) < x) { + return x; + } + _x = (x << 1); + continue ; + }; +} + +function make(hash, eq, hintSize) { + var s = power_2_above(16, hintSize); + return { + size: 0, + buckets: new Array(s), + hash: hash, + eq: eq + }; +} + +function clear(h) { + h.size = 0; + var h_buckets = h.buckets; + var len = h_buckets.length; + for(var i = 0; i < len; ++i){ + h_buckets[i] = undefined; + } +} + +function isEmpty(h) { + return h.size === 0; +} + +var emptyOpt; + +export { + emptyOpt , + make , + clear , + isEmpty , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_internalMapInt.js b/melange-node-modules/melange.belt/belt_internalMapInt.js new file mode 100644 index 0000000..017aa51 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_internalMapInt.js @@ -0,0 +1,367 @@ +// Generated by Melange + +import * as Belt__Belt_SortArray from "./belt_SortArray.js"; +import * as Belt__Belt_internalAVLtree from "./belt_internalAVLtree.js"; +import * as Caml from "melange.js/caml.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function add(t, x, data) { + if (t === undefined) { + return Belt__Belt_internalAVLtree.singleton(x, data); + } + var n = Caml_option.valFromOption(t); + var k = n.k; + if (x === k) { + return Belt__Belt_internalAVLtree.updateValue(n, data); + } + var v = n.v; + if (x < k) { + return Belt__Belt_internalAVLtree.bal(add(n.l, x, data), k, v, n.r); + } else { + return Belt__Belt_internalAVLtree.bal(n.l, k, v, add(n.r, x, data)); + } +} + +function get(_n, x) { + while(true) { + var n = _n; + if (n === undefined) { + return ; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + if (x === v) { + return Caml_option.some(n$1.v); + } + _n = x < v ? n$1.l : n$1.r; + continue ; + }; +} + +function getUndefined(_n, x) { + while(true) { + var n = _n; + if (n === undefined) { + return ; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + if (x === v) { + return n$1.v; + } + _n = x < v ? n$1.l : n$1.r; + continue ; + }; +} + +function getExn(_n, x) { + while(true) { + var n = _n; + if (n !== undefined) { + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + if (x === v) { + return n$1.v; + } + _n = x < v ? n$1.l : n$1.r; + continue ; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + }; +} + +function getWithDefault(_n, x, def) { + while(true) { + var n = _n; + if (n === undefined) { + return def; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + if (x === v) { + return n$1.v; + } + _n = x < v ? n$1.l : n$1.r; + continue ; + }; +} + +function has(_n, x) { + while(true) { + var n = _n; + if (n === undefined) { + return false; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + if (x === v) { + return true; + } + _n = x < v ? n$1.l : n$1.r; + continue ; + }; +} + +function remove(n, x) { + if (n === undefined) { + return n; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + var l = n$1.l; + var r = n$1.r; + if (x !== v) { + if (x < v) { + return Belt__Belt_internalAVLtree.bal(remove(l, x), v, n$1.v, r); + } else { + return Belt__Belt_internalAVLtree.bal(l, v, n$1.v, remove(r, x)); + } + } + if (l === undefined) { + return r; + } + if (r === undefined) { + return l; + } + var rn = Caml_option.valFromOption(r); + var kr = { + contents: rn.k + }; + var vr = { + contents: rn.v + }; + var r$1 = Belt__Belt_internalAVLtree.removeMinAuxWithRef(rn, kr, vr); + return Belt__Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); +} + +function splitAux(x, n) { + var v = n.k; + var d = n.v; + var l = n.l; + var r = n.r; + if (x === v) { + return [ + l, + Caml_option.some(d), + r + ]; + } + if (x < v) { + if (l === undefined) { + return [ + undefined, + undefined, + n + ]; + } + var match = splitAux(x, Caml_option.valFromOption(l)); + return [ + match[0], + match[1], + Belt__Belt_internalAVLtree.join(match[2], v, d, r) + ]; + } + if (r === undefined) { + return [ + n, + undefined, + undefined + ]; + } + var match$1 = splitAux(x, Caml_option.valFromOption(r)); + return [ + Belt__Belt_internalAVLtree.join(l, v, d, match$1[0]), + match$1[1], + match$1[2] + ]; +} + +function split(x, n) { + if (n !== undefined) { + return splitAux(x, n); + } else { + return [ + undefined, + undefined, + undefined + ]; + } +} + +function mergeU(s1, s2, f) { + if (s1 !== undefined) { + var n = Caml_option.valFromOption(s1); + if (n.h >= ( + s2 !== undefined ? s2.h : 0 + )) { + var v1 = n.k; + var d1 = n.v; + var l1 = n.l; + var r1 = n.r; + var match = split(v1, s2); + return Belt__Belt_internalAVLtree.concatOrJoin(mergeU(l1, match[0], f), v1, f(v1, Caml_option.some(d1), match[1]), mergeU(r1, match[2], f)); + } + + } else if (s2 === undefined) { + return ; + } + var n$1 = Caml_option.valFromOption(s2); + var v2 = n$1.k; + var d2 = n$1.v; + var l2 = n$1.l; + var r2 = n$1.r; + var match$1 = split(v2, s1); + return Belt__Belt_internalAVLtree.concatOrJoin(mergeU(match$1[0], l2, f), v2, f(v2, match$1[1], Caml_option.some(d2)), mergeU(match$1[2], r2, f)); +} + +function merge(s1, s2, f) { + return mergeU(s1, s2, Curry.__3(f)); +} + +function compareAux(_e1, _e2, vcmp) { + while(true) { + var e2 = _e2; + var e1 = _e1; + if (!e1) { + return 0; + } + if (!e2) { + return 0; + } + var h2 = e2.hd; + var h1 = e1.hd; + var c = Caml.caml_int_compare(h1.k, h2.k); + if (c !== 0) { + return c; + } + var cx = vcmp(h1.v, h2.v); + if (cx !== 0) { + return cx; + } + _e2 = Belt__Belt_internalAVLtree.stackAllLeft(h2.r, e2.tl); + _e1 = Belt__Belt_internalAVLtree.stackAllLeft(h1.r, e1.tl); + continue ; + }; +} + +function cmpU(s1, s2, cmp) { + var len1 = Belt__Belt_internalAVLtree.size(s1); + var len2 = Belt__Belt_internalAVLtree.size(s2); + if (len1 === len2) { + return compareAux(Belt__Belt_internalAVLtree.stackAllLeft(s1, /* [] */0), Belt__Belt_internalAVLtree.stackAllLeft(s2, /* [] */0), cmp); + } else if (len1 < len2) { + return -1; + } else { + return 1; + } +} + +function cmp(s1, s2, f) { + return cmpU(s1, s2, Curry.__2(f)); +} + +function eqAux(_e1, _e2, eq) { + while(true) { + var e2 = _e2; + var e1 = _e1; + if (!e1) { + return true; + } + if (!e2) { + return true; + } + var h2 = e2.hd; + var h1 = e1.hd; + if (!(h1.k === h2.k && eq(h1.v, h2.v))) { + return false; + } + _e2 = Belt__Belt_internalAVLtree.stackAllLeft(h2.r, e2.tl); + _e1 = Belt__Belt_internalAVLtree.stackAllLeft(h1.r, e1.tl); + continue ; + }; +} + +function eqU(s1, s2, eq) { + var len1 = Belt__Belt_internalAVLtree.size(s1); + var len2 = Belt__Belt_internalAVLtree.size(s2); + if (len1 === len2) { + return eqAux(Belt__Belt_internalAVLtree.stackAllLeft(s1, /* [] */0), Belt__Belt_internalAVLtree.stackAllLeft(s2, /* [] */0), eq); + } else { + return false; + } +} + +function eq(s1, s2, f) { + return eqU(s1, s2, Curry.__2(f)); +} + +function addMutate(t, x, data) { + if (t === undefined) { + return Belt__Belt_internalAVLtree.singleton(x, data); + } + var nt = Caml_option.valFromOption(t); + var k = nt.k; + if (x === k) { + nt.k = x; + nt.v = data; + return nt; + } + var l = nt.l; + var r = nt.r; + if (x < k) { + var ll = addMutate(l, x, data); + nt.l = ll; + } else { + nt.r = addMutate(r, x, data); + } + return Belt__Belt_internalAVLtree.balMutate(nt); +} + +function fromArray(xs) { + var len = xs.length; + if (len === 0) { + return ; + } + var next = Belt__Belt_SortArray.strictlySortedLengthU(xs, (function (param, param$1) { + return param[0] < param$1[0]; + })); + var result; + if (next >= 0) { + result = Belt__Belt_internalAVLtree.fromSortedArrayAux(xs, 0, next); + } else { + next = -next | 0; + result = Belt__Belt_internalAVLtree.fromSortedArrayRevAux(xs, next - 1 | 0, next); + } + for(var i = next; i < len; ++i){ + var match = xs[i]; + result = addMutate(result, match[0], match[1]); + } + return result; +} + +export { + add , + get , + getUndefined , + getExn , + getWithDefault , + has , + remove , + splitAux , + split , + mergeU , + merge , + compareAux , + cmpU , + cmp , + eqAux , + eqU , + eq , + addMutate , + fromArray , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_internalMapString.js b/melange-node-modules/melange.belt/belt_internalMapString.js new file mode 100644 index 0000000..827c1ba --- /dev/null +++ b/melange-node-modules/melange.belt/belt_internalMapString.js @@ -0,0 +1,367 @@ +// Generated by Melange + +import * as Belt__Belt_SortArray from "./belt_SortArray.js"; +import * as Belt__Belt_internalAVLtree from "./belt_internalAVLtree.js"; +import * as Caml from "melange.js/caml.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function add(t, x, data) { + if (t === undefined) { + return Belt__Belt_internalAVLtree.singleton(x, data); + } + var n = Caml_option.valFromOption(t); + var k = n.k; + if (x === k) { + return Belt__Belt_internalAVLtree.updateValue(n, data); + } + var v = n.v; + if (x < k) { + return Belt__Belt_internalAVLtree.bal(add(n.l, x, data), k, v, n.r); + } else { + return Belt__Belt_internalAVLtree.bal(n.l, k, v, add(n.r, x, data)); + } +} + +function get(_n, x) { + while(true) { + var n = _n; + if (n === undefined) { + return ; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + if (x === v) { + return Caml_option.some(n$1.v); + } + _n = x < v ? n$1.l : n$1.r; + continue ; + }; +} + +function getUndefined(_n, x) { + while(true) { + var n = _n; + if (n === undefined) { + return ; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + if (x === v) { + return n$1.v; + } + _n = x < v ? n$1.l : n$1.r; + continue ; + }; +} + +function getExn(_n, x) { + while(true) { + var n = _n; + if (n !== undefined) { + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + if (x === v) { + return n$1.v; + } + _n = x < v ? n$1.l : n$1.r; + continue ; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + }; +} + +function getWithDefault(_n, x, def) { + while(true) { + var n = _n; + if (n === undefined) { + return def; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + if (x === v) { + return n$1.v; + } + _n = x < v ? n$1.l : n$1.r; + continue ; + }; +} + +function has(_n, x) { + while(true) { + var n = _n; + if (n === undefined) { + return false; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + if (x === v) { + return true; + } + _n = x < v ? n$1.l : n$1.r; + continue ; + }; +} + +function remove(n, x) { + if (n === undefined) { + return n; + } + var n$1 = Caml_option.valFromOption(n); + var v = n$1.k; + var l = n$1.l; + var r = n$1.r; + if (x !== v) { + if (x < v) { + return Belt__Belt_internalAVLtree.bal(remove(l, x), v, n$1.v, r); + } else { + return Belt__Belt_internalAVLtree.bal(l, v, n$1.v, remove(r, x)); + } + } + if (l === undefined) { + return r; + } + if (r === undefined) { + return l; + } + var rn = Caml_option.valFromOption(r); + var kr = { + contents: rn.k + }; + var vr = { + contents: rn.v + }; + var r$1 = Belt__Belt_internalAVLtree.removeMinAuxWithRef(rn, kr, vr); + return Belt__Belt_internalAVLtree.bal(l, kr.contents, vr.contents, r$1); +} + +function splitAux(x, n) { + var v = n.k; + var d = n.v; + var l = n.l; + var r = n.r; + if (x === v) { + return [ + l, + Caml_option.some(d), + r + ]; + } + if (x < v) { + if (l === undefined) { + return [ + undefined, + undefined, + n + ]; + } + var match = splitAux(x, Caml_option.valFromOption(l)); + return [ + match[0], + match[1], + Belt__Belt_internalAVLtree.join(match[2], v, d, r) + ]; + } + if (r === undefined) { + return [ + n, + undefined, + undefined + ]; + } + var match$1 = splitAux(x, Caml_option.valFromOption(r)); + return [ + Belt__Belt_internalAVLtree.join(l, v, d, match$1[0]), + match$1[1], + match$1[2] + ]; +} + +function split(x, n) { + if (n !== undefined) { + return splitAux(x, n); + } else { + return [ + undefined, + undefined, + undefined + ]; + } +} + +function mergeU(s1, s2, f) { + if (s1 !== undefined) { + var n = Caml_option.valFromOption(s1); + if (n.h >= ( + s2 !== undefined ? s2.h : 0 + )) { + var v1 = n.k; + var d1 = n.v; + var l1 = n.l; + var r1 = n.r; + var match = split(v1, s2); + return Belt__Belt_internalAVLtree.concatOrJoin(mergeU(l1, match[0], f), v1, f(v1, Caml_option.some(d1), match[1]), mergeU(r1, match[2], f)); + } + + } else if (s2 === undefined) { + return ; + } + var n$1 = Caml_option.valFromOption(s2); + var v2 = n$1.k; + var d2 = n$1.v; + var l2 = n$1.l; + var r2 = n$1.r; + var match$1 = split(v2, s1); + return Belt__Belt_internalAVLtree.concatOrJoin(mergeU(match$1[0], l2, f), v2, f(v2, match$1[1], Caml_option.some(d2)), mergeU(match$1[2], r2, f)); +} + +function merge(s1, s2, f) { + return mergeU(s1, s2, Curry.__3(f)); +} + +function compareAux(_e1, _e2, vcmp) { + while(true) { + var e2 = _e2; + var e1 = _e1; + if (!e1) { + return 0; + } + if (!e2) { + return 0; + } + var h2 = e2.hd; + var h1 = e1.hd; + var c = Caml.caml_string_compare(h1.k, h2.k); + if (c !== 0) { + return c; + } + var cx = vcmp(h1.v, h2.v); + if (cx !== 0) { + return cx; + } + _e2 = Belt__Belt_internalAVLtree.stackAllLeft(h2.r, e2.tl); + _e1 = Belt__Belt_internalAVLtree.stackAllLeft(h1.r, e1.tl); + continue ; + }; +} + +function cmpU(s1, s2, cmp) { + var len1 = Belt__Belt_internalAVLtree.size(s1); + var len2 = Belt__Belt_internalAVLtree.size(s2); + if (len1 === len2) { + return compareAux(Belt__Belt_internalAVLtree.stackAllLeft(s1, /* [] */0), Belt__Belt_internalAVLtree.stackAllLeft(s2, /* [] */0), cmp); + } else if (len1 < len2) { + return -1; + } else { + return 1; + } +} + +function cmp(s1, s2, f) { + return cmpU(s1, s2, Curry.__2(f)); +} + +function eqAux(_e1, _e2, eq) { + while(true) { + var e2 = _e2; + var e1 = _e1; + if (!e1) { + return true; + } + if (!e2) { + return true; + } + var h2 = e2.hd; + var h1 = e1.hd; + if (!(h1.k === h2.k && eq(h1.v, h2.v))) { + return false; + } + _e2 = Belt__Belt_internalAVLtree.stackAllLeft(h2.r, e2.tl); + _e1 = Belt__Belt_internalAVLtree.stackAllLeft(h1.r, e1.tl); + continue ; + }; +} + +function eqU(s1, s2, eq) { + var len1 = Belt__Belt_internalAVLtree.size(s1); + var len2 = Belt__Belt_internalAVLtree.size(s2); + if (len1 === len2) { + return eqAux(Belt__Belt_internalAVLtree.stackAllLeft(s1, /* [] */0), Belt__Belt_internalAVLtree.stackAllLeft(s2, /* [] */0), eq); + } else { + return false; + } +} + +function eq(s1, s2, f) { + return eqU(s1, s2, Curry.__2(f)); +} + +function addMutate(t, x, data) { + if (t === undefined) { + return Belt__Belt_internalAVLtree.singleton(x, data); + } + var nt = Caml_option.valFromOption(t); + var k = nt.k; + if (x === k) { + nt.k = x; + nt.v = data; + return nt; + } + var l = nt.l; + var r = nt.r; + if (x < k) { + var ll = addMutate(l, x, data); + nt.l = ll; + } else { + nt.r = addMutate(r, x, data); + } + return Belt__Belt_internalAVLtree.balMutate(nt); +} + +function fromArray(xs) { + var len = xs.length; + if (len === 0) { + return ; + } + var next = Belt__Belt_SortArray.strictlySortedLengthU(xs, (function (param, param$1) { + return param[0] < param$1[0]; + })); + var result; + if (next >= 0) { + result = Belt__Belt_internalAVLtree.fromSortedArrayAux(xs, 0, next); + } else { + next = -next | 0; + result = Belt__Belt_internalAVLtree.fromSortedArrayRevAux(xs, next - 1 | 0, next); + } + for(var i = next; i < len; ++i){ + var match = xs[i]; + result = addMutate(result, match[0], match[1]); + } + return result; +} + +export { + add , + get , + getUndefined , + getExn , + getWithDefault , + has , + remove , + splitAux , + split , + mergeU , + merge , + compareAux , + cmpU , + cmp , + eqAux , + eqU , + eq , + addMutate , + fromArray , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_internalSetBuckets.js b/melange-node-modules/melange.belt/belt_internalSetBuckets.js new file mode 100644 index 0000000..ae5b88e --- /dev/null +++ b/melange-node-modules/melange.belt/belt_internalSetBuckets.js @@ -0,0 +1,188 @@ +// Generated by Melange + +import * as Belt__Belt_Array from "./belt_Array.js"; +import * as Curry from "melange.js/curry.js"; + +function copyAuxCont(_c, _prec) { + while(true) { + var prec = _prec; + var c = _c; + if (c === undefined) { + return ; + } + var ncopy = { + key: c.key, + next: undefined + }; + prec.next = ncopy; + _prec = ncopy; + _c = c.next; + continue ; + }; +} + +function copyBucket(c) { + if (c === undefined) { + return c; + } + var head = { + key: c.key, + next: undefined + }; + copyAuxCont(c.next, head); + return head; +} + +function copyBuckets(buckets) { + var len = buckets.length; + var newBuckets = new Array(len); + for(var i = 0; i < len; ++i){ + newBuckets[i] = copyBucket(buckets[i]); + } + return newBuckets; +} + +function copy(x) { + return { + size: x.size, + buckets: copyBuckets(x.buckets), + hash: x.hash, + eq: x.eq + }; +} + +function bucketLength(_accu, _buckets) { + while(true) { + var buckets = _buckets; + var accu = _accu; + if (buckets === undefined) { + return accu; + } + _buckets = buckets.next; + _accu = accu + 1 | 0; + continue ; + }; +} + +function doBucketIter(f, _buckets) { + while(true) { + var buckets = _buckets; + if (buckets === undefined) { + return ; + } + f(buckets.key); + _buckets = buckets.next; + continue ; + }; +} + +function forEachU(h, f) { + var d = h.buckets; + for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ + doBucketIter(f, d[i]); + } +} + +function forEach(h, f) { + forEachU(h, Curry.__1(f)); +} + +function fillArray(_i, arr, _cell) { + while(true) { + var cell = _cell; + var i = _i; + arr[i] = cell.key; + var v = cell.next; + if (v === undefined) { + return i + 1 | 0; + } + _cell = v; + _i = i + 1 | 0; + continue ; + }; +} + +function toArray(h) { + var d = h.buckets; + var current = 0; + var arr = new Array(h.size); + for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ + var cell = d[i]; + if (cell !== undefined) { + current = fillArray(current, arr, cell); + } + + } + return arr; +} + +function doBucketFold(f, _b, _accu) { + while(true) { + var accu = _accu; + var b = _b; + if (b === undefined) { + return accu; + } + _accu = f(accu, b.key); + _b = b.next; + continue ; + }; +} + +function reduceU(h, init, f) { + var d = h.buckets; + var accu = init; + for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ + accu = doBucketFold(f, d[i], accu); + } + return accu; +} + +function reduce(h, init, f) { + return reduceU(h, init, Curry.__2(f)); +} + +function getMaxBucketLength(h) { + return Belt__Belt_Array.reduceU(h.buckets, 0, (function (m, b) { + var len = bucketLength(0, b); + if (m > len) { + return m; + } else { + return len; + } + })); +} + +function getBucketHistogram(h) { + var mbl = getMaxBucketLength(h); + var histo = Belt__Belt_Array.makeByU(mbl + 1 | 0, (function (param) { + return 0; + })); + Belt__Belt_Array.forEachU(h.buckets, (function (b) { + var l = bucketLength(0, b); + histo[l] = histo[l] + 1 | 0; + })); + return histo; +} + +function logStats(h) { + var histogram = getBucketHistogram(h); + console.log({ + bindings: h.size, + buckets: h.buckets.length, + histogram: histogram + }); +} + +export { + copy , + forEachU , + forEach , + fillArray , + toArray , + reduceU , + reduce , + logStats , + getBucketHistogram , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_internalSetInt.js b/melange-node-modules/melange.belt/belt_internalSetInt.js new file mode 100644 index 0000000..f93d7e6 --- /dev/null +++ b/melange-node-modules/melange.belt/belt_internalSetInt.js @@ -0,0 +1,207 @@ +// Generated by Melange + +import * as Belt__Belt_SortArrayInt from "./belt_SortArrayInt.js"; +import * as Belt__Belt_internalAVLset from "./belt_internalAVLset.js"; +import * as Caml_option from "melange.js/caml_option.js"; + +function has(_t, x) { + while(true) { + var t = _t; + if (t === undefined) { + return false; + } + var n = Caml_option.valFromOption(t); + var v = n.v; + if (x === v) { + return true; + } + _t = x < v ? n.l : n.r; + continue ; + }; +} + +function compareAux(_e1, _e2) { + while(true) { + var e2 = _e2; + var e1 = _e1; + if (!e1) { + return 0; + } + if (!e2) { + return 0; + } + var h2 = e2.hd; + var h1 = e1.hd; + var k1 = h1.v; + var k2 = h2.v; + if (k1 !== k2) { + if (k1 < k2) { + return -1; + } else { + return 1; + } + } + _e2 = Belt__Belt_internalAVLset.stackAllLeft(h2.r, e2.tl); + _e1 = Belt__Belt_internalAVLset.stackAllLeft(h1.r, e1.tl); + continue ; + }; +} + +function cmp(s1, s2) { + var len1 = Belt__Belt_internalAVLset.size(s1); + var len2 = Belt__Belt_internalAVLset.size(s2); + if (len1 === len2) { + return compareAux(Belt__Belt_internalAVLset.stackAllLeft(s1, /* [] */0), Belt__Belt_internalAVLset.stackAllLeft(s2, /* [] */0)); + } else if (len1 < len2) { + return -1; + } else { + return 1; + } +} + +function eq(s1, s2) { + return cmp(s1, s2) === 0; +} + +function subset(_s1, _s2) { + while(true) { + var s2 = _s2; + var s1 = _s1; + if (s1 === undefined) { + return true; + } + if (s2 === undefined) { + return false; + } + var t2 = Caml_option.valFromOption(s2); + var t1 = Caml_option.valFromOption(s1); + var v1 = t1.v; + var l1 = t1.l; + var r1 = t1.r; + var v2 = t2.v; + var l2 = t2.l; + var r2 = t2.r; + if (v1 === v2) { + if (!subset(l1, l2)) { + return false; + } + _s2 = r2; + _s1 = r1; + continue ; + } + if (v1 < v2) { + if (!subset(Belt__Belt_internalAVLset.create(l1, v1, undefined), l2)) { + return false; + } + _s1 = r1; + continue ; + } + if (!subset(Belt__Belt_internalAVLset.create(undefined, v1, r1), r2)) { + return false; + } + _s1 = l1; + continue ; + }; +} + +function get(_n, x) { + while(true) { + var n = _n; + if (n === undefined) { + return ; + } + var t = Caml_option.valFromOption(n); + var v = t.v; + if (x === v) { + return v; + } + _n = x < v ? t.l : t.r; + continue ; + }; +} + +function getUndefined(_n, x) { + while(true) { + var n = _n; + if (n === undefined) { + return ; + } + var t = Caml_option.valFromOption(n); + var v = t.v; + if (x === v) { + return v; + } + _n = x < v ? t.l : t.r; + continue ; + }; +} + +function getExn(_n, x) { + while(true) { + var n = _n; + if (n !== undefined) { + var t = Caml_option.valFromOption(n); + var v = t.v; + if (x === v) { + return v; + } + _n = x < v ? t.l : t.r; + continue ; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + }; +} + +function addMutate(t, x) { + if (t === undefined) { + return Belt__Belt_internalAVLset.singleton(x); + } + var k = t.v; + if (x === k) { + return t; + } + var l = t.l; + var r = t.r; + if (x < k) { + t.l = addMutate(l, x); + } else { + t.r = addMutate(r, x); + } + return Belt__Belt_internalAVLset.balMutate(t); +} + +function fromArray(xs) { + var len = xs.length; + if (len === 0) { + return ; + } + var next = Belt__Belt_SortArrayInt.strictlySortedLength(xs); + var result; + if (next >= 0) { + result = Belt__Belt_internalAVLset.fromSortedArrayAux(xs, 0, next); + } else { + next = -next | 0; + result = Belt__Belt_internalAVLset.fromSortedArrayRevAux(xs, next - 1 | 0, next); + } + for(var i = next; i < len; ++i){ + result = addMutate(result, xs[i]); + } + return result; +} + +export { + has , + compareAux , + cmp , + eq , + subset , + get , + getUndefined , + getExn , + addMutate , + fromArray , +} +/* No side effect */ diff --git a/melange-node-modules/melange.belt/belt_internalSetString.js b/melange-node-modules/melange.belt/belt_internalSetString.js new file mode 100644 index 0000000..631e39b --- /dev/null +++ b/melange-node-modules/melange.belt/belt_internalSetString.js @@ -0,0 +1,207 @@ +// Generated by Melange + +import * as Belt__Belt_SortArrayString from "./belt_SortArrayString.js"; +import * as Belt__Belt_internalAVLset from "./belt_internalAVLset.js"; +import * as Caml_option from "melange.js/caml_option.js"; + +function has(_t, x) { + while(true) { + var t = _t; + if (t === undefined) { + return false; + } + var n = Caml_option.valFromOption(t); + var v = n.v; + if (x === v) { + return true; + } + _t = x < v ? n.l : n.r; + continue ; + }; +} + +function compareAux(_e1, _e2) { + while(true) { + var e2 = _e2; + var e1 = _e1; + if (!e1) { + return 0; + } + if (!e2) { + return 0; + } + var h2 = e2.hd; + var h1 = e1.hd; + var k1 = h1.v; + var k2 = h2.v; + if (k1 !== k2) { + if (k1 < k2) { + return -1; + } else { + return 1; + } + } + _e2 = Belt__Belt_internalAVLset.stackAllLeft(h2.r, e2.tl); + _e1 = Belt__Belt_internalAVLset.stackAllLeft(h1.r, e1.tl); + continue ; + }; +} + +function cmp(s1, s2) { + var len1 = Belt__Belt_internalAVLset.size(s1); + var len2 = Belt__Belt_internalAVLset.size(s2); + if (len1 === len2) { + return compareAux(Belt__Belt_internalAVLset.stackAllLeft(s1, /* [] */0), Belt__Belt_internalAVLset.stackAllLeft(s2, /* [] */0)); + } else if (len1 < len2) { + return -1; + } else { + return 1; + } +} + +function eq(s1, s2) { + return cmp(s1, s2) === 0; +} + +function subset(_s1, _s2) { + while(true) { + var s2 = _s2; + var s1 = _s1; + if (s1 === undefined) { + return true; + } + if (s2 === undefined) { + return false; + } + var t2 = Caml_option.valFromOption(s2); + var t1 = Caml_option.valFromOption(s1); + var v1 = t1.v; + var l1 = t1.l; + var r1 = t1.r; + var v2 = t2.v; + var l2 = t2.l; + var r2 = t2.r; + if (v1 === v2) { + if (!subset(l1, l2)) { + return false; + } + _s2 = r2; + _s1 = r1; + continue ; + } + if (v1 < v2) { + if (!subset(Belt__Belt_internalAVLset.create(l1, v1, undefined), l2)) { + return false; + } + _s1 = r1; + continue ; + } + if (!subset(Belt__Belt_internalAVLset.create(undefined, v1, r1), r2)) { + return false; + } + _s1 = l1; + continue ; + }; +} + +function get(_n, x) { + while(true) { + var n = _n; + if (n === undefined) { + return ; + } + var t = Caml_option.valFromOption(n); + var v = t.v; + if (x === v) { + return v; + } + _n = x < v ? t.l : t.r; + continue ; + }; +} + +function getUndefined(_n, x) { + while(true) { + var n = _n; + if (n === undefined) { + return ; + } + var t = Caml_option.valFromOption(n); + var v = t.v; + if (x === v) { + return v; + } + _n = x < v ? t.l : t.r; + continue ; + }; +} + +function getExn(_n, x) { + while(true) { + var n = _n; + if (n !== undefined) { + var t = Caml_option.valFromOption(n); + var v = t.v; + if (x === v) { + return v; + } + _n = x < v ? t.l : t.r; + continue ; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + }; +} + +function addMutate(t, x) { + if (t === undefined) { + return Belt__Belt_internalAVLset.singleton(x); + } + var k = t.v; + if (x === k) { + return t; + } + var l = t.l; + var r = t.r; + if (x < k) { + t.l = addMutate(l, x); + } else { + t.r = addMutate(r, x); + } + return Belt__Belt_internalAVLset.balMutate(t); +} + +function fromArray(xs) { + var len = xs.length; + if (len === 0) { + return ; + } + var next = Belt__Belt_SortArrayString.strictlySortedLength(xs); + var result; + if (next >= 0) { + result = Belt__Belt_internalAVLset.fromSortedArrayAux(xs, 0, next); + } else { + next = -next | 0; + result = Belt__Belt_internalAVLset.fromSortedArrayRevAux(xs, next - 1 | 0, next); + } + for(var i = next; i < len; ++i){ + result = addMutate(result, xs[i]); + } + return result; +} + +export { + has , + compareAux , + cmp , + eq , + subset , + get , + getUndefined , + getExn , + addMutate , + fromArray , +} +/* No side effect */ diff --git a/melange-node-modules/melange.dom/dom.js b/melange-node-modules/melange.dom/dom.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.dom/dom.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.dom/dom__.js b/melange-node-modules/melange.dom/dom__.js new file mode 100644 index 0000000..3d0be59 --- /dev/null +++ b/melange-node-modules/melange.dom/dom__.js @@ -0,0 +1,9 @@ +// Generated by Melange + + +var Dom__ = {}; + +export { + Dom__ , +} +/* No side effect */ diff --git a/melange-node-modules/melange.dom/dom_storage.js b/melange-node-modules/melange.dom/dom_storage.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.dom/dom_storage.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.dom/dom_storage2.js b/melange-node-modules/melange.dom/dom_storage2.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.dom/dom_storage2.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/caml.js b/melange-node-modules/melange.js/caml.js new file mode 100644 index 0000000..74df943 --- /dev/null +++ b/melange-node-modules/melange.js/caml.js @@ -0,0 +1,214 @@ +// Generated by Melange + + +function caml_int_compare(x, y) { + if (x < y) { + return -1; + } else if (x === y) { + return 0; + } else { + return 1; + } +} + +function caml_bool_compare(x, y) { + if (x) { + if (y) { + return 0; + } else { + return 1; + } + } else if (y) { + return -1; + } else { + return 0; + } +} + +function caml_float_compare(x, y) { + if (x === y) { + return 0; + } else if (x < y) { + return -1; + } else if (x > y || x === x) { + return 1; + } else if (y === y) { + return -1; + } else { + return 0; + } +} + +function caml_string_compare(s1, s2) { + if (s1 === s2) { + return 0; + } else if (s1 < s2) { + return -1; + } else { + return 1; + } +} + +function caml_bool_min(x, y) { + if (x) { + return y; + } else { + return x; + } +} + +function caml_int_min(x, y) { + if (x < y) { + return x; + } else { + return y; + } +} + +function caml_float_min(x, y) { + if (x < y) { + return x; + } else { + return y; + } +} + +function caml_string_min(x, y) { + if (x < y) { + return x; + } else { + return y; + } +} + +function caml_int32_min(x, y) { + if (x < y) { + return x; + } else { + return y; + } +} + +function caml_bool_max(x, y) { + if (x) { + return x; + } else { + return y; + } +} + +function caml_int_max(x, y) { + if (x > y) { + return x; + } else { + return y; + } +} + +function caml_float_max(x, y) { + if (x > y) { + return x; + } else { + return y; + } +} + +function caml_string_max(x, y) { + if (x > y) { + return x; + } else { + return y; + } +} + +function caml_int32_max(x, y) { + if (x > y) { + return x; + } else { + return y; + } +} + +function i64_eq(x, y) { + if (x[1] === y[1]) { + return x[0] === y[0]; + } else { + return false; + } +} + +function i64_ge(param, param$1) { + var other_hi = param$1[0]; + var hi = param[0]; + if (hi > other_hi) { + return true; + } else if (hi < other_hi) { + return false; + } else { + return param[1] >= param$1[1]; + } +} + +function i64_neq(x, y) { + return !i64_eq(x, y); +} + +function i64_lt(x, y) { + return !i64_ge(x, y); +} + +function i64_gt(x, y) { + if (x[0] > y[0]) { + return true; + } else if (x[0] < y[0]) { + return false; + } else { + return x[1] > y[1]; + } +} + +function i64_le(x, y) { + return !i64_gt(x, y); +} + +function i64_min(x, y) { + if (i64_ge(x, y)) { + return y; + } else { + return x; + } +} + +function i64_max(x, y) { + if (i64_gt(x, y)) { + return x; + } else { + return y; + } +} + +export { + caml_int_compare , + caml_bool_compare , + caml_float_compare , + caml_string_compare , + caml_bool_min , + caml_int_min , + caml_float_min , + caml_string_min , + caml_int32_min , + caml_bool_max , + caml_int_max , + caml_float_max , + caml_string_max , + caml_int32_max , + i64_eq , + i64_neq , + i64_lt , + i64_gt , + i64_le , + i64_ge , + i64_min , + i64_max , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_array.js b/melange-node-modules/melange.js/caml_array.js new file mode 100644 index 0000000..20ada79 --- /dev/null +++ b/melange-node-modules/melange.js/caml_array.js @@ -0,0 +1,122 @@ +// Generated by Melange + + +function sub(x, offset, len) { + var result = new Array(len); + var j = 0; + var 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) { + var l = _l; + var acc = _acc; + if (!l) { + return acc; + } + _l = l.tl; + _acc = l.hd.length + acc | 0; + continue ; + }; +} + +function fill(arr, _i, _l) { + while(true) { + var l = _l; + var i = _i; + if (!l) { + return ; + } + var x = l.hd; + var l$1 = x.length; + var k = i; + var 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) { + var v = len(0, l); + var result = new Array(v); + fill(result, 0, l); + return result; +} + +function set(xs, index, newval) { + if (index < 0 || index >= xs.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds", + Error: new Error() + }; + } + xs[index] = newval; +} + +function get(xs, index) { + if (index < 0 || index >= xs.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds", + Error: new Error() + }; + } + return xs[index]; +} + +function make(len, init) { + var b = new Array(len); + for(var i = 0; i < len; ++i){ + b[i] = init; + } + return b; +} + +function make_float(len) { + var b = new Array(len); + for(var i = 0; i < len; ++i){ + b[i] = 0; + } + return b; +} + +function blit(a1, i1, a2, i2, len) { + if (i2 <= i1) { + for(var j = 0; j < len; ++j){ + a2[j + i2 | 0] = a1[j + i1 | 0]; + } + return ; + } + for(var 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 , + make_float , + blit , + get , + set , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_array_extern.js b/melange-node-modules/melange.js/caml_array_extern.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/caml_array_extern.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/caml_bytes.js b/melange-node-modules/melange.js/caml_bytes.js new file mode 100644 index 0000000..9bd1fcd --- /dev/null +++ b/melange-node-modules/melange.js/caml_bytes.js @@ -0,0 +1,404 @@ +// Generated by Melange + +import * as Js__Caml_int64 from "./caml_int64.js"; + +function set(s, i, ch) { + if (i < 0 || i >= s.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds", + Error: new Error() + }; + } + s[i] = ch; +} + +function get(s, i) { + if (i < 0 || i >= s.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds", + Error: new Error() + }; + } + return s[i]; +} + +function caml_fill_bytes(s, i, l, c) { + if (l <= 0) { + return ; + } + for(var k = i ,k_finish = l + i | 0; k < k_finish; ++k){ + s[k] = c; + } +} + +function caml_create_bytes(len) { + if (len < 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.create", + Error: new Error() + }; + } + var result = new Array(len); + for(var i = 0; i < len; ++i){ + result[i] = /* '\000' */0; + } + return result; +} + +function caml_blit_bytes(s1, i1, s2, i2, len) { + if (len <= 0) { + return ; + } + if (s1 === s2) { + if (i1 < i2) { + var range_a = (s1.length - i2 | 0) - 1 | 0; + var range_b = len - 1 | 0; + var range = range_a > range_b ? range_b : range_a; + for(var j = range; j >= 0; --j){ + s1[i2 + j | 0] = s1[i1 + j | 0]; + } + return ; + } + if (i1 <= i2) { + return ; + } + var range_a$1 = (s1.length - i1 | 0) - 1 | 0; + var range_b$1 = len - 1 | 0; + var range$1 = range_a$1 > range_b$1 ? range_b$1 : range_a$1; + for(var k = 0; k <= range$1; ++k){ + s1[i2 + k | 0] = s1[i1 + k | 0]; + } + return ; + } + var off1 = s1.length - i1 | 0; + if (len <= off1) { + for(var i = 0; i < len; ++i){ + s2[i2 + i | 0] = s1[i1 + i | 0]; + } + return ; + } + for(var i$1 = 0; i$1 < off1; ++i$1){ + s2[i2 + i$1 | 0] = s1[i1 + i$1 | 0]; + } + for(var i$2 = off1; i$2 < len; ++i$2){ + s2[i2 + i$2 | 0] = /* '\000' */0; + } +} + +function bytes_to_string(a) { + var i = 0; + var len = a.length; + var s = ""; + var s_len = len; + if (i === 0 && len <= 4096 && len === a.length) { + return String.fromCharCode.apply(null, a); + } + var offset = 0; + while(s_len > 0) { + var next = s_len < 1024 ? s_len : 1024; + var tmp_bytes = new Array(next); + for(var k = 0; k < next; ++k){ + tmp_bytes[k] = a[k + offset | 0]; + } + s = s + String.fromCharCode.apply(null, tmp_bytes); + s_len = s_len - next | 0; + offset = offset + next | 0; + }; + return s; +} + +function caml_blit_string(s1, i1, s2, i2, len) { + if (len <= 0) { + return ; + } + var off1 = s1.length - i1 | 0; + if (len <= off1) { + for(var i = 0; i < len; ++i){ + s2[i2 + i | 0] = s1.charCodeAt(i1 + i | 0); + } + return ; + } + for(var i$1 = 0; i$1 < off1; ++i$1){ + s2[i2 + i$1 | 0] = s1.charCodeAt(i1 + i$1 | 0); + } + for(var i$2 = off1; i$2 < len; ++i$2){ + s2[i2 + i$2 | 0] = /* '\000' */0; + } +} + +function bytes_of_string(s) { + var len = s.length; + var res = new Array(len); + for(var i = 0; i < len; ++i){ + res[i] = s.charCodeAt(i); + } + return res; +} + +function caml_bytes_compare_aux(s1, s2, _off, len, def) { + while(true) { + var off = _off; + if (off >= len) { + return def; + } + var a = s1[off]; + var b = s2[off]; + if (a > b) { + return 1; + } + if (a < b) { + return -1; + } + _off = off + 1 | 0; + continue ; + }; +} + +function caml_bytes_compare(s1, s2) { + var len1 = s1.length; + var len2 = s2.length; + if (len1 === len2) { + return caml_bytes_compare_aux(s1, s2, 0, len1, 0); + } else if (len1 < len2) { + return caml_bytes_compare_aux(s1, s2, 0, len1, -1); + } else { + return caml_bytes_compare_aux(s1, s2, 0, len2, 1); + } +} + +function caml_bytes_equal(s1, s2) { + var len1 = s1.length; + var len2 = s2.length; + if (len1 === len2) { + var _off = 0; + while(true) { + var off = _off; + if (off === len1) { + return true; + } + var a = s1[off]; + var b = s2[off]; + if (a !== b) { + return false; + } + _off = off + 1 | 0; + continue ; + }; + } else { + return false; + } +} + +function caml_bytes_greaterthan(s1, s2) { + return caml_bytes_compare(s1, s2) > 0; +} + +function caml_bytes_greaterequal(s1, s2) { + return caml_bytes_compare(s1, s2) >= 0; +} + +function caml_bytes_lessthan(s1, s2) { + return caml_bytes_compare(s1, s2) < 0; +} + +function caml_bytes_lessequal(s1, s2) { + return caml_bytes_compare(s1, s2) <= 0; +} + +function bswap16(x) { + return ((x & 255) << 8) | ((x & 65280) >>> 8); +} + +function bswap32(x) { + return ((x & 255) << 24) | ((x & 65280) << 8) | ((x & 16711680) >>> 8) | ((x & -16777216) >>> 24); +} + +function bswap64(x) { + return Js__Caml_int64.or_(Js__Caml_int64.or_(Js__Caml_int64.or_(Js__Caml_int64.or_(Js__Caml_int64.or_(Js__Caml_int64.or_(Js__Caml_int64.or_(Js__Caml_int64.lsl_(Js__Caml_int64.and_(x, [ + 0, + 255 + ]), 56), Js__Caml_int64.lsl_(Js__Caml_int64.and_(x, [ + 0, + 65280 + ]), 40)), Js__Caml_int64.lsl_(Js__Caml_int64.and_(x, [ + 0, + 16711680 + ]), 24)), Js__Caml_int64.lsl_(Js__Caml_int64.and_(x, [ + 0, + 4278190080 + ]), 8)), Js__Caml_int64.lsr_(Js__Caml_int64.and_(x, [ + 255, + 0 + ]), 8)), Js__Caml_int64.lsr_(Js__Caml_int64.and_(x, [ + 65280, + 0 + ]), 24)), Js__Caml_int64.lsr_(Js__Caml_int64.and_(x, [ + 16711680, + 0 + ]), 40)), Js__Caml_int64.lsr_(Js__Caml_int64.and_(x, [ + -16777216, + 0 + ]), 56)); +} + +function get16u(str, idx) { + var b1 = str[idx]; + var b2 = str[idx + 1 | 0]; + return (b2 << 8) | b1; +} + +function get16(str, idx) { + if (idx < 0 || (idx + 1 | 0) >= str.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds", + Error: new Error() + }; + } + return get16u(str, idx); +} + +function get32(str, idx) { + if (idx < 0 || (idx + 3 | 0) >= str.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds", + Error: new Error() + }; + } + var b1 = str[idx]; + var b2 = str[idx + 1 | 0]; + var b3 = str[idx + 2 | 0]; + var b4 = str[idx + 3 | 0]; + return (b4 << 24) | (b3 << 16) | (b2 << 8) | b1; +} + +function get64(str, idx) { + if (idx < 0 || (idx + 7 | 0) >= str.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds", + Error: new Error() + }; + } + var b1 = str[idx]; + var b2 = str[idx + 1 | 0]; + var b3 = str[idx + 2 | 0]; + var b4 = str[idx + 3 | 0]; + var b5 = str[idx + 4 | 0]; + var b6 = str[idx + 5 | 0]; + var b7 = str[idx + 6 | 0]; + var b8 = str[idx + 7 | 0]; + return Js__Caml_int64.or_(Js__Caml_int64.lsl_(Js__Caml_int64.or_(Js__Caml_int64.lsl_(Js__Caml_int64.or_(Js__Caml_int64.lsl_(Js__Caml_int64.or_(Js__Caml_int64.lsl_(Js__Caml_int64.or_(Js__Caml_int64.lsl_(Js__Caml_int64.or_(Js__Caml_int64.lsl_(Js__Caml_int64.or_(Js__Caml_int64.lsl_(Js__Caml_int64.of_int32(b8), 56), Js__Caml_int64.of_int32(b7)), 48), Js__Caml_int64.of_int32(b6)), 40), Js__Caml_int64.of_int32(b5)), 32), Js__Caml_int64.of_int32(b4)), 24), Js__Caml_int64.of_int32(b3)), 16), Js__Caml_int64.of_int32(b2)), 8), Js__Caml_int64.of_int32(b1)); +} + +function set16u(b, idx, newval) { + var b2 = 255 & (newval >>> 8); + var b1 = 255 & newval; + b[idx] = b1; + b[idx + 1 | 0] = b2; +} + +function set16(b, idx, newval) { + if (idx < 0 || (idx + 1 | 0) >= b.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds", + Error: new Error() + }; + } + set16u(b, idx, newval); +} + +function set32u(str, idx, newval) { + var b4 = 255 & (newval >>> 24); + var b3 = 255 & (newval >>> 16); + var b2 = 255 & (newval >>> 8); + var b1 = 255 & newval; + str[idx] = b1; + str[idx + 1 | 0] = b2; + str[idx + 2 | 0] = b3; + str[idx + 3 | 0] = b4; +} + +function set32(str, idx, newval) { + if (idx < 0 || (idx + 3 | 0) >= str.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds", + Error: new Error() + }; + } + set32u(str, idx, newval); +} + +function set64u(str, idx, newval) { + var x = Js__Caml_int64.lsr_(newval, 56); + var b8 = 255 & (x[1] | 0); + var x$1 = Js__Caml_int64.lsr_(newval, 48); + var b7 = 255 & (x$1[1] | 0); + var x$2 = Js__Caml_int64.lsr_(newval, 40); + var b6 = 255 & (x$2[1] | 0); + var x$3 = Js__Caml_int64.lsr_(newval, 32); + var b5 = 255 & (x$3[1] | 0); + var x$4 = Js__Caml_int64.lsr_(newval, 24); + var b4 = 255 & (x$4[1] | 0); + var x$5 = Js__Caml_int64.lsr_(newval, 16); + var b3 = 255 & (x$5[1] | 0); + var x$6 = Js__Caml_int64.lsr_(newval, 8); + var b2 = 255 & (x$6[1] | 0); + var b1 = 255 & (newval[1] | 0); + str[idx] = b1; + str[idx + 1 | 0] = b2; + str[idx + 2 | 0] = b3; + str[idx + 3 | 0] = b4; + str[idx + 4 | 0] = b5; + str[idx + 5 | 0] = b6; + str[idx + 6 | 0] = b7; + str[idx + 7 | 0] = b8; +} + +function set64(str, idx, newval) { + if (idx < 0 || (idx + 7 | 0) >= str.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds", + Error: new Error() + }; + } + set64u(str, idx, newval); +} + +export { + caml_create_bytes , + caml_fill_bytes , + get , + set , + bytes_to_string , + caml_blit_bytes , + caml_blit_string , + bytes_of_string , + caml_bytes_compare , + caml_bytes_greaterthan , + caml_bytes_greaterequal , + caml_bytes_lessthan , + caml_bytes_lessequal , + caml_bytes_equal , + bswap16 , + bswap32 , + bswap64 , + get16u , + get16 , + get32 , + get64 , + set16u , + set16 , + set32u , + set32 , + set64u , + set64 , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_exceptions.js b/melange-node-modules/melange.js/caml_exceptions.js new file mode 100644 index 0000000..60f19d1 --- /dev/null +++ b/melange-node-modules/melange.js/caml_exceptions.js @@ -0,0 +1,45 @@ +// Generated by Melange + + +var id = { + contents: 0 +}; + +function create(str) { + id.contents = id.contents + 1 | 0; + return str + ("/" + id.contents); +} + +function caml_is_extension(e) { + if (e == null) { + return false; + } else { + return typeof e.RE_EXN_ID === "string"; + } +} + +function caml_exn_slot_name(x) { + return x.RE_EXN_ID; +} + +var caml_exn_slot_id = (function(x){ + if (x.RE_EXN_ID != null) { + var parts = x.RE_EXN_ID.split("/"); + if (parts.length > 1) { + return Number(parts[parts.length - 1]) + } else { + return -1; + } + } else { + return -1; + } +}); + +export { + id , + create , + caml_is_extension , + caml_exn_slot_name , + caml_exn_slot_id , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_external_polyfill.js b/melange-node-modules/melange.js/caml_external_polyfill.js new file mode 100644 index 0000000..eaea56f --- /dev/null +++ b/melange-node-modules/melange.js/caml_external_polyfill.js @@ -0,0 +1,32 @@ +// Generated by Melange + + +var getGlobalThis = (function(){ + if (typeof globalThis !== 'undefined') return globalThis; + if (typeof self !== 'undefined') return self; + if (typeof window !== 'undefined') return window; + if (typeof global !== 'undefined') return global; + if (typeof this !== 'undefined') return this; + throw new Error('Unable to locate global `this`'); +}); + +var resolve = (function(s){ + var myGlobal = getGlobalThis(); + if (myGlobal[s] === undefined){ + throw new Error(s + " not polyfilled by Melange yet\n") + } + return myGlobal[s] +}); + +var register = (function(s,fn){ + var myGlobal = getGlobalThis(); + myGlobal[s] = fn + return 0 +}); + +export { + getGlobalThis , + resolve , + register , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_float.js b/melange-node-modules/melange.js/caml_float.js new file mode 100644 index 0000000..f2cd63d --- /dev/null +++ b/melange-node-modules/melange.js/caml_float.js @@ -0,0 +1,134 @@ +// Generated by Melange + + +var caml_int32_float_of_bits = (function(x){ + return new Float32Array(new Int32Array([x]).buffer)[0] + }); + +var caml_int32_bits_of_float = (function(x){ + return new Int32Array(new Float32Array([x]).buffer)[0] +}); + +function caml_modf_float(x) { + if (!isFinite(x)) { + if (isNaN(x)) { + return [ + NaN, + NaN + ]; + } else { + return [ + 1 / x, + x + ]; + } + } + var neg = 1 / x < 0; + var x$1 = Math.abs(x); + var i = Math.floor(x$1); + var f = x$1 - i; + if (neg) { + return [ + - f, + - i + ]; + } else { + return [ + f, + i + ]; + } +} + +function caml_ldexp_float(x, exp) { + var x$p = x; + var exp$p = exp; + if (exp$p > 1023) { + exp$p = exp$p - 1023; + x$p = x$p * Math.pow(2, 1023); + if (exp$p > 1023) { + exp$p = exp$p - 1023; + x$p = x$p * Math.pow(2, 1023); + } + + } else if (exp$p < -1023) { + exp$p = exp$p + 1023; + x$p = x$p * Math.pow(2, -1023); + } + return x$p * Math.pow(2, exp$p); +} + +function caml_frexp_float(x) { + if (x === 0 || !isFinite(x)) { + return [ + x, + 0 + ]; + } + var neg = x < 0; + var x$p = Math.abs(x); + var exp = Math.floor(Math.LOG2E * Math.log(x$p)) + 1; + x$p = x$p * Math.pow(2, - exp); + if (x$p < 0.5) { + x$p = x$p * 2; + exp = exp - 1; + } + if (neg) { + x$p = - x$p; + } + return [ + x$p, + exp | 0 + ]; +} + +function caml_copysign_float(x, y) { + var x$1 = Math.abs(x); + var y$1 = y === 0 ? 1 / y : y; + if (y$1 < 0) { + return - x$1; + } else { + return x$1; + } +} + +function caml_expm1_float(x) { + var y = Math.exp(x); + var z = y - 1; + if (Math.abs(x) > 1) { + return z; + } else if (z === 0) { + return x; + } else { + return x * z / Math.log(y); + } +} + +function caml_hypot_float(x, y) { + var x0 = Math.abs(x); + var y0 = Math.abs(y); + var a = x0 > y0 ? x0 : y0; + var b = ( + x0 < y0 ? x0 : y0 + ) / ( + a !== 0 ? a : 1 + ); + return a * Math.sqrt(1 + b * b); +} + +function caml_log10_float(x) { + return Math.LOG10E * Math.log(x); +} + +export { + caml_int32_float_of_bits , + caml_int32_bits_of_float , + caml_modf_float , + caml_ldexp_float , + caml_frexp_float , + caml_copysign_float , + caml_expm1_float , + caml_hypot_float , + caml_log10_float , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_float_extern.js b/melange-node-modules/melange.js/caml_float_extern.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/caml_float_extern.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/caml_format.js b/melange-node-modules/melange.js/caml_format.js new file mode 100644 index 0000000..a9d1098 --- /dev/null +++ b/melange-node-modules/melange.js/caml_format.js @@ -0,0 +1,831 @@ +// Generated by Melange + +import * as Caml from "melange.js/caml.js"; +import * as Caml_int64 from "melange.js/caml_int64.js"; +import * as Js__Caml_int64 from "./caml_int64.js"; + +function parse_digit(c) { + if (c >= 65) { + if (c >= 97) { + if (c >= 123) { + return -1; + } else { + return c - 87 | 0; + } + } else if (c >= 91) { + return -1; + } else { + return c - 55 | 0; + } + } else if (c > 57 || c < 48) { + return -1; + } else { + return c - /* '0' */48 | 0; + } +} + +function int_of_string_base(param) { + switch (param) { + case /* Oct */0 : + return 8; + case /* Hex */1 : + return 16; + case /* Dec */2 : + return 10; + case /* Bin */3 : + return 2; + + } +} + +function parse_sign_and_base(s) { + var sign = 1; + var base = /* Dec */2; + var i = 0; + var match = s.charCodeAt(i); + switch (match) { + case 43 : + i = i + 1 | 0; + break; + case 44 : + break; + case 45 : + sign = -1; + i = i + 1 | 0; + break; + default: + + } + if (s[i] === "0") { + var match$1 = s.charCodeAt(i + 1 | 0); + if (match$1 >= 89) { + if (match$1 >= 111) { + if (match$1 < 121) { + switch (match$1) { + case 111 : + base = /* Oct */0; + i = i + 2 | 0; + break; + case 117 : + i = i + 2 | 0; + break; + case 112 : + case 113 : + case 114 : + case 115 : + case 116 : + case 118 : + case 119 : + break; + case 120 : + base = /* Hex */1; + i = i + 2 | 0; + break; + + } + } + + } else if (match$1 === 98) { + base = /* Bin */3; + i = i + 2 | 0; + } + + } else if (match$1 !== 66) { + if (match$1 >= 79) { + switch (match$1) { + case 79 : + base = /* Oct */0; + i = i + 2 | 0; + break; + case 85 : + i = i + 2 | 0; + break; + case 80 : + case 81 : + case 82 : + case 83 : + case 84 : + case 86 : + case 87 : + break; + case 88 : + base = /* Hex */1; + i = i + 2 | 0; + break; + + } + } + + } else { + base = /* Bin */3; + i = i + 2 | 0; + } + } + return [ + i, + sign, + base + ]; +} + +function caml_int_of_string(s) { + var match = parse_sign_and_base(s); + var i = match[0]; + var base = int_of_string_base(match[2]); + var threshold = 4294967295; + var len = s.length; + var c = i < len ? s.charCodeAt(i) : /* '\000' */0; + var d = parse_digit(c); + if (d < 0 || d >= base) { + throw { + RE_EXN_ID: "Failure", + _1: "int_of_string", + Error: new Error() + }; + } + var aux = function (_acc, _k) { + while(true) { + var k = _k; + var acc = _acc; + if (k === len) { + return acc; + } + var a = s.charCodeAt(k); + if (a === /* '_' */95) { + _k = k + 1 | 0; + continue ; + } + var v = parse_digit(a); + if (v < 0 || v >= base) { + throw { + RE_EXN_ID: "Failure", + _1: "int_of_string", + Error: new Error() + }; + } + var acc$1 = base * acc + v; + if (acc$1 > threshold) { + throw { + RE_EXN_ID: "Failure", + _1: "int_of_string", + Error: new Error() + }; + } + _k = k + 1 | 0; + _acc = acc$1; + continue ; + }; + }; + var res = match[1] * aux(d, i + 1 | 0); + var or_res = res | 0; + if (base === 10 && res !== or_res) { + throw { + RE_EXN_ID: "Failure", + _1: "int_of_string", + Error: new Error() + }; + } + return or_res; +} + +function caml_int64_of_string(s) { + var match = parse_sign_and_base(s); + var hbase = match[2]; + var i = match[0]; + var base = Caml_int64.of_int32(int_of_string_base(hbase)); + var sign = Caml_int64.of_int32(match[1]); + var threshold; + switch (hbase) { + case /* Oct */0 : + threshold = [ + 536870911, + 4294967295 + ]; + break; + case /* Hex */1 : + threshold = [ + 268435455, + 4294967295 + ]; + break; + case /* Dec */2 : + threshold = [ + 429496729, + 2576980377 + ]; + break; + case /* Bin */3 : + threshold = Caml_int64.max_int; + break; + + } + var len = s.length; + var c = i < len ? s.charCodeAt(i) : /* '\000' */0; + var d = Caml_int64.of_int32(parse_digit(c)); + if (Caml.i64_lt(d, Caml_int64.zero) || Caml.i64_ge(d, base)) { + throw { + RE_EXN_ID: "Failure", + _1: "int64_of_string", + Error: new Error() + }; + } + var aux = function (_acc, _k) { + while(true) { + var k = _k; + var acc = _acc; + if (k === len) { + return acc; + } + var a = s.charCodeAt(k); + if (a === /* '_' */95) { + _k = k + 1 | 0; + continue ; + } + var v = Caml_int64.of_int32(parse_digit(a)); + if (Caml.i64_lt(v, Caml_int64.zero) || Caml.i64_ge(v, base) || Caml.i64_gt(acc, threshold)) { + throw { + RE_EXN_ID: "Failure", + _1: "int64_of_string", + Error: new Error() + }; + } + var acc$1 = Caml_int64.add(Caml_int64.mul(base, acc), v); + _k = k + 1 | 0; + _acc = acc$1; + continue ; + }; + }; + var res = Caml_int64.mul(sign, aux(d, i + 1 | 0)); + var or_res = Caml_int64.or_(res, Caml_int64.zero); + if (Caml.i64_eq(base, [ + 0, + 10 + ]) && Caml.i64_neq(res, or_res)) { + throw { + RE_EXN_ID: "Failure", + _1: "int64_of_string", + Error: new Error() + }; + } + return or_res; +} + +function int_of_base(param) { + switch (param) { + case /* Oct */0 : + return 8; + case /* Hex */1 : + return 16; + case /* Dec */2 : + return 10; + + } +} + +function lowercase(c) { + if (c >= /* 'A' */65 && c <= /* 'Z' */90 || c >= /* '\192' */192 && c <= /* '\214' */214 || c >= /* '\216' */216 && c <= /* '\222' */222) { + return c + 32 | 0; + } else { + return c; + } +} + +function parse_format(fmt) { + var len = fmt.length; + if (len > 31) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "format_int: format too long", + Error: new Error() + }; + } + var f = { + justify: "+", + signstyle: "-", + filter: " ", + alternate: false, + base: /* Dec */2, + signedconv: false, + width: 0, + uppercase: false, + sign: 1, + prec: -1, + conv: "f" + }; + var _i = 0; + while(true) { + var i = _i; + if (i >= len) { + return f; + } + var c = fmt.charCodeAt(i); + var exit = 0; + if (c >= 69) { + if (c >= 88) { + if (c >= 121) { + exit = 1; + } else { + switch (c) { + case 88 : + f.base = /* Hex */1; + f.uppercase = true; + _i = i + 1 | 0; + continue ; + case 101 : + case 102 : + case 103 : + exit = 5; + break; + case 100 : + case 105 : + exit = 4; + break; + case 111 : + f.base = /* Oct */0; + _i = i + 1 | 0; + continue ; + case 117 : + f.base = /* Dec */2; + _i = i + 1 | 0; + continue ; + case 89 : + case 90 : + case 91 : + case 92 : + case 93 : + case 94 : + case 95 : + case 96 : + case 97 : + case 98 : + case 99 : + case 104 : + case 106 : + case 107 : + case 108 : + case 109 : + case 110 : + case 112 : + case 113 : + case 114 : + case 115 : + case 116 : + case 118 : + case 119 : + exit = 1; + break; + case 120 : + f.base = /* Hex */1; + _i = i + 1 | 0; + continue ; + + } + } + } else if (c >= 72) { + exit = 1; + } else { + f.signedconv = true; + f.uppercase = true; + f.conv = String.fromCharCode(lowercase(c)); + _i = i + 1 | 0; + continue ; + } + } else { + switch (c) { + case 35 : + f.alternate = true; + _i = i + 1 | 0; + continue ; + case 32 : + case 43 : + exit = 2; + break; + case 45 : + f.justify = "-"; + _i = i + 1 | 0; + continue ; + case 46 : + f.prec = 0; + var j = i + 1 | 0; + while((function(j){ + return function () { + var w = fmt.charCodeAt(j) - /* '0' */48 | 0; + return w >= 0 && w <= 9; + } + }(j))()) { + f.prec = (Math.imul(f.prec, 10) + fmt.charCodeAt(j) | 0) - /* '0' */48 | 0; + j = j + 1 | 0; + }; + _i = j; + continue ; + case 33 : + case 34 : + case 36 : + case 37 : + case 38 : + case 39 : + case 40 : + case 41 : + case 42 : + case 44 : + case 47 : + exit = 1; + break; + case 48 : + f.filter = "0"; + _i = i + 1 | 0; + continue ; + case 49 : + case 50 : + case 51 : + case 52 : + case 53 : + case 54 : + case 55 : + case 56 : + case 57 : + exit = 3; + break; + default: + exit = 1; + } + } + switch (exit) { + case 1 : + _i = i + 1 | 0; + continue ; + case 2 : + f.signstyle = String.fromCharCode(c); + _i = i + 1 | 0; + continue ; + case 3 : + f.width = 0; + var j$1 = i; + while((function(j$1){ + return function () { + var w = fmt.charCodeAt(j$1) - /* '0' */48 | 0; + return w >= 0 && w <= 9; + } + }(j$1))()) { + f.width = (Math.imul(f.width, 10) + fmt.charCodeAt(j$1) | 0) - /* '0' */48 | 0; + j$1 = j$1 + 1 | 0; + }; + _i = j$1; + continue ; + case 4 : + f.signedconv = true; + f.base = /* Dec */2; + _i = i + 1 | 0; + continue ; + case 5 : + f.signedconv = true; + f.conv = String.fromCharCode(c); + _i = i + 1 | 0; + continue ; + + } + }; +} + +function finish_formatting(config, rawbuffer) { + var justify = config.justify; + var signstyle = config.signstyle; + var filter = config.filter; + var alternate = config.alternate; + var base = config.base; + var signedconv = config.signedconv; + var width = config.width; + var uppercase = config.uppercase; + var sign = config.sign; + var len = rawbuffer.length; + if (signedconv && (sign < 0 || signstyle !== "-")) { + len = len + 1 | 0; + } + if (alternate) { + if (base === /* Oct */0) { + len = len + 1 | 0; + } else if (base === /* Hex */1) { + len = len + 2 | 0; + } + + } + var buffer = ""; + if (justify === "+" && filter === " ") { + for(var _for = len; _for < width; ++_for){ + buffer = buffer + filter; + } + } + if (signedconv) { + if (sign < 0) { + buffer = buffer + "-"; + } else if (signstyle !== "-") { + buffer = buffer + signstyle; + } + + } + if (alternate && base === /* Oct */0) { + buffer = buffer + "0"; + } + if (alternate && base === /* Hex */1) { + buffer = buffer + "0x"; + } + if (justify === "+" && filter === "0") { + for(var _for$1 = len; _for$1 < width; ++_for$1){ + buffer = buffer + filter; + } + } + buffer = uppercase ? buffer + rawbuffer.toUpperCase() : buffer + rawbuffer; + if (justify === "-") { + for(var _for$2 = len; _for$2 < width; ++_for$2){ + buffer = buffer + " "; + } + } + return buffer; +} + +function caml_format_int(fmt, i) { + if (fmt === "%d") { + return String(i); + } + var f = parse_format(fmt); + var i$1 = i < 0 ? ( + f.signedconv ? (f.sign = -1, (-i >>> 0)) : (i >>> 0) + ) : i; + var s = i$1.toString(int_of_base(f.base)); + if (f.prec >= 0) { + f.filter = " "; + var n = f.prec - s.length | 0; + if (n > 0) { + s = "0".repeat(n) + s; + } + + } + return finish_formatting(f, s); +} + +function dec_of_pos_int64(x) { + if (!Caml.i64_lt(x, Caml_int64.zero)) { + return Js__Caml_int64.to_string(x); + } + var wbase = [ + 0, + 10 + ]; + var y = Js__Caml_int64.discard_sign(x); + var match = Js__Caml_int64.div_mod(y, wbase); + var match$1 = Js__Caml_int64.div_mod(Caml_int64.add([ + 0, + 8 + ], match[1]), wbase); + var quotient = Caml_int64.add(Caml_int64.add([ + 214748364, + 3435973836 + ], match[0]), match$1[0]); + return Js__Caml_int64.to_string(quotient) + "0123456789"[Caml_int64.to_int32(match$1[1])]; +} + +function oct_of_int64(x) { + var s = ""; + var wbase = [ + 0, + 8 + ]; + var cvtbl = "01234567"; + if (Caml.i64_lt(x, Caml_int64.zero)) { + var y = Js__Caml_int64.discard_sign(x); + var match = Js__Caml_int64.div_mod(y, wbase); + var quotient = Caml_int64.add([ + 268435456, + 0 + ], match[0]); + var modulus = match[1]; + s = cvtbl[Caml_int64.to_int32(modulus)] + s; + while(Caml.i64_neq(quotient, Caml_int64.zero)) { + var match$1 = Js__Caml_int64.div_mod(quotient, wbase); + quotient = match$1[0]; + modulus = match$1[1]; + s = cvtbl[Caml_int64.to_int32(modulus)] + s; + }; + } else { + var match$2 = Js__Caml_int64.div_mod(x, wbase); + var quotient$1 = match$2[0]; + var modulus$1 = match$2[1]; + s = cvtbl[Caml_int64.to_int32(modulus$1)] + s; + while(Caml.i64_neq(quotient$1, Caml_int64.zero)) { + var match$3 = Js__Caml_int64.div_mod(quotient$1, wbase); + quotient$1 = match$3[0]; + modulus$1 = match$3[1]; + s = cvtbl[Caml_int64.to_int32(modulus$1)] + s; + }; + } + return s; +} + +function caml_int64_format(fmt, x) { + if (fmt === "%d") { + return Js__Caml_int64.to_string(x); + } + var f = parse_format(fmt); + var x$1 = f.signedconv && Caml.i64_lt(x, Caml_int64.zero) ? (f.sign = -1, Caml_int64.neg(x)) : x; + var match = f.base; + var s; + switch (match) { + case /* Oct */0 : + s = oct_of_int64(x$1); + break; + case /* Hex */1 : + s = Js__Caml_int64.to_hex(x$1); + break; + case /* Dec */2 : + s = dec_of_pos_int64(x$1); + break; + + } + var fill_s; + if (f.prec >= 0) { + f.filter = " "; + var n = f.prec - s.length | 0; + fill_s = n > 0 ? "0".repeat(n) + s : s; + } else { + fill_s = s; + } + return finish_formatting(f, fill_s); +} + +function caml_format_float(fmt, x) { + var f = parse_format(fmt); + var prec = f.prec < 0 ? 6 : f.prec; + var x$1 = x < 0 ? (f.sign = -1, - x) : x; + var s = ""; + if (isNaN(x$1)) { + s = "nan"; + f.filter = " "; + } else if (isFinite(x$1)) { + var match = f.conv; + switch (match) { + case "e" : + s = x$1.toExponential(prec); + var i = s.length; + if (s[i - 3 | 0] === "e") { + s = s.slice(0, i - 1 | 0) + ("0" + s.slice(i - 1 | 0)); + } + break; + case "f" : + s = x$1.toFixed(prec); + break; + case "g" : + var prec$1 = prec !== 0 ? prec : 1; + s = x$1.toExponential(prec$1 - 1 | 0); + var j = s.indexOf("e"); + var exp = Number(s.slice(j + 1 | 0)) | 0; + if (exp < -4 || x$1 >= 1e21 || x$1.toFixed().length > prec$1) { + var i$1 = j - 1 | 0; + while(s[i$1] === "0") { + i$1 = i$1 - 1 | 0; + }; + if (s[i$1] === ".") { + i$1 = i$1 - 1 | 0; + } + s = s.slice(0, i$1 + 1 | 0) + s.slice(j); + var i$2 = s.length; + if (s[i$2 - 3 | 0] === "e") { + s = s.slice(0, i$2 - 1 | 0) + ("0" + s.slice(i$2 - 1 | 0)); + } + + } else { + var p = prec$1; + if (exp < 0) { + p = p - (exp + 1 | 0) | 0; + s = x$1.toFixed(p); + } else { + while((function () { + s = x$1.toFixed(p); + return s.length > (prec$1 + 1 | 0); + })()) { + p = p - 1 | 0; + }; + } + if (p !== 0) { + var k = s.length - 1 | 0; + while(s[k] === "0") { + k = k - 1 | 0; + }; + if (s[k] === ".") { + k = k - 1 | 0; + } + s = s.slice(0, k + 1 | 0); + } + + } + break; + default: + + } + } else { + s = "inf"; + f.filter = " "; + } + return finish_formatting(f, s); +} + +var caml_hexstring_of_float = (function(x,prec,style){ + if (!isFinite(x)) { + if (isNaN(x)) return "nan"; + return x > 0 ? "infinity":"-infinity"; + } + var sign = (x==0 && 1/x == -Infinity)?1:(x>=0)?0:1; + if(sign) x = -x; + var exp = 0; + if (x == 0) { } + else if (x < 1) { + while (x < 1 && exp > -1022) { x *= 2; exp-- } + } else { + while (x >= 2) { x /= 2; exp++ } + } + var exp_sign = exp < 0 ? '' : '+'; + var sign_str = ''; + if (sign) sign_str = '-' + else { + switch(style){ + case 43 /* '+' */: sign_str = '+'; break; + case 32 /* ' ' */: sign_str = ' '; break; + default: break; + } + } + if (prec >= 0 && prec < 13) { + /* If a precision is given, and is small, round mantissa accordingly */ + var cst = Math.pow(2,prec * 4); + x = Math.round(x * cst) / cst; + } + var x_str = x.toString(16); + if(prec >= 0){ + var idx = x_str.indexOf('.'); + if(idx<0) { + x_str += '.' + '0'.repeat(prec); + } + else { + var size = idx+1+prec; + if(x_str.length < size) + x_str += '0'.repeat(size - x_str.length); + else + x_str = x_str.substr(0,size); + } + } + return (sign_str + '0x' + x_str + 'p' + exp_sign + exp.toString(10)); +}); + +var float_of_string = (function(s,exn){ + + var res = +s; + if ((s.length > 0) && (res === res)) + return res; + s = s.replace(/_/g, ""); + res = +s; + if (((s.length > 0) && (res === res)) || /^[+-]?nan$/i.test(s)) { + return res; + }; + var m = /^ *([+-]?)0x([0-9a-f]+)\.?([0-9a-f]*)p([+-]?[0-9]+)/i.exec(s); + // 1 2 3 4 + if(m){ + var m3 = m[3].replace(/0+$/,''); + var mantissa = parseInt(m[1] + m[2] + m3, 16); + var exponent = (m[4]|0) - 4*m3.length; + res = mantissa * Math.pow(2, exponent); + return res; + } + if (/^\+?inf(inity)?$/i.test(s)) + return Infinity; + if (/^-inf(inity)?$/i.test(s)) + return -Infinity; + throw exn; +}); + +function caml_float_of_string(s) { + return float_of_string(s, { + RE_EXN_ID: "Failure", + _1: "float_of_string" + }); +} + +var caml_nativeint_format = caml_format_int; + +var caml_int32_format = caml_format_int; + +var caml_int32_of_string = caml_int_of_string; + +var caml_nativeint_of_string = caml_int_of_string; + +export { + caml_format_float , + caml_hexstring_of_float , + caml_format_int , + caml_nativeint_format , + caml_int32_format , + caml_float_of_string , + caml_int64_format , + caml_int_of_string , + caml_int32_of_string , + caml_int64_of_string , + caml_nativeint_of_string , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_gc.js b/melange-node-modules/melange.js/caml_gc.js new file mode 100644 index 0000000..62f0664 --- /dev/null +++ b/melange-node-modules/melange.js/caml_gc.js @@ -0,0 +1,55 @@ +// Generated by Melange + + +function caml_gc_counters(param) { + return [ + 0, + 0, + 0 + ]; +} + +function caml_gc_set(param) { + +} + +function caml_gc_minor(param) { + +} + +function caml_gc_major_slice(param) { + return 0; +} + +function caml_gc_major(param) { + +} + +function caml_gc_full_major(param) { + +} + +function caml_gc_compaction(param) { + +} + +function caml_final_register(param, param$1) { + +} + +function caml_final_release(param) { + +} + +export { + caml_gc_counters , + caml_gc_set , + caml_gc_minor , + caml_gc_major_slice , + caml_gc_major , + caml_gc_full_major , + caml_gc_compaction , + caml_final_register , + caml_final_release , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_hash.js b/melange-node-modules/melange.js/caml_hash.js new file mode 100644 index 0000000..82e3469 --- /dev/null +++ b/melange-node-modules/melange.js/caml_hash.js @@ -0,0 +1,105 @@ +// Generated by Melange + +import * as Js__Caml_hash_primitive from "./caml_hash_primitive.js"; + +function push_back(q, v) { + var cell = { + content: v, + next: undefined + }; + var last = q.last; + if (last !== undefined) { + q.length = q.length + 1 | 0; + last.next = cell; + q.last = cell; + } else { + q.length = 1; + q.first = cell; + q.last = cell; + } +} + +function unsafe_pop(q) { + var cell = q.first; + var next = cell.next; + if (next === undefined) { + q.length = 0; + q.first = undefined; + q.last = undefined; + } else { + q.length = q.length - 1 | 0; + q.first = next; + } + return cell.content; +} + +function caml_hash(count, _limit, seed, obj) { + var hash = seed; + if (typeof obj === "number") { + var u = obj | 0; + hash = Js__Caml_hash_primitive.caml_hash_mix_int(hash, (u + u | 0) + 1 | 0); + return Js__Caml_hash_primitive.caml_hash_final_mix(hash); + } + if (typeof obj === "string") { + hash = Js__Caml_hash_primitive.caml_hash_mix_string(hash, obj); + return Js__Caml_hash_primitive.caml_hash_final_mix(hash); + } + var queue = { + length: 0, + first: undefined, + last: undefined + }; + var num = count; + push_back(queue, obj); + num = num - 1 | 0; + while(queue.length !== 0 && num > 0) { + var obj$1 = unsafe_pop(queue); + if (typeof obj$1 === "number") { + var u$1 = obj$1 | 0; + hash = Js__Caml_hash_primitive.caml_hash_mix_int(hash, (u$1 + u$1 | 0) + 1 | 0); + num = num - 1 | 0; + } else if (typeof obj$1 === "string") { + hash = Js__Caml_hash_primitive.caml_hash_mix_string(hash, obj$1); + num = num - 1 | 0; + } else if (typeof obj$1 === "boolean") { + var u$2 = obj$1 ? 1 : 0; + hash = Js__Caml_hash_primitive.caml_hash_mix_int(hash, (u$2 + u$2 | 0) + 1 | 0); + num = num - 1 | 0; + } else if (typeof obj$1 !== "undefined" && typeof obj$1 !== "symbol" && typeof obj$1 !== "function") { + var size = obj$1.length | 0; + if (size !== 0) { + var obj_tag = obj$1.TAG | 0; + var tag = (size << 10) | obj_tag; + if (obj_tag === 248) { + hash = Js__Caml_hash_primitive.caml_hash_mix_int(hash, obj$1[1]); + } else { + hash = Js__Caml_hash_primitive.caml_hash_mix_int(hash, tag); + var v = size - 1 | 0; + var block = v < num ? v : num; + for(var i = 0; i <= block; ++i){ + push_back(queue, obj$1[i]); + } + } + } else { + var size$1 = (function(obj,cb){ + var size = 0 + for(var k in obj){ + cb(obj[k]) + ++ size + } + return size + })(obj$1, (function (v) { + push_back(queue, v); + })); + hash = Js__Caml_hash_primitive.caml_hash_mix_int(hash, (size$1 << 10) | 0); + } + } + + }; + return Js__Caml_hash_primitive.caml_hash_final_mix(hash); +} + +export { + caml_hash , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_hash_primitive.js b/melange-node-modules/melange.js/caml_hash_primitive.js new file mode 100644 index 0000000..50fdcd0 --- /dev/null +++ b/melange-node-modules/melange.js/caml_hash_primitive.js @@ -0,0 +1,51 @@ +// Generated by Melange + + +function rotl32(x, n) { + return (x << n) | (x >>> (32 - n | 0)) | 0; +} + +function caml_hash_mix_int(h, d) { + var d$1 = d; + d$1 = Math.imul(d$1, -862048943); + d$1 = rotl32(d$1, 15); + d$1 = Math.imul(d$1, 461845907); + var h$1 = h ^ d$1; + h$1 = rotl32(h$1, 13); + return (h$1 + (h$1 << 2) | 0) - 430675100 | 0; +} + +function caml_hash_final_mix(h) { + var h$1 = h ^ (h >>> 16); + h$1 = Math.imul(h$1, -2048144789); + h$1 = h$1 ^ (h$1 >>> 13); + h$1 = Math.imul(h$1, -1028477387); + return h$1 ^ (h$1 >>> 16); +} + +function caml_hash_mix_string(h, s) { + var len = s.length; + var block = (len / 4 | 0) - 1 | 0; + var hash = h; + for(var i = 0; i <= block; ++i){ + var j = (i << 2); + var w = s.charCodeAt(j) | (s.charCodeAt(j + 1 | 0) << 8) | (s.charCodeAt(j + 2 | 0) << 16) | (s.charCodeAt(j + 3 | 0) << 24); + hash = caml_hash_mix_int(hash, w); + } + var modulo = len & 3; + if (modulo !== 0) { + var w$1 = modulo === 3 ? (s.charCodeAt(len - 1 | 0) << 16) | (s.charCodeAt(len - 2 | 0) << 8) | s.charCodeAt(len - 3 | 0) : ( + modulo === 2 ? (s.charCodeAt(len - 1 | 0) << 8) | s.charCodeAt(len - 2 | 0) : s.charCodeAt(len - 1 | 0) + ); + hash = caml_hash_mix_int(hash, w$1); + } + hash = hash ^ len; + return hash; +} + +export { + caml_hash_mix_int , + caml_hash_mix_string , + caml_hash_final_mix , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_int32.js b/melange-node-modules/melange.js/caml_int32.js new file mode 100644 index 0000000..06c8ad6 --- /dev/null +++ b/melange-node-modules/melange.js/caml_int32.js @@ -0,0 +1,28 @@ +// Generated by Melange + + +function div(x, y) { + if (y === 0) { + throw { + RE_EXN_ID: "Division_by_zero", + Error: new Error() + }; + } + return x / y | 0; +} + +function mod_(x, y) { + if (y === 0) { + throw { + RE_EXN_ID: "Division_by_zero", + Error: new Error() + }; + } + return x % y; +} + +export { + div , + mod_ , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_int32_extern.js b/melange-node-modules/melange.js/caml_int32_extern.js new file mode 100644 index 0000000..d03045a --- /dev/null +++ b/melange-node-modules/melange.js/caml_int32_extern.js @@ -0,0 +1,9 @@ +// Generated by Melange + + +var Ops = {}; + +export { + Ops , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_int64.js b/melange-node-modules/melange.js/caml_int64.js new file mode 100644 index 0000000..5dc43e6 --- /dev/null +++ b/melange-node-modules/melange.js/caml_int64.js @@ -0,0 +1,598 @@ +// Generated by Melange + +import * as Js__Caml from "./caml.js"; + +function mk(lo, hi) { + return [ + hi, + (lo >>> 0) + ]; +} + +var min_int = [ + -2147483648, + 0 +]; + +var max_int = [ + 2147483647, + 4294967295 +]; + +var one = [ + 0, + 1 +]; + +var zero = [ + 0, + 0 +]; + +var neg_one = [ + -1, + 4294967295 +]; + +function neg_signed(x) { + return (x & -2147483648) !== 0; +} + +function non_neg_signed(x) { + return (x & -2147483648) === 0; +} + +function succ(param) { + var x_lo = param[1]; + var x_hi = param[0]; + var lo = x_lo + 1 | 0; + return [ + x_hi + ( + lo === 0 ? 1 : 0 + ) | 0, + (lo >>> 0) + ]; +} + +function neg(param) { + var other_lo = (param[1] ^ -1) + 1 | 0; + return [ + (param[0] ^ -1) + ( + other_lo === 0 ? 1 : 0 + ) | 0, + (other_lo >>> 0) + ]; +} + +function add_aux(param, y_lo, y_hi) { + var x_lo = param[1]; + var lo = x_lo + y_lo | 0; + var overflow = neg_signed(x_lo) && (neg_signed(y_lo) || non_neg_signed(lo)) || neg_signed(y_lo) && non_neg_signed(lo) ? 1 : 0; + return [ + param[0] + y_hi + overflow | 0, + (lo >>> 0) + ]; +} + +function add(self, param) { + return add_aux(self, param[1], param[0]); +} + +function equal_null(x, y) { + if (y !== null) { + return Js__Caml.i64_eq(x, y); + } else { + return false; + } +} + +function equal_undefined(x, y) { + if (y !== undefined) { + return Js__Caml.i64_eq(x, y); + } else { + return false; + } +} + +function equal_nullable(x, y) { + if (y == null) { + return false; + } else { + return Js__Caml.i64_eq(x, y); + } +} + +function sub_aux(x, lo, hi) { + var y_lo = ((lo ^ -1) + 1 >>> 0); + var y_hi = (hi ^ -1) + ( + y_lo === 0 ? 1 : 0 + ) | 0; + return add_aux(x, y_lo, y_hi); +} + +function sub(self, param) { + return sub_aux(self, param[1], param[0]); +} + +function lsl_(x, numBits) { + if (numBits === 0) { + return x; + } + var lo = x[1]; + if (numBits >= 32) { + return [ + (lo << (numBits - 32 | 0)), + 0 + ]; + } else { + return [ + (lo >>> (32 - numBits | 0)) | (x[0] << numBits), + ((lo << numBits) >>> 0) + ]; + } +} + +function lsr_(x, numBits) { + if (numBits === 0) { + return x; + } + var hi = x[0]; + var offset = numBits - 32 | 0; + if (offset === 0) { + return [ + 0, + (hi >>> 0) + ]; + } else if (offset > 0) { + return [ + 0, + (hi >>> offset) + ]; + } else { + return [ + (hi >>> numBits), + (((hi << (-offset | 0)) | (x[1] >>> numBits)) >>> 0) + ]; + } +} + +function asr_(x, numBits) { + if (numBits === 0) { + return x; + } + var hi = x[0]; + if (numBits < 32) { + return [ + (hi >> numBits), + (((hi << (32 - numBits | 0)) | (x[1] >>> numBits)) >>> 0) + ]; + } else { + return [ + hi >= 0 ? 0 : -1, + ((hi >> (numBits - 32 | 0)) >>> 0) + ]; + } +} + +function is_zero(param) { + if (param[0] !== 0) { + return false; + } else { + return param[1] === 0; + } +} + +function mul(_this, _other) { + while(true) { + var other = _other; + var $$this = _this; + var lo; + var this_hi = $$this[0]; + var exit = 0; + var exit$1 = 0; + var exit$2 = 0; + if (this_hi !== 0) { + exit$2 = 4; + } else { + if ($$this[1] === 0) { + return zero; + } + exit$2 = 4; + } + if (exit$2 === 4) { + if (other[0] !== 0) { + exit$1 = 3; + } else { + if (other[1] === 0) { + return zero; + } + exit$1 = 3; + } + } + if (exit$1 === 3) { + if (this_hi !== -2147483648 || $$this[1] !== 0) { + exit = 2; + } else { + lo = other[1]; + } + } + if (exit === 2) { + var other_hi = other[0]; + var lo$1 = $$this[1]; + var exit$3 = 0; + if (other_hi !== -2147483648 || other[1] !== 0) { + exit$3 = 3; + } else { + lo = lo$1; + } + if (exit$3 === 3) { + var other_lo = other[1]; + if (this_hi < 0) { + if (other_hi >= 0) { + return neg(mul(neg($$this), other)); + } + _other = neg(other); + _this = neg($$this); + continue ; + } + if (other_hi < 0) { + return neg(mul($$this, neg(other))); + } + var a48 = (this_hi >>> 16); + var a32 = this_hi & 65535; + var a16 = (lo$1 >>> 16); + var a00 = lo$1 & 65535; + var b48 = (other_hi >>> 16); + var b32 = other_hi & 65535; + var b16 = (other_lo >>> 16); + var b00 = other_lo & 65535; + var c48 = 0; + var c32 = 0; + var c16 = 0; + var c00 = a00 * b00; + c16 = (c00 >>> 16) + a16 * b00; + c32 = (c16 >>> 16); + c16 = (c16 & 65535) + a00 * b16; + c32 = c32 + (c16 >>> 16) + a32 * b00; + c48 = (c32 >>> 16); + c32 = (c32 & 65535) + a16 * b16; + c48 = c48 + (c32 >>> 16); + c32 = (c32 & 65535) + a00 * b32; + c48 = c48 + (c32 >>> 16); + c32 = c32 & 65535; + c48 = c48 + (a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48) & 65535; + return [ + c32 | (c48 << 16), + ((c00 & 65535 | ((c16 & 65535) << 16)) >>> 0) + ]; + } + + } + if ((lo & 1) === 0) { + return zero; + } else { + return min_int; + } + }; +} + +function xor(param, param$1) { + return [ + param[0] ^ param$1[0], + ((param[1] ^ param$1[1]) >>> 0) + ]; +} + +function or_(param, param$1) { + return [ + param[0] | param$1[0], + ((param[1] | param$1[1]) >>> 0) + ]; +} + +function and_(param, param$1) { + return [ + param[0] & param$1[0], + ((param[1] & param$1[1]) >>> 0) + ]; +} + +function to_float(param) { + return param[0] * 0x100000000 + param[1]; +} + +function of_float(x) { + if (isNaN(x) || !isFinite(x)) { + return zero; + } + if (x <= -9.22337203685477581e+18) { + return min_int; + } + if (x + 1 >= 9.22337203685477581e+18) { + return max_int; + } + if (x < 0) { + return neg(of_float(- x)); + } + var hi = x / 4294967296 | 0; + var lo = x % 4294967296 | 0; + return [ + hi, + (lo >>> 0) + ]; +} + +function isSafeInteger(param) { + var hi = param[0]; + var top11Bits = (hi >> 21); + if (top11Bits === 0) { + return true; + } else if (top11Bits === -1) { + return !(param[1] === 0 && hi === -2097152); + } else { + return false; + } +} + +function to_string(self) { + if (isSafeInteger(self)) { + return String(to_float(self)); + } + if (self[0] < 0) { + if (Js__Caml.i64_eq(self, min_int)) { + return "-9223372036854775808"; + } else { + return "-" + to_string(neg(self)); + } + } + var approx_div1 = of_float(Math.floor(to_float(self) / 10)); + var lo = approx_div1[1]; + var hi = approx_div1[0]; + var match = sub_aux(sub_aux(self, (lo << 3), (lo >>> 29) | (hi << 3)), (lo << 1), (lo >>> 31) | (hi << 1)); + var rem_lo = match[1]; + var rem_hi = match[0]; + if (rem_lo === 0 && rem_hi === 0) { + return to_string(approx_div1) + "0"; + } + if (rem_hi < 0) { + var rem_lo$1 = ((rem_lo ^ -1) + 1 >>> 0); + var delta = Math.ceil(rem_lo$1 / 10); + var remainder = 10 * delta - rem_lo$1; + return to_string(sub_aux(approx_div1, delta | 0, 0)) + String(remainder | 0); + } + var delta$1 = Math.floor(rem_lo / 10); + var remainder$1 = rem_lo - 10 * delta$1; + return to_string(add_aux(approx_div1, delta$1 | 0, 0)) + String(remainder$1 | 0); +} + +function div(_self, _other) { + while(true) { + var other = _other; + var self = _self; + var exit = 0; + if (other[0] !== 0 || other[1] !== 0) { + exit = 1; + } else { + throw { + RE_EXN_ID: "Division_by_zero", + Error: new Error() + }; + } + if (exit === 1) { + var self_hi = self[0]; + var exit$1 = 0; + if (self_hi !== -2147483648) { + if (self_hi !== 0) { + exit$1 = 2; + } else { + if (self[1] === 0) { + return zero; + } + exit$1 = 2; + } + } else if (self[1] !== 0) { + exit$1 = 2; + } else { + if (Js__Caml.i64_eq(other, one) || Js__Caml.i64_eq(other, neg_one)) { + return self; + } + if (Js__Caml.i64_eq(other, min_int)) { + return one; + } + var half_this = asr_(self, 1); + var approx = lsl_(div(half_this, other), 1); + var exit$2 = 0; + if (approx[0] !== 0) { + exit$2 = 3; + } else { + if (approx[1] === 0) { + if (other[0] < 0) { + return one; + } else { + return neg(one); + } + } + exit$2 = 3; + } + if (exit$2 === 3) { + var rem = sub(self, mul(other, approx)); + return add(approx, div(rem, other)); + } + + } + if (exit$1 === 2) { + var other_hi = other[0]; + var exit$3 = 0; + if (other_hi !== -2147483648) { + exit$3 = 3; + } else { + if (other[1] === 0) { + return zero; + } + exit$3 = 3; + } + if (exit$3 === 3) { + if (self_hi < 0) { + if (other_hi >= 0) { + return neg(div(neg(self), other)); + } + _other = neg(other); + _self = neg(self); + continue ; + } + if (other_hi < 0) { + return neg(div(self, neg(other))); + } + var res = zero; + var rem$1 = self; + while(Js__Caml.i64_ge(rem$1, other)) { + var b = Math.floor(to_float(rem$1) / to_float(other)); + var approx$1 = 1 > b ? 1 : b; + var log2 = Math.ceil(Math.log(approx$1) / Math.LN2); + var delta = log2 <= 48 ? 1 : Math.pow(2, log2 - 48); + var approxRes = of_float(approx$1); + var approxRem = mul(approxRes, other); + while(approxRem[0] < 0 || Js__Caml.i64_gt(approxRem, rem$1)) { + approx$1 = approx$1 - delta; + approxRes = of_float(approx$1); + approxRem = mul(approxRes, other); + }; + if (is_zero(approxRes)) { + approxRes = one; + } + res = add(res, approxRes); + rem$1 = sub(rem$1, approxRem); + }; + return res; + } + + } + + } + + }; +} + +function mod_(self, other) { + return sub(self, mul(div(self, other), other)); +} + +function div_mod(self, other) { + var quotient = div(self, other); + return [ + quotient, + sub(self, mul(quotient, other)) + ]; +} + +function compare(self, other) { + var y = other[0]; + var x = self[0]; + var v = x < y ? -1 : ( + x === y ? 0 : 1 + ); + if (v !== 0) { + return v; + } + var y$1 = other[1]; + var x$1 = self[1]; + if (x$1 < y$1) { + return -1; + } else if (x$1 === y$1) { + return 0; + } else { + return 1; + } +} + +function of_int32(lo) { + return [ + lo < 0 ? -1 : 0, + (lo >>> 0) + ]; +} + +function to_int32(x) { + return x[1] | 0; +} + +function to_hex(x) { + var x_lo = x[1]; + var x_hi = x[0]; + var aux = function (v) { + return (v >>> 0).toString(16); + }; + if (x_hi === 0 && x_lo === 0) { + return "0"; + } + if (x_lo === 0) { + return aux(x_hi) + "00000000"; + } + if (x_hi === 0) { + return aux(x_lo); + } + var lo = aux(x_lo); + var pad = 8 - lo.length | 0; + if (pad <= 0) { + return aux(x_hi) + lo; + } else { + return aux(x_hi) + ("0".repeat(pad) + lo); + } +} + +function discard_sign(x) { + return [ + 2147483647 & x[0], + x[1] + ]; +} + +function float_of_bits(x) { + return (function(lo,hi){ return (new Float64Array(new Int32Array([lo,hi]).buffer))[0]})(x[1], x[0]); +} + +function bits_of_float(x) { + var match = (function(x){return new Int32Array(new Float64Array([x]).buffer)})(x); + return [ + match[1], + (match[0] >>> 0) + ]; +} + +export { + mk , + succ , + min_int , + max_int , + one , + zero , + neg_one , + of_int32 , + to_int32 , + add , + neg , + sub , + lsl_ , + lsr_ , + asr_ , + is_zero , + mul , + xor , + or_ , + and_ , + equal_null , + equal_undefined , + equal_nullable , + to_float , + of_float , + div , + mod_ , + compare , + float_of_bits , + bits_of_float , + div_mod , + to_hex , + discard_sign , + to_string , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_int64_extern.js b/melange-node-modules/melange.js/caml_int64_extern.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/caml_int64_extern.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/caml_io.js b/melange-node-modules/melange.js/caml_io.js new file mode 100644 index 0000000..ef6e155 --- /dev/null +++ b/melange-node-modules/melange.js/caml_io.js @@ -0,0 +1,82 @@ +// Generated by Melange + + +var stdout = { + buffer: "", + output: (function (param, s) { + var v = s.length - 1 | 0; + if (((typeof process !== "undefined") && process.stdout && process.stdout.write)) { + return process.stdout.write(s); + } else { + if (s[v] === "\n") { + console.log(s.slice(0, v)); + } else { + console.log(s); + } + return ; + } + }) +}; + +var stderr = { + buffer: "", + output: (function (param, s) { + var v = s.length - 1 | 0; + if (s[v] === "\n") { + console.log(s.slice(0, v)); + } else { + console.log(s); + } + }) +}; + +function caml_ml_flush(oc) { + if (oc.buffer !== "") { + oc.output(oc, oc.buffer); + oc.buffer = ""; + return ; + } + +} + +function caml_ml_output(oc, str, offset, len) { + var str$1 = offset === 0 && len === str.length ? str : str.slice(offset, len); + if (((typeof process !== "undefined") && process.stdout && process.stdout.write) && oc === stdout) { + return process.stdout.write(str$1); + } + var id = str$1.lastIndexOf("\n"); + if (id < 0) { + oc.buffer = oc.buffer + str$1; + } else { + oc.buffer = oc.buffer + str$1.slice(0, id + 1 | 0); + caml_ml_flush(oc); + oc.buffer = oc.buffer + str$1.slice(id + 1 | 0); + } +} + +function caml_ml_output_char(oc, $$char) { + caml_ml_output(oc, String.fromCharCode($$char), 0, 1); +} + +function caml_ml_out_channels_list(param) { + return { + hd: stdout, + tl: { + hd: stderr, + tl: /* [] */0 + } + }; +} + +var stdin; + +export { + stdin , + stdout , + stderr , + caml_ml_flush , + caml_ml_output , + caml_ml_output_char , + caml_ml_out_channels_list , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_js_exceptions.js b/melange-node-modules/melange.js/caml_js_exceptions.js new file mode 100644 index 0000000..d7c4470 --- /dev/null +++ b/melange-node-modules/melange.js/caml_js_exceptions.js @@ -0,0 +1,32 @@ +// Generated by Melange + +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Js__Caml_exceptions from "./caml_exceptions.js"; + +var $$Error = /* @__PURE__ */Caml_exceptions.create("Js__Caml_js_exceptions.Error"); + +function internalToOCamlException(e) { + if (Js__Caml_exceptions.caml_is_extension(e)) { + return e; + } else { + return { + RE_EXN_ID: $$Error, + _1: e + }; + } +} + +function caml_as_js_exn(exn) { + if (exn.RE_EXN_ID === $$Error) { + return Caml_option.some(exn._1); + } + +} + +export { + $$Error , + internalToOCamlException , + caml_as_js_exn , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_lexer.js b/melange-node-modules/melange.js/caml_lexer.js new file mode 100644 index 0000000..fe074de --- /dev/null +++ b/melange-node-modules/melange.js/caml_lexer.js @@ -0,0 +1,258 @@ +// Generated by Melange + + +/***********************************************************************/ +/* */ +/* Objective Caml */ +/* */ +/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ +/* */ +/* Copyright 1996 Institut National de Recherche en Informatique et */ +/* en Automatique. All rights reserved. This file is distributed */ +/* under the terms of the GNU Library General Public License, with */ +/* the special exception on linking described in file ../LICENSE. */ +/* */ +/***********************************************************************/ + +/* $Id: lexing.c 6045 2004-01-01 16:42:43Z doligez $ */ + +/* The table-driven automaton for lexers generated by camllex. */ + +function caml_lex_array(s) { + var l = s.length / 2; + var a = new Array(l); + // when s.charCodeAt(2 * i + 1 ) > 128 (0x80) + // a[i] < 0 + // for(var i = 0 ; i <= 0xffff; ++i) { if (i << 16 >> 16 !==i){console.log(i<<16>>16, 'vs',i)}} + // + for (var i = 0; i < l; i++) + a[i] = (s.charCodeAt(2 * i) | (s.charCodeAt(2 * i + 1) << 8)) << 16 >> 16; + return a; +} +; + +var caml_lex_engine_aux = (function (tbl, start_state, lexbuf, exn){ + + if (!Array.isArray(tbl.lex_default)) { + tbl.lex_base = caml_lex_array(tbl.lex_base); + tbl.lex_backtrk = caml_lex_array(tbl.lex_backtrk); + tbl.lex_check = caml_lex_array(tbl.lex_check); + tbl.lex_trans = caml_lex_array(tbl.lex_trans); + tbl.lex_default = caml_lex_array(tbl.lex_default); + } + var c; + var state = start_state; + //var buffer = bytes_of_string(lexbuf.lex_buffer); + var buffer = lexbuf.lex_buffer; + if (state >= 0) { + /* First entry */ + lexbuf.lex_last_pos = lexbuf.lex_start_pos = lexbuf.lex_curr_pos; + lexbuf.lex_last_action = -1; + } + else { + /* Reentry after refill */ + state = -state - 1; + } + for (;;) { + /* Lookup base address or action number for current state */ + var base = tbl.lex_base[state]; + if (base < 0) + return -base - 1; + /* See if it's a backtrack point */ + var backtrk = tbl.lex_backtrk[state]; + if (backtrk >= 0) { + lexbuf.lex_last_pos = lexbuf.lex_curr_pos; + lexbuf.lex_last_action = backtrk; + } + /* See if we need a refill */ + if (lexbuf.lex_curr_pos >= lexbuf.lex_buffer_len) { + if (lexbuf.lex_eof_reached === 0) + return -state - 1; + else + c = 256; + } + else { + /* Read next input char */ + c = buffer[lexbuf.lex_curr_pos]; + lexbuf.lex_curr_pos++; + } + /* Determine next state */ + if (tbl.lex_check[base + c] === state) { + state = tbl.lex_trans[base + c]; + } + else { + state = tbl.lex_default[state]; + } + /* If no transition on this char, return to last backtrack point */ + if (state < 0) { + lexbuf.lex_curr_pos = lexbuf.lex_last_pos; + if (lexbuf.lex_last_action == -1) + throw exn + else + return lexbuf.lex_last_action; + } + else { + /* Erase the EOF condition only if the EOF pseudo-character was + consumed by the automaton (i.e. there was no backtrack above) + */ + if (c == 256) + lexbuf.lex_eof_reached = 0; + } + } +}); + +var empty_token_lit = "lexing: empty token"; + +function caml_lex_engine(tbls, i, buf) { + return caml_lex_engine_aux(tbls, i, buf, { + RE_EXN_ID: "Failure", + _1: empty_token_lit + }); +} + +/***********************************************/ +/* New lexer engine, with memory of positions */ +/***********************************************/ + +/** + * s -> Lexing.lex_tables.lex_code + * mem -> Lexing.lexbuf.lex_mem (* int array *) + */ + +function caml_lex_run_mem(s, i, mem, curr_pos) { + for (;;) { + var dst = s.charCodeAt(i); + i++; + if (dst == 0xff) + return; + var src = s.charCodeAt(i); + i++; + if (src == 0xff) + mem[dst] = curr_pos; + else + mem[dst] = mem[src]; + } +} + + +/** + * s -> Lexing.lex_tables.lex_code + * mem -> Lexing.lexbuf.lex_mem (* int array *) + */ + +function caml_lex_run_tag(s, i, mem) { + for (;;) { + var dst = s.charCodeAt(i); + i++; + if (dst == 0xff) + return; + var src = s.charCodeAt(i); + i++; + if (src == 0xff) + mem[dst] = -1; + else + mem[dst] = mem[src]; + } +} +; + +var caml_new_lex_engine_aux = (function (tbl, start_state, lexbuf, exn) { + + if (!Array.isArray(tbl.lex_default)) { + tbl.lex_base = caml_lex_array(tbl.lex_base); + tbl.lex_backtrk = caml_lex_array(tbl.lex_backtrk); + tbl.lex_check = caml_lex_array(tbl.lex_check); + tbl.lex_trans = caml_lex_array(tbl.lex_trans); + tbl.lex_default = caml_lex_array(tbl.lex_default); + } + if(!Array.isArray(tbl.lex_default_code)){ + tbl.lex_base_code = caml_lex_array(tbl.lex_base_code); + tbl.lex_backtrk_code = caml_lex_array(tbl.lex_backtrk_code); + tbl.lex_check_code = caml_lex_array(tbl.lex_check_code); + tbl.lex_trans_code = caml_lex_array(tbl.lex_trans_code); + tbl.lex_default_code = caml_lex_array(tbl.lex_default_code); + } + var c, state = start_state; + //var buffer = caml_bytes_of_string(lexbuf.lex_buffer); + var buffer = lexbuf.lex_buffer; + if (state >= 0) { + /* First entry */ + lexbuf.lex_last_pos = lexbuf.lex_start_pos = lexbuf.lex_curr_pos; + lexbuf.lex_last_action = -1; + } + else { + /* Reentry after refill */ + state = -state - 1; + } + for (;;) { + /* Lookup base address or action number for current state */ + var base = tbl.lex_base[state]; + if (base < 0) { + var pc_off = tbl.lex_base_code[state]; + caml_lex_run_tag(tbl.lex_code, pc_off, lexbuf.lex_mem); + return -base - 1; + } + /* See if it's a backtrack point */ + var backtrk = tbl.lex_backtrk[state]; + if (backtrk >= 0) { + var pc_off = tbl.lex_backtrk_code[state]; + caml_lex_run_tag(tbl.lex_code, pc_off, lexbuf.lex_mem); + lexbuf.lex_last_pos = lexbuf.lex_curr_pos; + lexbuf.lex_last_action = backtrk; + } + /* See if we need a refill */ + if (lexbuf.lex_curr_pos >= lexbuf.lex_buffer_len) { + if (lexbuf.lex_eof_reached == 0) + return -state - 1; + else + c = 256; + } + else { + /* Read next input char */ + c = buffer[lexbuf.lex_curr_pos]; + lexbuf.lex_curr_pos++; + } + /* Determine next state */ + var pstate = state; + if (tbl.lex_check[base + c] == state) + state = tbl.lex_trans[base + c]; + else + state = tbl.lex_default[state]; + /* If no transition on this char, return to last backtrack point */ + if (state < 0) { + lexbuf.lex_curr_pos = lexbuf.lex_last_pos; + if (lexbuf.lex_last_action == -1) + throw exn; + else + return lexbuf.lex_last_action; + } + else { + /* If some transition, get and perform memory moves */ + var base_code = tbl.lex_base_code[pstate], pc_off; + if (tbl.lex_check_code[base_code + c] == pstate) + pc_off = tbl.lex_trans_code[base_code + c]; + else + pc_off = tbl.lex_default_code[pstate]; + if (pc_off > 0) + caml_lex_run_mem(tbl.lex_code, pc_off, lexbuf.lex_mem, lexbuf.lex_curr_pos); + /* Erase the EOF condition only if the EOF pseudo-character was + consumed by the automaton (i.e. there was no backtrack above) + */ + if (c == 256) + lexbuf.lex_eof_reached = 0; + } + } + }); + +function caml_new_lex_engine(tbl, i, buf) { + return caml_new_lex_engine_aux(tbl, i, buf, { + RE_EXN_ID: "Failure", + _1: empty_token_lit + }); +} + +export { + caml_lex_engine , + caml_new_lex_engine , +} +/* Not a pure module */ diff --git a/melange-node-modules/melange.js/caml_md5.js b/melange-node-modules/melange.js/caml_md5.js new file mode 100644 index 0000000..b40265b --- /dev/null +++ b/melange-node-modules/melange.js/caml_md5.js @@ -0,0 +1,168 @@ +// Generated by Melange + + +function cmn(q, a, b, x, s, t) { + var a$1 = ((a + q | 0) + x | 0) + t | 0; + return ((a$1 << s) | (a$1 >>> (32 - s | 0)) | 0) + b | 0; +} + +function f(a, b, c, d, x, s, t) { + return cmn(b & c | (b ^ -1) & d, a, b, x, s, t); +} + +function g(a, b, c, d, x, s, t) { + return cmn(b & d | c & (d ^ -1), a, b, x, s, t); +} + +function h(a, b, c, d, x, s, t) { + return cmn(b ^ c ^ d, a, b, x, s, t); +} + +function i(a, b, c, d, x, s, t) { + return cmn(c ^ (b | d ^ -1), a, b, x, s, t); +} + +function cycle(x, k) { + var a = x[0]; + var b = x[1]; + var c = x[2]; + var d = x[3]; + a = f(a, b, c, d, k[0], 7, -680876936); + d = f(d, a, b, c, k[1], 12, -389564586); + c = f(c, d, a, b, k[2], 17, 606105819); + b = f(b, c, d, a, k[3], 22, -1044525330); + a = f(a, b, c, d, k[4], 7, -176418897); + d = f(d, a, b, c, k[5], 12, 1200080426); + c = f(c, d, a, b, k[6], 17, -1473231341); + b = f(b, c, d, a, k[7], 22, -45705983); + a = f(a, b, c, d, k[8], 7, 1770035416); + d = f(d, a, b, c, k[9], 12, -1958414417); + c = f(c, d, a, b, k[10], 17, -42063); + b = f(b, c, d, a, k[11], 22, -1990404162); + a = f(a, b, c, d, k[12], 7, 1804603682); + d = f(d, a, b, c, k[13], 12, -40341101); + c = f(c, d, a, b, k[14], 17, -1502002290); + b = f(b, c, d, a, k[15], 22, 1236535329); + a = g(a, b, c, d, k[1], 5, -165796510); + d = g(d, a, b, c, k[6], 9, -1069501632); + c = g(c, d, a, b, k[11], 14, 643717713); + b = g(b, c, d, a, k[0], 20, -373897302); + a = g(a, b, c, d, k[5], 5, -701558691); + d = g(d, a, b, c, k[10], 9, 38016083); + c = g(c, d, a, b, k[15], 14, -660478335); + b = g(b, c, d, a, k[4], 20, -405537848); + a = g(a, b, c, d, k[9], 5, 568446438); + d = g(d, a, b, c, k[14], 9, -1019803690); + c = g(c, d, a, b, k[3], 14, -187363961); + b = g(b, c, d, a, k[8], 20, 1163531501); + a = g(a, b, c, d, k[13], 5, -1444681467); + d = g(d, a, b, c, k[2], 9, -51403784); + c = g(c, d, a, b, k[7], 14, 1735328473); + b = g(b, c, d, a, k[12], 20, -1926607734); + a = h(a, b, c, d, k[5], 4, -378558); + d = h(d, a, b, c, k[8], 11, -2022574463); + c = h(c, d, a, b, k[11], 16, 1839030562); + b = h(b, c, d, a, k[14], 23, -35309556); + a = h(a, b, c, d, k[1], 4, -1530992060); + d = h(d, a, b, c, k[4], 11, 1272893353); + c = h(c, d, a, b, k[7], 16, -155497632); + b = h(b, c, d, a, k[10], 23, -1094730640); + a = h(a, b, c, d, k[13], 4, 681279174); + d = h(d, a, b, c, k[0], 11, -358537222); + c = h(c, d, a, b, k[3], 16, -722521979); + b = h(b, c, d, a, k[6], 23, 76029189); + a = h(a, b, c, d, k[9], 4, -640364487); + d = h(d, a, b, c, k[12], 11, -421815835); + c = h(c, d, a, b, k[15], 16, 530742520); + b = h(b, c, d, a, k[2], 23, -995338651); + a = i(a, b, c, d, k[0], 6, -198630844); + d = i(d, a, b, c, k[7], 10, 1126891415); + c = i(c, d, a, b, k[14], 15, -1416354905); + b = i(b, c, d, a, k[5], 21, -57434055); + a = i(a, b, c, d, k[12], 6, 1700485571); + d = i(d, a, b, c, k[3], 10, -1894986606); + c = i(c, d, a, b, k[10], 15, -1051523); + b = i(b, c, d, a, k[1], 21, -2054922799); + a = i(a, b, c, d, k[8], 6, 1873313359); + d = i(d, a, b, c, k[15], 10, -30611744); + c = i(c, d, a, b, k[6], 15, -1560198380); + b = i(b, c, d, a, k[13], 21, 1309151649); + a = i(a, b, c, d, k[4], 6, -145523070); + d = i(d, a, b, c, k[11], 10, -1120210379); + c = i(c, d, a, b, k[2], 15, 718787259); + b = i(b, c, d, a, k[9], 21, -343485551); + x[0] = a + x[0] | 0; + x[1] = b + x[1] | 0; + x[2] = c + x[2] | 0; + x[3] = d + x[3] | 0; +} + +var state = [ + 1732584193, + -271733879, + -1732584194, + 271733878 +]; + +var md5blk = [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 +]; + +function caml_md5_string(s, start, len) { + var s$1 = s.slice(start, len); + var n = s$1.length; + state[0] = 1732584193; + state[1] = -271733879; + state[2] = -1732584194; + state[3] = 271733878; + for(var i = 0; i <= 15; ++i){ + md5blk[i] = 0; + } + var i_end = n / 64 | 0; + for(var i$1 = 1; i$1 <= i_end; ++i$1){ + for(var j = 0; j <= 15; ++j){ + var k = ((i$1 << 6) - 64 | 0) + (j << 2) | 0; + md5blk[j] = ((s$1.charCodeAt(k) + (s$1.charCodeAt(k + 1 | 0) << 8) | 0) + (s$1.charCodeAt(k + 2 | 0) << 16) | 0) + (s$1.charCodeAt(k + 3 | 0) << 24) | 0; + } + cycle(state, md5blk); + } + var s_tail = s$1.slice((i_end << 6)); + for(var kk = 0; kk <= 15; ++kk){ + md5blk[kk] = 0; + } + var i_end$1 = s_tail.length - 1 | 0; + for(var i$2 = 0; i$2 <= i_end$1; ++i$2){ + md5blk[i$2 / 4 | 0] = md5blk[i$2 / 4 | 0] | (s_tail.charCodeAt(i$2) << (i$2 % 4 << 3)); + } + var i$3 = i_end$1 + 1 | 0; + md5blk[i$3 / 4 | 0] = md5blk[i$3 / 4 | 0] | (128 << (i$3 % 4 << 3)); + if (i$3 > 55) { + cycle(state, md5blk); + for(var i$4 = 0; i$4 <= 15; ++i$4){ + md5blk[i$4] = 0; + } + } + md5blk[14] = (n << 3); + cycle(state, md5blk); + return String.fromCharCode(state[0] & 255, (state[0] >> 8) & 255, (state[0] >> 16) & 255, (state[0] >> 24) & 255, state[1] & 255, (state[1] >> 8) & 255, (state[1] >> 16) & 255, (state[1] >> 24) & 255, state[2] & 255, (state[2] >> 8) & 255, (state[2] >> 16) & 255, (state[2] >> 24) & 255, state[3] & 255, (state[3] >> 8) & 255, (state[3] >> 16) & 255, (state[3] >> 24) & 255); +} + +export { + caml_md5_string , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_module.js b/melange-node-modules/melange.js/caml_module.js new file mode 100644 index 0000000..6effbcc --- /dev/null +++ b/melange-node-modules/melange.js/caml_module.js @@ -0,0 +1,117 @@ +// Generated by Melange + +import * as Js__Caml_obj from "./caml_obj.js"; + +function init_mod(loc, shape) { + var undef_module = function (param) { + throw { + RE_EXN_ID: "Undefined_recursive_module", + _1: loc, + Error: new Error() + }; + }; + var loop = function (shape, struct_, idx) { + if (typeof shape === "number") { + switch (shape) { + case /* Function */0 : + struct_[idx] = undef_module; + return ; + case /* Lazy */1 : + struct_[idx] = { + LAZY_DONE: true, + VAL: undef_module + }; + return ; + case /* Class */2 : + struct_[idx] = [ + undef_module, + undef_module, + undef_module, + 0 + ]; + return ; + + } + } else { + if (shape.TAG === /* Module */0) { + var comps = shape._0; + var v = {}; + struct_[idx] = v; + var len = comps.length; + for(var i = 0; i < len; ++i){ + var match = comps[i]; + loop(match[0], v, match[1]); + } + return ; + } + struct_[idx] = shape._0; + return ; + } + }; + var res = {}; + var dummy_name = "dummy"; + loop(shape, res, dummy_name); + return res[dummy_name]; +} + +function update_mod(shape, o, n) { + var aux = function (shape, o, n, parent, i) { + if (typeof shape === "number") { + switch (shape) { + case /* Function */0 : + parent[i] = n; + return ; + case /* Lazy */1 : + case /* Class */2 : + return Js__Caml_obj.update_dummy(o, n); + + } + } else { + if (shape.TAG !== /* Module */0) { + return ; + } + var comps = shape._0; + for(var i$1 = 0 ,i_finish = comps.length; i$1 < i_finish; ++i$1){ + var match = comps[i$1]; + var name = match[1]; + aux(match[0], o[name], n[name], o, name); + } + return ; + } + }; + if (typeof shape === "number") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/runtime/caml_module.ml", + 99, + 9 + ], + Error: new Error() + }; + } + if (shape.TAG === /* Module */0) { + var comps = shape._0; + for(var i = 0 ,i_finish = comps.length; i < i_finish; ++i){ + var match = comps[i]; + var name = match[1]; + aux(match[0], o[name], n[name], o, name); + } + return ; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/runtime/caml_module.ml", + 99, + 9 + ], + Error: new Error() + }; +} + +export { + init_mod , + update_mod , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_nativeint_extern.js b/melange-node-modules/melange.js/caml_nativeint_extern.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/caml_nativeint_extern.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/caml_obj.js b/melange-node-modules/melange.js/caml_obj.js new file mode 100644 index 0000000..3163279 --- /dev/null +++ b/melange-node-modules/melange.js/caml_obj.js @@ -0,0 +1,438 @@ +// Generated by Melange + +import * as Caml from "melange.js/caml.js"; + +var for_in = (function(o,foo){ + for (var x in o) { foo(x) }}); + +var caml_obj_dup = (function(x){ + if(Array.isArray(x)){ + var len = x.length + var v = new Array(len) + for(var i = 0 ; i < len ; ++i){ + v[i] = x[i] + } + if(x.TAG !== undefined){ + v.TAG = x.TAG // TODO this can be removed eventually + } + return v + } + return Object.assign({},x) +}); + +var update_dummy = (function(x,y){ + var k + if(Array.isArray(y)){ + for(k = 0; k < y.length ; ++k){ + x[k] = y[k] + } + if(y.TAG !== undefined){ + x.TAG = y.TAG + } + } else { + for (var k in y){ + x[k] = y[k] + } + } +}); + +function caml_compare(a, b) { + if (a === b) { + return 0; + } + var a_type = typeof a; + var b_type = typeof b; + switch (a_type) { + case "bigint" : + if (b_type === "bigint") { + return Caml.caml_float_compare(a, b); + } + break; + case "boolean" : + if (b_type === "boolean") { + return Caml.caml_int_compare(a, b); + } + break; + case "function" : + if (b_type === "function") { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "compare: functional value", + Error: new Error() + }; + } + break; + case "number" : + if (b_type === "number") { + return Caml.caml_float_compare(a, b); + } + break; + case "string" : + if (b_type === "string") { + return Caml.caml_string_compare(a, b); + } else { + return 1; + } + case "undefined" : + return -1; + default: + + } + switch (b_type) { + case "string" : + return -1; + case "undefined" : + return 1; + default: + if (a_type === "boolean") { + return 1; + } + if (b_type === "boolean") { + return -1; + } + if (a_type === "function") { + return 1; + } + if (b_type === "function") { + return -1; + } + if (a_type === "number") { + if (b === null || b.BS_PRIVATE_NESTED_SOME_NONE !== undefined) { + return 1; + } else { + return -1; + } + } + if (b_type === "number") { + if (a === null || a.BS_PRIVATE_NESTED_SOME_NONE !== undefined) { + return -1; + } else { + return 1; + } + } + if (a === null) { + if (b.BS_PRIVATE_NESTED_SOME_NONE !== undefined) { + return 1; + } else { + return -1; + } + } + if (b === null) { + if (a.BS_PRIVATE_NESTED_SOME_NONE !== undefined) { + return -1; + } else { + return 1; + } + } + if (a.BS_PRIVATE_NESTED_SOME_NONE !== undefined) { + if (b.BS_PRIVATE_NESTED_SOME_NONE !== undefined) { + return aux_obj_compare(a, b); + } else { + return -1; + } + } + var tag_a = a.TAG | 0; + var tag_b = b.TAG | 0; + if (tag_a === 248) { + return Caml.caml_int_compare(a[1], b[1]); + } + if (tag_a === 251) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "equal: abstract value", + Error: new Error() + }; + } + if (tag_a !== tag_b) { + if (tag_a < tag_b) { + return -1; + } else { + return 1; + } + } + var len_a = a.length | 0; + var len_b = b.length | 0; + if (len_a === len_b) { + if (Array.isArray(a)) { + var _i = 0; + while(true) { + var i = _i; + if (i === len_a) { + return 0; + } + var res = caml_compare(a[i], b[i]); + if (res !== 0) { + return res; + } + _i = i + 1 | 0; + continue ; + }; + } else if ((a instanceof Date && b instanceof Date)) { + return (a - b); + } else { + return aux_obj_compare(a, b); + } + } else if (len_a < len_b) { + var _i$1 = 0; + while(true) { + var i$1 = _i$1; + if (i$1 === len_a) { + return -1; + } + var res$1 = caml_compare(a[i$1], b[i$1]); + if (res$1 !== 0) { + return res$1; + } + _i$1 = i$1 + 1 | 0; + continue ; + }; + } else { + var _i$2 = 0; + while(true) { + var i$2 = _i$2; + if (i$2 === len_b) { + return 1; + } + var res$2 = caml_compare(a[i$2], b[i$2]); + if (res$2 !== 0) { + return res$2; + } + _i$2 = i$2 + 1 | 0; + continue ; + }; + } + } +} + +function aux_obj_compare(a, b) { + var min_key_lhs = { + contents: undefined + }; + var min_key_rhs = { + contents: undefined + }; + var do_key = function (param, key) { + var min_key = param[2]; + var b = param[1]; + if (!(!Object.prototype.hasOwnProperty.call(b, key) || caml_compare(param[0][key], b[key]) > 0)) { + return ; + } + var mk = min_key.contents; + if (mk !== undefined && key >= mk) { + return ; + } else { + min_key.contents = key; + return ; + } + }; + var partial_arg = [ + a, + b, + min_key_rhs + ]; + var do_key_a = function (param) { + return do_key(partial_arg, param); + }; + var partial_arg$1 = [ + b, + a, + min_key_lhs + ]; + var do_key_b = function (param) { + return do_key(partial_arg$1, param); + }; + for_in(a, do_key_a); + for_in(b, do_key_b); + var match = min_key_lhs.contents; + var match$1 = min_key_rhs.contents; + if (match !== undefined) { + if (match$1 !== undefined) { + return Caml.caml_string_compare(match, match$1); + } else { + return -1; + } + } else if (match$1 !== undefined) { + return 1; + } else { + return 0; + } +} + +function caml_equal(a, b) { + if (a === b) { + return true; + } + var a_type = typeof a; + if (a_type === "string" || a_type === "number" || a_type === "bigint" || a_type === "boolean" || a_type === "undefined" || a === null) { + return false; + } + var b_type = typeof b; + if (a_type === "function" || b_type === "function") { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "equal: functional value", + Error: new Error() + }; + } + if (b_type === "number" || b_type === "bigint" || b_type === "undefined" || b === null) { + return false; + } + var tag_a = a.TAG | 0; + var tag_b = b.TAG | 0; + if (tag_a === 248) { + return a[1] === b[1]; + } + if (tag_a === 251) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "equal: abstract value", + Error: new Error() + }; + } + if (tag_a !== tag_b) { + return false; + } + var len_a = a.length | 0; + var len_b = b.length | 0; + if (len_a === len_b) { + if (Array.isArray(a)) { + var _i = 0; + while(true) { + var i = _i; + if (i === len_a) { + return true; + } + if (!caml_equal(a[i], b[i])) { + return false; + } + _i = i + 1 | 0; + continue ; + }; + } else if ((a instanceof Date && b instanceof Date)) { + return !(a > b || a < b); + } else { + var result = { + contents: true + }; + var do_key_a = function (key) { + if (!Object.prototype.hasOwnProperty.call(b, key)) { + result.contents = false; + return ; + } + + }; + var do_key_b = function (key) { + if (!Object.prototype.hasOwnProperty.call(a, key) || !caml_equal(b[key], a[key])) { + result.contents = false; + return ; + } + + }; + for_in(a, do_key_a); + if (result.contents) { + for_in(b, do_key_b); + } + return result.contents; + } + } else { + return false; + } +} + +function caml_equal_null(x, y) { + if (y !== null) { + return caml_equal(x, y); + } else { + return x === y; + } +} + +function caml_equal_undefined(x, y) { + if (y !== undefined) { + return caml_equal(x, y); + } else { + return x === y; + } +} + +function caml_equal_nullable(x, y) { + if (y == null) { + return x === y; + } else { + return caml_equal(x, y); + } +} + +function caml_notequal(a, b) { + if ((typeof a === "number" || typeof a === "bigint") && (typeof b === "number" || typeof b === "bigint")) { + return a !== b; + } else { + return !caml_equal(a, b); + } +} + +function caml_greaterequal(a, b) { + if ((typeof a === "number" || typeof a === "bigint") && (typeof b === "number" || typeof b === "bigint")) { + return a >= b; + } else { + return caml_compare(a, b) >= 0; + } +} + +function caml_greaterthan(a, b) { + if ((typeof a === "number" || typeof a === "bigint") && (typeof b === "number" || typeof b === "bigint")) { + return a > b; + } else { + return caml_compare(a, b) > 0; + } +} + +function caml_lessequal(a, b) { + if ((typeof a === "number" || typeof a === "bigint") && (typeof b === "number" || typeof b === "bigint")) { + return a <= b; + } else { + return caml_compare(a, b) <= 0; + } +} + +function caml_lessthan(a, b) { + if ((typeof a === "number" || typeof a === "bigint") && (typeof b === "number" || typeof b === "bigint")) { + return a < b; + } else { + return caml_compare(a, b) < 0; + } +} + +function caml_min(x, y) { + if (caml_compare(x, y) <= 0) { + return x; + } else { + return y; + } +} + +function caml_max(x, y) { + if (caml_compare(x, y) >= 0) { + return x; + } else { + return y; + } +} + +export { + caml_obj_dup , + update_dummy , + caml_compare , + caml_equal , + caml_equal_null , + caml_equal_undefined , + caml_equal_nullable , + caml_notequal , + caml_greaterequal , + caml_greaterthan , + caml_lessthan , + caml_lessequal , + caml_min , + caml_max , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_oo.js b/melange-node-modules/melange.js/caml_oo.js new file mode 100644 index 0000000..2cb63b1 --- /dev/null +++ b/melange-node-modules/melange.js/caml_oo.js @@ -0,0 +1,49 @@ +// Generated by Melange + +import * as Caml_array from "melange.js/caml_array.js"; +import * as Js__Caml_exceptions from "./caml_exceptions.js"; + +var caml_methods_cache = Caml_array.make(1000, 0); + +function caml_set_oo_id(b) { + b[1] = Js__Caml_exceptions.id.contents; + Js__Caml_exceptions.id.contents = Js__Caml_exceptions.id.contents + 1 | 0; + return b; +} + +function caml_get_public_method(obj, tag, cacheid) { + var meths = obj[0]; + var offs = caml_methods_cache[cacheid]; + if (meths[offs] === tag) { + return meths[offs - 1 | 0]; + } + var aux = function (_i) { + while(true) { + var i = _i; + if (i < 3) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/runtime/caml_oo.ml", + 66, + 20 + ], + Error: new Error() + }; + } + if (meths[i] === tag) { + caml_methods_cache[cacheid] = i; + return i; + } + _i = i - 2 | 0; + continue ; + }; + }; + return meths[aux((meths[0] << 1) + 1 | 0) - 1 | 0]; +} + +export { + caml_get_public_method , + caml_set_oo_id , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_oo_curry.js b/melange-node-modules/melange.js/caml_oo_curry.js new file mode 100644 index 0000000..e824f4a --- /dev/null +++ b/melange-node-modules/melange.js/caml_oo_curry.js @@ -0,0 +1,54 @@ +// Generated by Melange + +import * as Js__Caml_oo from "./caml_oo.js"; +import * as Js__Curry from "./curry.js"; + +function js(label, cacheid, obj, args) { + var meth = Js__Caml_oo.caml_get_public_method(obj, label, cacheid); + return Js__Curry.app(meth, args); +} + +function js1(label, cacheid, a0) { + return Js__Curry._1(Js__Caml_oo.caml_get_public_method(a0, label, cacheid), a0); +} + +function js2(label, cacheid, a0, a1) { + return Js__Curry._2(Js__Caml_oo.caml_get_public_method(a0, label, cacheid), a0, a1); +} + +function js3(label, cacheid, a0, a1, a2) { + return Js__Curry._3(Js__Caml_oo.caml_get_public_method(a0, label, cacheid), a0, a1, a2); +} + +function js4(label, cacheid, a0, a1, a2, a3) { + return Js__Curry._4(Js__Caml_oo.caml_get_public_method(a0, label, cacheid), a0, a1, a2, a3); +} + +function js5(label, cacheid, a0, a1, a2, a3, a4) { + return Js__Curry._5(Js__Caml_oo.caml_get_public_method(a0, label, cacheid), a0, a1, a2, a3, a4); +} + +function js6(label, cacheid, a0, a1, a2, a3, a4, a5) { + return Js__Curry._6(Js__Caml_oo.caml_get_public_method(a0, label, cacheid), a0, a1, a2, a3, a4, a5); +} + +function js7(label, cacheid, a0, a1, a2, a3, a4, a5, a6) { + return Js__Curry._7(Js__Caml_oo.caml_get_public_method(a0, label, cacheid), a0, a1, a2, a3, a4, a5, a6); +} + +function js8(label, cacheid, a0, a1, a2, a3, a4, a5, a6, a7) { + return Js__Curry._8(Js__Caml_oo.caml_get_public_method(a0, label, cacheid), a0, a1, a2, a3, a4, a5, a6, a7); +} + +export { + js , + js1 , + js2 , + js3 , + js4 , + js5 , + js6 , + js7 , + js8 , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_option.js b/melange-node-modules/melange.js/caml_option.js new file mode 100644 index 0000000..335c297 --- /dev/null +++ b/melange-node-modules/melange.js/caml_option.js @@ -0,0 +1,86 @@ +// Generated by Melange + + +function isNested(x) { + return x.BS_PRIVATE_NESTED_SOME_NONE !== undefined; +} + +function some(x) { + if (x === undefined) { + return { + BS_PRIVATE_NESTED_SOME_NONE: 0 + }; + } else if (x !== null && x.BS_PRIVATE_NESTED_SOME_NONE !== undefined) { + return { + BS_PRIVATE_NESTED_SOME_NONE: x.BS_PRIVATE_NESTED_SOME_NONE + 1 | 0 + }; + } else { + return x; + } +} + +function nullable_to_opt(x) { + if (x == null) { + return ; + } else { + return some(x); + } +} + +function undefined_to_opt(x) { + if (x === undefined) { + return ; + } else { + return some(x); + } +} + +function null_to_opt(x) { + if (x === null) { + return ; + } else { + return some(x); + } +} + +function valFromOption(x) { + if (!(x !== null && x.BS_PRIVATE_NESTED_SOME_NONE !== undefined)) { + return x; + } + var depth = x.BS_PRIVATE_NESTED_SOME_NONE; + if (depth === 0) { + return ; + } else { + return { + BS_PRIVATE_NESTED_SOME_NONE: depth - 1 | 0 + }; + } +} + +function option_get(x) { + if (x === undefined) { + return ; + } else { + return valFromOption(x); + } +} + +function option_unwrap(x) { + if (x !== undefined) { + return x.VAL; + } else { + return x; + } +} + +export { + nullable_to_opt , + undefined_to_opt , + null_to_opt , + valFromOption , + some , + isNested , + option_get , + option_unwrap , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_parser.js b/melange-node-modules/melange.js/caml_parser.js new file mode 100644 index 0000000..5c5020e --- /dev/null +++ b/melange-node-modules/melange.js/caml_parser.js @@ -0,0 +1,303 @@ +// Generated by Melange + + +/***********************************************************************/ +/* */ +/* Objective Caml */ +/* */ +/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ +/* */ +/* Copyright 1996 Institut National de Recherche en Informatique et */ +/* en Automatique. All rights reserved. This file is distributed */ +/* under the terms of the GNU Library General Public License, with */ +/* the special exception on linking described in file ../LICENSE. */ +/* */ +/***********************************************************************/ + +/* $Id: parsing.c 8983 2008-08-06 09:38:25Z xleroy $ */ + +/* The PDA automaton for parsers generated by camlyacc */ + +/* The pushdown automata */ + +/** + * caml_lex_array("abcd") + * [25185, 25699] + * @param s + * @returns {any[]} + * TODO: duplicated with module {!Caml_lex} + */ +function caml_lex_array(s) { + var l = s.length / 2; + var a = new Array(l); + for (var i = 0; i < l; i++) + a[i] = (s.charCodeAt(2 * i) | (s.charCodeAt(2 * i + 1) << 8)) << 16 >> 16; + return a; +} +/** + * Note that TS enum is not friendly to Closure compiler + * @enum{number} + */ +var Automata = { + START: 0, + LOOP: 6, + TOKEN_READ: 1, + TEST_SHIFT: 7, + ERROR_DETECTED: 5, + SHIFT: 8, + SHIFT_RECOVER: 9, + STACK_GROWN_1: 2, + REDUCE: 10, + STACK_GROWN_2: 3, + SEMANTIC_ACTION_COMPUTED: 4 +}; +/** + * @enum{number} + */ +var Result = { + READ_TOKEN: 0, + RAISE_PARSE_ERROR: 1, + GROW_STACKS_1: 2, + GROW_STACKS_2: 3, + COMPUTE_SEMANTIC_ACTION: 4, + CALL_ERROR_FUNCTION: 5 +}; +var PARSER_TRACE = false; +; + +var caml_parse_engine = (function (tables /* parser_table */, env /* parser_env */, cmd /* parser_input*/, arg /* Obj.t*/) { + var ERRCODE = 256; + //var START = 0; + //var TOKEN_READ = 1; + //var STACKS_GROWN_1 = 2; + //var STACKS_GROWN_2 = 3; + //var SEMANTIC_ACTION_COMPUTED = 4; + //var ERROR_DETECTED = 5; + //var loop = 6; + //var testshift = 7; + //var shift = 8; + //var shift_recover = 9; + //var reduce = 10; + // Parsing.parser_env + var env_s_stack = 's_stack'; // array + var env_v_stack = 'v_stack'; // array + var env_symb_start_stack = 'symb_start_stack'; // array + var env_symb_end_stack = 'symb_end_stack'; // array + var env_stacksize = 'stacksize'; + var env_stackbase = 'stackbase'; + var env_curr_char = 'curr_char'; + var env_lval = 'lval'; // Obj.t + var env_symb_start = 'symb_start'; // position + var env_symb_end = 'symb_end'; // position + var env_asp = 'asp'; + var env_rule_len = 'rule_len'; + var env_rule_number = 'rule_number'; + var env_sp = 'sp'; + var env_state = 'state'; + var env_errflag = 'errflag'; + // Parsing.parse_tables + // var _tbl_actions = 1; + var tbl_transl_const = 'transl_const'; // array + var tbl_transl_block = 'transl_block'; // array + var tbl_lhs = 'lhs'; + var tbl_len = 'len'; + var tbl_defred = 'defred'; + var tbl_dgoto = 'dgoto'; + var tbl_sindex = 'sindex'; + var tbl_rindex = 'rindex'; + var tbl_gindex = 'gindex'; + var tbl_tablesize = 'tablesize'; + var tbl_table = 'table'; + var tbl_check = 'check'; + // var _tbl_error_function = 14; + // var _tbl_names_const = 15; + // var _tbl_names_block = 16; + if (!tables.preprocessed) { + tables.defred = caml_lex_array(tables[tbl_defred]); + tables.sindex = caml_lex_array(tables[tbl_sindex]); + tables.check = caml_lex_array(tables[tbl_check]); + tables.rindex = caml_lex_array(tables[tbl_rindex]); + tables.table = caml_lex_array(tables[tbl_table]); + tables.len = caml_lex_array(tables[tbl_len]); + tables.lhs = caml_lex_array(tables[tbl_lhs]); + tables.gindex = caml_lex_array(tables[tbl_gindex]); + tables.dgoto = caml_lex_array(tables[tbl_dgoto]); + tables.preprocessed = true; + } + var res; + var n, n1, n2, state1; + // RESTORE + var sp = env[env_sp]; + var state = env[env_state]; + var errflag = env[env_errflag]; + exit: for (;;) { + //console.error("State", Automata[cmd]); + switch (cmd) { + case Automata.START: + state = 0; + errflag = 0; + // Fall through + case Automata.LOOP: + n = tables.defred[state]; + if (n != 0) { + cmd = Automata.REDUCE; + break; + } + if (env[env_curr_char] >= 0) { + cmd = Automata.TEST_SHIFT; + break; + } + res = Result.READ_TOKEN; + break exit; + /* The ML code calls the lexer and updates */ + /* symb_start and symb_end */ + case Automata.TOKEN_READ: + if (typeof arg !== 'number') { + env[env_curr_char] = tables[tbl_transl_block][arg.TAG | 0 /* + 1 */]; + env[env_lval] = arg._0; // token carries payload + } + else { + env[env_curr_char] = tables[tbl_transl_const][arg /* + 1 */]; + env[env_lval] = 0; // const token + } + if (PARSER_TRACE) { + console.error("State %d, read token", state, arg); + } + // Fall through + case Automata.TEST_SHIFT: + n1 = tables.sindex[state]; + n2 = n1 + env[env_curr_char]; + if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && + tables.check[n2] == env[env_curr_char]) { + cmd = Automata.SHIFT; + break; + } + n1 = tables.rindex[state]; + n2 = n1 + env[env_curr_char]; + if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && + tables.check[n2] == env[env_curr_char]) { + n = tables.table[n2]; + cmd = Automata.REDUCE; + break; + } + if (errflag <= 0) { + res = Result.CALL_ERROR_FUNCTION; + break exit; + } + // Fall through + /* The ML code calls the error function */ + case Automata.ERROR_DETECTED: + if (errflag < 3) { + errflag = 3; + for (;;) { + state1 = env[env_s_stack][sp /* + 1*/]; + n1 = tables.sindex[state1]; + n2 = n1 + ERRCODE; + if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && + tables.check[n2] == ERRCODE) { + cmd = Automata.SHIFT_RECOVER; + break; + } + else { + if (sp <= env[env_stackbase]) + return Result.RAISE_PARSE_ERROR; + /* The ML code raises Parse_error */ + sp--; + } + } + } + else { + if (env[env_curr_char] == 0) + return Result.RAISE_PARSE_ERROR; + /* The ML code raises Parse_error */ + env[env_curr_char] = -1; + cmd = Automata.LOOP; + break; + } + // Fall through + case Automata.SHIFT: + env[env_curr_char] = -1; + if (errflag > 0) + errflag--; + // Fall through + case Automata.SHIFT_RECOVER: + if (PARSER_TRACE) { + console.error("State %d: shift to state %d", state, tables.table[n2]); + } + state = tables.table[n2]; + sp++; + if (sp >= env[env_stacksize]) { + res = Result.GROW_STACKS_1; + break exit; + } + // Fall through + /* The ML code resizes the stacks */ + case Automata.STACK_GROWN_1: + env[env_s_stack][sp /* + 1 */] = state; + env[env_v_stack][sp /* + 1 */] = env[env_lval]; + env[env_symb_start_stack][sp /* + 1 */] = env[env_symb_start]; + env[env_symb_end_stack][sp /* + 1 */] = env[env_symb_end]; + cmd = Automata.LOOP; + break; + case Automata.REDUCE: + if (PARSER_TRACE) { + console.error("State %d : reduce by rule %d", state, n); + } + var m = tables.len[n]; + env[env_asp] = sp; + env[env_rule_number] = n; + env[env_rule_len] = m; + sp = sp - m + 1; + m = tables.lhs[n]; + state1 = env[env_s_stack][sp - 1]; // + n1 = tables.gindex[m]; + n2 = n1 + state1; + if (n1 != 0 && n2 >= 0 && n2 <= tables[tbl_tablesize] && + tables.check[n2] == state1) + state = tables.table[n2]; + else + state = tables.dgoto[m]; + if (sp >= env[env_stacksize]) { + res = Result.GROW_STACKS_2; + break exit; + } + // Fall through + /* The ML code resizes the stacks */ + case Automata.STACK_GROWN_2: + res = Result.COMPUTE_SEMANTIC_ACTION; + break exit; + /* The ML code calls the semantic action */ + case Automata.SEMANTIC_ACTION_COMPUTED: + env[env_s_stack][sp /* + 1 */] = state; + env[env_v_stack][sp /* + 1*/] = arg; + var asp = env[env_asp]; + env[env_symb_end_stack][sp /* + 1*/] = env[env_symb_end_stack][asp /* + 1*/]; + if (sp > asp) { + /* This is an epsilon production. Take symb_start equal to symb_end. */ + env[env_symb_start_stack][sp /* + 1*/] = env[env_symb_end_stack][asp /*+ 1*/]; + } + cmd = Automata.LOOP; + break; + /* Should not happen */ + default: + return Result.RAISE_PARSE_ERROR; + } + } + // SAVE + env[env_sp] = sp; + env[env_state] = state; + env[env_errflag] = errflag; + return res; +}); + +var caml_set_parser_trace = (function (v) { + var old = PARSER_TRACE; + PARSER_TRACE = v; + return old; +}); + +export { + caml_parse_engine , + caml_set_parser_trace , +} +/* Not a pure module */ diff --git a/melange-node-modules/melange.js/caml_splice_call.js b/melange-node-modules/melange.js/caml_splice_call.js new file mode 100644 index 0000000..67d0c80 --- /dev/null +++ b/melange-node-modules/melange.js/caml_splice_call.js @@ -0,0 +1,52 @@ +// Generated by Melange + + +var spliceApply = (function(fn,args){ + var i, argLen; + argLen = args.length + var applied = [] + for(i = 0; i < argLen - 1; ++i){ + applied.push(args[i]) + } + var lastOne = args[argLen - 1] + for(i = 0; i < lastOne.length; ++i ){ + applied.push(lastOne[i]) + } + return fn.apply(null,applied) +}); + +var spliceNewApply = (function (ctor,args){ + var i, argLen; + argLen = args.length + var applied = [null] // Function.prototype.bind.apply(fn, args) requires the first element in `args` to be `null` + for(i = 0; i < argLen - 1; ++i){ + applied.push(args[i]) + } + var lastOne = args[argLen - 1] + for(i = 0; i < lastOne.length; ++i ){ + applied.push(lastOne[i]) + } + var C = Function.prototype.bind.apply(ctor, applied) + return new C() +}); + +var spliceObjApply = (function(obj,name,args){ + var i, argLen; + argLen = args.length + var applied = [] + for(i = 0; i < argLen - 1; ++i){ + applied.push(args[i]) + } + var lastOne = args[argLen - 1] + for(i = 0; i < lastOne.length; ++i ){ + applied.push(lastOne[i]) + } + return (obj[name]).apply(obj,applied) +}); + +export { + spliceApply , + spliceNewApply , + spliceObjApply , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_string.js b/melange-node-modules/melange.js/caml_string.js new file mode 100644 index 0000000..4b321b9 --- /dev/null +++ b/melange-node-modules/melange.js/caml_string.js @@ -0,0 +1,23 @@ +// Generated by Melange + + +function get(s, i) { + if (i >= s.length || i < 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds", + Error: new Error() + }; + } + return s.charCodeAt(i); +} + +function make(n, ch) { + return String.fromCharCode(ch).repeat(n); +} + +export { + get , + make , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_string_extern.js b/melange-node-modules/melange.js/caml_string_extern.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/caml_string_extern.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/caml_sys.js b/melange-node-modules/melange.js/caml_sys.js new file mode 100644 index 0000000..d54a7ac --- /dev/null +++ b/melange-node-modules/melange.js/caml_sys.js @@ -0,0 +1,108 @@ +// Generated by Melange + + +function caml_sys_getenv(s) { + if (typeof process === "undefined" || process.env === undefined) { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + var x = process.env[s]; + if (x !== undefined) { + return x; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; +} + +var os_type = (function(_){ + if(typeof process !== 'undefined' && process.platform === 'win32'){ + return "Win32" + } + else { + return "Unix" + } +}); + +function caml_sys_time(param) { + if (typeof process === "undefined" || process.uptime === undefined) { + return -1; + } else { + return process.uptime(); + } +} + +function caml_sys_system_command(_cmd) { + return 127; +} + +var caml_sys_getcwd = (function(param){ + if (typeof process === "undefined" || process.cwd === undefined){ + return "/" + } + return process.cwd() + }); + +function caml_sys_executable_name(param) { + if (typeof process === "undefined") { + return ""; + } + var argv = process.argv; + if (argv == null) { + return ""; + } else { + return argv[0]; + } +} + +function caml_sys_argv(param) { + if (typeof process === "undefined") { + return [""]; + } + var argv = process.argv; + if (argv == null) { + return [""]; + } else { + return argv; + } +} + +function caml_sys_exit(exit_code) { + if (typeof process !== "undefined") { + return process.exit(exit_code); + } + +} + +function caml_sys_is_directory(_s) { + throw { + RE_EXN_ID: "Failure", + _1: "caml_sys_is_directory not implemented", + Error: new Error() + }; +} + +function caml_sys_file_exists(_s) { + throw { + RE_EXN_ID: "Failure", + _1: "caml_sys_file_exists not implemented", + Error: new Error() + }; +} + +export { + caml_sys_getenv , + caml_sys_time , + os_type , + caml_sys_system_command , + caml_sys_getcwd , + caml_sys_executable_name , + caml_sys_argv , + caml_sys_exit , + caml_sys_is_directory , + caml_sys_file_exists , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/caml_undefined_extern.js b/melange-node-modules/melange.js/caml_undefined_extern.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/caml_undefined_extern.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/curry.js b/melange-node-modules/melange.js/curry.js new file mode 100644 index 0000000..4ee3803 --- /dev/null +++ b/melange-node-modules/melange.js/curry.js @@ -0,0 +1,526 @@ +// Generated by Melange + +import * as Caml_array from "melange.js/caml_array.js"; + +function app(_f, _args) { + while(true) { + var args = _args; + var f = _f; + var init_arity = f.length; + var arity = init_arity === 0 ? 1 : init_arity; + var len = args.length; + var d = arity - len | 0; + if (d === 0) { + return f.apply(null, args); + } + if (d >= 0) { + return (function(f,args){ + return function (x) { + return app(f, args.concat([x])); + } + }(f,args)); + } + _args = Caml_array.sub(args, arity, -d | 0); + _f = f.apply(null, Caml_array.sub(args, 0, arity)); + continue ; + }; +} + +function _1(o, a0) { + var arity = o.length; + if (arity === 1) { + return o(a0); + } else { + switch (arity) { + case 1 : + return o(a0); + case 2 : + return function (param) { + return o(a0, param); + }; + case 3 : + return function (param, param$1) { + return o(a0, param, param$1); + }; + case 4 : + return function (param, param$1, param$2) { + return o(a0, param, param$1, param$2); + }; + case 5 : + return function (param, param$1, param$2, param$3) { + return o(a0, param, param$1, param$2, param$3); + }; + case 6 : + return function (param, param$1, param$2, param$3, param$4) { + return o(a0, param, param$1, param$2, param$3, param$4); + }; + case 7 : + return function (param, param$1, param$2, param$3, param$4, param$5) { + return o(a0, param, param$1, param$2, param$3, param$4, param$5); + }; + default: + return app(o, [a0]); + } + } +} + +function __1(o) { + var arity = o.length; + if (arity === 1) { + return o; + } else { + return function (a0) { + return _1(o, a0); + }; + } +} + +function _2(o, a0, a1) { + var arity = o.length; + if (arity === 2) { + return o(a0, a1); + } else { + switch (arity) { + case 1 : + return app(o(a0), [a1]); + case 2 : + return o(a0, a1); + case 3 : + return function (param) { + return o(a0, a1, param); + }; + case 4 : + return function (param, param$1) { + return o(a0, a1, param, param$1); + }; + case 5 : + return function (param, param$1, param$2) { + return o(a0, a1, param, param$1, param$2); + }; + case 6 : + return function (param, param$1, param$2, param$3) { + return o(a0, a1, param, param$1, param$2, param$3); + }; + case 7 : + return function (param, param$1, param$2, param$3, param$4) { + return o(a0, a1, param, param$1, param$2, param$3, param$4); + }; + default: + return app(o, [ + a0, + a1 + ]); + } + } +} + +function __2(o) { + var arity = o.length; + if (arity === 2) { + return o; + } else { + return function (a0, a1) { + return _2(o, a0, a1); + }; + } +} + +function _3(o, a0, a1, a2) { + var arity = o.length; + if (arity === 3) { + return o(a0, a1, a2); + } else { + switch (arity) { + case 1 : + return app(o(a0), [ + a1, + a2 + ]); + case 2 : + return app(o(a0, a1), [a2]); + case 3 : + return o(a0, a1, a2); + case 4 : + return function (param) { + return o(a0, a1, a2, param); + }; + case 5 : + return function (param, param$1) { + return o(a0, a1, a2, param, param$1); + }; + case 6 : + return function (param, param$1, param$2) { + return o(a0, a1, a2, param, param$1, param$2); + }; + case 7 : + return function (param, param$1, param$2, param$3) { + return o(a0, a1, a2, param, param$1, param$2, param$3); + }; + default: + return app(o, [ + a0, + a1, + a2 + ]); + } + } +} + +function __3(o) { + var arity = o.length; + if (arity === 3) { + return o; + } else { + return function (a0, a1, a2) { + return _3(o, a0, a1, a2); + }; + } +} + +function _4(o, a0, a1, a2, a3) { + var arity = o.length; + if (arity === 4) { + return o(a0, a1, a2, a3); + } else { + switch (arity) { + case 1 : + return app(o(a0), [ + a1, + a2, + a3 + ]); + case 2 : + return app(o(a0, a1), [ + a2, + a3 + ]); + case 3 : + return app(o(a0, a1, a2), [a3]); + case 4 : + return o(a0, a1, a2, a3); + case 5 : + return function (param) { + return o(a0, a1, a2, a3, param); + }; + case 6 : + return function (param, param$1) { + return o(a0, a1, a2, a3, param, param$1); + }; + case 7 : + return function (param, param$1, param$2) { + return o(a0, a1, a2, a3, param, param$1, param$2); + }; + default: + return app(o, [ + a0, + a1, + a2, + a3 + ]); + } + } +} + +function __4(o) { + var arity = o.length; + if (arity === 4) { + return o; + } else { + return function (a0, a1, a2, a3) { + return _4(o, a0, a1, a2, a3); + }; + } +} + +function _5(o, a0, a1, a2, a3, a4) { + var arity = o.length; + if (arity === 5) { + return o(a0, a1, a2, a3, a4); + } else { + switch (arity) { + case 1 : + return app(o(a0), [ + a1, + a2, + a3, + a4 + ]); + case 2 : + return app(o(a0, a1), [ + a2, + a3, + a4 + ]); + case 3 : + return app(o(a0, a1, a2), [ + a3, + a4 + ]); + case 4 : + return app(o(a0, a1, a2, a3), [a4]); + case 5 : + return o(a0, a1, a2, a3, a4); + case 6 : + return function (param) { + return o(a0, a1, a2, a3, a4, param); + }; + case 7 : + return function (param, param$1) { + return o(a0, a1, a2, a3, a4, param, param$1); + }; + default: + return app(o, [ + a0, + a1, + a2, + a3, + a4 + ]); + } + } +} + +function __5(o) { + var arity = o.length; + if (arity === 5) { + return o; + } else { + return function (a0, a1, a2, a3, a4) { + return _5(o, a0, a1, a2, a3, a4); + }; + } +} + +function _6(o, a0, a1, a2, a3, a4, a5) { + var arity = o.length; + if (arity === 6) { + return o(a0, a1, a2, a3, a4, a5); + } else { + switch (arity) { + case 1 : + return app(o(a0), [ + a1, + a2, + a3, + a4, + a5 + ]); + case 2 : + return app(o(a0, a1), [ + a2, + a3, + a4, + a5 + ]); + case 3 : + return app(o(a0, a1, a2), [ + a3, + a4, + a5 + ]); + case 4 : + return app(o(a0, a1, a2, a3), [ + a4, + a5 + ]); + case 5 : + return app(o(a0, a1, a2, a3, a4), [a5]); + case 6 : + return o(a0, a1, a2, a3, a4, a5); + case 7 : + return function (param) { + return o(a0, a1, a2, a3, a4, a5, param); + }; + default: + return app(o, [ + a0, + a1, + a2, + a3, + a4, + a5 + ]); + } + } +} + +function __6(o) { + var arity = o.length; + if (arity === 6) { + return o; + } else { + return function (a0, a1, a2, a3, a4, a5) { + return _6(o, a0, a1, a2, a3, a4, a5); + }; + } +} + +function _7(o, a0, a1, a2, a3, a4, a5, a6) { + var arity = o.length; + if (arity === 7) { + return o(a0, a1, a2, a3, a4, a5, a6); + } else { + switch (arity) { + case 1 : + return app(o(a0), [ + a1, + a2, + a3, + a4, + a5, + a6 + ]); + case 2 : + return app(o(a0, a1), [ + a2, + a3, + a4, + a5, + a6 + ]); + case 3 : + return app(o(a0, a1, a2), [ + a3, + a4, + a5, + a6 + ]); + case 4 : + return app(o(a0, a1, a2, a3), [ + a4, + a5, + a6 + ]); + case 5 : + return app(o(a0, a1, a2, a3, a4), [ + a5, + a6 + ]); + case 6 : + return app(o(a0, a1, a2, a3, a4, a5), [a6]); + case 7 : + return o(a0, a1, a2, a3, a4, a5, a6); + default: + return app(o, [ + a0, + a1, + a2, + a3, + a4, + a5, + a6 + ]); + } + } +} + +function __7(o) { + var arity = o.length; + if (arity === 7) { + return o; + } else { + return function (a0, a1, a2, a3, a4, a5, a6) { + return _7(o, a0, a1, a2, a3, a4, a5, a6); + }; + } +} + +function _8(o, a0, a1, a2, a3, a4, a5, a6, a7) { + var arity = o.length; + if (arity === 8) { + return o(a0, a1, a2, a3, a4, a5, a6, a7); + } else { + switch (arity) { + case 1 : + return app(o(a0), [ + a1, + a2, + a3, + a4, + a5, + a6, + a7 + ]); + case 2 : + return app(o(a0, a1), [ + a2, + a3, + a4, + a5, + a6, + a7 + ]); + case 3 : + return app(o(a0, a1, a2), [ + a3, + a4, + a5, + a6, + a7 + ]); + case 4 : + return app(o(a0, a1, a2, a3), [ + a4, + a5, + a6, + a7 + ]); + case 5 : + return app(o(a0, a1, a2, a3, a4), [ + a5, + a6, + a7 + ]); + case 6 : + return app(o(a0, a1, a2, a3, a4, a5), [ + a6, + a7 + ]); + case 7 : + return app(o(a0, a1, a2, a3, a4, a5, a6), [a7]); + default: + return app(o, [ + a0, + a1, + a2, + a3, + a4, + a5, + a6, + a7 + ]); + } + } +} + +function __8(o) { + var arity = o.length; + if (arity === 8) { + return o; + } else { + return function (a0, a1, a2, a3, a4, a5, a6, a7) { + return _8(o, a0, a1, a2, a3, a4, a5, a6, a7); + }; + } +} + +export { + app , + _1 , + __1 , + _2 , + __2 , + _3 , + __3 , + _4 , + __4 , + _5 , + __5 , + _6 , + __6 , + _7 , + __7 , + _8 , + __8 , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js.js b/melange-node-modules/melange.js/js.js new file mode 100644 index 0000000..9baf361 --- /dev/null +++ b/melange-node-modules/melange.js/js.js @@ -0,0 +1,24 @@ +// Generated by Melange + +import * as Js__Js_OO from "./js_OO.js"; +import * as Js__Js_internal from "./js_internal.js"; + +var Obj = {}; + +var Js_OO = Js__Js_OO; + +var Private = { + Js_OO: Js_OO +}; + +var Fn = Js__Js_internal.Fn; + +var Internal = Js__Js_internal.Internal; + +export { + Fn , + Internal , + Obj , + Private , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_OO.js b/melange-node-modules/melange.js/js_OO.js new file mode 100644 index 0000000..7b98e0c --- /dev/null +++ b/melange-node-modules/melange.js/js_OO.js @@ -0,0 +1,15 @@ +// Generated by Melange + + +var Callback = {}; + +var Meth = {}; + +var Internal = {}; + +export { + Callback , + Meth , + Internal , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js__.js b/melange-node-modules/melange.js/js__.js new file mode 100644 index 0000000..0a83578 --- /dev/null +++ b/melange-node-modules/melange.js/js__.js @@ -0,0 +1,9 @@ +// Generated by Melange + + +var Js__ = {}; + +export { + Js__ , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_array.js b/melange-node-modules/melange.js/js_array.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_array.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/js_array2.js b/melange-node-modules/melange.js/js_array2.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_array2.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/js_bigint.js b/melange-node-modules/melange.js/js_bigint.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_bigint.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/js_cast.js b/melange-node-modules/melange.js/js_cast.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_cast.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/js_console.js b/melange-node-modules/melange.js/js_console.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_console.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/js_date.js b/melange-node-modules/melange.js/js_date.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_date.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/js_dict.js b/melange-node-modules/melange.js/js_dict.js new file mode 100644 index 0000000..b9658ab --- /dev/null +++ b/melange-node-modules/melange.js/js_dict.js @@ -0,0 +1,85 @@ +// Generated by Melange + +import * as Caml_option from "melange.js/caml_option.js"; + +function get(dict, k) { + if ((k in dict)) { + return Caml_option.some(dict[k]); + } + +} + +var unsafeDeleteKey = (function (dict,key){ + delete dict[key]; + }); + +function entries(dict) { + var keys = Object.keys(dict); + var l = keys.length; + var values = new Array(l); + for(var i = 0; i < l; ++i){ + var key = keys[i]; + values[i] = [ + key, + dict[key] + ]; + } + return values; +} + +function values(dict) { + var keys = Object.keys(dict); + var l = keys.length; + var values$1 = new Array(l); + for(var i = 0; i < l; ++i){ + values$1[i] = dict[keys[i]]; + } + return values$1; +} + +function fromList(entries) { + var dict = {}; + var _param = entries; + while(true) { + var param = _param; + if (!param) { + return dict; + } + var match = param.hd; + dict[match[0]] = match[1]; + _param = param.tl; + continue ; + }; +} + +function fromArray(entries) { + var dict = {}; + var l = entries.length; + for(var i = 0; i < l; ++i){ + var match = entries[i]; + dict[match[0]] = match[1]; + } + return dict; +} + +function map(f, source) { + var target = {}; + var keys = Object.keys(source); + var l = keys.length; + for(var i = 0; i < l; ++i){ + var key = keys[i]; + target[key] = f(source[key]); + } + return target; +} + +export { + get , + unsafeDeleteKey , + entries , + values , + fromList , + fromArray , + map , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_exn.js b/melange-node-modules/melange.js/js_exn.js new file mode 100644 index 0000000..62056f5 --- /dev/null +++ b/melange-node-modules/melange.js/js_exn.js @@ -0,0 +1,48 @@ +// Generated by Melange + +import * as Js__Caml_js_exceptions from "./caml_js_exceptions.js"; + +var anyToExnInternal = Js__Caml_js_exceptions.internalToOCamlException; + +function raiseError(str) { + throw new Error(str); +} + +function raiseEvalError(str) { + throw new EvalError(str); +} + +function raiseRangeError(str) { + throw new RangeError(str); +} + +function raiseReferenceError(str) { + throw new ReferenceError(str); +} + +function raiseSyntaxError(str) { + throw new SyntaxError(str); +} + +function raiseTypeError(str) { + throw new TypeError(str); +} + +function raiseUriError(str) { + throw new URIError(str); +} + +var $$Error$1 = Js__Caml_js_exceptions.$$Error; + +export { + $$Error$1 as $$Error, + anyToExnInternal , + raiseError , + raiseEvalError , + raiseRangeError , + raiseReferenceError , + raiseSyntaxError , + raiseTypeError , + raiseUriError , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_float.js b/melange-node-modules/melange.js/js_float.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_float.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/js_global.js b/melange-node-modules/melange.js/js_global.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_global.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/js_int.js b/melange-node-modules/melange.js/js_int.js new file mode 100644 index 0000000..7c1cfbe --- /dev/null +++ b/melange-node-modules/melange.js/js_int.js @@ -0,0 +1,17 @@ +// Generated by Melange + + +function equal(x, y) { + return x === y; +} + +var max = 2147483647; + +var min = -2147483648; + +export { + equal , + max , + min , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_internal.js b/melange-node-modules/melange.js/js_internal.js new file mode 100644 index 0000000..eb866d1 --- /dev/null +++ b/melange-node-modules/melange.js/js_internal.js @@ -0,0 +1,12 @@ +// Generated by Melange + + +var Fn = {}; + +var Internal = {}; + +export { + Fn , + Internal , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_json.js b/melange-node-modules/melange.js/js_json.js new file mode 100644 index 0000000..82d002f --- /dev/null +++ b/melange-node-modules/melange.js/js_json.js @@ -0,0 +1,172 @@ +// Generated by Melange + +import * as Caml_option from "melange.js/caml_option.js"; + +function classify(x) { + var ty = typeof x; + if (ty === "string") { + return { + TAG: /* JSONString */0, + _0: x + }; + } else if (ty === "number") { + return { + TAG: /* JSONNumber */1, + _0: x + }; + } else if (ty === "boolean") { + if (x === true) { + return /* JSONTrue */1; + } else { + return /* JSONFalse */0; + } + } else if (x === null) { + return /* JSONNull */2; + } else if (Array.isArray(x)) { + return { + TAG: /* JSONArray */3, + _0: x + }; + } else { + return { + TAG: /* JSONObject */2, + _0: x + }; + } +} + +function test(x, v) { + switch (v) { + case /* String */0 : + return typeof x === "string"; + case /* Number */1 : + return typeof x === "number"; + case /* Object */2 : + if (x !== null && typeof x === "object") { + return !Array.isArray(x); + } else { + return false; + } + case /* Array */3 : + return Array.isArray(x); + case /* Boolean */4 : + return typeof x === "boolean"; + case /* Null */5 : + return x === null; + + } +} + +function decodeString(json) { + if (typeof json === "string") { + return json; + } + +} + +function decodeNumber(json) { + if (typeof json === "number") { + return json; + } + +} + +function decodeObject(json) { + if (typeof json === "object" && !Array.isArray(json) && json !== null) { + return Caml_option.some(json); + } + +} + +function decodeArray(json) { + if (Array.isArray(json)) { + return json; + } + +} + +function decodeBoolean(json) { + if (typeof json === "boolean") { + return json; + } + +} + +function decodeNull(json) { + if (json === null) { + return null; + } + +} + +var patch = (function (json) { + var x = [json]; + var q = [{ kind: 0, i: 0, parent: x }]; + while (q.length !== 0) { + // begin pop the stack + var cur = q[q.length - 1]; + if (cur.kind === 0) { + cur.val = cur.parent[cur.i]; // patch the undefined value for array + if (++cur.i === cur.parent.length) { + q.pop(); + } + } else { + q.pop(); + } + // finish + var task = cur.val; + if (typeof task === "object") { + if (Array.isArray(task) && task.length !== 0) { + q.push({ kind: 0, i: 0, parent: task, val: undefined }); + } else { + for (var k in task) { + if (k === "RE_PRIVATE_NONE") { + if (cur.kind === 0) { + cur.parent[cur.i - 1] = undefined; + } else { + cur.parent[cur.i] = undefined; + } + continue; + } + q.push({ kind: 1, i: k, parent: task, val: task[k] }); + } + } + } + } + return x[0]; +}); + +function serializeExn(x) { + return (function(obj){ + var output= JSON.stringify(obj,function(_,value){ + if(value===undefined){ + return {RE_PRIVATE_NONE : true} + } + return value + }); + + if(output === undefined){ + // JSON.stringify will raise TypeError when it detects cylic objects + throw new TypeError("output is undefined") + } + return output + })(x); +} + +function deserializeUnsafe(s) { + return patch(JSON.parse(s)); +} + +export { + classify , + test , + decodeString , + decodeNumber , + decodeObject , + decodeArray , + decodeBoolean , + decodeNull , + deserializeUnsafe , + serializeExn , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_list.js b/melange-node-modules/melange.js/js_list.js new file mode 100644 index 0000000..6922bd4 --- /dev/null +++ b/melange-node-modules/melange.js/js_list.js @@ -0,0 +1,334 @@ +// Generated by Melange + +import * as Caml_obj from "melange.js/caml_obj.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Js__Js_vector from "./js_vector.js"; + +function length(l) { + var _len = 0; + var _param = l; + while(true) { + var param = _param; + var len = _len; + if (!param) { + return len; + } + _param = param.tl; + _len = len + 1 | 0; + continue ; + }; +} + +function cons(x, xs) { + return { + hd: x, + tl: xs + }; +} + +function isEmpty(x) { + return Caml_obj.caml_equal(x, /* [] */0); +} + +function hd(param) { + if (param) { + return Caml_option.some(param.hd); + } + +} + +function tl(param) { + if (param) { + return param.tl; + } + +} + +function nth(l, n) { + if (n < 0) { + return ; + } + var _l = l; + var _n = n; + while(true) { + var n$1 = _n; + var l$1 = _l; + if (!l$1) { + return ; + } + if (n$1 === 0) { + return Caml_option.some(l$1.hd); + } + _n = n$1 - 1 | 0; + _l = l$1.tl; + continue ; + }; +} + +function revAppend(_l1, _l2) { + while(true) { + var l2 = _l2; + var l1 = _l1; + if (!l1) { + return l2; + } + _l2 = { + hd: l1.hd, + tl: l2 + }; + _l1 = l1.tl; + continue ; + }; +} + +function rev(l) { + return revAppend(l, /* [] */0); +} + +function mapRevAux(f, _acc, _ls) { + while(true) { + var ls = _ls; + var acc = _acc; + if (!ls) { + return acc; + } + _ls = ls.tl; + _acc = { + hd: f(ls.hd), + tl: acc + }; + continue ; + }; +} + +function mapRev(f, ls) { + return mapRevAux(f, /* [] */0, ls); +} + +function map(f, ls) { + return revAppend(mapRevAux(f, /* [] */0, ls), /* [] */0); +} + +function iter(f, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + f(param.hd); + _param = param.tl; + continue ; + }; +} + +function iteri(f, l) { + var _i = 0; + var _param = l; + while(true) { + var param = _param; + var i = _i; + if (!param) { + return ; + } + f(i, param.hd); + _param = param.tl; + _i = i + 1 | 0; + continue ; + }; +} + +function foldLeft(f, _accu, _l) { + while(true) { + var l = _l; + var accu = _accu; + if (!l) { + return accu; + } + _l = l.tl; + _accu = f(accu, l.hd); + continue ; + }; +} + +function tailLoop(f, _acc, _param) { + while(true) { + var param = _param; + var acc = _acc; + if (!param) { + return acc; + } + _param = param.tl; + _acc = f(param.hd, acc); + continue ; + }; +} + +function foldRight(f, l, init) { + var loop = function (n, param) { + if (!param) { + return init; + } + var t = param.tl; + var h = param.hd; + if (n < 1000) { + return f(h, loop(n + 1 | 0, t)); + } else { + return f(h, tailLoop(f, init, revAppend(t, /* [] */0))); + } + }; + return loop(0, l); +} + +function flatten(lx) { + var _acc = /* [] */0; + var _lx = lx; + while(true) { + var lx$1 = _lx; + var acc = _acc; + if (!lx$1) { + return revAppend(acc, /* [] */0); + } + _lx = lx$1.tl; + _acc = revAppend(lx$1.hd, acc); + continue ; + }; +} + +function filterRevAux(f, _acc, _xs) { + while(true) { + var xs = _xs; + var acc = _acc; + if (!xs) { + return acc; + } + var ys = xs.tl; + var y = xs.hd; + if (f(y)) { + _xs = ys; + _acc = { + hd: y, + tl: acc + }; + continue ; + } + _xs = ys; + continue ; + }; +} + +function filter(f, xs) { + return revAppend(filterRevAux(f, /* [] */0, xs), /* [] */0); +} + +function filterMapRevAux(f, _acc, _xs) { + while(true) { + var xs = _xs; + var acc = _acc; + if (!xs) { + return acc; + } + var ys = xs.tl; + var z = f(xs.hd); + if (z !== undefined) { + _xs = ys; + _acc = { + hd: Caml_option.valFromOption(z), + tl: acc + }; + continue ; + } + _xs = ys; + continue ; + }; +} + +function filterMap(f, xs) { + return revAppend(filterMapRevAux(f, /* [] */0, xs), /* [] */0); +} + +function countBy(f, xs) { + var _acc = 0; + var _xs = xs; + while(true) { + var xs$1 = _xs; + var acc = _acc; + if (!xs$1) { + return acc; + } + _xs = xs$1.tl; + _acc = f(xs$1.hd) ? acc + 1 | 0 : acc; + continue ; + }; +} + +function init(n, f) { + return Js__Js_vector.toList(Js__Js_vector.init(n, f)); +} + +function toVector(xs) { + if (!xs) { + return []; + } + var a = new Array(length(xs)); + var _i = 0; + var _param = xs; + while(true) { + var param = _param; + var i = _i; + if (!param) { + return a; + } + a[i] = param.hd; + _param = param.tl; + _i = i + 1 | 0; + continue ; + }; +} + +function equal(cmp, _xs, _ys) { + while(true) { + var ys = _ys; + var xs = _xs; + if (!xs) { + if (ys) { + return false; + } else { + return true; + } + } + if (!ys) { + return false; + } + if (!cmp(xs.hd, ys.hd)) { + return false; + } + _ys = ys.tl; + _xs = xs.tl; + continue ; + }; +} + +export { + length , + cons , + isEmpty , + hd , + tl , + nth , + revAppend , + rev , + mapRev , + map , + iter , + iteri , + foldLeft , + foldRight , + flatten , + filter , + filterMap , + countBy , + init , + toVector , + equal , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_map.js b/melange-node-modules/melange.js/js_map.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_map.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/js_mapperRt.js b/melange-node-modules/melange.js/js_mapperRt.js new file mode 100644 index 0000000..914702b --- /dev/null +++ b/melange-node-modules/melange.js/js_mapperRt.js @@ -0,0 +1,54 @@ +// Generated by Melange + + +function raiseWhenNotFound(x) { + if (x == null) { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + return x; +} + +function fromInt(len, xs, $$enum) { + var _i = 0; + while(true) { + var i = _i; + if (i === len) { + return ; + } + var k = xs[i]; + if (k === $$enum) { + return i; + } + _i = i + 1 | 0; + continue ; + }; +} + +function fromIntAssert(len, xs, $$enum) { + var _i = 0; + while(true) { + var i = _i; + if (i === len) { + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + } + var k = xs[i]; + if (k === $$enum) { + return i; + } + _i = i + 1 | 0; + continue ; + }; +} + +export { + raiseWhenNotFound , + fromInt , + fromIntAssert , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_math.js b/melange-node-modules/melange.js/js_math.js new file mode 100644 index 0000000..48f2d12 --- /dev/null +++ b/melange-node-modules/melange.js/js_math.js @@ -0,0 +1,50 @@ +// Generated by Melange + +import * as Js__Js_int from "./js_int.js"; + +function unsafe_ceil(prim) { + return Math.ceil(prim); +} + +function ceil_int(f) { + if (f > Js__Js_int.max) { + return Js__Js_int.max; + } else if (f < Js__Js_int.min) { + return Js__Js_int.min; + } else { + return Math.ceil(f); + } +} + +function unsafe_floor(prim) { + return Math.floor(prim); +} + +function floor_int(f) { + if (f > Js__Js_int.max) { + return Js__Js_int.max; + } else if (f < Js__Js_int.min) { + return Js__Js_int.min; + } else { + return Math.floor(f); + } +} + +function random_int(min, max) { + return floor_int(Math.random() * (max - min | 0)) + min | 0; +} + +var ceil = ceil_int; + +var floor = floor_int; + +export { + unsafe_ceil , + ceil_int , + ceil , + unsafe_floor , + floor_int , + floor , + random_int , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_null.js b/melange-node-modules/melange.js/js_null.js new file mode 100644 index 0000000..3906595 --- /dev/null +++ b/melange-node-modules/melange.js/js_null.js @@ -0,0 +1,49 @@ +// Generated by Melange + +import * as Caml_option from "melange.js/caml_option.js"; + +function test(x) { + return x === null; +} + +function getExn(f) { + if (f !== null) { + return f; + } + throw new Error("Js.Null.getExn"); +} + +function bind(x, f) { + if (x !== null) { + return f(x); + } else { + return null; + } +} + +function iter(x, f) { + if (x !== null) { + return f(x); + } + +} + +function fromOption(x) { + if (x !== undefined) { + return Caml_option.valFromOption(x); + } else { + return null; + } +} + +var from_opt = fromOption; + +export { + test , + getExn , + bind , + iter , + fromOption , + from_opt , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_null_undefined.js b/melange-node-modules/melange.js/js_null_undefined.js new file mode 100644 index 0000000..231742d --- /dev/null +++ b/melange-node-modules/melange.js/js_null_undefined.js @@ -0,0 +1,35 @@ +// Generated by Melange + +import * as Caml_option from "melange.js/caml_option.js"; + +function bind(x, f) { + if (x == null) { + return x; + } else { + return f(x); + } +} + +function iter(x, f) { + if (!(x == null)) { + return f(x); + } + +} + +function fromOption(x) { + if (x !== undefined) { + return Caml_option.valFromOption(x); + } + +} + +var from_opt = fromOption; + +export { + bind , + iter , + fromOption , + from_opt , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_option.js b/melange-node-modules/melange.js/js_option.js new file mode 100644 index 0000000..a18f9a6 --- /dev/null +++ b/melange-node-modules/melange.js/js_option.js @@ -0,0 +1,103 @@ +// Generated by Melange + +import * as Caml_option from "melange.js/caml_option.js"; + +function some(x) { + return Caml_option.some(x); +} + +function isSome(param) { + return param !== undefined; +} + +function isSomeValue(eq, v, x) { + if (x !== undefined) { + return eq(v, Caml_option.valFromOption(x)); + } else { + return false; + } +} + +function isNone(param) { + return param === undefined; +} + +function getExn(x) { + if (x !== undefined) { + return Caml_option.valFromOption(x); + } + throw new Error("getExn"); +} + +function equal(eq, a, b) { + if (a !== undefined) { + if (b !== undefined) { + return eq(Caml_option.valFromOption(a), Caml_option.valFromOption(b)); + } else { + return false; + } + } else { + return b === undefined; + } +} + +function andThen(f, x) { + if (x !== undefined) { + return f(Caml_option.valFromOption(x)); + } + +} + +function map(f, x) { + if (x !== undefined) { + return Caml_option.some(f(Caml_option.valFromOption(x))); + } + +} + +function getWithDefault(a, x) { + if (x !== undefined) { + return Caml_option.valFromOption(x); + } else { + return a; + } +} + +function filter(f, x) { + if (x === undefined) { + return ; + } + var x$1 = Caml_option.valFromOption(x); + if (f(x$1)) { + return Caml_option.some(x$1); + } + +} + +function firstSome(a, b) { + if (a !== undefined) { + return a; + } else if (b !== undefined) { + return b; + } else { + return ; + } +} + +var $$default = getWithDefault; + +export { + some , + isSome , + isSomeValue , + isNone , + getExn , + equal , + andThen , + map , + getWithDefault , + $$default as default, + filter , + firstSome , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_promise.js b/melange-node-modules/melange.js/js_promise.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_promise.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/js_re.js b/melange-node-modules/melange.js/js_re.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_re.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/js_result.js b/melange-node-modules/melange.js/js_result.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_result.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/js_set.js b/melange-node-modules/melange.js/js_set.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_set.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/js_string.js b/melange-node-modules/melange.js/js_string.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_string.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/js_string2.js b/melange-node-modules/melange.js/js_string2.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_string2.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/js_typed_array.js b/melange-node-modules/melange.js/js_typed_array.js new file mode 100644 index 0000000..1d648d4 --- /dev/null +++ b/melange-node-modules/melange.js/js_typed_array.js @@ -0,0 +1,39 @@ +// Generated by Melange + + +var $$ArrayBuffer = {}; + +var $$Int8Array = {}; + +var $$Uint8Array = {}; + +var $$Uint8ClampedArray = {}; + +var $$Int16Array = {}; + +var $$Uint16Array = {}; + +var $$Int32Array = {}; + +var $$Uint32Array = {}; + +var $$Float32Array = {}; + +var $$Float64Array = {}; + +var $$DataView = {}; + +export { + $$ArrayBuffer , + $$Int8Array , + $$Uint8Array , + $$Uint8ClampedArray , + $$Int16Array , + $$Uint16Array , + $$Int32Array , + $$Uint32Array , + $$Float32Array , + $$Float64Array , + $$DataView , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_typed_array2.js b/melange-node-modules/melange.js/js_typed_array2.js new file mode 100644 index 0000000..1d648d4 --- /dev/null +++ b/melange-node-modules/melange.js/js_typed_array2.js @@ -0,0 +1,39 @@ +// Generated by Melange + + +var $$ArrayBuffer = {}; + +var $$Int8Array = {}; + +var $$Uint8Array = {}; + +var $$Uint8ClampedArray = {}; + +var $$Int16Array = {}; + +var $$Uint16Array = {}; + +var $$Int32Array = {}; + +var $$Uint32Array = {}; + +var $$Float32Array = {}; + +var $$Float64Array = {}; + +var $$DataView = {}; + +export { + $$ArrayBuffer , + $$Int8Array , + $$Uint8Array , + $$Uint8ClampedArray , + $$Int16Array , + $$Uint16Array , + $$Int32Array , + $$Uint32Array , + $$Float32Array , + $$Float64Array , + $$DataView , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_types.js b/melange-node-modules/melange.js/js_types.js new file mode 100644 index 0000000..6e47c0b --- /dev/null +++ b/melange-node-modules/melange.js/js_types.js @@ -0,0 +1,77 @@ +// Generated by Melange + + +function classify(x) { + var ty = typeof x; + if (ty === "undefined") { + return /* JSUndefined */3; + } else if (x === null) { + return /* JSNull */2; + } else if (ty === "number") { + return { + TAG: /* JSNumber */0, + _0: x + }; + } else if (ty === "bigint") { + return { + TAG: /* JSBigInt */5, + _0: x + }; + } else if (ty === "string") { + return { + TAG: /* JSString */1, + _0: x + }; + } else if (ty === "boolean") { + if (x === true) { + return /* JSTrue */1; + } else { + return /* JSFalse */0; + } + } else if (ty === "symbol") { + return { + TAG: /* JSSymbol */4, + _0: x + }; + } else if (ty === "function") { + return { + TAG: /* JSFunction */2, + _0: x + }; + } else { + return { + TAG: /* JSObject */3, + _0: x + }; + } +} + +function test(x, v) { + switch (v) { + case /* Undefined */0 : + return typeof x === "undefined"; + case /* Null */1 : + return x === null; + case /* Boolean */2 : + return typeof x === "boolean"; + case /* Number */3 : + return typeof x === "number"; + case /* String */4 : + return typeof x === "string"; + case /* Function */5 : + return typeof x === "function"; + case /* Object */6 : + return typeof x === "object"; + case /* Symbol */7 : + return typeof x === "symbol"; + case /* BigInt */8 : + return typeof x === "bigint"; + + } +} + +export { + test , + classify , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_undefined.js b/melange-node-modules/melange.js/js_undefined.js new file mode 100644 index 0000000..4eb7567 --- /dev/null +++ b/melange-node-modules/melange.js/js_undefined.js @@ -0,0 +1,52 @@ +// Generated by Melange + +import * as Caml_option from "melange.js/caml_option.js"; + +function test(x) { + return x === undefined; +} + +function testAny(x) { + return x === undefined; +} + +function getExn(f) { + if (f !== undefined) { + return f; + } + throw new Error("Js.Undefined.getExn"); +} + +function bind(x, f) { + if (x !== undefined) { + return f(x); + } + +} + +function iter(x, f) { + if (x !== undefined) { + return f(x); + } + +} + +function fromOption(x) { + if (x !== undefined) { + return Caml_option.valFromOption(x); + } + +} + +var from_opt = fromOption; + +export { + test , + testAny , + getExn , + bind , + iter , + fromOption , + from_opt , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_vector.js b/melange-node-modules/melange.js/js_vector.js new file mode 100644 index 0000000..41270e0 --- /dev/null +++ b/melange-node-modules/melange.js/js_vector.js @@ -0,0 +1,134 @@ +// Generated by Melange + + +function filterInPlace(p, a) { + var i = 0; + var j = 0; + while(i < a.length) { + var v = a[i]; + if (p(v)) { + a[j] = v; + j = j + 1 | 0; + } + i = i + 1 | 0; + }; + a.splice(j); +} + +function empty(a) { + a.splice(0); +} + +function pushBack(x, xs) { + xs.push(x); +} + +function memByRef(x, xs) { + return xs.indexOf(x) >= 0; +} + +function iter(f, xs) { + for(var i = 0 ,i_finish = xs.length; i < i_finish; ++i){ + f(xs[i]); + } +} + +function iteri(f, a) { + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + f(i, a[i]); + } +} + +function toList(a) { + var _i = a.length - 1 | 0; + var _res = /* [] */0; + while(true) { + var res = _res; + var i = _i; + if (i < 0) { + return res; + } + _res = { + hd: a[i], + tl: res + }; + _i = i - 1 | 0; + continue ; + }; +} + +function init(n, f) { + var v = new Array(n); + for(var i = 0; i < n; ++i){ + v[i] = f(i); + } + return v; +} + +function copy(x) { + var len = x.length; + var b = new Array(len); + for(var i = 0; i < len; ++i){ + b[i] = x[i]; + } + return b; +} + +function map(f, a) { + var l = a.length; + var r = new Array(l); + for(var i = 0; i < l; ++i){ + r[i] = f(a[i]); + } + return r; +} + +function foldLeft(f, x, a) { + var r = x; + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + r = f(r, a[i]); + } + return r; +} + +function foldRight(f, a, x) { + var r = x; + for(var i = a.length - 1 | 0; i >= 0; --i){ + r = f(a[i], r); + } + return r; +} + +function mapi(f, a) { + var l = a.length; + if (l === 0) { + return []; + } + var r = new Array(l); + for(var i = 0; i < l; ++i){ + r[i] = f(i, a[i]); + } + return r; +} + +function append(x, a) { + return a.concat([x]); +} + +export { + filterInPlace , + empty , + pushBack , + copy , + memByRef , + iter , + iteri , + toList , + map , + mapi , + foldLeft , + foldRight , + init , + append , +} +/* No side effect */ diff --git a/melange-node-modules/melange.js/js_weakmap.js b/melange-node-modules/melange.js/js_weakmap.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_weakmap.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/js_weakset.js b/melange-node-modules/melange.js/js_weakset.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange.js/js_weakset.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange.js/melange_mini_stdlib.js b/melange-node-modules/melange.js/melange_mini_stdlib.js new file mode 100644 index 0000000..7df5e32 --- /dev/null +++ b/melange-node-modules/melange.js/melange_mini_stdlib.js @@ -0,0 +1,12 @@ +// Generated by Melange + + +var Obj = {}; + +var Pervasives = {}; + +export { + Obj , + Pervasives , +} +/* No side effect */ diff --git a/melange-node-modules/melange/arg.js b/melange-node-modules/melange/arg.js new file mode 100644 index 0000000..59ff90f --- /dev/null +++ b/melange-node-modules/melange/arg.js @@ -0,0 +1,1027 @@ +// Generated by Melange + +import * as Caml_array from "melange.js/caml_array.js"; +import * as Caml_bytes from "melange.js/caml_bytes.js"; +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Caml_format from "melange.js/caml_format.js"; +import * as Caml_io from "melange.js/caml_io.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Caml_obj from "melange.js/caml_obj.js"; +import * as Caml_string from "melange.js/caml_string.js"; +import * as Caml_sys from "melange.js/caml_sys.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Array from "./array.js"; +import * as Stdlib__Buffer from "./buffer.js"; +import * as Stdlib__Bytes from "./bytes.js"; +import * as Stdlib__Int from "./int.js"; +import * as Stdlib__List from "./list.js"; +import * as Stdlib__Printf from "./printf.js"; +import * as Stdlib__String from "./string.js"; + +var Bad = /* @__PURE__ */Caml_exceptions.create("Stdlib.Arg.Bad"); + +var Help = /* @__PURE__ */Caml_exceptions.create("Stdlib.Arg.Help"); + +var Stop = /* @__PURE__ */Caml_exceptions.create("Stdlib.Arg.Stop"); + +function assoc3(x, _l) { + while(true) { + var l = _l; + if (l) { + var match = l.hd; + if (Caml_obj.caml_equal(match[0], x)) { + return match[1]; + } + _l = l.tl; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; +} + +function split(s) { + var i = Stdlib__String.index(s, /* '=' */61); + var len = s.length; + return [ + Stdlib__String.sub(s, 0, i), + Stdlib__String.sub(s, i + 1 | 0, len - (i + 1 | 0) | 0) + ]; +} + +function make_symlist(prefix, sep, suffix, l) { + if (l) { + return Stdlib__List.fold_left((function (x, y) { + return x + (sep + y); + }), prefix + l.hd, l.tl) + suffix; + } else { + return ""; + } +} + +function help_action(param) { + throw { + RE_EXN_ID: Stop, + _1: { + TAG: /* Unknown */0, + _0: "-help" + }, + Error: new Error() + }; +} + +function add_help(speclist) { + var add1; + try { + assoc3("-help", speclist); + add1 = /* [] */0; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + add1 = { + hd: [ + "-help", + { + TAG: /* Unit */0, + _0: help_action + }, + " Display this list of options" + ], + tl: /* [] */0 + }; + } else { + throw exn; + } + } + var add2; + try { + assoc3("--help", speclist); + add2 = /* [] */0; + } + catch (raw_exn$1){ + var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); + if (exn$1.RE_EXN_ID === Stdlib.Not_found) { + add2 = { + hd: [ + "--help", + { + TAG: /* Unit */0, + _0: help_action + }, + " Display this list of options" + ], + tl: /* [] */0 + }; + } else { + throw exn$1; + } + } + return Stdlib.$at(speclist, Stdlib.$at(add1, add2)); +} + +function usage_b(buf, speclist, errmsg) { + Curry._1(Stdlib__Printf.bprintf(buf, /* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + }, + _1: "%s\n" + }), errmsg); + Stdlib__List.iter((function (param) { + var doc = param[2]; + if (doc.length === 0) { + return ; + } + var spec = param[1]; + var key = param[0]; + if (spec.TAG === /* Symbol */11) { + return Curry._3(Stdlib__Printf.bprintf(buf, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: " ", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* Char_literal */12, + _0: /* ' ' */32, + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + } + } + } + }, + _1: " %s %s%s\n" + }), key, make_symlist("{", "|", "}", spec._0), doc); + } else { + return Curry._2(Stdlib__Printf.bprintf(buf, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: " ", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* Char_literal */12, + _0: /* ' ' */32, + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + } + } + }, + _1: " %s %s\n" + }), key, doc); + } + }), add_help(speclist)); +} + +function usage_string(speclist, errmsg) { + var b = Stdlib__Buffer.create(200); + usage_b(b, speclist, errmsg); + return Stdlib__Buffer.contents(b); +} + +function usage(speclist, errmsg) { + Curry._1(Stdlib__Printf.eprintf(/* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: /* End_of_format */0 + }, + _1: "%s" + }), usage_string(speclist, errmsg)); +} + +var current = { + contents: 0 +}; + +function bool_of_string_opt(x) { + try { + return Stdlib.bool_of_string(x); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Invalid_argument) { + return ; + } + throw exn; + } +} + +function int_of_string_opt(x) { + try { + return Caml_format.caml_int_of_string(x); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Failure) { + return ; + } + throw exn; + } +} + +function float_of_string_opt(x) { + try { + return Caml_format.caml_float_of_string(x); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Failure) { + return ; + } + throw exn; + } +} + +function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist, anonfun, errmsg) { + var initpos = current.contents; + var convert_error = function (error) { + var b = Stdlib__Buffer.create(200); + var progname = initpos < argv.contents.length ? Caml_array.get(argv.contents, initpos) : "(?)"; + switch (error.TAG | 0) { + case /* Unknown */0 : + var s = error._0; + switch (s) { + case "--help" : + case "-help" : + break; + default: + Curry._2(Stdlib__Printf.bprintf(b, /* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: ": unknown option '", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: "'.\n", + _1: /* End_of_format */0 + } + } + } + }, + _1: "%s: unknown option '%s'.\n" + }), progname, s); + } + break; + case /* Wrong */1 : + Curry._4(Stdlib__Printf.bprintf(b, /* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: ": wrong argument '", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: "'; option '", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: "' expects ", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: ".\n", + _1: /* End_of_format */0 + } + } + } + } + } + } + } + }, + _1: "%s: wrong argument '%s'; option '%s' expects %s.\n" + }), progname, error._1, error._0, error._2); + break; + case /* Missing */2 : + Curry._2(Stdlib__Printf.bprintf(b, /* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: ": option '", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: "' needs an argument.\n", + _1: /* End_of_format */0 + } + } + } + }, + _1: "%s: option '%s' needs an argument.\n" + }), progname, error._0); + break; + case /* Message */3 : + Curry._2(Stdlib__Printf.bprintf(b, /* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: ": ", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: ".\n", + _1: /* End_of_format */0 + } + } + } + }, + _1: "%s: %s.\n" + }), progname, error._0); + break; + + } + usage_b(b, speclist.contents, errmsg); + if (Caml_obj.caml_equal(error, { + TAG: /* Unknown */0, + _0: "-help" + }) || Caml_obj.caml_equal(error, { + TAG: /* Unknown */0, + _0: "--help" + })) { + return { + RE_EXN_ID: Help, + _1: Stdlib__Buffer.contents(b) + }; + } else { + return { + RE_EXN_ID: Bad, + _1: Stdlib__Buffer.contents(b) + }; + } + }; + current.contents = current.contents + 1 | 0; + while(current.contents < argv.contents.length) { + try { + var s = Caml_array.get(argv.contents, current.contents); + if (Stdlib__String.starts_with("-", s)) { + var match; + try { + match = [ + assoc3(s, speclist.contents), + undefined + ]; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + try { + var match$1 = split(s); + match = [ + assoc3(match$1[0], speclist.contents), + match$1[1] + ]; + } + catch (raw_exn$1){ + var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); + if (exn$1.RE_EXN_ID === Stdlib.Not_found) { + throw { + RE_EXN_ID: Stop, + _1: { + TAG: /* Unknown */0, + _0: s + }, + Error: new Error() + }; + } + throw exn$1; + } + } else { + throw exn; + } + } + var follow = match[1]; + var no_arg = (function(s,follow){ + return function no_arg(param) { + if (follow === undefined) { + return ; + } + throw { + RE_EXN_ID: Stop, + _1: { + TAG: /* Wrong */1, + _0: s, + _1: follow, + _2: "no argument" + }, + Error: new Error() + }; + } + }(s,follow)); + var get_arg = (function(s,follow){ + return function get_arg(param) { + if (follow !== undefined) { + return follow; + } + if ((current.contents + 1 | 0) < argv.contents.length) { + return Caml_array.get(argv.contents, current.contents + 1 | 0); + } + throw { + RE_EXN_ID: Stop, + _1: { + TAG: /* Missing */2, + _0: s + }, + Error: new Error() + }; + } + }(s,follow)); + var consume_arg = (function(follow){ + return function consume_arg(param) { + if (follow !== undefined) { + return ; + } else { + current.contents = current.contents + 1 | 0; + return ; + } + } + }(follow)); + var treat_action = (function(s){ + return function treat_action(param) { + switch (param.TAG | 0) { + case /* Unit */0 : + no_arg(undefined); + return Curry._1(param._0, undefined); + case /* Bool */1 : + var arg = get_arg(undefined); + var s$1 = bool_of_string_opt(arg); + if (s$1 !== undefined) { + Curry._1(param._0, s$1); + } else { + throw { + RE_EXN_ID: Stop, + _1: { + TAG: /* Wrong */1, + _0: s, + _1: arg, + _2: "a boolean" + }, + Error: new Error() + }; + } + return consume_arg(undefined); + case /* Set */2 : + no_arg(undefined); + param._0.contents = true; + return ; + case /* Clear */3 : + no_arg(undefined); + param._0.contents = false; + return ; + case /* String */4 : + var arg$1 = get_arg(undefined); + Curry._1(param._0, arg$1); + return consume_arg(undefined); + case /* Set_string */5 : + param._0.contents = get_arg(undefined); + return consume_arg(undefined); + case /* Int */6 : + var arg$2 = get_arg(undefined); + var x = int_of_string_opt(arg$2); + if (x !== undefined) { + Curry._1(param._0, x); + } else { + throw { + RE_EXN_ID: Stop, + _1: { + TAG: /* Wrong */1, + _0: s, + _1: arg$2, + _2: "an integer" + }, + Error: new Error() + }; + } + return consume_arg(undefined); + case /* Set_int */7 : + var arg$3 = get_arg(undefined); + var x$1 = int_of_string_opt(arg$3); + if (x$1 !== undefined) { + param._0.contents = x$1; + } else { + throw { + RE_EXN_ID: Stop, + _1: { + TAG: /* Wrong */1, + _0: s, + _1: arg$3, + _2: "an integer" + }, + Error: new Error() + }; + } + return consume_arg(undefined); + case /* Float */8 : + var arg$4 = get_arg(undefined); + var x$2 = float_of_string_opt(arg$4); + if (x$2 !== undefined) { + Curry._1(param._0, x$2); + } else { + throw { + RE_EXN_ID: Stop, + _1: { + TAG: /* Wrong */1, + _0: s, + _1: arg$4, + _2: "a float" + }, + Error: new Error() + }; + } + return consume_arg(undefined); + case /* Set_float */9 : + var arg$5 = get_arg(undefined); + var x$3 = float_of_string_opt(arg$5); + if (x$3 !== undefined) { + param._0.contents = x$3; + } else { + throw { + RE_EXN_ID: Stop, + _1: { + TAG: /* Wrong */1, + _0: s, + _1: arg$5, + _2: "a float" + }, + Error: new Error() + }; + } + return consume_arg(undefined); + case /* Tuple */10 : + no_arg(undefined); + return Stdlib__List.iter(treat_action, param._0); + case /* Symbol */11 : + var symb = param._0; + var arg$6 = get_arg(undefined); + if (Stdlib__List.mem(arg$6, symb)) { + Curry._1(param._1, arg$6); + return consume_arg(undefined); + } + throw { + RE_EXN_ID: Stop, + _1: { + TAG: /* Wrong */1, + _0: s, + _1: arg$6, + _2: "one of: " + make_symlist("", " ", "", symb) + }, + Error: new Error() + }; + case /* Rest */12 : + var f = param._0; + no_arg(undefined); + while(current.contents < (argv.contents.length - 1 | 0)) { + Curry._1(f, Caml_array.get(argv.contents, current.contents + 1 | 0)); + consume_arg(undefined); + }; + return ; + case /* Rest_all */13 : + no_arg(undefined); + var acc = /* [] */0; + while(current.contents < (argv.contents.length - 1 | 0)) { + acc = { + hd: Caml_array.get(argv.contents, current.contents + 1 | 0), + tl: acc + }; + consume_arg(undefined); + }; + return Curry._1(param._0, Stdlib__List.rev(acc)); + case /* Expand */14 : + if (!allow_expand) { + throw { + RE_EXN_ID: Stdlib.Invalid_argument, + _1: "Arg.Expand is is only allowed with Arg.parse_and_expand_argv_dynamic", + Error: new Error() + }; + } + var arg$7 = get_arg(undefined); + var newarg = Curry._1(param._0, arg$7); + consume_arg(undefined); + var before = Stdlib__Array.sub(argv.contents, 0, current.contents + 1 | 0); + var after = Stdlib__Array.sub(argv.contents, current.contents + 1 | 0, (argv.contents.length - current.contents | 0) - 1 | 0); + argv.contents = Caml_array.concat({ + hd: before, + tl: { + hd: newarg, + tl: { + hd: after, + tl: /* [] */0 + } + } + }); + return ; + + } + } + }(s)); + treat_action(match[0]); + } else { + Curry._1(anonfun, s); + } + } + catch (raw_exn$2){ + var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$2); + if (exn$2.RE_EXN_ID === Bad) { + throw convert_error({ + TAG: /* Message */3, + _0: exn$2._1 + }); + } + if (exn$2.RE_EXN_ID === Stop) { + throw convert_error(exn$2._1); + } + throw exn$2; + } + current.contents = current.contents + 1 | 0; + }; +} + +function parse_and_expand_argv_dynamic(current, argv, speclist, anonfun, errmsg) { + parse_and_expand_argv_dynamic_aux(true, current, argv, speclist, anonfun, errmsg); +} + +function parse_argv_dynamic(currentOpt, argv, speclist, anonfun, errmsg) { + var current$1 = currentOpt !== undefined ? currentOpt : current; + parse_and_expand_argv_dynamic_aux(false, current$1, { + contents: argv + }, speclist, anonfun, errmsg); +} + +function parse_argv(currentOpt, argv, speclist, anonfun, errmsg) { + var current$1 = currentOpt !== undefined ? currentOpt : current; + parse_argv_dynamic(current$1, argv, { + contents: speclist + }, anonfun, errmsg); +} + +function parse(l, f, msg) { + try { + return parse_argv(undefined, Caml_sys.caml_sys_argv(0), l, f, msg); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Bad) { + Curry._1(Stdlib__Printf.eprintf(/* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: /* End_of_format */0 + }, + _1: "%s" + }), exn._1); + return Stdlib.exit(2); + } + if (exn.RE_EXN_ID === Help) { + Curry._1(Stdlib__Printf.printf(/* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: /* End_of_format */0 + }, + _1: "%s" + }), exn._1); + return Stdlib.exit(0); + } + throw exn; + } +} + +function parse_dynamic(l, f, msg) { + try { + return parse_argv_dynamic(undefined, Caml_sys.caml_sys_argv(0), l, f, msg); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Bad) { + Curry._1(Stdlib__Printf.eprintf(/* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: /* End_of_format */0 + }, + _1: "%s" + }), exn._1); + return Stdlib.exit(2); + } + if (exn.RE_EXN_ID === Help) { + Curry._1(Stdlib__Printf.printf(/* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: /* End_of_format */0 + }, + _1: "%s" + }), exn._1); + return Stdlib.exit(0); + } + throw exn; + } +} + +function parse_expand(l, f, msg) { + try { + var argv = { + contents: Caml_sys.caml_sys_argv(0) + }; + var spec = { + contents: l + }; + var current$1 = { + contents: current.contents + }; + return parse_and_expand_argv_dynamic(current$1, argv, spec, f, msg); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Bad) { + Curry._1(Stdlib__Printf.eprintf(/* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: /* End_of_format */0 + }, + _1: "%s" + }), exn._1); + return Stdlib.exit(2); + } + if (exn.RE_EXN_ID === Help) { + Curry._1(Stdlib__Printf.printf(/* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: /* End_of_format */0 + }, + _1: "%s" + }), exn._1); + return Stdlib.exit(0); + } + throw exn; + } +} + +function second_word(s) { + var len = s.length; + var loop = function (_n) { + while(true) { + var n = _n; + if (n >= len) { + return len; + } + if (Caml_string.get(s, n) !== /* ' ' */32) { + return n; + } + _n = n + 1 | 0; + continue ; + }; + }; + var n; + try { + n = Stdlib__String.index(s, /* '\t' */9); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + var exit = 0; + var n$1; + try { + n$1 = Stdlib__String.index(s, /* ' ' */32); + exit = 2; + } + catch (raw_exn$1){ + var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); + if (exn$1.RE_EXN_ID === Stdlib.Not_found) { + return len; + } + throw exn$1; + } + if (exit === 2) { + return loop(n$1 + 1 | 0); + } + + } else { + throw exn; + } + } + return loop(n + 1 | 0); +} + +function max_arg_len(cur, param) { + var kwd = param[0]; + if (param[1].TAG === /* Symbol */11) { + return Stdlib__Int.max(cur, kwd.length); + } else { + return Stdlib__Int.max(cur, kwd.length + second_word(param[2]) | 0); + } +} + +function replace_leading_tab(s) { + var seen = { + contents: false + }; + return Stdlib__String.map((function (c) { + if (c !== 9 || seen.contents) { + return c; + } else { + seen.contents = true; + return /* ' ' */32; + } + }), s); +} + +function align(limitOpt, speclist) { + var limit = limitOpt !== undefined ? limitOpt : Stdlib.max_int; + var completed = add_help(speclist); + var len = Stdlib__List.fold_left(max_arg_len, 0, completed); + var len$1 = Stdlib__Int.min(len, limit); + return Stdlib__List.map((function (param) { + var kwd = param[0]; + var spec = param[1]; + if (param[2] === "") { + return param; + } + if (spec.TAG === /* Symbol */11) { + var msg = param[2]; + var cutcol = second_word(msg); + var n = Stdlib__Int.max(0, len$1 - cutcol | 0) + 3 | 0; + var spaces = Caml_bytes.bytes_to_string(Stdlib__Bytes.make(n, /* ' ' */32)); + return [ + kwd, + spec, + "\n" + (spaces + replace_leading_tab(msg)) + ]; + } + var msg$1 = param[2]; + var spec$1 = param[1]; + var cutcol$1 = second_word(msg$1); + var kwd_len = kwd.length; + var diff = (len$1 - kwd_len | 0) - cutcol$1 | 0; + if (diff <= 0) { + return [ + kwd, + spec$1, + replace_leading_tab(msg$1) + ]; + } + var spaces$1 = Caml_bytes.bytes_to_string(Stdlib__Bytes.make(diff, /* ' ' */32)); + var prefix = Stdlib__String.sub(replace_leading_tab(msg$1), 0, cutcol$1); + var suffix = Stdlib__String.sub(msg$1, cutcol$1, msg$1.length - cutcol$1 | 0); + return [ + kwd, + spec$1, + prefix + (spaces$1 + suffix) + ]; + }), completed); +} + +function trim_cr(s) { + var len = s.length; + if (len > 0 && Caml_string.get(s, len - 1 | 0) === /* '\r' */13) { + return Stdlib__String.sub(s, 0, len - 1 | 0); + } else { + return s; + } +} + +function read_aux(trim, sep, file) { + var ic = Stdlib.open_in_bin(file); + var buf = Stdlib__Buffer.create(200); + var words = { + contents: /* [] */0 + }; + var stash = function (param) { + var word = Stdlib__Buffer.contents(buf); + var word$1 = trim ? trim_cr(word) : word; + words.contents = { + hd: word$1, + tl: words.contents + }; + buf.position = 0; + }; + try { + while(true) { + var c = Caml_external_polyfill.resolve("caml_ml_input_char")(ic); + if (c === sep) { + stash(undefined); + } else { + Stdlib__Buffer.add_char(buf, c); + } + }; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID !== Stdlib.End_of_file) { + throw exn; + } + + } + if (buf.position > 0) { + stash(undefined); + } + Caml_external_polyfill.resolve("caml_ml_close_channel")(ic); + return Stdlib__Array.of_list(Stdlib__List.rev(words.contents)); +} + +function read_arg(param) { + return read_aux(true, /* '\n' */10, param); +} + +function read_arg0(param) { + return read_aux(false, /* '\000' */0, param); +} + +function write_aux(sep, file, args) { + var oc = Stdlib.open_out_bin(file); + Stdlib__Array.iter((function (s) { + Curry._2(Stdlib__Printf.fprintf(oc, /* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* Char */0, + _0: /* End_of_format */0 + } + }, + _1: "%s%c" + }), s, sep); + }), args); + Caml_io.caml_ml_flush(oc); + Caml_external_polyfill.resolve("caml_ml_close_channel")(oc); +} + +function write_arg(param, param$1) { + return write_aux(/* '\n' */10, param, param$1); +} + +function write_arg0(param, param$1) { + return write_aux(/* '\000' */0, param, param$1); +} + +export { + parse , + parse_dynamic , + parse_argv , + parse_argv_dynamic , + parse_and_expand_argv_dynamic , + parse_expand , + Help , + Bad , + usage , + usage_string , + align , + current , + read_arg , + read_arg0 , + write_arg , + write_arg0 , +} +/* No side effect */ diff --git a/melange-node-modules/melange/array.js b/melange-node-modules/melange/array.js new file mode 100644 index 0000000..a66c000 --- /dev/null +++ b/melange-node-modules/melange/array.js @@ -0,0 +1,786 @@ +// Generated by Melange + +import * as Caml_array from "melange.js/caml_array.js"; +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Caml_obj from "melange.js/caml_obj.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib__Seq from "./seq.js"; + +var Floatarray = {}; + +function init(l, f) { + if (l === 0) { + return []; + } + if (l < 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Array.init", + Error: new Error() + }; + } + var res = Caml_array.make(l, Curry._1(f, 0)); + for(var i = 1; i < l; ++i){ + res[i] = Curry._1(f, i); + } + return res; +} + +function make_matrix(sx, sy, init) { + var res = Caml_array.make(sx, []); + for(var x = 0; x < sx; ++x){ + res[x] = Caml_array.make(sy, init); + } + return res; +} + +function copy(a) { + var l = a.length; + if (l === 0) { + return []; + } else { + return Caml_array.sub(a, 0, l); + } +} + +function append(a1, a2) { + var 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 { + RE_EXN_ID: "Invalid_argument", + _1: "Array.sub", + Error: new Error() + }; + } + return Caml_array.sub(a, ofs, len); +} + +function fill(a, ofs, len, v) { + if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Array.fill", + Error: new Error() + }; + } + for(var 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 { + RE_EXN_ID: "Invalid_argument", + _1: "Array.blit", + Error: new Error() + }; + } + Caml_array.blit(a1, ofs1, a2, ofs2, len); +} + +function iter(f, a) { + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + Curry._1(f, a[i]); + } +} + +function iter2(f, a, b) { + if (a.length !== b.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Array.iter2: arrays must have the same length", + Error: new Error() + }; + } + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + Curry._2(f, a[i], b[i]); + } +} + +function map(f, a) { + var l = a.length; + if (l === 0) { + return []; + } + var r = Caml_array.make(l, Curry._1(f, a[0])); + for(var i = 1; i < l; ++i){ + r[i] = Curry._1(f, a[i]); + } + return r; +} + +function map_inplace(f, a) { + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + a[i] = Curry._1(f, a[i]); + } +} + +function mapi_inplace(f, a) { + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + a[i] = Curry._2(f, i, a[i]); + } +} + +function map2(f, a, b) { + var la = a.length; + var lb = b.length; + if (la !== lb) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Array.map2: arrays must have the same length", + Error: new Error() + }; + } + if (la === 0) { + return []; + } + var r = Caml_array.make(la, Curry._2(f, a[0], b[0])); + for(var i = 1; i < la; ++i){ + r[i] = Curry._2(f, a[i], b[i]); + } + return r; +} + +function iteri(f, a) { + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + Curry._2(f, i, a[i]); + } +} + +function mapi(f, a) { + var l = a.length; + if (l === 0) { + return []; + } + var r = Caml_array.make(l, Curry._2(f, 0, a[0])); + for(var i = 1; i < l; ++i){ + r[i] = Curry._2(f, i, a[i]); + } + return r; +} + +function to_list(a) { + var _i = a.length - 1 | 0; + var _res = /* [] */0; + while(true) { + var res = _res; + var i = _i; + if (i < 0) { + return res; + } + _res = { + hd: a[i], + tl: res + }; + _i = i - 1 | 0; + continue ; + }; +} + +function list_length(_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + _param = param.tl; + _accu = accu + 1 | 0; + continue ; + }; +} + +function of_list(l) { + if (!l) { + return []; + } + var a = Caml_array.make(list_length(0, l), l.hd); + var _i = 1; + var _param = l.tl; + while(true) { + var param = _param; + var i = _i; + if (!param) { + return a; + } + a[i] = param.hd; + _param = param.tl; + _i = i + 1 | 0; + continue ; + }; +} + +function fold_left(f, x, a) { + var r = x; + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + r = Curry._2(f, r, a[i]); + } + return r; +} + +function fold_left_map(f, acc, input_array) { + var len = input_array.length; + if (len === 0) { + return [ + acc, + [] + ]; + } + var match = Curry._2(f, acc, input_array[0]); + var output_array = Caml_array.make(len, match[1]); + var acc$1 = match[0]; + for(var i = 1; i < len; ++i){ + var match$1 = Curry._2(f, acc$1, input_array[i]); + acc$1 = match$1[0]; + output_array[i] = match$1[1]; + } + return [ + acc$1, + output_array + ]; +} + +function fold_right(f, a, x) { + var r = x; + for(var i = a.length - 1 | 0; i >= 0; --i){ + r = Curry._2(f, a[i], r); + } + return r; +} + +function exists(p, a) { + var n = a.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return false; + } + if (Curry._1(p, a[i])) { + return true; + } + _i = i + 1 | 0; + continue ; + }; +} + +function for_all(p, a) { + var n = a.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return true; + } + if (!Curry._1(p, a[i])) { + return false; + } + _i = i + 1 | 0; + continue ; + }; +} + +function for_all2(p, l1, l2) { + var n1 = l1.length; + var n2 = l2.length; + if (n1 !== n2) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Array.for_all2", + Error: new Error() + }; + } + var _i = 0; + while(true) { + var i = _i; + if (i === n1) { + return true; + } + if (!Curry._2(p, l1[i], l2[i])) { + return false; + } + _i = i + 1 | 0; + continue ; + }; +} + +function exists2(p, l1, l2) { + var n1 = l1.length; + var n2 = l2.length; + if (n1 !== n2) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Array.exists2", + Error: new Error() + }; + } + var _i = 0; + while(true) { + var i = _i; + if (i === n1) { + return false; + } + if (Curry._2(p, l1[i], l2[i])) { + return true; + } + _i = i + 1 | 0; + continue ; + }; +} + +function mem(x, a) { + var n = a.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return false; + } + if (Caml_obj.caml_equal(a[i], x)) { + return true; + } + _i = i + 1 | 0; + continue ; + }; +} + +function memq(x, a) { + var n = a.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return false; + } + if (x === a[i]) { + return true; + } + _i = i + 1 | 0; + continue ; + }; +} + +function find_opt(p, a) { + var n = a.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return ; + } + var x = a[i]; + if (Curry._1(p, x)) { + return Caml_option.some(x); + } + _i = i + 1 | 0; + continue ; + }; +} + +function find_index(p, a) { + var n = a.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return ; + } + if (Curry._1(p, a[i])) { + return i; + } + _i = i + 1 | 0; + continue ; + }; +} + +function find_map(f, a) { + var n = a.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return ; + } + var r = Curry._1(f, a[i]); + if (r !== undefined) { + return r; + } + _i = i + 1 | 0; + continue ; + }; +} + +function find_mapi(f, a) { + var n = a.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return ; + } + var r = Curry._2(f, i, a[i]); + if (r !== undefined) { + return r; + } + _i = i + 1 | 0; + continue ; + }; +} + +function split(x) { + if (Caml_obj.caml_equal(x, [])) { + return [ + [], + [] + ]; + } + var match = x[0]; + var n = x.length; + var a = Caml_array.make(n, match[0]); + var b = Caml_array.make(n, match[1]); + for(var i = 1; i < n; ++i){ + var match$1 = x[i]; + a[i] = match$1[0]; + b[i] = match$1[1]; + } + return [ + a, + b + ]; +} + +function combine(a, b) { + var na = a.length; + var nb = b.length; + if (na !== nb) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Array.combine", + Error: new Error() + }; + } + if (na === 0) { + return []; + } + var x = Caml_array.make(na, [ + a[0], + b[0] + ]); + for(var i = 1; i < na; ++i){ + x[i] = [ + a[i], + b[i] + ]; + } + return x; +} + +var Bottom = /* @__PURE__ */Caml_exceptions.create("Stdlib.Array.Bottom"); + +function sort(cmp, a) { + var maxson = function (l, i) { + var i31 = ((i + i | 0) + i | 0) + 1 | 0; + var x = i31; + if ((i31 + 2 | 0) < l) { + if (Curry._2(cmp, Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { + x = i31 + 1 | 0; + } + if (Curry._2(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 && Curry._2(cmp, Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { + return i31 + 1 | 0; + } + if (i31 < l) { + return i31; + } + throw { + RE_EXN_ID: Bottom, + _1: i, + Error: new Error() + }; + }; + var trickle = function (l, i, e) { + try { + var _i = i; + while(true) { + var i$1 = _i; + var j = maxson(l, i$1); + if (Curry._2(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_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Bottom) { + return Caml_array.set(a, exn._1, e); + } + throw exn; + } + }; + var bubble = function (l, i) { + try { + var _i = i; + while(true) { + var i$1 = _i; + var j = maxson(l, i$1); + Caml_array.set(a, i$1, Caml_array.get(a, j)); + _i = j; + continue ; + }; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Bottom) { + return exn._1; + } + throw exn; + } + }; + var trickleup = function (_i, e) { + while(true) { + var i = _i; + var father = (i - 1 | 0) / 3 | 0; + if (i === father) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "array.cppo.ml", + 353, + 4 + ], + Error: new Error() + }; + } + if (Curry._2(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 ; + }; + }; + var l = a.length; + for(var i = ((l + 1 | 0) / 3 | 0) - 1 | 0; i >= 0; --i){ + trickle(l, i, Caml_array.get(a, i)); + } + for(var i$1 = l - 1 | 0; i$1 >= 2; --i$1){ + var 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 ; + } + var 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) { + var merge = function (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { + var src1r = src1ofs + src1len | 0; + var src2r = src2ofs + src2len | 0; + var _i1 = src1ofs; + var _s1 = Caml_array.get(a, src1ofs); + var _i2 = src2ofs; + var _s2 = Caml_array.get(src2, src2ofs); + var _d = dstofs; + while(true) { + var d = _d; + var s2 = _s2; + var i2 = _i2; + var s1 = _s1; + var i1 = _i1; + if (Curry._2(cmp, s1, s2) <= 0) { + Caml_array.set(dst, d, s1); + var 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); + var 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 ; + }; + }; + var isortto = function (srcofs, dst, dstofs, len) { + for(var i = 0; i < len; ++i){ + var e = Caml_array.get(a, srcofs + i | 0); + var j = (dstofs + i | 0) - 1 | 0; + while(j >= dstofs && Curry._2(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); + } + }; + var sortto = function (srcofs, dst, dstofs, len) { + if (len <= 5) { + return isortto(srcofs, dst, dstofs, len); + } + var l1 = len / 2 | 0; + var 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); + }; + var l = a.length; + if (l <= 5) { + return isortto(0, a, 0, l); + } + var l1 = l / 2 | 0; + var l2 = l - l1 | 0; + var 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); +} + +function to_seq(a) { + var aux = function (i, param) { + if (i >= a.length) { + return /* Nil */0; + } + var x = a[i]; + var partial_arg = i + 1 | 0; + return /* Cons */{ + _0: x, + _1: (function (param) { + return aux(partial_arg, param); + }) + }; + }; + return function (param) { + return aux(0, param); + }; +} + +function to_seqi(a) { + var aux = function (i, param) { + if (i >= a.length) { + return /* Nil */0; + } + var x = a[i]; + var partial_arg = i + 1 | 0; + return /* Cons */{ + _0: [ + i, + x + ], + _1: (function (param) { + return aux(partial_arg, param); + }) + }; + }; + return function (param) { + return aux(0, param); + }; +} + +function of_seq(i) { + var l = Stdlib__Seq.fold_left((function (acc, x) { + return { + hd: x, + tl: acc + }; + }), /* [] */0, i); + if (!l) { + return []; + } + var len = list_length(0, l); + var a = Caml_array.make(len, l.hd); + var _i = len - 2 | 0; + var _param = l.tl; + while(true) { + var param = _param; + var i$1 = _i; + if (!param) { + return a; + } + a[i$1] = param.hd; + _param = param.tl; + _i = i$1 - 1 | 0; + continue ; + }; +} + +var concat = Caml_array.concat; + +var fast_sort = stable_sort; + +export { + init , + make_matrix , + append , + concat , + sub , + copy , + fill , + blit , + to_list , + of_list , + iter , + iteri , + map , + map_inplace , + mapi , + mapi_inplace , + fold_left , + fold_left_map , + fold_right , + iter2 , + map2 , + for_all , + exists , + for_all2 , + exists2 , + mem , + memq , + find_opt , + find_index , + find_map , + find_mapi , + split , + combine , + sort , + stable_sort , + fast_sort , + to_seq , + to_seqi , + of_seq , + Floatarray , +} +/* No side effect */ diff --git a/melange-node-modules/melange/arrayLabels.js b/melange-node-modules/melange/arrayLabels.js new file mode 100644 index 0000000..e89549c --- /dev/null +++ b/melange-node-modules/melange/arrayLabels.js @@ -0,0 +1,127 @@ +// Generated by Melange + +import * as Stdlib__Array from "./array.js"; + +var init = Stdlib__Array.init; + +var make_matrix = Stdlib__Array.make_matrix; + +var append = Stdlib__Array.append; + +var concat = Stdlib__Array.concat; + +var sub = Stdlib__Array.sub; + +var copy = Stdlib__Array.copy; + +var fill = Stdlib__Array.fill; + +var blit = Stdlib__Array.blit; + +var to_list = Stdlib__Array.to_list; + +var of_list = Stdlib__Array.of_list; + +var iter = Stdlib__Array.iter; + +var iteri = Stdlib__Array.iteri; + +var map = Stdlib__Array.map; + +var map_inplace = Stdlib__Array.map_inplace; + +var mapi = Stdlib__Array.mapi; + +var mapi_inplace = Stdlib__Array.mapi_inplace; + +var fold_left = Stdlib__Array.fold_left; + +var fold_left_map = Stdlib__Array.fold_left_map; + +var fold_right = Stdlib__Array.fold_right; + +var iter2 = Stdlib__Array.iter2; + +var map2 = Stdlib__Array.map2; + +var for_all = Stdlib__Array.for_all; + +var exists = Stdlib__Array.exists; + +var for_all2 = Stdlib__Array.for_all2; + +var exists2 = Stdlib__Array.exists2; + +var mem = Stdlib__Array.mem; + +var memq = Stdlib__Array.memq; + +var find_opt = Stdlib__Array.find_opt; + +var find_index = Stdlib__Array.find_index; + +var find_map = Stdlib__Array.find_map; + +var find_mapi = Stdlib__Array.find_mapi; + +var split = Stdlib__Array.split; + +var combine = Stdlib__Array.combine; + +var sort = Stdlib__Array.sort; + +var stable_sort = Stdlib__Array.stable_sort; + +var fast_sort = Stdlib__Array.fast_sort; + +var to_seq = Stdlib__Array.to_seq; + +var to_seqi = Stdlib__Array.to_seqi; + +var of_seq = Stdlib__Array.of_seq; + +var Floatarray = Stdlib__Array.Floatarray; + +export { + init , + make_matrix , + append , + concat , + sub , + copy , + fill , + blit , + to_list , + of_list , + iter , + iteri , + map , + map_inplace , + mapi , + mapi_inplace , + fold_left , + fold_left_map , + fold_right , + iter2 , + map2 , + for_all , + exists , + for_all2 , + exists2 , + mem , + memq , + find_opt , + find_index , + find_map , + find_mapi , + split , + combine , + sort , + stable_sort , + fast_sort , + to_seq , + to_seqi , + of_seq , + Floatarray , +} +/* No side effect */ diff --git a/melange-node-modules/melange/atomic.js b/melange-node-modules/melange/atomic.js new file mode 100644 index 0000000..ef8b273 --- /dev/null +++ b/melange-node-modules/melange/atomic.js @@ -0,0 +1,31 @@ +// Generated by Melange + +import * as CamlinternalAtomic from "./camlinternalAtomic.js"; + +var make = CamlinternalAtomic.make; + +var get = CamlinternalAtomic.get; + +var set = CamlinternalAtomic.set; + +var exchange = CamlinternalAtomic.exchange; + +var compare_and_set = CamlinternalAtomic.compare_and_set; + +var fetch_and_add = CamlinternalAtomic.fetch_and_add; + +var incr = CamlinternalAtomic.incr; + +var decr = CamlinternalAtomic.decr; + +export { + make , + get , + set , + exchange , + compare_and_set , + fetch_and_add , + incr , + decr , +} +/* No side effect */ diff --git a/melange-node-modules/melange/bool.js b/melange-node-modules/melange/bool.js new file mode 100644 index 0000000..bd7835f --- /dev/null +++ b/melange-node-modules/melange/bool.js @@ -0,0 +1,58 @@ +// Generated by Melange + +import * as Caml from "melange.js/caml.js"; +import * as Caml_hash from "melange.js/caml_hash.js"; + +function equal(prim0, prim1) { + return prim0 === prim1; +} + +var compare = Caml.caml_int_compare; + +function to_int(param) { + if (param) { + return 1; + } else { + return 0; + } +} + +function to_float(param) { + if (param) { + return 1; + } else { + return 0; + } +} + +function to_string(param) { + if (param) { + return "true"; + } else { + return "false"; + } +} + +function seeded_hash(seed, x) { + return Caml_hash.caml_hash(10, 100, seed, x); +} + +function hash(x) { + return Caml_hash.caml_hash(10, 100, 0, x); +} + +function not(prim) { + return !prim; +} + +export { + not , + equal , + compare , + to_int , + to_float , + to_string , + seeded_hash , + hash , +} +/* No side effect */ diff --git a/melange-node-modules/melange/buffer.js b/melange-node-modules/melange/buffer.js new file mode 100644 index 0000000..89d58a4 --- /dev/null +++ b/melange-node-modules/melange/buffer.js @@ -0,0 +1,569 @@ +// Generated by Melange + +import * as Caml_bytes from "melange.js/caml_bytes.js"; +import * as Caml_string from "melange.js/caml_string.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Bytes from "./bytes.js"; +import * as Stdlib__Seq from "./seq.js"; +import * as Stdlib__String from "./string.js"; +import * as Stdlib__Sys from "./sys.js"; + +function create(n) { + var n$1 = n < 1 ? 1 : n; + var n$2 = n$1 > Stdlib__Sys.max_string_length ? Stdlib__Sys.max_string_length : n$1; + var s = Caml_bytes.caml_create_bytes(n$2); + return { + inner: { + buffer: s, + length: n$2 + }, + position: 0, + initial_buffer: s + }; +} + +function contents(b) { + return Stdlib__Bytes.sub_string(b.inner.buffer, 0, b.position); +} + +function to_bytes(b) { + return Stdlib__Bytes.sub(b.inner.buffer, 0, b.position); +} + +function sub(b, ofs, len) { + if (ofs < 0 || len < 0 || ofs > (b.position - len | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Buffer.sub", + Error: new Error() + }; + } + return Stdlib__Bytes.sub_string(b.inner.buffer, ofs, len); +} + +function blit(src, srcoff, dst, dstoff, len) { + if (len < 0 || srcoff < 0 || srcoff > (src.position - len | 0) || dstoff < 0 || dstoff > (dst.length - len | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Buffer.blit", + Error: new Error() + }; + } + Stdlib__Bytes.blit(src.inner.buffer, srcoff, dst, dstoff, len); +} + +function nth(b, ofs) { + var position = b.position; + var match = b.inner; + if (ofs < 0 || ofs >= position || position > match.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Buffer.nth", + Error: new Error() + }; + } + return match.buffer[ofs]; +} + +function length(b) { + return b.position; +} + +function clear(b) { + b.position = 0; +} + +function reset(b) { + b.position = 0; + var inner_buffer = b.initial_buffer; + var inner_length = b.initial_buffer.length; + var inner = { + buffer: inner_buffer, + length: inner_length + }; + b.inner = inner; +} + +function resize(b, more) { + var old_pos = b.position; + var old_len = b.inner.length; + var new_len = old_len; + while((old_pos + more | 0) > new_len) { + new_len = (new_len << 1); + }; + if (new_len > Stdlib__Sys.max_string_length) { + if ((old_pos + more | 0) <= Stdlib__Sys.max_string_length) { + new_len = Stdlib__Sys.max_string_length; + } else { + throw { + RE_EXN_ID: "Failure", + _1: "Buffer.add: cannot grow buffer", + Error: new Error() + }; + } + } + var new_buffer = Caml_bytes.caml_create_bytes(new_len); + Stdlib__Bytes.blit(b.inner.buffer, 0, new_buffer, 0, b.position); + b.inner = { + buffer: new_buffer, + length: new_len + }; +} + +function add_char(b, c) { + var pos = b.position; + var match = b.inner; + if (pos >= match.length) { + resize(b, 1); + Caml_bytes.set(b.inner.buffer, b.position, c); + } else { + match.buffer[pos] = c; + } + b.position = pos + 1 | 0; +} + +function add_substring(b, s, offset, len) { + if (offset < 0 || len < 0 || offset > (s.length - len | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Buffer.add_substring/add_subbytes", + Error: new Error() + }; + } + var position = b.position; + var match = b.inner; + var new_position = position + len | 0; + if (new_position > match.length) { + resize(b, len); + Stdlib__Bytes.blit_string(s, offset, b.inner.buffer, b.position, len); + } else { + Caml_bytes.caml_blit_string(s, offset, match.buffer, position, len); + } + b.position = new_position; +} + +function add_subbytes(b, s, offset, len) { + add_substring(b, Caml_bytes.bytes_to_string(s), offset, len); +} + +function add_string(b, s) { + var len = s.length; + var position = b.position; + var match = b.inner; + var new_position = position + len | 0; + if (new_position > match.length) { + resize(b, len); + Stdlib__Bytes.blit_string(s, 0, b.inner.buffer, b.position, len); + } else { + Caml_bytes.caml_blit_string(s, 0, match.buffer, position, len); + } + b.position = new_position; +} + +function add_bytes(b, s) { + add_string(b, Caml_bytes.bytes_to_string(s)); +} + +function add_buffer(b, bs) { + add_subbytes(b, bs.inner.buffer, 0, bs.position); +} + +function really_input_up_to(ic, buf, ofs, len) { + var _already_read = 0; + var _ofs = ofs; + var _to_read = len; + while(true) { + var to_read = _to_read; + var ofs$1 = _ofs; + var already_read = _already_read; + if (to_read === 0) { + return already_read; + } + var r = Stdlib.input(ic, buf, ofs$1, to_read); + if (r === 0) { + return already_read; + } + var already_read$1 = already_read + r | 0; + var ofs$2 = ofs$1 + r | 0; + var to_read$1 = to_read - r | 0; + _to_read = to_read$1; + _ofs = ofs$2; + _already_read = already_read$1; + continue ; + }; +} + +function unsafe_add_channel_up_to(b, ic, len) { + if ((b.position + len | 0) > b.inner.length) { + resize(b, len); + } + var n = really_input_up_to(ic, b.inner.buffer, b.position, len); + b.position = b.position + n | 0; + return n; +} + +function add_channel(b, ic, len) { + if (len < 0 || len > Stdlib__Sys.max_string_length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Buffer.add_channel", + Error: new Error() + }; + } + var n = unsafe_add_channel_up_to(b, ic, len); + if (n < len) { + throw { + RE_EXN_ID: Stdlib.End_of_file, + Error: new Error() + }; + } + +} + +function output_buffer(oc, b) { + Stdlib.output(oc, b.inner.buffer, 0, b.position); +} + +function closing(param) { + if (param === 40) { + return /* ')' */41; + } + if (param === 123) { + return /* '}' */125; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "buffer.cppo.ml", + 223, + 9 + ], + Error: new Error() + }; +} + +function advance_to_closing(opening, closing, k, s, start) { + var _k = k; + var _i = start; + var lim = s.length; + while(true) { + var i = _i; + var k$1 = _k; + if (i >= lim) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + if (Caml_string.get(s, i) === opening) { + _i = i + 1 | 0; + _k = k$1 + 1 | 0; + continue ; + } + if (Caml_string.get(s, i) === closing) { + if (k$1 === 0) { + return i; + } + _i = i + 1 | 0; + _k = k$1 - 1 | 0; + continue ; + } + _i = i + 1 | 0; + continue ; + }; +} + +function advance_to_non_alpha(s, start) { + var _i = start; + var lim = s.length; + while(true) { + var i = _i; + if (i >= lim) { + return lim; + } + var match = Caml_string.get(s, i); + if (match >= 91) { + if (match >= 97) { + if (match >= 123) { + return i; + } + + } else if (match !== 95) { + return i; + } + + } else if (match >= 58) { + if (match < 65) { + return i; + } + + } else if (match < 48) { + return i; + } + _i = i + 1 | 0; + continue ; + }; +} + +function find_ident(s, start, lim) { + if (start >= lim) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + var c = Caml_string.get(s, start); + if (c !== 40 && c !== 123) { + var stop = advance_to_non_alpha(s, start + 1 | 0); + return [ + Stdlib__String.sub(s, start, stop - start | 0), + stop + ]; + } + var new_start = start + 1 | 0; + var stop$1 = advance_to_closing(c, closing(c), 0, s, new_start); + return [ + Stdlib__String.sub(s, new_start, (stop$1 - start | 0) - 1 | 0), + stop$1 + 1 | 0 + ]; +} + +function add_substitute(b, f, s) { + var lim = s.length; + var _previous = /* ' ' */32; + var _i = 0; + while(true) { + var i = _i; + var previous = _previous; + if (i >= lim) { + if (previous === /* '\\' */92) { + return add_char(b, previous); + } else { + return ; + } + } + var current = Caml_string.get(s, i); + if (current !== 36) { + if (previous === /* '\\' */92) { + add_char(b, /* '\\' */92); + add_char(b, current); + _i = i + 1 | 0; + _previous = /* ' ' */32; + continue ; + } + if (current !== 92) { + add_char(b, current); + _i = i + 1 | 0; + _previous = current; + continue ; + } + _i = i + 1 | 0; + _previous = current; + continue ; + } + if (previous === /* '\\' */92) { + add_char(b, current); + _i = i + 1 | 0; + _previous = /* ' ' */32; + continue ; + } + var j = i + 1 | 0; + var match = find_ident(s, j, lim); + add_string(b, Curry._1(f, match[0])); + _i = match[1]; + _previous = /* ' ' */32; + continue ; + }; +} + +function truncate(b, len) { + if (len < 0 || len > b.position) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Buffer.truncate", + Error: new Error() + }; + } + b.position = len; +} + +function to_seq(b) { + var aux = function (i, param) { + if (i >= b.position) { + return /* Nil */0; + } + var x = Caml_bytes.get(b.inner.buffer, i); + var partial_arg = i + 1 | 0; + return /* Cons */{ + _0: x, + _1: (function (param) { + return aux(partial_arg, param); + }) + }; + }; + return function (param) { + return aux(0, param); + }; +} + +function to_seqi(b) { + var aux = function (i, param) { + if (i >= b.position) { + return /* Nil */0; + } + var x = Caml_bytes.get(b.inner.buffer, i); + var partial_arg = i + 1 | 0; + return /* Cons */{ + _0: [ + i, + x + ], + _1: (function (param) { + return aux(partial_arg, param); + }) + }; + }; + return function (param) { + return aux(0, param); + }; +} + +function add_seq(b, seq) { + Stdlib__Seq.iter((function (param) { + return add_char(b, param); + }), seq); +} + +function of_seq(i) { + var b = create(32); + Stdlib__Seq.iter((function (param) { + return add_char(b, param); + }), i); + return b; +} + +function add_int8(b, x) { + var position = b.position; + var match = b.inner; + var new_position = position + 1 | 0; + if (new_position > match.length) { + resize(b, 1); + Caml_bytes.set(b.inner.buffer, b.position, x); + } else { + match.buffer[position] = x; + } + b.position = new_position; +} + +function add_int16_ne(b, x) { + var position = b.position; + var match = b.inner; + var new_position = position + 2 | 0; + if (new_position > match.length) { + resize(b, 2); + Caml_bytes.set16(b.inner.buffer, b.position, x); + } else { + Caml_bytes.set16u(match.buffer, position, x); + } + b.position = new_position; +} + +function add_int32_ne(b, x) { + var position = b.position; + var match = b.inner; + var new_position = position + 4 | 0; + if (new_position > match.length) { + resize(b, 4); + Caml_bytes.set32(b.inner.buffer, b.position, x); + } else { + Caml_bytes.set32u(match.buffer, position, x); + } + b.position = new_position; +} + +function add_int64_ne(b, x) { + var position = b.position; + var match = b.inner; + var new_position = position + 8 | 0; + if (new_position > match.length) { + resize(b, 8); + Caml_bytes.set64(b.inner.buffer, b.position, x); + } else { + Caml_bytes.set64u(match.buffer, position, x); + } + b.position = new_position; +} + +function add_int16_le(b, x) { + add_int16_ne(b, Stdlib__Sys.big_endian ? Caml_bytes.bswap16(x) : x); +} + +function add_int16_be(b, x) { + add_int16_ne(b, Stdlib__Sys.big_endian ? x : Caml_bytes.bswap16(x)); +} + +function add_int32_le(b, x) { + add_int32_ne(b, Stdlib__Sys.big_endian ? Caml_bytes.bswap32(x) : x); +} + +function add_int32_be(b, x) { + add_int32_ne(b, Stdlib__Sys.big_endian ? x : Caml_bytes.bswap32(x)); +} + +function add_int64_le(b, x) { + add_int64_ne(b, Stdlib__Sys.big_endian ? Caml_bytes.bswap64(x) : x); +} + +function add_int64_be(b, x) { + add_int64_ne(b, Stdlib__Sys.big_endian ? x : Caml_bytes.bswap64(x)); +} + +var add_uint8 = add_int8; + +var add_uint16_ne = add_int16_ne; + +var add_uint16_be = add_int16_be; + +var add_uint16_le = add_int16_le; + +export { + create , + contents , + to_bytes , + sub , + blit , + nth , + length , + clear , + reset , + output_buffer , + truncate , + add_char , + add_string , + add_bytes , + add_substring , + add_subbytes , + add_substitute , + add_buffer , + add_channel , + to_seq , + to_seqi , + add_seq , + of_seq , + add_uint8 , + add_int8 , + add_uint16_ne , + add_uint16_be , + add_uint16_le , + add_int16_ne , + add_int16_be , + add_int16_le , + add_int32_ne , + add_int32_be , + add_int32_le , + add_int64_ne , + add_int64_be , + add_int64_le , +} +/* No side effect */ diff --git a/melange-node-modules/melange/bytes.js b/melange-node-modules/melange/bytes.js new file mode 100644 index 0000000..d5611e6 --- /dev/null +++ b/melange-node-modules/melange/bytes.js @@ -0,0 +1,1596 @@ +// Generated by Melange + +import * as Caml_bytes from "melange.js/caml_bytes.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Char from "./char.js"; +import * as Stdlib__Int from "./int.js"; +import * as Stdlib__Seq from "./seq.js"; +import * as Stdlib__Sys from "./sys.js"; + +function make(n, c) { + var s = Caml_bytes.caml_create_bytes(n); + Caml_bytes.caml_fill_bytes(s, 0, n, c); + return s; +} + +function init(n, f) { + var s = Caml_bytes.caml_create_bytes(n); + for(var i = 0; i < n; ++i){ + s[i] = Curry._1(f, i); + } + return s; +} + +var empty = []; + +function copy(s) { + var len = s.length; + var r = Caml_bytes.caml_create_bytes(len); + Caml_bytes.caml_blit_bytes(s, 0, r, 0, len); + return r; +} + +function to_string(b) { + return Caml_bytes.bytes_to_string(copy(b)); +} + +function of_string(s) { + return copy(Caml_bytes.bytes_of_string(s)); +} + +function sub(s, ofs, len) { + if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.sub / Bytes.sub", + Error: new Error() + }; + } + var r = Caml_bytes.caml_create_bytes(len); + Caml_bytes.caml_blit_bytes(s, ofs, r, 0, len); + return r; +} + +function sub_string(b, ofs, len) { + return Caml_bytes.bytes_to_string(sub(b, ofs, len)); +} + +function $plus$plus(a, b) { + var c = a + b | 0; + var match = a < 0; + var match$1 = b < 0; + var match$2 = c < 0; + if (match) { + if (!match$1) { + return c; + } + if (match$2) { + return c; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Bytes.extend", + Error: new Error() + }; + } + if (match$1) { + return c; + } + if (match$2) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Bytes.extend", + Error: new Error() + }; + } + return c; +} + +function extend(s, left, right) { + var len = $plus$plus($plus$plus(s.length, left), right); + var r = Caml_bytes.caml_create_bytes(len); + var match = left < 0 ? [ + -left | 0, + 0 + ] : [ + 0, + left + ]; + var dstoff = match[1]; + var srcoff = match[0]; + var cpylen = Stdlib__Int.min(s.length - srcoff | 0, len - dstoff | 0); + if (cpylen > 0) { + Caml_bytes.caml_blit_bytes(s, srcoff, r, dstoff, cpylen); + } + return r; +} + +function fill(s, ofs, len, c) { + if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.fill / Bytes.fill", + Error: new Error() + }; + } + Caml_bytes.caml_fill_bytes(s, ofs, len, c); +} + +function blit(s1, ofs1, s2, ofs2, len) { + if (len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Bytes.blit", + Error: new Error() + }; + } + Caml_bytes.caml_blit_bytes(s1, ofs1, s2, ofs2, len); +} + +function blit_string(s1, ofs1, s2, ofs2, len) { + if (len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.blit / Bytes.blit_string", + Error: new Error() + }; + } + Caml_bytes.caml_blit_string(s1, ofs1, s2, ofs2, len); +} + +function iter(f, a) { + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + Curry._1(f, a[i]); + } +} + +function iteri(f, a) { + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + Curry._2(f, i, a[i]); + } +} + +function ensure_ge(x, y) { + if (x >= y) { + return x; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Bytes.concat", + Error: new Error() + }; +} + +function sum_lengths(_acc, seplen, _param) { + while(true) { + var param = _param; + var acc = _acc; + if (!param) { + return acc; + } + var hd = param.hd; + if (!param.tl) { + return hd.length + acc | 0; + } + _param = param.tl; + _acc = ensure_ge((hd.length + seplen | 0) + acc | 0, acc); + continue ; + }; +} + +function concat(sep, l) { + if (!l) { + return empty; + } + var seplen = sep.length; + var dst = Caml_bytes.caml_create_bytes(sum_lengths(0, seplen, l)); + var _pos = 0; + var _param = l; + while(true) { + var param = _param; + var pos = _pos; + if (!param) { + return dst; + } + var hd = param.hd; + if (param.tl) { + Caml_bytes.caml_blit_bytes(hd, 0, dst, pos, hd.length); + Caml_bytes.caml_blit_bytes(sep, 0, dst, pos + hd.length | 0, seplen); + _param = param.tl; + _pos = (pos + hd.length | 0) + seplen | 0; + continue ; + } + Caml_bytes.caml_blit_bytes(hd, 0, dst, pos, hd.length); + return dst; + }; +} + +function cat(s1, s2) { + var l1 = s1.length; + var l2 = s2.length; + var r = Caml_bytes.caml_create_bytes(l1 + l2 | 0); + Caml_bytes.caml_blit_bytes(s1, 0, r, 0, l1); + Caml_bytes.caml_blit_bytes(s2, 0, r, l1, l2); + return r; +} + +function is_space(param) { + if (param > 13 || param < 9) { + return param === 32; + } else { + return param !== 11; + } +} + +function trim(s) { + var len = s.length; + var i = 0; + while(i < len && is_space(s[i])) { + i = i + 1 | 0; + }; + var j = len - 1 | 0; + while(j >= i && is_space(s[j])) { + j = j - 1 | 0; + }; + if (j >= i) { + return sub(s, i, (j - i | 0) + 1 | 0); + } else { + return empty; + } +} + +function unsafe_escape(s) { + var n = 0; + for(var i = 0 ,i_finish = s.length; i < i_finish; ++i){ + var match = s[i]; + n = n + ( + match >= 32 ? ( + match > 92 || match < 34 ? ( + match >= 127 ? 4 : 1 + ) : ( + match > 91 || match < 35 ? 2 : 1 + ) + ) : ( + match >= 11 ? ( + match !== 13 ? 4 : 2 + ) : ( + match >= 8 ? 2 : 4 + ) + ) + ) | 0; + } + if (n === s.length) { + return s; + } + var s$p = Caml_bytes.caml_create_bytes(n); + n = 0; + for(var i$1 = 0 ,i_finish$1 = s.length; i$1 < i_finish$1; ++i$1){ + var c = s[i$1]; + var exit = 0; + if (c >= 35) { + if (c !== 92) { + if (c >= 127) { + exit = 1; + } else { + s$p[n] = c; + } + } else { + exit = 2; + } + } else if (c >= 32) { + if (c >= 34) { + exit = 2; + } else { + s$p[n] = c; + } + } else if (c >= 14) { + exit = 1; + } else { + switch (c) { + case 8 : + s$p[n] = /* '\\' */92; + n = n + 1 | 0; + s$p[n] = /* 'b' */98; + break; + case 9 : + s$p[n] = /* '\\' */92; + n = n + 1 | 0; + s$p[n] = /* 't' */116; + break; + case 10 : + s$p[n] = /* '\\' */92; + n = n + 1 | 0; + s$p[n] = /* 'n' */110; + break; + case 0 : + case 1 : + case 2 : + case 3 : + case 4 : + case 5 : + case 6 : + case 7 : + case 11 : + case 12 : + exit = 1; + break; + case 13 : + s$p[n] = /* '\\' */92; + n = n + 1 | 0; + s$p[n] = /* 'r' */114; + break; + + } + } + switch (exit) { + case 1 : + s$p[n] = /* '\\' */92; + n = n + 1 | 0; + s$p[n] = 48 + (c / 100 | 0) | 0; + n = n + 1 | 0; + s$p[n] = 48 + (c / 10 | 0) % 10 | 0; + n = n + 1 | 0; + s$p[n] = 48 + c % 10 | 0; + break; + case 2 : + s$p[n] = /* '\\' */92; + n = n + 1 | 0; + s$p[n] = c; + break; + + } + n = n + 1 | 0; + } + return s$p; +} + +function escaped(b) { + return unsafe_escape(copy(b)); +} + +function map(f, s) { + var l = s.length; + if (l === 0) { + return s; + } + var r = Caml_bytes.caml_create_bytes(l); + for(var i = 0; i < l; ++i){ + r[i] = Curry._1(f, s[i]); + } + return r; +} + +function mapi(f, s) { + var l = s.length; + if (l === 0) { + return s; + } + var r = Caml_bytes.caml_create_bytes(l); + for(var i = 0; i < l; ++i){ + r[i] = Curry._2(f, i, s[i]); + } + return r; +} + +function fold_left(f, x, a) { + var r = x; + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + r = Curry._2(f, r, a[i]); + } + return r; +} + +function fold_right(f, a, x) { + var r = x; + for(var i = a.length - 1 | 0; i >= 0; --i){ + r = Curry._2(f, a[i], r); + } + return r; +} + +function exists(p, s) { + var n = s.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return false; + } + if (Curry._1(p, s[i])) { + return true; + } + _i = i + 1 | 0; + continue ; + }; +} + +function for_all(p, s) { + var n = s.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return true; + } + if (!Curry._1(p, s[i])) { + return false; + } + _i = i + 1 | 0; + continue ; + }; +} + +function uppercase_ascii(s) { + return map(Stdlib__Char.uppercase_ascii, s); +} + +function lowercase_ascii(s) { + return map(Stdlib__Char.lowercase_ascii, s); +} + +function apply1(f, s) { + if (s.length === 0) { + return s; + } + var r = copy(s); + r[0] = Curry._1(f, s[0]); + return r; +} + +function capitalize_ascii(s) { + return apply1(Stdlib__Char.uppercase_ascii, s); +} + +function uncapitalize_ascii(s) { + return apply1(Stdlib__Char.lowercase_ascii, s); +} + +function starts_with(prefix, s) { + var len_s = s.length; + var len_pre = prefix.length; + if (len_s >= len_pre) { + var _i = 0; + while(true) { + var i = _i; + if (i === len_pre) { + return true; + } + if (s[i] !== prefix[i]) { + return false; + } + _i = i + 1 | 0; + continue ; + }; + } else { + return false; + } +} + +function ends_with(suffix, s) { + var len_s = s.length; + var len_suf = suffix.length; + var diff = len_s - len_suf | 0; + if (diff >= 0) { + var _i = 0; + while(true) { + var i = _i; + if (i === len_suf) { + return true; + } + if (s[diff + i | 0] !== suffix[i]) { + return false; + } + _i = i + 1 | 0; + continue ; + }; + } else { + return false; + } +} + +function index_rec(s, lim, _i, c) { + while(true) { + var i = _i; + if (i >= lim) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + if (s[i] === c) { + return i; + } + _i = i + 1 | 0; + continue ; + }; +} + +function index(s, c) { + return index_rec(s, s.length, 0, c); +} + +function index_rec_opt(s, lim, _i, c) { + while(true) { + var i = _i; + if (i >= lim) { + return ; + } + if (s[i] === c) { + return i; + } + _i = i + 1 | 0; + continue ; + }; +} + +function index_opt(s, c) { + return index_rec_opt(s, s.length, 0, c); +} + +function index_from(s, i, c) { + var l = s.length; + if (i < 0 || i > l) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from / Bytes.index_from", + Error: new Error() + }; + } + return index_rec(s, l, i, c); +} + +function index_from_opt(s, i, c) { + var l = s.length; + if (i < 0 || i > l) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from_opt / Bytes.index_from_opt", + Error: new Error() + }; + } + return index_rec_opt(s, l, i, c); +} + +function rindex_rec(s, _i, c) { + while(true) { + var i = _i; + if (i < 0) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + if (s[i] === c) { + return i; + } + _i = i - 1 | 0; + continue ; + }; +} + +function rindex(s, c) { + return rindex_rec(s, s.length - 1 | 0, c); +} + +function rindex_from(s, i, c) { + if (i < -1 || i >= s.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from / Bytes.rindex_from", + Error: new Error() + }; + } + return rindex_rec(s, i, c); +} + +function rindex_rec_opt(s, _i, c) { + while(true) { + var i = _i; + if (i < 0) { + return ; + } + if (s[i] === c) { + return i; + } + _i = i - 1 | 0; + continue ; + }; +} + +function rindex_opt(s, c) { + return rindex_rec_opt(s, s.length - 1 | 0, c); +} + +function rindex_from_opt(s, i, c) { + if (i < -1 || i >= s.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from_opt / Bytes.rindex_from_opt", + Error: new Error() + }; + } + return rindex_rec_opt(s, i, c); +} + +function contains_from(s, i, c) { + var l = s.length; + if (i < 0 || i > l) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.contains_from / Bytes.contains_from", + Error: new Error() + }; + } + try { + index_rec(s, l, i, c); + return true; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + return false; + } + throw exn; + } +} + +function contains(s, c) { + return contains_from(s, 0, c); +} + +function rcontains_from(s, i, c) { + if (i < 0 || i >= s.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.rcontains_from / Bytes.rcontains_from", + Error: new Error() + }; + } + try { + rindex_rec(s, i, c); + return true; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + return false; + } + throw exn; + } +} + +var compare = Caml_bytes.caml_bytes_compare; + +function split_on_char(sep, s) { + var r = /* [] */0; + var j = s.length; + for(var i = s.length - 1 | 0; i >= 0; --i){ + if (s[i] === sep) { + r = { + hd: sub(s, i + 1 | 0, (j - i | 0) - 1 | 0), + tl: r + }; + j = i; + } + + } + return { + hd: sub(s, 0, j), + tl: r + }; +} + +function to_seq(s) { + var aux = function (i, param) { + if (i === s.length) { + return /* Nil */0; + } + var x = Caml_bytes.get(s, i); + var partial_arg = i + 1 | 0; + return /* Cons */{ + _0: x, + _1: (function (param) { + return aux(partial_arg, param); + }) + }; + }; + return function (param) { + return aux(0, param); + }; +} + +function to_seqi(s) { + var aux = function (i, param) { + if (i === s.length) { + return /* Nil */0; + } + var x = Caml_bytes.get(s, i); + var partial_arg = i + 1 | 0; + return /* Cons */{ + _0: [ + i, + x + ], + _1: (function (param) { + return aux(partial_arg, param); + }) + }; + }; + return function (param) { + return aux(0, param); + }; +} + +function of_seq(i) { + var n = { + contents: 0 + }; + var buf = { + contents: make(256, /* '\000' */0) + }; + var resize = function (param) { + var new_len = Stdlib__Int.min((buf.contents.length << 1), Stdlib__Sys.max_string_length); + if (buf.contents.length === new_len) { + throw { + RE_EXN_ID: "Failure", + _1: "Bytes.of_seq: cannot grow bytes", + Error: new Error() + }; + } + var new_buf = make(new_len, /* '\000' */0); + blit(buf.contents, 0, new_buf, 0, n.contents); + buf.contents = new_buf; + }; + Stdlib__Seq.iter((function (c) { + if (n.contents === buf.contents.length) { + resize(undefined); + } + Caml_bytes.set(buf.contents, n.contents, c); + n.contents = n.contents + 1 | 0; + }), i); + return sub(buf.contents, 0, n.contents); +} + +function unsafe_get_uint16_le(b, i) { + if (Stdlib__Sys.big_endian) { + return Caml_bytes.bswap16(Caml_bytes.get16u(b, i)); + } else { + return Caml_bytes.get16u(b, i); + } +} + +function unsafe_get_uint16_be(b, i) { + if (Stdlib__Sys.big_endian) { + return Caml_bytes.get16u(b, i); + } else { + return Caml_bytes.bswap16(Caml_bytes.get16u(b, i)); + } +} + +function get_int8(b, i) { + return ((Caml_bytes.get(b, i) << (Stdlib__Sys.int_size - 8 | 0)) >> (Stdlib__Sys.int_size - 8 | 0)); +} + +function get_uint16_le(b, i) { + if (Stdlib__Sys.big_endian) { + return Caml_bytes.bswap16(Caml_bytes.get16(b, i)); + } else { + return Caml_bytes.get16(b, i); + } +} + +function get_uint16_be(b, i) { + if (Stdlib__Sys.big_endian) { + return Caml_bytes.get16(b, i); + } else { + return Caml_bytes.bswap16(Caml_bytes.get16(b, i)); + } +} + +function get_int16_ne(b, i) { + return ((Caml_bytes.get16(b, i) << (Stdlib__Sys.int_size - 16 | 0)) >> (Stdlib__Sys.int_size - 16 | 0)); +} + +function get_int16_le(b, i) { + return ((get_uint16_le(b, i) << (Stdlib__Sys.int_size - 16 | 0)) >> (Stdlib__Sys.int_size - 16 | 0)); +} + +function get_int16_be(b, i) { + return ((get_uint16_be(b, i) << (Stdlib__Sys.int_size - 16 | 0)) >> (Stdlib__Sys.int_size - 16 | 0)); +} + +function get_int32_le(b, i) { + if (Stdlib__Sys.big_endian) { + return Caml_bytes.bswap32(Caml_bytes.get32(b, i)); + } else { + return Caml_bytes.get32(b, i); + } +} + +function get_int32_be(b, i) { + if (Stdlib__Sys.big_endian) { + return Caml_bytes.get32(b, i); + } else { + return Caml_bytes.bswap32(Caml_bytes.get32(b, i)); + } +} + +function get_int64_le(b, i) { + if (Stdlib__Sys.big_endian) { + return Caml_bytes.bswap64(Caml_bytes.get64(b, i)); + } else { + return Caml_bytes.get64(b, i); + } +} + +function get_int64_be(b, i) { + if (Stdlib__Sys.big_endian) { + return Caml_bytes.get64(b, i); + } else { + return Caml_bytes.bswap64(Caml_bytes.get64(b, i)); + } +} + +function unsafe_set_uint16_le(b, i, x) { + if (Stdlib__Sys.big_endian) { + return Caml_bytes.set16u(b, i, Caml_bytes.bswap16(x)); + } else { + return Caml_bytes.set16u(b, i, x); + } +} + +function unsafe_set_uint16_be(b, i, x) { + if (Stdlib__Sys.big_endian) { + return Caml_bytes.set16u(b, i, x); + } else { + return Caml_bytes.set16u(b, i, Caml_bytes.bswap16(x)); + } +} + +function set_int16_le(b, i, x) { + if (Stdlib__Sys.big_endian) { + return Caml_bytes.set16(b, i, Caml_bytes.bswap16(x)); + } else { + return Caml_bytes.set16(b, i, x); + } +} + +function set_int16_be(b, i, x) { + if (Stdlib__Sys.big_endian) { + return Caml_bytes.set16(b, i, x); + } else { + return Caml_bytes.set16(b, i, Caml_bytes.bswap16(x)); + } +} + +function set_int32_le(b, i, x) { + if (Stdlib__Sys.big_endian) { + return Caml_bytes.set32(b, i, Caml_bytes.bswap32(x)); + } else { + return Caml_bytes.set32(b, i, x); + } +} + +function set_int32_be(b, i, x) { + if (Stdlib__Sys.big_endian) { + return Caml_bytes.set32(b, i, x); + } else { + return Caml_bytes.set32(b, i, Caml_bytes.bswap32(x)); + } +} + +function set_int64_le(b, i, x) { + if (Stdlib__Sys.big_endian) { + return Caml_bytes.set64(b, i, Caml_bytes.bswap64(x)); + } else { + return Caml_bytes.set64(b, i, x); + } +} + +function set_int64_be(b, i, x) { + if (Stdlib__Sys.big_endian) { + return Caml_bytes.set64(b, i, x); + } else { + return Caml_bytes.set64(b, i, Caml_bytes.bswap64(x)); + } +} + +var set_uint8 = Caml_bytes.set; + +var set_uint16_ne = Caml_bytes.set16; + +function get_utf_8_uchar(b, i) { + var b0 = Caml_bytes.get(b, i); + var max = b.length - 1 | 0; + var exit = 0; + if (b0 >= 224) { + if (b0 >= 237) { + if (b0 >= 245) { + return 16842749; + } + switch (b0) { + case 237 : + var i$1 = i + 1 | 0; + if (i$1 > max) { + return 16842749; + } + var b1 = b[i$1]; + if ((b1 >>> 5) !== 4) { + return 16842749; + } + var i$2 = i$1 + 1 | 0; + if (i$2 > max) { + return 33619965; + } + var b2 = b[i$2]; + if ((b2 >>> 6) !== 2) { + return 33619965; + } + var u = ((b0 & 15) << 12) | ((b1 & 63) << 6) | b2 & 63; + return 184549376 | u; + case 238 : + case 239 : + exit = 1; + break; + case 240 : + var i$3 = i + 1 | 0; + if (i$3 > max) { + return 16842749; + } + var b1$1 = b[i$3]; + if (b1$1 < 144 || 191 < b1$1) { + return 16842749; + } + var i$4 = i$3 + 1 | 0; + if (i$4 > max) { + return 33619965; + } + var b2$1 = b[i$4]; + if ((b2$1 >>> 6) !== 2) { + return 33619965; + } + var i$5 = i$4 + 1 | 0; + if (i$5 > max) { + return 50397181; + } + var b3 = b[i$5]; + if ((b3 >>> 6) !== 2) { + return 50397181; + } + var u$1 = ((b0 & 7) << 18) | ((b1$1 & 63) << 12) | ((b2$1 & 63) << 6) | b3 & 63; + return 201326592 | u$1; + case 241 : + case 242 : + case 243 : + exit = 2; + break; + case 244 : + var i$6 = i + 1 | 0; + if (i$6 > max) { + return 16842749; + } + var b1$2 = b[i$6]; + if ((b1$2 >>> 4) !== 8) { + return 16842749; + } + var i$7 = i$6 + 1 | 0; + if (i$7 > max) { + return 33619965; + } + var b2$2 = b[i$7]; + if ((b2$2 >>> 6) !== 2) { + return 33619965; + } + var i$8 = i$7 + 1 | 0; + if (i$8 > max) { + return 50397181; + } + var b3$1 = b[i$8]; + if ((b3$1 >>> 6) !== 2) { + return 50397181; + } + var u$2 = ((b0 & 7) << 18) | ((b1$2 & 63) << 12) | ((b2$2 & 63) << 6) | b3$1 & 63; + return 201326592 | u$2; + + } + } else if (b0 >= 225) { + exit = 1; + } else { + var i$9 = i + 1 | 0; + if (i$9 > max) { + return 16842749; + } + var b1$3 = b[i$9]; + if ((b1$3 >>> 5) !== 5) { + return 16842749; + } + var i$10 = i$9 + 1 | 0; + if (i$10 > max) { + return 33619965; + } + var b2$3 = b[i$10]; + if ((b2$3 >>> 6) !== 2) { + return 33619965; + } + var u$3 = ((b0 & 15) << 12) | ((b1$3 & 63) << 6) | b2$3 & 63; + return 184549376 | u$3; + } + } else { + if (b0 < 128) { + return 150994944 | b0; + } + if (b0 < 194) { + return 16842749; + } + var i$11 = i + 1 | 0; + if (i$11 > max) { + return 16842749; + } + var b1$4 = b[i$11]; + if ((b1$4 >>> 6) !== 2) { + return 16842749; + } + var u$4 = ((b0 & 31) << 6) | b1$4 & 63; + return 167772160 | u$4; + } + switch (exit) { + case 1 : + var i$12 = i + 1 | 0; + if (i$12 > max) { + return 16842749; + } + var b1$5 = b[i$12]; + if ((b1$5 >>> 6) !== 2) { + return 16842749; + } + var i$13 = i$12 + 1 | 0; + if (i$13 > max) { + return 33619965; + } + var b2$4 = b[i$13]; + if ((b2$4 >>> 6) !== 2) { + return 33619965; + } + var u$5 = ((b0 & 15) << 12) | ((b1$5 & 63) << 6) | b2$4 & 63; + return 184549376 | u$5; + case 2 : + var i$14 = i + 1 | 0; + if (i$14 > max) { + return 16842749; + } + var b1$6 = b[i$14]; + if ((b1$6 >>> 6) !== 2) { + return 16842749; + } + var i$15 = i$14 + 1 | 0; + if (i$15 > max) { + return 33619965; + } + var b2$5 = b[i$15]; + if ((b2$5 >>> 6) !== 2) { + return 33619965; + } + var i$16 = i$15 + 1 | 0; + if (i$16 > max) { + return 50397181; + } + var b3$2 = b[i$16]; + if ((b3$2 >>> 6) !== 2) { + return 50397181; + } + var u$6 = ((b0 & 7) << 18) | ((b1$6 & 63) << 12) | ((b2$5 & 63) << 6) | b3$2 & 63; + return 201326592 | u$6; + + } +} + +function set_utf_8_uchar(b, i, u) { + var max = b.length - 1 | 0; + var u$1 = u; + if (u$1 < 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bytes.cppo.ml", + 654, + 20 + ], + Error: new Error() + }; + } + if (u$1 <= 127) { + Caml_bytes.set(b, i, u$1); + return 1; + } + if (u$1 <= 2047) { + var last = i + 1 | 0; + if (last > max) { + return 0; + } else { + Caml_bytes.set(b, i, 192 | (u$1 >>> 6)); + b[last] = 128 | u$1 & 63; + return 2; + } + } + if (u$1 <= 65535) { + var last$1 = i + 2 | 0; + if (last$1 > max) { + return 0; + } else { + Caml_bytes.set(b, i, 224 | (u$1 >>> 12)); + b[i + 1 | 0] = 128 | (u$1 >>> 6) & 63; + b[last$1] = 128 | u$1 & 63; + return 3; + } + } + if (u$1 <= 1114111) { + var last$2 = i + 3 | 0; + if (last$2 > max) { + return 0; + } else { + Caml_bytes.set(b, i, 240 | (u$1 >>> 18)); + b[i + 1 | 0] = 128 | (u$1 >>> 12) & 63; + b[i + 2 | 0] = 128 | (u$1 >>> 6) & 63; + b[last$2] = 128 | u$1 & 63; + return 4; + } + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bytes.cppo.ml", + 679, + 9 + ], + Error: new Error() + }; +} + +function is_valid_utf_8(b) { + var max = b.length - 1 | 0; + var _i = 0; + while(true) { + var i = _i; + if (i > max) { + return true; + } + var match = b[i]; + var exit = 0; + if (match >= 224) { + if (match >= 237) { + if (match >= 245) { + return false; + } + switch (match) { + case 237 : + var last = i + 2 | 0; + if (last > max || (b[i + 1 | 0] >>> 5) !== 4 || (b[last] >>> 6) !== 2) { + return false; + } + _i = last + 1 | 0; + continue ; + case 238 : + case 239 : + exit = 1; + break; + case 240 : + var last$1 = i + 3 | 0; + var tmp = true; + if (last$1 <= max) { + var b$1 = b[i + 1 | 0]; + tmp = b$1 < 144 || 191 < b$1 || (b[i + 2 | 0] >>> 6) !== 2 || (b[last$1] >>> 6) !== 2; + } + if (tmp) { + return false; + } + _i = last$1 + 1 | 0; + continue ; + case 241 : + case 242 : + case 243 : + exit = 2; + break; + case 244 : + var last$2 = i + 3 | 0; + if (last$2 > max || (b[i + 1 | 0] >>> 4) !== 8 || (b[i + 2 | 0] >>> 6) !== 2 || (b[last$2] >>> 6) !== 2) { + return false; + } + _i = last$2 + 1 | 0; + continue ; + + } + } else if (match >= 225) { + exit = 1; + } else { + var last$3 = i + 2 | 0; + if (last$3 > max || (b[i + 1 | 0] >>> 5) !== 5 || (b[last$3] >>> 6) !== 2) { + return false; + } + _i = last$3 + 1 | 0; + continue ; + } + } else { + if (match >= 128) { + if (match < 194) { + return false; + } + var last$4 = i + 1 | 0; + if (last$4 > max || (b[last$4] >>> 6) !== 2) { + return false; + } + _i = last$4 + 1 | 0; + continue ; + } + _i = i + 1 | 0; + continue ; + } + switch (exit) { + case 1 : + var last$5 = i + 2 | 0; + if (last$5 > max || (b[i + 1 | 0] >>> 6) !== 2 || (b[last$5] >>> 6) !== 2) { + return false; + } + _i = last$5 + 1 | 0; + continue ; + case 2 : + var last$6 = i + 3 | 0; + if (last$6 > max || (b[i + 1 | 0] >>> 6) !== 2 || (b[i + 2 | 0] >>> 6) !== 2 || (b[last$6] >>> 6) !== 2) { + return false; + } + _i = last$6 + 1 | 0; + continue ; + + } + }; +} + +function get_utf_16be_uchar(b, i) { + var max = b.length - 1 | 0; + if (i < 0 || i > max) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds", + Error: new Error() + }; + } + if (i === max) { + return 16842749; + } + var u = unsafe_get_uint16_be(b, i); + if (u < 55296 || u > 57343) { + return 167772160 | u; + } + if (u > 56319) { + return 33619965; + } + var last = i + 3 | 0; + if (last > max) { + return (((max - i | 0) + 1 | 0) << 24) | 65533; + } + var u$1 = unsafe_get_uint16_be(b, i + 2 | 0); + if (u$1 < 56320 || u$1 > 57343) { + return 33619965; + } + var u$2 = (((u & 1023) << 10) | u$1 & 1023) + 65536 | 0; + return 201326592 | u$2; +} + +function set_utf_16be_uchar(b, i, u) { + var max = b.length - 1 | 0; + if (i < 0 || i > max) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds", + Error: new Error() + }; + } + var u$1 = u; + if (u$1 < 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bytes.cppo.ml", + 766, + 20 + ], + Error: new Error() + }; + } + if (u$1 <= 65535) { + var last = i + 1 | 0; + if (last > max) { + return 0; + } else { + unsafe_set_uint16_be(b, i, u$1); + return 2; + } + } + if (u$1 <= 1114111) { + var last$1 = i + 3 | 0; + if (last$1 > max) { + return 0; + } + var u$p = u$1 - 65536 | 0; + var hi = 55296 | (u$p >>> 10); + var lo = 56320 | u$p & 1023; + unsafe_set_uint16_be(b, i, hi); + unsafe_set_uint16_be(b, i + 2 | 0, lo); + return 4; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bytes.cppo.ml", + 777, + 9 + ], + Error: new Error() + }; +} + +function is_valid_utf_16be(b) { + var max = b.length - 1 | 0; + var _i = 0; + while(true) { + var i = _i; + if (i > max) { + return true; + } + if (i === max) { + return false; + } + var u = unsafe_get_uint16_be(b, i); + if (u < 55296 || u > 57343) { + _i = i + 2 | 0; + continue ; + } + if (u > 56319) { + return false; + } + var last = i + 3 | 0; + if (last > max) { + return false; + } + var u$1 = unsafe_get_uint16_be(b, i + 2 | 0); + if (u$1 < 56320 || u$1 > 57343) { + return false; + } + _i = i + 4 | 0; + continue ; + }; +} + +function get_utf_16le_uchar(b, i) { + var max = b.length - 1 | 0; + if (i < 0 || i > max) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds", + Error: new Error() + }; + } + if (i === max) { + return 16842749; + } + var u = unsafe_get_uint16_le(b, i); + if (u < 55296 || u > 57343) { + return 167772160 | u; + } + if (u > 56319) { + return 33619965; + } + var last = i + 3 | 0; + if (last > max) { + return (((max - i | 0) + 1 | 0) << 24) | 65533; + } + var u$1 = unsafe_get_uint16_le(b, i + 2 | 0); + if (u$1 < 56320 || u$1 > 57343) { + return 33619965; + } + var u$2 = (((u & 1023) << 10) | u$1 & 1023) + 65536 | 0; + return 201326592 | u$2; +} + +function set_utf_16le_uchar(b, i, u) { + var max = b.length - 1 | 0; + if (i < 0 || i > max) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "index out of bounds", + Error: new Error() + }; + } + var u$1 = u; + if (u$1 < 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bytes.cppo.ml", + 820, + 20 + ], + Error: new Error() + }; + } + if (u$1 <= 65535) { + var last = i + 1 | 0; + if (last > max) { + return 0; + } else { + unsafe_set_uint16_le(b, i, u$1); + return 2; + } + } + if (u$1 <= 1114111) { + var last$1 = i + 3 | 0; + if (last$1 > max) { + return 0; + } + var u$p = u$1 - 65536 | 0; + var hi = 55296 | (u$p >>> 10); + var lo = 56320 | u$p & 1023; + unsafe_set_uint16_le(b, i, hi); + unsafe_set_uint16_le(b, i + 2 | 0, lo); + return 4; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "bytes.cppo.ml", + 831, + 9 + ], + Error: new Error() + }; +} + +function is_valid_utf_16le(b) { + var max = b.length - 1 | 0; + var _i = 0; + while(true) { + var i = _i; + if (i > max) { + return true; + } + if (i === max) { + return false; + } + var u = unsafe_get_uint16_le(b, i); + if (u < 55296 || u > 57343) { + _i = i + 2 | 0; + continue ; + } + if (u > 56319) { + return false; + } + var last = i + 3 | 0; + if (last > max) { + return false; + } + var u$1 = unsafe_get_uint16_le(b, i + 2 | 0); + if (u$1 < 56320 || u$1 > 57343) { + return false; + } + _i = i + 4 | 0; + continue ; + }; +} + +var equal = Caml_bytes.caml_bytes_equal; + +var unsafe_to_string = Caml_bytes.bytes_to_string; + +var unsafe_of_string = Caml_bytes.bytes_of_string; + +var get_uint8 = Caml_bytes.get; + +var get_uint16_ne = Caml_bytes.get16; + +var get_int32_ne = Caml_bytes.get32; + +var get_int64_ne = Caml_bytes.get64; + +var set_int8 = Caml_bytes.set; + +var set_uint16_be = set_int16_be; + +var set_uint16_le = set_int16_le; + +var set_int16_ne = Caml_bytes.set16; + +var set_int32_ne = Caml_bytes.set32; + +var set_int64_ne = Caml_bytes.set64; + +export { + make , + init , + empty , + copy , + of_string , + to_string , + sub , + sub_string , + extend , + fill , + blit , + blit_string , + concat , + cat , + iter , + iteri , + map , + mapi , + fold_left , + fold_right , + for_all , + exists , + trim , + escaped , + index , + index_opt , + rindex , + rindex_opt , + index_from , + index_from_opt , + rindex_from , + rindex_from_opt , + contains , + contains_from , + rcontains_from , + uppercase_ascii , + lowercase_ascii , + capitalize_ascii , + uncapitalize_ascii , + compare , + equal , + starts_with , + ends_with , + unsafe_to_string , + unsafe_of_string , + split_on_char , + to_seq , + to_seqi , + of_seq , + get_utf_8_uchar , + set_utf_8_uchar , + is_valid_utf_8 , + get_utf_16be_uchar , + set_utf_16be_uchar , + is_valid_utf_16be , + get_utf_16le_uchar , + set_utf_16le_uchar , + is_valid_utf_16le , + get_uint8 , + get_int8 , + get_uint16_ne , + get_uint16_be , + get_uint16_le , + get_int16_ne , + get_int16_be , + get_int16_le , + get_int32_ne , + get_int32_be , + get_int32_le , + get_int64_ne , + get_int64_be , + get_int64_le , + set_uint8 , + set_int8 , + set_uint16_ne , + set_uint16_be , + set_uint16_le , + set_int16_ne , + set_int16_be , + set_int16_le , + set_int32_ne , + set_int32_be , + set_int32_le , + set_int64_ne , + set_int64_be , + set_int64_le , + unsafe_escape , +} +/* No side effect */ diff --git a/melange-node-modules/melange/bytesLabels.js b/melange-node-modules/melange/bytesLabels.js new file mode 100644 index 0000000..90e75d5 --- /dev/null +++ b/melange-node-modules/melange/bytesLabels.js @@ -0,0 +1,157 @@ +// Generated by Melange + +import * as Stdlib__Bytes from "./bytes.js"; + +var make = Stdlib__Bytes.make; + +var init = Stdlib__Bytes.init; + +var empty = Stdlib__Bytes.empty; + +var copy = Stdlib__Bytes.copy; + +var of_string = Stdlib__Bytes.of_string; + +var to_string = Stdlib__Bytes.to_string; + +var sub = Stdlib__Bytes.sub; + +var sub_string = Stdlib__Bytes.sub_string; + +var extend = Stdlib__Bytes.extend; + +var fill = Stdlib__Bytes.fill; + +var blit = Stdlib__Bytes.blit; + +var blit_string = Stdlib__Bytes.blit_string; + +var concat = Stdlib__Bytes.concat; + +var cat = Stdlib__Bytes.cat; + +var iter = Stdlib__Bytes.iter; + +var iteri = Stdlib__Bytes.iteri; + +var map = Stdlib__Bytes.map; + +var mapi = Stdlib__Bytes.mapi; + +var fold_left = Stdlib__Bytes.fold_left; + +var fold_right = Stdlib__Bytes.fold_right; + +var for_all = Stdlib__Bytes.for_all; + +var exists = Stdlib__Bytes.exists; + +var trim = Stdlib__Bytes.trim; + +var escaped = Stdlib__Bytes.escaped; + +var index = Stdlib__Bytes.index; + +var index_opt = Stdlib__Bytes.index_opt; + +var rindex = Stdlib__Bytes.rindex; + +var rindex_opt = Stdlib__Bytes.rindex_opt; + +var index_from = Stdlib__Bytes.index_from; + +var index_from_opt = Stdlib__Bytes.index_from_opt; + +var rindex_from = Stdlib__Bytes.rindex_from; + +var rindex_from_opt = Stdlib__Bytes.rindex_from_opt; + +var contains = Stdlib__Bytes.contains; + +var contains_from = Stdlib__Bytes.contains_from; + +var rcontains_from = Stdlib__Bytes.rcontains_from; + +var uppercase_ascii = Stdlib__Bytes.uppercase_ascii; + +var lowercase_ascii = Stdlib__Bytes.lowercase_ascii; + +var capitalize_ascii = Stdlib__Bytes.capitalize_ascii; + +var uncapitalize_ascii = Stdlib__Bytes.uncapitalize_ascii; + +var compare = Stdlib__Bytes.compare; + +var equal = Stdlib__Bytes.equal; + +var starts_with = Stdlib__Bytes.starts_with; + +var ends_with = Stdlib__Bytes.ends_with; + +var unsafe_to_string = Stdlib__Bytes.unsafe_to_string; + +var unsafe_of_string = Stdlib__Bytes.unsafe_of_string; + +var split_on_char = Stdlib__Bytes.split_on_char; + +var to_seq = Stdlib__Bytes.to_seq; + +var to_seqi = Stdlib__Bytes.to_seqi; + +var of_seq = Stdlib__Bytes.of_seq; + +var unsafe_escape = Stdlib__Bytes.unsafe_escape; + +export { + make , + init , + empty , + copy , + of_string , + to_string , + sub , + sub_string , + extend , + fill , + blit , + blit_string , + concat , + cat , + iter , + iteri , + map , + mapi , + fold_left , + fold_right , + for_all , + exists , + trim , + escaped , + index , + index_opt , + rindex , + rindex_opt , + index_from , + index_from_opt , + rindex_from , + rindex_from_opt , + contains , + contains_from , + rcontains_from , + uppercase_ascii , + lowercase_ascii , + capitalize_ascii , + uncapitalize_ascii , + compare , + equal , + starts_with , + ends_with , + unsafe_to_string , + unsafe_of_string , + split_on_char , + to_seq , + to_seqi , + of_seq , + unsafe_escape , +} +/* No side effect */ diff --git a/melange-node-modules/melange/callback.js b/melange-node-modules/melange/callback.js new file mode 100644 index 0000000..ad98eea --- /dev/null +++ b/melange-node-modules/melange/callback.js @@ -0,0 +1,19 @@ +// Generated by Melange + +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Stdlib__Obj from "./obj.js"; + +function register(name, v) { + Caml_external_polyfill.resolve("caml_register_named_value")(name, v); +} + +function register_exception(name, exn) { + var slot = (exn.TAG | 0) === Stdlib__Obj.object_tag ? exn : exn[0]; + Caml_external_polyfill.resolve("caml_register_named_value")(name, slot); +} + +export { + register , + register_exception , +} +/* No side effect */ diff --git a/melange-node-modules/melange/camlinternalAtomic.js b/melange-node-modules/melange/camlinternalAtomic.js new file mode 100644 index 0000000..c995a3c --- /dev/null +++ b/melange-node-modules/melange/camlinternalAtomic.js @@ -0,0 +1,58 @@ +// Generated by Melange + + +function make(v) { + return { + v: v + }; +} + +function get(r) { + return r.v; +} + +function set(r, v) { + r.v = v; +} + +function exchange(r, v) { + var cur = r.v; + r.v = v; + return cur; +} + +function compare_and_set(r, seen, v) { + var cur = r.v; + if (cur === seen) { + r.v = v; + return true; + } else { + return false; + } +} + +function fetch_and_add(r, n) { + var cur = r.v; + r.v = cur + n | 0; + return cur; +} + +function incr(r) { + fetch_and_add(r, 1); +} + +function decr(r) { + fetch_and_add(r, -1); +} + +export { + make , + get , + set , + exchange , + compare_and_set , + fetch_and_add , + incr , + decr , +} +/* No side effect */ diff --git a/melange-node-modules/melange/camlinternalFormat.js b/melange-node-modules/melange/camlinternalFormat.js new file mode 100644 index 0000000..b2d01b4 --- /dev/null +++ b/melange-node-modules/melange/camlinternalFormat.js @@ -0,0 +1,7495 @@ +// Generated by Melange + +import * as Caml_bytes from "melange.js/caml_bytes.js"; +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; +import * as Caml_format from "melange.js/caml_format.js"; +import * as Caml_io from "melange.js/caml_io.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Caml_obj from "melange.js/caml_obj.js"; +import * as Caml_string from "melange.js/caml_string.js"; +import * as CamlinternalFormatBasics from "./camlinternalFormatBasics.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Buffer from "./buffer.js"; +import * as Stdlib__Bytes from "./bytes.js"; +import * as Stdlib__Char from "./char.js"; +import * as Stdlib__Int from "./int.js"; +import * as Stdlib__String from "./string.js"; + +function create_char_set(param) { + return Stdlib__Bytes.make(32, /* '\000' */0); +} + +function add_in_char_set(char_set, c) { + var str_ind = (c >>> 3); + var mask = (1 << (c & 7)); + Caml_bytes.set(char_set, str_ind, Stdlib.char_of_int(Caml_bytes.get(char_set, str_ind) | mask)); +} + +var freeze_char_set = Stdlib__Bytes.to_string; + +function rev_char_set(char_set) { + var char_set$p = Stdlib__Bytes.make(32, /* '\000' */0); + for(var i = 0; i <= 31; ++i){ + Caml_bytes.set(char_set$p, i, Stdlib.char_of_int(Caml_string.get(char_set, i) ^ 255)); + } + return Caml_bytes.bytes_to_string(char_set$p); +} + +function is_in_char_set(char_set, c) { + var str_ind = (c >>> 3); + var mask = (1 << (c & 7)); + return (Caml_string.get(char_set, str_ind) & mask) !== 0; +} + +function pad_of_pad_opt(pad_opt) { + if (pad_opt !== undefined) { + return { + TAG: /* Lit_padding */0, + _0: /* Right */1, + _1: pad_opt + }; + } else { + return /* No_padding */0; + } +} + +function prec_of_prec_opt(prec_opt) { + if (prec_opt !== undefined) { + return /* Lit_precision */{ + _0: prec_opt + }; + } else { + return /* No_precision */0; + } +} + +function param_format_of_ignored_format(ign, fmt) { + if (typeof ign === "number") { + switch (ign) { + case /* Ignored_char */0 : + return /* Param_format_EBB */{ + _0: { + TAG: /* Char */0, + _0: fmt + } + }; + case /* Ignored_caml_char */1 : + return /* Param_format_EBB */{ + _0: { + TAG: /* Caml_char */1, + _0: fmt + } + }; + case /* Ignored_reader */2 : + return /* Param_format_EBB */{ + _0: { + TAG: /* Reader */19, + _0: fmt + } + }; + case /* Ignored_scan_next_char */3 : + return /* Param_format_EBB */{ + _0: { + TAG: /* Scan_next_char */22, + _0: fmt + } + }; + + } + } else { + switch (ign.TAG | 0) { + case /* Ignored_string */0 : + return /* Param_format_EBB */{ + _0: { + TAG: /* String */2, + _0: pad_of_pad_opt(ign._0), + _1: fmt + } + }; + case /* Ignored_caml_string */1 : + return /* Param_format_EBB */{ + _0: { + TAG: /* Caml_string */3, + _0: pad_of_pad_opt(ign._0), + _1: fmt + } + }; + case /* Ignored_int */2 : + return /* Param_format_EBB */{ + _0: { + TAG: /* Int */4, + _0: ign._0, + _1: pad_of_pad_opt(ign._1), + _2: /* No_precision */0, + _3: fmt + } + }; + case /* Ignored_int32 */3 : + return /* Param_format_EBB */{ + _0: { + TAG: /* Int32 */5, + _0: ign._0, + _1: pad_of_pad_opt(ign._1), + _2: /* No_precision */0, + _3: fmt + } + }; + case /* Ignored_nativeint */4 : + return /* Param_format_EBB */{ + _0: { + TAG: /* Nativeint */6, + _0: ign._0, + _1: pad_of_pad_opt(ign._1), + _2: /* No_precision */0, + _3: fmt + } + }; + case /* Ignored_int64 */5 : + return /* Param_format_EBB */{ + _0: { + TAG: /* Int64 */7, + _0: ign._0, + _1: pad_of_pad_opt(ign._1), + _2: /* No_precision */0, + _3: fmt + } + }; + case /* Ignored_float */6 : + return /* Param_format_EBB */{ + _0: { + TAG: /* Float */8, + _0: [ + /* Float_flag_ */0, + /* Float_f */0 + ], + _1: pad_of_pad_opt(ign._0), + _2: prec_of_prec_opt(ign._1), + _3: fmt + } + }; + case /* Ignored_bool */7 : + return /* Param_format_EBB */{ + _0: { + TAG: /* Bool */9, + _0: pad_of_pad_opt(ign._0), + _1: fmt + } + }; + case /* Ignored_format_arg */8 : + return /* Param_format_EBB */{ + _0: { + TAG: /* Format_arg */13, + _0: ign._0, + _1: ign._1, + _2: fmt + } + }; + case /* Ignored_format_subst */9 : + return /* Param_format_EBB */{ + _0: { + TAG: /* Format_subst */14, + _0: ign._0, + _1: ign._1, + _2: fmt + } + }; + case /* Ignored_scan_char_set */10 : + return /* Param_format_EBB */{ + _0: { + TAG: /* Scan_char_set */20, + _0: ign._0, + _1: ign._1, + _2: fmt + } + }; + case /* Ignored_scan_get_counter */11 : + return /* Param_format_EBB */{ + _0: { + TAG: /* Scan_get_counter */21, + _0: ign._0, + _1: fmt + } + }; + + } + } +} + +function default_float_precision(fconv) { + var match = fconv[1]; + if (match !== 5) { + return -6; + } else { + return 12; + } +} + +function buffer_check_size(buf, overhead) { + var len = buf.bytes.length; + var min_len = buf.ind + overhead | 0; + if (min_len <= len) { + return ; + } + var new_len = Stdlib__Int.max((len << 1), min_len); + var new_str = Caml_bytes.caml_create_bytes(new_len); + Stdlib__Bytes.blit(buf.bytes, 0, new_str, 0, len); + buf.bytes = new_str; +} + +function buffer_add_char(buf, c) { + buffer_check_size(buf, 1); + Caml_bytes.set(buf.bytes, buf.ind, c); + buf.ind = buf.ind + 1 | 0; +} + +function buffer_add_string(buf, s) { + var str_len = s.length; + buffer_check_size(buf, str_len); + Stdlib__String.blit(s, 0, buf.bytes, buf.ind, str_len); + buf.ind = buf.ind + str_len | 0; +} + +function buffer_contents(buf) { + return Stdlib__Bytes.sub_string(buf.bytes, 0, buf.ind); +} + +function char_of_iconv(iconv) { + switch (iconv) { + case /* Int_x */6 : + case /* Int_Cx */7 : + return /* 'x' */120; + case /* Int_X */8 : + case /* Int_CX */9 : + return /* 'X' */88; + case /* Int_o */10 : + case /* Int_Co */11 : + return /* 'o' */111; + case /* Int_d */0 : + case /* Int_pd */1 : + case /* Int_sd */2 : + case /* Int_Cd */13 : + return /* 'd' */100; + case /* Int_i */3 : + case /* Int_pi */4 : + case /* Int_si */5 : + case /* Int_Ci */14 : + return /* 'i' */105; + case /* Int_u */12 : + case /* Int_Cu */15 : + return /* 'u' */117; + + } +} + +function char_of_fconv(cFOpt, fconv) { + var cF = cFOpt !== undefined ? cFOpt : /* 'F' */70; + var match = fconv[1]; + switch (match) { + case /* Float_f */0 : + return /* 'f' */102; + case /* Float_e */1 : + return /* 'e' */101; + case /* Float_E */2 : + return /* 'E' */69; + case /* Float_g */3 : + return /* 'g' */103; + case /* Float_G */4 : + return /* 'G' */71; + case /* Float_F */5 : + return cF; + case /* Float_h */6 : + return /* 'h' */104; + case /* Float_H */7 : + return /* 'H' */72; + case /* Float_CF */8 : + return /* 'F' */70; + + } +} + +function char_of_counter(counter) { + switch (counter) { + case /* Line_counter */0 : + return /* 'l' */108; + case /* Char_counter */1 : + return /* 'n' */110; + case /* Token_counter */2 : + return /* 'N' */78; + + } +} + +function bprint_char_set(buf, char_set) { + var print_out = function (set, _i) { + while(true) { + var i = _i; + if (i >= 256) { + return ; + } + if (is_in_char_set(set, Stdlib.char_of_int(i))) { + var match = Stdlib.char_of_int(i); + if (match > 93 || match < 45) { + if (match >= 255) { + return print_char(buf, 255); + } else { + return print_second(set, i + 1 | 0); + } + } else if (match > 92 || match < 46) { + return print_out(set, i + 1 | 0); + } else { + return print_second(set, i + 1 | 0); + } + } + _i = i + 1 | 0; + continue ; + }; + }; + var print_char = function (buf, i) { + var c = Stdlib.char_of_int(i); + if (c !== 37) { + if (c !== 64) { + return buffer_add_char(buf, c); + } else { + buffer_add_char(buf, /* '%' */37); + return buffer_add_char(buf, /* '@' */64); + } + } else { + buffer_add_char(buf, /* '%' */37); + return buffer_add_char(buf, /* '%' */37); + } + }; + var print_second = function (set, i) { + if (is_in_char_set(set, Stdlib.char_of_int(i))) { + var match = Stdlib.char_of_int(i); + if (match > 93 || match < 45) { + if (match >= 255) { + print_char(buf, 254); + return print_char(buf, 255); + } + + } else if ((match > 92 || match < 46) && !is_in_char_set(set, Stdlib.char_of_int(i + 1 | 0))) { + print_char(buf, i - 1 | 0); + return print_out(set, i + 1 | 0); + } + if (is_in_char_set(set, Stdlib.char_of_int(i + 1 | 0))) { + var i$1 = i - 1 | 0; + var _j = i + 2 | 0; + while(true) { + var j = _j; + if (j === 256 || !is_in_char_set(set, Stdlib.char_of_int(j))) { + print_char(buf, i$1); + print_char(buf, /* '-' */45); + print_char(buf, j - 1 | 0); + if (j < 256) { + return print_out(set, j + 1 | 0); + } else { + return ; + } + } + _j = j + 1 | 0; + continue ; + }; + } else { + print_char(buf, i - 1 | 0); + print_char(buf, i); + return print_out(set, i + 2 | 0); + } + } + print_char(buf, i - 1 | 0); + print_out(set, i + 1 | 0); + }; + var print_start = function (set) { + var is_alone = function (c) { + var before = Stdlib__Char.chr(c - 1 | 0); + var after = Stdlib__Char.chr(c + 1 | 0); + if (is_in_char_set(set, c)) { + return !(is_in_char_set(set, before) && is_in_char_set(set, after)); + } else { + return false; + } + }; + if (is_alone(/* ']' */93)) { + buffer_add_char(buf, /* ']' */93); + } + print_out(set, 1); + if (is_alone(/* '-' */45)) { + return buffer_add_char(buf, /* '-' */45); + } + + }; + buffer_add_char(buf, /* '[' */91); + print_start(is_in_char_set(char_set, /* '\000' */0) ? (buffer_add_char(buf, /* '^' */94), rev_char_set(char_set)) : char_set); + buffer_add_char(buf, /* ']' */93); +} + +function bprint_padty(buf, padty) { + switch (padty) { + case /* Left */0 : + return buffer_add_char(buf, /* '-' */45); + case /* Right */1 : + return ; + case /* Zeros */2 : + return buffer_add_char(buf, /* '0' */48); + + } +} + +function bprint_ignored_flag(buf, ign_flag) { + if (ign_flag) { + return buffer_add_char(buf, /* '_' */95); + } + +} + +function bprint_pad_opt(buf, pad_opt) { + if (pad_opt !== undefined) { + return buffer_add_string(buf, Caml_format.caml_format_int("%d", pad_opt)); + } + +} + +function bprint_padding(buf, pad) { + if (typeof pad === "number") { + return ; + } + if (pad.TAG === /* Lit_padding */0) { + bprint_padty(buf, pad._0); + return buffer_add_string(buf, Caml_format.caml_format_int("%d", pad._1)); + } + bprint_padty(buf, pad._0); + buffer_add_char(buf, /* '*' */42); +} + +function bprint_precision(buf, prec) { + if (typeof prec === "number") { + if (prec) { + return buffer_add_string(buf, ".*"); + } else { + return ; + } + } else { + buffer_add_char(buf, /* '.' */46); + return buffer_add_string(buf, Caml_format.caml_format_int("%d", prec._0)); + } +} + +function bprint_iconv_flag(buf, iconv) { + switch (iconv) { + case /* Int_pd */1 : + case /* Int_pi */4 : + return buffer_add_char(buf, /* '+' */43); + case /* Int_sd */2 : + case /* Int_si */5 : + return buffer_add_char(buf, /* ' ' */32); + case /* Int_d */0 : + case /* Int_i */3 : + case /* Int_x */6 : + case /* Int_X */8 : + case /* Int_o */10 : + case /* Int_u */12 : + return ; + case /* Int_Cx */7 : + case /* Int_CX */9 : + case /* Int_Co */11 : + case /* Int_Cd */13 : + case /* Int_Ci */14 : + case /* Int_Cu */15 : + return buffer_add_char(buf, /* '#' */35); + + } +} + +function bprint_int_fmt(buf, ign_flag, iconv, pad, prec) { + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + bprint_iconv_flag(buf, iconv); + bprint_padding(buf, pad); + bprint_precision(buf, prec); + buffer_add_char(buf, char_of_iconv(iconv)); +} + +function bprint_altint_fmt(buf, ign_flag, iconv, pad, prec, c) { + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + bprint_iconv_flag(buf, iconv); + bprint_padding(buf, pad); + bprint_precision(buf, prec); + buffer_add_char(buf, c); + buffer_add_char(buf, char_of_iconv(iconv)); +} + +function bprint_fconv_flag(buf, fconv) { + var match = fconv[0]; + switch (match) { + case /* Float_flag_ */0 : + break; + case /* Float_flag_p */1 : + buffer_add_char(buf, /* '+' */43); + break; + case /* Float_flag_s */2 : + buffer_add_char(buf, /* ' ' */32); + break; + + } + var match$1 = fconv[1]; + if (match$1 >= 8) { + return buffer_add_char(buf, /* '#' */35); + } + +} + +function bprint_float_fmt(buf, ign_flag, fconv, pad, prec) { + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + bprint_fconv_flag(buf, fconv); + bprint_padding(buf, pad); + bprint_precision(buf, prec); + buffer_add_char(buf, char_of_fconv(undefined, fconv)); +} + +function string_of_formatting_lit(formatting_lit) { + if (typeof formatting_lit === "number") { + switch (formatting_lit) { + case /* Close_box */0 : + return "@]"; + case /* Close_tag */1 : + return "@}"; + case /* FFlush */2 : + return "@?"; + case /* Force_newline */3 : + return "@\n"; + case /* Flush_newline */4 : + return "@."; + case /* Escaped_at */5 : + return "@@"; + case /* Escaped_percent */6 : + return "@%"; + + } + } else { + switch (formatting_lit.TAG | 0) { + case /* Break */0 : + case /* Magic_size */1 : + return formatting_lit._0; + case /* Scan_indic */2 : + return "@" + Caml_bytes.bytes_to_string(Stdlib__Bytes.make(1, formatting_lit._0)); + + } + } +} + +function bprint_char_literal(buf, chr) { + if (chr !== 37) { + return buffer_add_char(buf, chr); + } else { + return buffer_add_string(buf, "%%"); + } +} + +function bprint_string_literal(buf, str) { + for(var i = 0 ,i_finish = str.length; i < i_finish; ++i){ + bprint_char_literal(buf, Caml_string.get(str, i)); + } +} + +function bprint_fmtty(buf, _fmtty) { + while(true) { + var fmtty = _fmtty; + if (typeof fmtty === "number") { + return ; + } + switch (fmtty.TAG | 0) { + case /* Char_ty */0 : + buffer_add_string(buf, "%c"); + _fmtty = fmtty._0; + continue ; + case /* String_ty */1 : + buffer_add_string(buf, "%s"); + _fmtty = fmtty._0; + continue ; + case /* Int_ty */2 : + buffer_add_string(buf, "%i"); + _fmtty = fmtty._0; + continue ; + case /* Int32_ty */3 : + buffer_add_string(buf, "%li"); + _fmtty = fmtty._0; + continue ; + case /* Nativeint_ty */4 : + buffer_add_string(buf, "%ni"); + _fmtty = fmtty._0; + continue ; + case /* Int64_ty */5 : + buffer_add_string(buf, "%Li"); + _fmtty = fmtty._0; + continue ; + case /* Float_ty */6 : + buffer_add_string(buf, "%f"); + _fmtty = fmtty._0; + continue ; + case /* Bool_ty */7 : + buffer_add_string(buf, "%B"); + _fmtty = fmtty._0; + continue ; + case /* Format_arg_ty */8 : + buffer_add_string(buf, "%{"); + bprint_fmtty(buf, fmtty._0); + buffer_add_string(buf, "%}"); + _fmtty = fmtty._1; + continue ; + case /* Format_subst_ty */9 : + buffer_add_string(buf, "%("); + bprint_fmtty(buf, fmtty._0); + buffer_add_string(buf, "%)"); + _fmtty = fmtty._2; + continue ; + case /* Alpha_ty */10 : + buffer_add_string(buf, "%a"); + _fmtty = fmtty._0; + continue ; + case /* Theta_ty */11 : + buffer_add_string(buf, "%t"); + _fmtty = fmtty._0; + continue ; + case /* Any_ty */12 : + buffer_add_string(buf, "%?"); + _fmtty = fmtty._0; + continue ; + case /* Reader_ty */13 : + buffer_add_string(buf, "%r"); + _fmtty = fmtty._0; + continue ; + case /* Ignored_reader_ty */14 : + buffer_add_string(buf, "%_r"); + _fmtty = fmtty._0; + continue ; + + } + }; +} + +function int_of_custom_arity(param) { + if (param) { + return 1 + int_of_custom_arity(param._0) | 0; + } else { + return 0; + } +} + +function bprint_fmt(buf, fmt) { + var _fmt = fmt; + var _ign_flag = false; + while(true) { + var ign_flag = _ign_flag; + var fmt$1 = _fmt; + if (typeof fmt$1 === "number") { + return ; + } + switch (fmt$1.TAG | 0) { + case /* Char */0 : + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + buffer_add_char(buf, /* 'c' */99); + _ign_flag = false; + _fmt = fmt$1._0; + continue ; + case /* Caml_char */1 : + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + buffer_add_char(buf, /* 'C' */67); + _ign_flag = false; + _fmt = fmt$1._0; + continue ; + case /* String */2 : + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + bprint_padding(buf, fmt$1._0); + buffer_add_char(buf, /* 's' */115); + _ign_flag = false; + _fmt = fmt$1._1; + continue ; + case /* Caml_string */3 : + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + bprint_padding(buf, fmt$1._0); + buffer_add_char(buf, /* 'S' */83); + _ign_flag = false; + _fmt = fmt$1._1; + continue ; + case /* Int */4 : + bprint_int_fmt(buf, ign_flag, fmt$1._0, fmt$1._1, fmt$1._2); + _ign_flag = false; + _fmt = fmt$1._3; + continue ; + case /* Int32 */5 : + bprint_altint_fmt(buf, ign_flag, fmt$1._0, fmt$1._1, fmt$1._2, /* 'l' */108); + _ign_flag = false; + _fmt = fmt$1._3; + continue ; + case /* Nativeint */6 : + bprint_altint_fmt(buf, ign_flag, fmt$1._0, fmt$1._1, fmt$1._2, /* 'n' */110); + _ign_flag = false; + _fmt = fmt$1._3; + continue ; + case /* Int64 */7 : + bprint_altint_fmt(buf, ign_flag, fmt$1._0, fmt$1._1, fmt$1._2, /* 'L' */76); + _ign_flag = false; + _fmt = fmt$1._3; + continue ; + case /* Float */8 : + bprint_float_fmt(buf, ign_flag, fmt$1._0, fmt$1._1, fmt$1._2); + _ign_flag = false; + _fmt = fmt$1._3; + continue ; + case /* Bool */9 : + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + bprint_padding(buf, fmt$1._0); + buffer_add_char(buf, /* 'B' */66); + _ign_flag = false; + _fmt = fmt$1._1; + continue ; + case /* Flush */10 : + buffer_add_string(buf, "%!"); + _fmt = fmt$1._0; + continue ; + case /* String_literal */11 : + bprint_string_literal(buf, fmt$1._0); + _fmt = fmt$1._1; + continue ; + case /* Char_literal */12 : + bprint_char_literal(buf, fmt$1._0); + _fmt = fmt$1._1; + continue ; + case /* Format_arg */13 : + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + bprint_pad_opt(buf, fmt$1._0); + buffer_add_char(buf, /* '{' */123); + bprint_fmtty(buf, fmt$1._1); + buffer_add_char(buf, /* '%' */37); + buffer_add_char(buf, /* '}' */125); + _ign_flag = false; + _fmt = fmt$1._2; + continue ; + case /* Format_subst */14 : + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + bprint_pad_opt(buf, fmt$1._0); + buffer_add_char(buf, /* '(' */40); + bprint_fmtty(buf, fmt$1._1); + buffer_add_char(buf, /* '%' */37); + buffer_add_char(buf, /* ')' */41); + _ign_flag = false; + _fmt = fmt$1._2; + continue ; + case /* Alpha */15 : + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + buffer_add_char(buf, /* 'a' */97); + _ign_flag = false; + _fmt = fmt$1._0; + continue ; + case /* Theta */16 : + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + buffer_add_char(buf, /* 't' */116); + _ign_flag = false; + _fmt = fmt$1._0; + continue ; + case /* Formatting_lit */17 : + bprint_string_literal(buf, string_of_formatting_lit(fmt$1._0)); + _fmt = fmt$1._1; + continue ; + case /* Formatting_gen */18 : + var fmting_gen = fmt$1._0; + if (fmting_gen.TAG === /* Open_tag */0) { + buffer_add_string(buf, "@{"); + buffer_add_string(buf, fmting_gen._0._1); + } else { + buffer_add_string(buf, "@["); + buffer_add_string(buf, fmting_gen._0._1); + } + _fmt = fmt$1._1; + continue ; + case /* Reader */19 : + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + buffer_add_char(buf, /* 'r' */114); + _ign_flag = false; + _fmt = fmt$1._0; + continue ; + case /* Scan_char_set */20 : + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + bprint_pad_opt(buf, fmt$1._0); + bprint_char_set(buf, fmt$1._1); + _ign_flag = false; + _fmt = fmt$1._2; + continue ; + case /* Scan_get_counter */21 : + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + buffer_add_char(buf, char_of_counter(fmt$1._0)); + _ign_flag = false; + _fmt = fmt$1._1; + continue ; + case /* Scan_next_char */22 : + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + bprint_string_literal(buf, "0c"); + _ign_flag = false; + _fmt = fmt$1._0; + continue ; + case /* Ignored_param */23 : + var fmt$p = param_format_of_ignored_format(fmt$1._0, fmt$1._1); + _ign_flag = true; + _fmt = fmt$p._0; + continue ; + case /* Custom */24 : + for(var _i = 1 ,_i_finish = int_of_custom_arity(fmt$1._0); _i <= _i_finish; ++_i){ + buffer_add_char(buf, /* '%' */37); + bprint_ignored_flag(buf, ign_flag); + buffer_add_char(buf, /* '?' */63); + } + _ign_flag = false; + _fmt = fmt$1._2; + continue ; + + } + }; +} + +function string_of_fmt(fmt) { + var buf = { + ind: 0, + bytes: Caml_bytes.caml_create_bytes(16) + }; + bprint_fmt(buf, fmt); + return buffer_contents(buf); +} + +function symm(param) { + if (typeof param === "number") { + return /* End_of_fmtty */0; + } + switch (param.TAG | 0) { + case /* Char_ty */0 : + return { + TAG: /* Char_ty */0, + _0: symm(param._0) + }; + case /* String_ty */1 : + return { + TAG: /* String_ty */1, + _0: symm(param._0) + }; + case /* Int_ty */2 : + return { + TAG: /* Int_ty */2, + _0: symm(param._0) + }; + case /* Int32_ty */3 : + return { + TAG: /* Int32_ty */3, + _0: symm(param._0) + }; + case /* Nativeint_ty */4 : + return { + TAG: /* Nativeint_ty */4, + _0: symm(param._0) + }; + case /* Int64_ty */5 : + return { + TAG: /* Int64_ty */5, + _0: symm(param._0) + }; + case /* Float_ty */6 : + return { + TAG: /* Float_ty */6, + _0: symm(param._0) + }; + case /* Bool_ty */7 : + return { + TAG: /* Bool_ty */7, + _0: symm(param._0) + }; + case /* Format_arg_ty */8 : + return { + TAG: /* Format_arg_ty */8, + _0: param._0, + _1: symm(param._1) + }; + case /* Format_subst_ty */9 : + return { + TAG: /* Format_subst_ty */9, + _0: param._1, + _1: param._0, + _2: symm(param._2) + }; + case /* Alpha_ty */10 : + return { + TAG: /* Alpha_ty */10, + _0: symm(param._0) + }; + case /* Theta_ty */11 : + return { + TAG: /* Theta_ty */11, + _0: symm(param._0) + }; + case /* Any_ty */12 : + return { + TAG: /* Any_ty */12, + _0: symm(param._0) + }; + case /* Reader_ty */13 : + return { + TAG: /* Reader_ty */13, + _0: symm(param._0) + }; + case /* Ignored_reader_ty */14 : + return { + TAG: /* Ignored_reader_ty */14, + _0: symm(param._0) + }; + + } +} + +function fmtty_rel_det(param) { + if (typeof param === "number") { + return [ + (function (param) { + return /* Refl */0; + }), + (function (param) { + return /* Refl */0; + }), + (function (param) { + return /* Refl */0; + }), + (function (param) { + return /* Refl */0; + }) + ]; + } + switch (param.TAG | 0) { + case /* Char_ty */0 : + var match = fmtty_rel_det(param._0); + var af = match[1]; + var fa = match[0]; + return [ + (function (param) { + Curry._1(fa, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(af, /* Refl */0); + return /* Refl */0; + }), + match[2], + match[3] + ]; + case /* String_ty */1 : + var match$1 = fmtty_rel_det(param._0); + var af$1 = match$1[1]; + var fa$1 = match$1[0]; + return [ + (function (param) { + Curry._1(fa$1, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(af$1, /* Refl */0); + return /* Refl */0; + }), + match$1[2], + match$1[3] + ]; + case /* Int_ty */2 : + var match$2 = fmtty_rel_det(param._0); + var af$2 = match$2[1]; + var fa$2 = match$2[0]; + return [ + (function (param) { + Curry._1(fa$2, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(af$2, /* Refl */0); + return /* Refl */0; + }), + match$2[2], + match$2[3] + ]; + case /* Int32_ty */3 : + var match$3 = fmtty_rel_det(param._0); + var af$3 = match$3[1]; + var fa$3 = match$3[0]; + return [ + (function (param) { + Curry._1(fa$3, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(af$3, /* Refl */0); + return /* Refl */0; + }), + match$3[2], + match$3[3] + ]; + case /* Nativeint_ty */4 : + var match$4 = fmtty_rel_det(param._0); + var af$4 = match$4[1]; + var fa$4 = match$4[0]; + return [ + (function (param) { + Curry._1(fa$4, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(af$4, /* Refl */0); + return /* Refl */0; + }), + match$4[2], + match$4[3] + ]; + case /* Int64_ty */5 : + var match$5 = fmtty_rel_det(param._0); + var af$5 = match$5[1]; + var fa$5 = match$5[0]; + return [ + (function (param) { + Curry._1(fa$5, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(af$5, /* Refl */0); + return /* Refl */0; + }), + match$5[2], + match$5[3] + ]; + case /* Float_ty */6 : + var match$6 = fmtty_rel_det(param._0); + var af$6 = match$6[1]; + var fa$6 = match$6[0]; + return [ + (function (param) { + Curry._1(fa$6, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(af$6, /* Refl */0); + return /* Refl */0; + }), + match$6[2], + match$6[3] + ]; + case /* Bool_ty */7 : + var match$7 = fmtty_rel_det(param._0); + var af$7 = match$7[1]; + var fa$7 = match$7[0]; + return [ + (function (param) { + Curry._1(fa$7, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(af$7, /* Refl */0); + return /* Refl */0; + }), + match$7[2], + match$7[3] + ]; + case /* Format_arg_ty */8 : + var match$8 = fmtty_rel_det(param._1); + var af$8 = match$8[1]; + var fa$8 = match$8[0]; + return [ + (function (param) { + Curry._1(fa$8, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(af$8, /* Refl */0); + return /* Refl */0; + }), + match$8[2], + match$8[3] + ]; + case /* Format_subst_ty */9 : + var match$9 = fmtty_rel_det(param._2); + var de = match$9[3]; + var ed = match$9[2]; + var af$9 = match$9[1]; + var fa$9 = match$9[0]; + var ty = trans(symm(param._0), param._1); + var match$10 = fmtty_rel_det(ty); + var jd = match$10[3]; + var dj = match$10[2]; + var ga = match$10[1]; + var ag = match$10[0]; + return [ + (function (param) { + Curry._1(fa$9, /* Refl */0); + Curry._1(ag, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(ga, /* Refl */0); + Curry._1(af$9, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(ed, /* Refl */0); + Curry._1(dj, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(jd, /* Refl */0); + Curry._1(de, /* Refl */0); + return /* Refl */0; + }) + ]; + case /* Alpha_ty */10 : + var match$11 = fmtty_rel_det(param._0); + var af$10 = match$11[1]; + var fa$10 = match$11[0]; + return [ + (function (param) { + Curry._1(fa$10, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(af$10, /* Refl */0); + return /* Refl */0; + }), + match$11[2], + match$11[3] + ]; + case /* Theta_ty */11 : + var match$12 = fmtty_rel_det(param._0); + var af$11 = match$12[1]; + var fa$11 = match$12[0]; + return [ + (function (param) { + Curry._1(fa$11, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(af$11, /* Refl */0); + return /* Refl */0; + }), + match$12[2], + match$12[3] + ]; + case /* Any_ty */12 : + var match$13 = fmtty_rel_det(param._0); + var af$12 = match$13[1]; + var fa$12 = match$13[0]; + return [ + (function (param) { + Curry._1(fa$12, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(af$12, /* Refl */0); + return /* Refl */0; + }), + match$13[2], + match$13[3] + ]; + case /* Reader_ty */13 : + var match$14 = fmtty_rel_det(param._0); + var de$1 = match$14[3]; + var ed$1 = match$14[2]; + var af$13 = match$14[1]; + var fa$13 = match$14[0]; + return [ + (function (param) { + Curry._1(fa$13, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(af$13, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(ed$1, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(de$1, /* Refl */0); + return /* Refl */0; + }) + ]; + case /* Ignored_reader_ty */14 : + var match$15 = fmtty_rel_det(param._0); + var de$2 = match$15[3]; + var ed$2 = match$15[2]; + var af$14 = match$15[1]; + var fa$14 = match$15[0]; + return [ + (function (param) { + Curry._1(fa$14, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(af$14, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(ed$2, /* Refl */0); + return /* Refl */0; + }), + (function (param) { + Curry._1(de$2, /* Refl */0); + return /* Refl */0; + }) + ]; + + } +} + +function trans(ty1, ty2) { + var exit = 0; + if (typeof ty1 === "number") { + if (typeof ty2 === "number") { + return /* End_of_fmtty */0; + } + switch (ty2.TAG | 0) { + case /* Format_arg_ty */8 : + exit = 6; + break; + case /* Format_subst_ty */9 : + exit = 7; + break; + case /* Alpha_ty */10 : + exit = 1; + break; + case /* Theta_ty */11 : + exit = 2; + break; + case /* Any_ty */12 : + exit = 3; + break; + case /* Reader_ty */13 : + exit = 4; + break; + case /* Ignored_reader_ty */14 : + exit = 5; + break; + default: + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 850, + 23 + ], + Error: new Error() + }; + } + } else { + switch (ty1.TAG | 0) { + case /* Char_ty */0 : + if (typeof ty2 === "number") { + exit = 8; + } else { + switch (ty2.TAG | 0) { + case /* Char_ty */0 : + return { + TAG: /* Char_ty */0, + _0: trans(ty1._0, ty2._0) + }; + case /* Format_arg_ty */8 : + exit = 6; + break; + case /* Format_subst_ty */9 : + exit = 7; + break; + case /* Alpha_ty */10 : + exit = 1; + break; + case /* Theta_ty */11 : + exit = 2; + break; + case /* Any_ty */12 : + exit = 3; + break; + case /* Reader_ty */13 : + exit = 4; + break; + case /* Ignored_reader_ty */14 : + exit = 5; + break; + + } + } + break; + case /* String_ty */1 : + if (typeof ty2 === "number") { + exit = 8; + } else { + switch (ty2.TAG | 0) { + case /* String_ty */1 : + return { + TAG: /* String_ty */1, + _0: trans(ty1._0, ty2._0) + }; + case /* Format_arg_ty */8 : + exit = 6; + break; + case /* Format_subst_ty */9 : + exit = 7; + break; + case /* Alpha_ty */10 : + exit = 1; + break; + case /* Theta_ty */11 : + exit = 2; + break; + case /* Any_ty */12 : + exit = 3; + break; + case /* Reader_ty */13 : + exit = 4; + break; + case /* Ignored_reader_ty */14 : + exit = 5; + break; + + } + } + break; + case /* Int_ty */2 : + if (typeof ty2 === "number") { + exit = 8; + } else { + switch (ty2.TAG | 0) { + case /* Int_ty */2 : + return { + TAG: /* Int_ty */2, + _0: trans(ty1._0, ty2._0) + }; + case /* Format_arg_ty */8 : + exit = 6; + break; + case /* Format_subst_ty */9 : + exit = 7; + break; + case /* Alpha_ty */10 : + exit = 1; + break; + case /* Theta_ty */11 : + exit = 2; + break; + case /* Any_ty */12 : + exit = 3; + break; + case /* Reader_ty */13 : + exit = 4; + break; + case /* Ignored_reader_ty */14 : + exit = 5; + break; + + } + } + break; + case /* Int32_ty */3 : + if (typeof ty2 === "number") { + exit = 8; + } else { + switch (ty2.TAG | 0) { + case /* Int32_ty */3 : + return { + TAG: /* Int32_ty */3, + _0: trans(ty1._0, ty2._0) + }; + case /* Format_arg_ty */8 : + exit = 6; + break; + case /* Format_subst_ty */9 : + exit = 7; + break; + case /* Alpha_ty */10 : + exit = 1; + break; + case /* Theta_ty */11 : + exit = 2; + break; + case /* Any_ty */12 : + exit = 3; + break; + case /* Reader_ty */13 : + exit = 4; + break; + case /* Ignored_reader_ty */14 : + exit = 5; + break; + + } + } + break; + case /* Nativeint_ty */4 : + if (typeof ty2 === "number") { + exit = 8; + } else { + switch (ty2.TAG | 0) { + case /* Nativeint_ty */4 : + return { + TAG: /* Nativeint_ty */4, + _0: trans(ty1._0, ty2._0) + }; + case /* Format_arg_ty */8 : + exit = 6; + break; + case /* Format_subst_ty */9 : + exit = 7; + break; + case /* Alpha_ty */10 : + exit = 1; + break; + case /* Theta_ty */11 : + exit = 2; + break; + case /* Any_ty */12 : + exit = 3; + break; + case /* Reader_ty */13 : + exit = 4; + break; + case /* Ignored_reader_ty */14 : + exit = 5; + break; + + } + } + break; + case /* Int64_ty */5 : + if (typeof ty2 === "number") { + exit = 8; + } else { + switch (ty2.TAG | 0) { + case /* Int64_ty */5 : + return { + TAG: /* Int64_ty */5, + _0: trans(ty1._0, ty2._0) + }; + case /* Format_arg_ty */8 : + exit = 6; + break; + case /* Format_subst_ty */9 : + exit = 7; + break; + case /* Alpha_ty */10 : + exit = 1; + break; + case /* Theta_ty */11 : + exit = 2; + break; + case /* Any_ty */12 : + exit = 3; + break; + case /* Reader_ty */13 : + exit = 4; + break; + case /* Ignored_reader_ty */14 : + exit = 5; + break; + + } + } + break; + case /* Float_ty */6 : + if (typeof ty2 === "number") { + exit = 8; + } else { + switch (ty2.TAG | 0) { + case /* Float_ty */6 : + return { + TAG: /* Float_ty */6, + _0: trans(ty1._0, ty2._0) + }; + case /* Format_arg_ty */8 : + exit = 6; + break; + case /* Format_subst_ty */9 : + exit = 7; + break; + case /* Alpha_ty */10 : + exit = 1; + break; + case /* Theta_ty */11 : + exit = 2; + break; + case /* Any_ty */12 : + exit = 3; + break; + case /* Reader_ty */13 : + exit = 4; + break; + case /* Ignored_reader_ty */14 : + exit = 5; + break; + + } + } + break; + case /* Bool_ty */7 : + if (typeof ty2 === "number") { + exit = 8; + } else { + switch (ty2.TAG | 0) { + case /* Bool_ty */7 : + return { + TAG: /* Bool_ty */7, + _0: trans(ty1._0, ty2._0) + }; + case /* Format_arg_ty */8 : + exit = 6; + break; + case /* Format_subst_ty */9 : + exit = 7; + break; + case /* Alpha_ty */10 : + exit = 1; + break; + case /* Theta_ty */11 : + exit = 2; + break; + case /* Any_ty */12 : + exit = 3; + break; + case /* Reader_ty */13 : + exit = 4; + break; + case /* Ignored_reader_ty */14 : + exit = 5; + break; + + } + } + break; + case /* Format_arg_ty */8 : + if (typeof ty2 === "number") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 836, + 26 + ], + Error: new Error() + }; + } + switch (ty2.TAG | 0) { + case /* Format_arg_ty */8 : + return { + TAG: /* Format_arg_ty */8, + _0: trans(ty1._0, ty2._0), + _1: trans(ty1._1, ty2._1) + }; + case /* Alpha_ty */10 : + exit = 1; + break; + case /* Theta_ty */11 : + exit = 2; + break; + case /* Any_ty */12 : + exit = 3; + break; + case /* Reader_ty */13 : + exit = 4; + break; + case /* Ignored_reader_ty */14 : + exit = 5; + break; + default: + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 836, + 26 + ], + Error: new Error() + }; + } + break; + case /* Format_subst_ty */9 : + if (typeof ty2 === "number") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 846, + 28 + ], + Error: new Error() + }; + } + switch (ty2.TAG | 0) { + case /* Format_arg_ty */8 : + exit = 6; + break; + case /* Format_subst_ty */9 : + var ty = trans(symm(ty1._1), ty2._0); + var match = fmtty_rel_det(ty); + Curry._1(match[1], /* Refl */0); + Curry._1(match[3], /* Refl */0); + return { + TAG: /* Format_subst_ty */9, + _0: ty1._0, + _1: ty2._1, + _2: trans(ty1._2, ty2._2) + }; + case /* Alpha_ty */10 : + exit = 1; + break; + case /* Theta_ty */11 : + exit = 2; + break; + case /* Any_ty */12 : + exit = 3; + break; + case /* Reader_ty */13 : + exit = 4; + break; + case /* Ignored_reader_ty */14 : + exit = 5; + break; + default: + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 846, + 28 + ], + Error: new Error() + }; + } + break; + case /* Alpha_ty */10 : + if (typeof ty2 === "number") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 814, + 21 + ], + Error: new Error() + }; + } + if (ty2.TAG === /* Alpha_ty */10) { + return { + TAG: /* Alpha_ty */10, + _0: trans(ty1._0, ty2._0) + }; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 814, + 21 + ], + Error: new Error() + }; + case /* Theta_ty */11 : + if (typeof ty2 === "number") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 818, + 21 + ], + Error: new Error() + }; + } + switch (ty2.TAG | 0) { + case /* Alpha_ty */10 : + exit = 1; + break; + case /* Theta_ty */11 : + return { + TAG: /* Theta_ty */11, + _0: trans(ty1._0, ty2._0) + }; + default: + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 818, + 21 + ], + Error: new Error() + }; + } + break; + case /* Any_ty */12 : + if (typeof ty2 === "number") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 822, + 19 + ], + Error: new Error() + }; + } + switch (ty2.TAG | 0) { + case /* Alpha_ty */10 : + exit = 1; + break; + case /* Theta_ty */11 : + exit = 2; + break; + case /* Any_ty */12 : + return { + TAG: /* Any_ty */12, + _0: trans(ty1._0, ty2._0) + }; + default: + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 822, + 19 + ], + Error: new Error() + }; + } + break; + case /* Reader_ty */13 : + if (typeof ty2 === "number") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 826, + 22 + ], + Error: new Error() + }; + } + switch (ty2.TAG | 0) { + case /* Alpha_ty */10 : + exit = 1; + break; + case /* Theta_ty */11 : + exit = 2; + break; + case /* Any_ty */12 : + exit = 3; + break; + case /* Reader_ty */13 : + return { + TAG: /* Reader_ty */13, + _0: trans(ty1._0, ty2._0) + }; + default: + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 826, + 22 + ], + Error: new Error() + }; + } + break; + case /* Ignored_reader_ty */14 : + if (typeof ty2 === "number") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 831, + 30 + ], + Error: new Error() + }; + } + switch (ty2.TAG | 0) { + case /* Alpha_ty */10 : + exit = 1; + break; + case /* Theta_ty */11 : + exit = 2; + break; + case /* Any_ty */12 : + exit = 3; + break; + case /* Reader_ty */13 : + exit = 4; + break; + case /* Ignored_reader_ty */14 : + return { + TAG: /* Ignored_reader_ty */14, + _0: trans(ty1._0, ty2._0) + }; + default: + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 831, + 30 + ], + Error: new Error() + }; + } + break; + + } + } + switch (exit) { + case 1 : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 815, + 21 + ], + Error: new Error() + }; + case 2 : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 819, + 21 + ], + Error: new Error() + }; + case 3 : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 823, + 19 + ], + Error: new Error() + }; + case 4 : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 827, + 22 + ], + Error: new Error() + }; + case 5 : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 832, + 30 + ], + Error: new Error() + }; + case 6 : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 837, + 26 + ], + Error: new Error() + }; + case 7 : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 847, + 28 + ], + Error: new Error() + }; + case 8 : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 851, + 23 + ], + Error: new Error() + }; + + } +} + +function fmtty_of_formatting_gen(formatting_gen) { + return fmtty_of_fmt(formatting_gen._0._0); +} + +function fmtty_of_fmt(_fmtty) { + while(true) { + var fmtty = _fmtty; + if (typeof fmtty === "number") { + return /* End_of_fmtty */0; + } + switch (fmtty.TAG | 0) { + case /* String */2 : + case /* Caml_string */3 : + break; + case /* Int */4 : + var ty_rest = fmtty_of_fmt(fmtty._3); + var prec_ty = fmtty_of_precision_fmtty(fmtty._2, { + TAG: /* Int_ty */2, + _0: ty_rest + }); + return fmtty_of_padding_fmtty(fmtty._1, prec_ty); + case /* Int32 */5 : + var ty_rest$1 = fmtty_of_fmt(fmtty._3); + var prec_ty$1 = fmtty_of_precision_fmtty(fmtty._2, { + TAG: /* Int32_ty */3, + _0: ty_rest$1 + }); + return fmtty_of_padding_fmtty(fmtty._1, prec_ty$1); + case /* Nativeint */6 : + var ty_rest$2 = fmtty_of_fmt(fmtty._3); + var prec_ty$2 = fmtty_of_precision_fmtty(fmtty._2, { + TAG: /* Nativeint_ty */4, + _0: ty_rest$2 + }); + return fmtty_of_padding_fmtty(fmtty._1, prec_ty$2); + case /* Int64 */7 : + var ty_rest$3 = fmtty_of_fmt(fmtty._3); + var prec_ty$3 = fmtty_of_precision_fmtty(fmtty._2, { + TAG: /* Int64_ty */5, + _0: ty_rest$3 + }); + return fmtty_of_padding_fmtty(fmtty._1, prec_ty$3); + case /* Float */8 : + var ty_rest$4 = fmtty_of_fmt(fmtty._3); + var prec_ty$4 = fmtty_of_precision_fmtty(fmtty._2, { + TAG: /* Float_ty */6, + _0: ty_rest$4 + }); + return fmtty_of_padding_fmtty(fmtty._1, prec_ty$4); + case /* Bool */9 : + return fmtty_of_padding_fmtty(fmtty._0, { + TAG: /* Bool_ty */7, + _0: fmtty_of_fmt(fmtty._1) + }); + case /* Flush */10 : + _fmtty = fmtty._0; + continue ; + case /* Format_arg */13 : + return { + TAG: /* Format_arg_ty */8, + _0: fmtty._1, + _1: fmtty_of_fmt(fmtty._2) + }; + case /* Format_subst */14 : + var ty = fmtty._1; + return { + TAG: /* Format_subst_ty */9, + _0: ty, + _1: ty, + _2: fmtty_of_fmt(fmtty._2) + }; + case /* Alpha */15 : + return { + TAG: /* Alpha_ty */10, + _0: fmtty_of_fmt(fmtty._0) + }; + case /* Theta */16 : + return { + TAG: /* Theta_ty */11, + _0: fmtty_of_fmt(fmtty._0) + }; + case /* Formatting_gen */18 : + return CamlinternalFormatBasics.concat_fmtty(fmtty_of_formatting_gen(fmtty._0), fmtty_of_fmt(fmtty._1)); + case /* Reader */19 : + return { + TAG: /* Reader_ty */13, + _0: fmtty_of_fmt(fmtty._0) + }; + case /* Scan_char_set */20 : + return { + TAG: /* String_ty */1, + _0: fmtty_of_fmt(fmtty._2) + }; + case /* Scan_get_counter */21 : + return { + TAG: /* Int_ty */2, + _0: fmtty_of_fmt(fmtty._1) + }; + case /* Char */0 : + case /* Caml_char */1 : + case /* Scan_next_char */22 : + return { + TAG: /* Char_ty */0, + _0: fmtty_of_fmt(fmtty._0) + }; + case /* Ignored_param */23 : + var ign = fmtty._0; + var fmt = fmtty._1; + if (typeof ign === "number") { + if (ign === /* Ignored_reader */2) { + return { + TAG: /* Ignored_reader_ty */14, + _0: fmtty_of_fmt(fmt) + }; + } else { + return fmtty_of_fmt(fmt); + } + } else if (ign.TAG === /* Ignored_format_subst */9) { + return CamlinternalFormatBasics.concat_fmtty(ign._1, fmtty_of_fmt(fmt)); + } else { + return fmtty_of_fmt(fmt); + } + case /* Custom */24 : + return fmtty_of_custom(fmtty._0, fmtty_of_fmt(fmtty._2)); + default: + _fmtty = fmtty._1; + continue ; + } + return fmtty_of_padding_fmtty(fmtty._0, { + TAG: /* String_ty */1, + _0: fmtty_of_fmt(fmtty._1) + }); + }; +} + +function fmtty_of_custom(arity, fmtty) { + if (arity) { + return { + TAG: /* Any_ty */12, + _0: fmtty_of_custom(arity._0, fmtty) + }; + } else { + return fmtty; + } +} + +function fmtty_of_padding_fmtty(pad, fmtty) { + if (typeof pad === "number" || pad.TAG === /* Lit_padding */0) { + return fmtty; + } else { + return { + TAG: /* Int_ty */2, + _0: fmtty + }; + } +} + +function fmtty_of_precision_fmtty(prec, fmtty) { + if (typeof prec === "number" && prec) { + return { + TAG: /* Int_ty */2, + _0: fmtty + }; + } else { + return fmtty; + } +} + +var Type_mismatch = /* @__PURE__ */Caml_exceptions.create("CamlinternalFormat.Type_mismatch"); + +function type_padding(pad, fmtty) { + if (typeof pad === "number") { + return /* Padding_fmtty_EBB */{ + _0: /* No_padding */0, + _1: fmtty + }; + } + if (pad.TAG === /* Lit_padding */0) { + return /* Padding_fmtty_EBB */{ + _0: { + TAG: /* Lit_padding */0, + _0: pad._0, + _1: pad._1 + }, + _1: fmtty + }; + } + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Int_ty */2) { + return /* Padding_fmtty_EBB */{ + _0: { + TAG: /* Arg_padding */1, + _0: pad._0 + }, + _1: fmtty._0 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; +} + +function type_padprec(pad, prec, fmtty) { + var match = type_padding(pad, fmtty); + if (typeof prec !== "number") { + return /* Padprec_fmtty_EBB */{ + _0: match._0, + _1: /* Lit_precision */{ + _0: prec._0 + }, + _2: match._1 + }; + } + if (!prec) { + return /* Padprec_fmtty_EBB */{ + _0: match._0, + _1: /* No_precision */0, + _2: match._1 + }; + } + var rest = match._1; + if (typeof rest === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (rest.TAG === /* Int_ty */2) { + return /* Padprec_fmtty_EBB */{ + _0: match._0, + _1: /* Arg_precision */1, + _2: rest._0 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; +} + +function type_format_gen(fmt, fmtty) { + if (typeof fmt === "number") { + return /* Fmt_fmtty_EBB */{ + _0: /* End_of_format */0, + _1: fmtty + }; + } + switch (fmt.TAG | 0) { + case /* Char */0 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Char_ty */0) { + var match = type_format_gen(fmt._0, fmtty._0); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Char */0, + _0: match._0 + }, + _1: match._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Caml_char */1 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Char_ty */0) { + var match$1 = type_format_gen(fmt._0, fmtty._0); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Caml_char */1, + _0: match$1._0 + }, + _1: match$1._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* String */2 : + var match$2 = type_padding(fmt._0, fmtty); + var fmtty_rest = match$2._1; + if (typeof fmtty_rest === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty_rest.TAG === /* String_ty */1) { + var match$3 = type_format_gen(fmt._1, fmtty_rest._0); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* String */2, + _0: match$2._0, + _1: match$3._0 + }, + _1: match$3._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Caml_string */3 : + var match$4 = type_padding(fmt._0, fmtty); + var fmtty_rest$1 = match$4._1; + if (typeof fmtty_rest$1 === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty_rest$1.TAG === /* String_ty */1) { + var match$5 = type_format_gen(fmt._1, fmtty_rest$1._0); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Caml_string */3, + _0: match$4._0, + _1: match$5._0 + }, + _1: match$5._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Int */4 : + var match$6 = type_padprec(fmt._1, fmt._2, fmtty); + var fmtty_rest$2 = match$6._2; + if (typeof fmtty_rest$2 === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty_rest$2.TAG === /* Int_ty */2) { + var match$7 = type_format_gen(fmt._3, fmtty_rest$2._0); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Int */4, + _0: fmt._0, + _1: match$6._0, + _2: match$6._1, + _3: match$7._0 + }, + _1: match$7._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Int32 */5 : + var match$8 = type_padprec(fmt._1, fmt._2, fmtty); + var fmtty_rest$3 = match$8._2; + if (typeof fmtty_rest$3 === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty_rest$3.TAG === /* Int32_ty */3) { + var match$9 = type_format_gen(fmt._3, fmtty_rest$3._0); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Int32 */5, + _0: fmt._0, + _1: match$8._0, + _2: match$8._1, + _3: match$9._0 + }, + _1: match$9._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Nativeint */6 : + var match$10 = type_padprec(fmt._1, fmt._2, fmtty); + var fmtty_rest$4 = match$10._2; + if (typeof fmtty_rest$4 === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty_rest$4.TAG === /* Nativeint_ty */4) { + var match$11 = type_format_gen(fmt._3, fmtty_rest$4._0); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Nativeint */6, + _0: fmt._0, + _1: match$10._0, + _2: match$10._1, + _3: match$11._0 + }, + _1: match$11._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Int64 */7 : + var match$12 = type_padprec(fmt._1, fmt._2, fmtty); + var fmtty_rest$5 = match$12._2; + if (typeof fmtty_rest$5 === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty_rest$5.TAG === /* Int64_ty */5) { + var match$13 = type_format_gen(fmt._3, fmtty_rest$5._0); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Int64 */7, + _0: fmt._0, + _1: match$12._0, + _2: match$12._1, + _3: match$13._0 + }, + _1: match$13._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Float */8 : + var match$14 = type_padprec(fmt._1, fmt._2, fmtty); + var fmtty_rest$6 = match$14._2; + if (typeof fmtty_rest$6 === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty_rest$6.TAG === /* Float_ty */6) { + var match$15 = type_format_gen(fmt._3, fmtty_rest$6._0); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Float */8, + _0: fmt._0, + _1: match$14._0, + _2: match$14._1, + _3: match$15._0 + }, + _1: match$15._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Bool */9 : + var match$16 = type_padding(fmt._0, fmtty); + var fmtty_rest$7 = match$16._1; + if (typeof fmtty_rest$7 === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty_rest$7.TAG === /* Bool_ty */7) { + var match$17 = type_format_gen(fmt._1, fmtty_rest$7._0); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Bool */9, + _0: match$16._0, + _1: match$17._0 + }, + _1: match$17._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Flush */10 : + var match$18 = type_format_gen(fmt._0, fmtty); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Flush */10, + _0: match$18._0 + }, + _1: match$18._1 + }; + case /* String_literal */11 : + var match$19 = type_format_gen(fmt._1, fmtty); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* String_literal */11, + _0: fmt._0, + _1: match$19._0 + }, + _1: match$19._1 + }; + case /* Char_literal */12 : + var match$20 = type_format_gen(fmt._1, fmtty); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Char_literal */12, + _0: fmt._0, + _1: match$20._0 + }, + _1: match$20._1 + }; + case /* Format_arg */13 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Format_arg_ty */8) { + var sub_fmtty$p = fmtty._0; + if (Caml_obj.caml_notequal(/* Fmtty_EBB */{ + _0: fmt._1 + }, /* Fmtty_EBB */{ + _0: sub_fmtty$p + })) { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + var match$21 = type_format_gen(fmt._2, fmtty._1); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Format_arg */13, + _0: fmt._0, + _1: sub_fmtty$p, + _2: match$21._0 + }, + _1: match$21._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Format_subst */14 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Format_subst_ty */9) { + var sub_fmtty1 = fmtty._0; + if (Caml_obj.caml_notequal(/* Fmtty_EBB */{ + _0: CamlinternalFormatBasics.erase_rel(fmt._1) + }, /* Fmtty_EBB */{ + _0: CamlinternalFormatBasics.erase_rel(sub_fmtty1) + })) { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + var match$22 = type_format_gen(fmt._2, CamlinternalFormatBasics.erase_rel(fmtty._2)); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Format_subst */14, + _0: fmt._0, + _1: sub_fmtty1, + _2: match$22._0 + }, + _1: match$22._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Alpha */15 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Alpha_ty */10) { + var match$23 = type_format_gen(fmt._0, fmtty._0); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Alpha */15, + _0: match$23._0 + }, + _1: match$23._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Theta */16 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Theta_ty */11) { + var match$24 = type_format_gen(fmt._0, fmtty._0); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Theta */16, + _0: match$24._0 + }, + _1: match$24._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Formatting_lit */17 : + var match$25 = type_format_gen(fmt._1, fmtty); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Formatting_lit */17, + _0: fmt._0, + _1: match$25._0 + }, + _1: match$25._1 + }; + case /* Formatting_gen */18 : + var formatting_gen = fmt._0; + var fmt0 = fmt._1; + if (formatting_gen.TAG === /* Open_tag */0) { + var match$26 = formatting_gen._0; + var match$27 = type_format_gen(match$26._0, fmtty); + var match$28 = type_format_gen(fmt0, match$27._1); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Formatting_gen */18, + _0: { + TAG: /* Open_tag */0, + _0: /* Format */{ + _0: match$27._0, + _1: match$26._1 + } + }, + _1: match$28._0 + }, + _1: match$28._1 + }; + } + var match$29 = formatting_gen._0; + var match$30 = type_format_gen(match$29._0, fmtty); + var match$31 = type_format_gen(fmt0, match$30._1); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Formatting_gen */18, + _0: { + TAG: /* Open_box */1, + _0: /* Format */{ + _0: match$30._0, + _1: match$29._1 + } + }, + _1: match$31._0 + }, + _1: match$31._1 + }; + case /* Reader */19 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Reader_ty */13) { + var match$32 = type_format_gen(fmt._0, fmtty._0); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Reader */19, + _0: match$32._0 + }, + _1: match$32._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Scan_char_set */20 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* String_ty */1) { + var match$33 = type_format_gen(fmt._2, fmtty._0); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Scan_char_set */20, + _0: fmt._0, + _1: fmt._1, + _2: match$33._0 + }, + _1: match$33._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Scan_get_counter */21 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Int_ty */2) { + var match$34 = type_format_gen(fmt._1, fmtty._0); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Scan_get_counter */21, + _0: fmt._0, + _1: match$34._0 + }, + _1: match$34._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Ignored_param */23 : + var ign = fmt._0; + var fmt$1 = fmt._1; + if (typeof ign === "number") { + if (ign !== /* Ignored_reader */2) { + return type_ignored_param_one(ign, fmt$1, fmtty); + } + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Ignored_reader_ty */14) { + var match$35 = type_format_gen(fmt$1, fmtty._0); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: /* Ignored_reader */2, + _1: match$35._0 + }, + _1: match$35._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } else { + switch (ign.TAG | 0) { + case /* Ignored_format_arg */8 : + return type_ignored_param_one({ + TAG: /* Ignored_format_arg */8, + _0: ign._0, + _1: ign._1 + }, fmt$1, fmtty); + case /* Ignored_format_subst */9 : + var match$36 = type_ignored_format_substitution(ign._1, fmt$1, fmtty); + var match$37 = match$36._1; + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: { + TAG: /* Ignored_format_subst */9, + _0: ign._0, + _1: match$36._0 + }, + _1: match$37._0 + }, + _1: match$37._1 + }; + default: + return type_ignored_param_one(ign, fmt$1, fmtty); + } + } + case /* Scan_next_char */22 : + case /* Custom */24 : + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + + } +} + +function type_ignored_format_substitution(sub_fmtty, fmt, fmtty) { + if (typeof sub_fmtty === "number") { + return /* Fmtty_fmt_EBB */{ + _0: /* End_of_fmtty */0, + _1: type_format_gen(fmt, fmtty) + }; + } + switch (sub_fmtty.TAG | 0) { + case /* Char_ty */0 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Char_ty */0) { + var match = type_ignored_format_substitution(sub_fmtty._0, fmt, fmtty._0); + return /* Fmtty_fmt_EBB */{ + _0: { + TAG: /* Char_ty */0, + _0: match._0 + }, + _1: match._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* String_ty */1 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* String_ty */1) { + var match$1 = type_ignored_format_substitution(sub_fmtty._0, fmt, fmtty._0); + return /* Fmtty_fmt_EBB */{ + _0: { + TAG: /* String_ty */1, + _0: match$1._0 + }, + _1: match$1._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Int_ty */2 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Int_ty */2) { + var match$2 = type_ignored_format_substitution(sub_fmtty._0, fmt, fmtty._0); + return /* Fmtty_fmt_EBB */{ + _0: { + TAG: /* Int_ty */2, + _0: match$2._0 + }, + _1: match$2._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Int32_ty */3 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Int32_ty */3) { + var match$3 = type_ignored_format_substitution(sub_fmtty._0, fmt, fmtty._0); + return /* Fmtty_fmt_EBB */{ + _0: { + TAG: /* Int32_ty */3, + _0: match$3._0 + }, + _1: match$3._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Nativeint_ty */4 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Nativeint_ty */4) { + var match$4 = type_ignored_format_substitution(sub_fmtty._0, fmt, fmtty._0); + return /* Fmtty_fmt_EBB */{ + _0: { + TAG: /* Nativeint_ty */4, + _0: match$4._0 + }, + _1: match$4._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Int64_ty */5 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Int64_ty */5) { + var match$5 = type_ignored_format_substitution(sub_fmtty._0, fmt, fmtty._0); + return /* Fmtty_fmt_EBB */{ + _0: { + TAG: /* Int64_ty */5, + _0: match$5._0 + }, + _1: match$5._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Float_ty */6 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Float_ty */6) { + var match$6 = type_ignored_format_substitution(sub_fmtty._0, fmt, fmtty._0); + return /* Fmtty_fmt_EBB */{ + _0: { + TAG: /* Float_ty */6, + _0: match$6._0 + }, + _1: match$6._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Bool_ty */7 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Bool_ty */7) { + var match$7 = type_ignored_format_substitution(sub_fmtty._0, fmt, fmtty._0); + return /* Fmtty_fmt_EBB */{ + _0: { + TAG: /* Bool_ty */7, + _0: match$7._0 + }, + _1: match$7._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Format_arg_ty */8 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Format_arg_ty */8) { + var sub2_fmtty$p = fmtty._0; + if (Caml_obj.caml_notequal(/* Fmtty_EBB */{ + _0: sub_fmtty._0 + }, /* Fmtty_EBB */{ + _0: sub2_fmtty$p + })) { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + var match$8 = type_ignored_format_substitution(sub_fmtty._1, fmt, fmtty._1); + return /* Fmtty_fmt_EBB */{ + _0: { + TAG: /* Format_arg_ty */8, + _0: sub2_fmtty$p, + _1: match$8._0 + }, + _1: match$8._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Format_subst_ty */9 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Format_subst_ty */9) { + var sub2_fmtty$p$1 = fmtty._1; + var sub1_fmtty$p = fmtty._0; + if (Caml_obj.caml_notequal(/* Fmtty_EBB */{ + _0: CamlinternalFormatBasics.erase_rel(sub_fmtty._0) + }, /* Fmtty_EBB */{ + _0: CamlinternalFormatBasics.erase_rel(sub1_fmtty$p) + })) { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (Caml_obj.caml_notequal(/* Fmtty_EBB */{ + _0: CamlinternalFormatBasics.erase_rel(sub_fmtty._1) + }, /* Fmtty_EBB */{ + _0: CamlinternalFormatBasics.erase_rel(sub2_fmtty$p$1) + })) { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + var sub_fmtty$p = trans(symm(sub1_fmtty$p), sub2_fmtty$p$1); + var match$9 = fmtty_rel_det(sub_fmtty$p); + Curry._1(match$9[1], /* Refl */0); + Curry._1(match$9[3], /* Refl */0); + var match$10 = type_ignored_format_substitution(CamlinternalFormatBasics.erase_rel(sub_fmtty._2), fmt, fmtty._2); + return /* Fmtty_fmt_EBB */{ + _0: { + TAG: /* Format_subst_ty */9, + _0: sub1_fmtty$p, + _1: sub2_fmtty$p$1, + _2: symm(match$10._0) + }, + _1: match$10._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Alpha_ty */10 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Alpha_ty */10) { + var match$11 = type_ignored_format_substitution(sub_fmtty._0, fmt, fmtty._0); + return /* Fmtty_fmt_EBB */{ + _0: { + TAG: /* Alpha_ty */10, + _0: match$11._0 + }, + _1: match$11._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Theta_ty */11 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Theta_ty */11) { + var match$12 = type_ignored_format_substitution(sub_fmtty._0, fmt, fmtty._0); + return /* Fmtty_fmt_EBB */{ + _0: { + TAG: /* Theta_ty */11, + _0: match$12._0 + }, + _1: match$12._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Any_ty */12 : + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Reader_ty */13 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Reader_ty */13) { + var match$13 = type_ignored_format_substitution(sub_fmtty._0, fmt, fmtty._0); + return /* Fmtty_fmt_EBB */{ + _0: { + TAG: /* Reader_ty */13, + _0: match$13._0 + }, + _1: match$13._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + case /* Ignored_reader_ty */14 : + if (typeof fmtty === "number") { + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + } + if (fmtty.TAG === /* Ignored_reader_ty */14) { + var match$14 = type_ignored_format_substitution(sub_fmtty._0, fmt, fmtty._0); + return /* Fmtty_fmt_EBB */{ + _0: { + TAG: /* Ignored_reader_ty */14, + _0: match$14._0 + }, + _1: match$14._1 + }; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; + + } +} + +function type_ignored_param_one(ign, fmt, fmtty) { + var match = type_format_gen(fmt, fmtty); + return /* Fmt_fmtty_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: ign, + _1: match._0 + }, + _1: match._1 + }; +} + +function type_format(fmt, fmtty) { + var match = type_format_gen(fmt, fmtty); + if (typeof match._1 === "number") { + return match._0; + } + throw { + RE_EXN_ID: Type_mismatch, + Error: new Error() + }; +} + +function recast(fmt, fmtty) { + return type_format(fmt, CamlinternalFormatBasics.erase_rel(symm(fmtty))); +} + +function fix_padding(padty, width, str) { + var len = str.length; + var width$1 = Stdlib.abs(width); + var padty$1 = width < 0 ? /* Left */0 : padty; + if (width$1 <= len) { + return str; + } + var res = Stdlib__Bytes.make(width$1, padty$1 === /* Zeros */2 ? /* '0' */48 : /* ' ' */32); + switch (padty$1) { + case /* Left */0 : + Stdlib__String.blit(str, 0, res, 0, len); + break; + case /* Right */1 : + Stdlib__String.blit(str, 0, res, width$1 - len | 0, len); + break; + case /* Zeros */2 : + if (len > 0 && (Caml_string.get(str, 0) === /* '+' */43 || Caml_string.get(str, 0) === /* '-' */45 || Caml_string.get(str, 0) === /* ' ' */32)) { + Caml_bytes.set(res, 0, Caml_string.get(str, 0)); + Stdlib__String.blit(str, 1, res, (width$1 - len | 0) + 1 | 0, len - 1 | 0); + } else if (len > 1 && Caml_string.get(str, 0) === /* '0' */48 && (Caml_string.get(str, 1) === /* 'x' */120 || Caml_string.get(str, 1) === /* 'X' */88)) { + Caml_bytes.set(res, 1, Caml_string.get(str, 1)); + Stdlib__String.blit(str, 2, res, (width$1 - len | 0) + 2 | 0, len - 2 | 0); + } else { + Stdlib__String.blit(str, 0, res, width$1 - len | 0, len); + } + break; + + } + return Caml_bytes.bytes_to_string(res); +} + +function fix_int_precision(prec, str) { + var prec$1 = Stdlib.abs(prec); + var len = str.length; + var c = Caml_string.get(str, 0); + var exit = 0; + if (c >= 58) { + if (c >= 71) { + if (c > 102 || c < 97) { + return str; + } + exit = 2; + } else { + if (c < 65) { + return str; + } + exit = 2; + } + } else if (c !== 32) { + if (c < 43) { + return str; + } + switch (c) { + case 43 : + case 45 : + exit = 1; + break; + case 44 : + case 46 : + case 47 : + return str; + case 48 : + if ((prec$1 + 2 | 0) > len && len > 1 && (Caml_string.get(str, 1) === /* 'x' */120 || Caml_string.get(str, 1) === /* 'X' */88)) { + var res = Stdlib__Bytes.make(prec$1 + 2 | 0, /* '0' */48); + Caml_bytes.set(res, 1, Caml_string.get(str, 1)); + Stdlib__String.blit(str, 2, res, (prec$1 - len | 0) + 4 | 0, len - 2 | 0); + return Caml_bytes.bytes_to_string(res); + } + exit = 2; + break; + case 49 : + case 50 : + case 51 : + case 52 : + case 53 : + case 54 : + case 55 : + case 56 : + case 57 : + exit = 2; + break; + + } + } else { + exit = 1; + } + switch (exit) { + case 1 : + if ((prec$1 + 1 | 0) <= len) { + return str; + } + var res$1 = Stdlib__Bytes.make(prec$1 + 1 | 0, /* '0' */48); + Caml_bytes.set(res$1, 0, c); + Stdlib__String.blit(str, 1, res$1, (prec$1 - len | 0) + 2 | 0, len - 1 | 0); + return Caml_bytes.bytes_to_string(res$1); + case 2 : + if (prec$1 <= len) { + return str; + } + var res$2 = Stdlib__Bytes.make(prec$1, /* '0' */48); + Stdlib__String.blit(str, 0, res$2, prec$1 - len | 0, len); + return Caml_bytes.bytes_to_string(res$2); + + } +} + +function string_to_caml_string(str) { + var str$1 = Stdlib__String.escaped(str); + var l = str$1.length; + var res = Stdlib__Bytes.make(l + 2 | 0, /* '"' */34); + Caml_bytes.caml_blit_string(str$1, 0, res, 1, l); + return Caml_bytes.bytes_to_string(res); +} + +function format_of_iconv(param) { + switch (param) { + case /* Int_pd */1 : + return "%+d"; + case /* Int_sd */2 : + return "% d"; + case /* Int_pi */4 : + return "%+i"; + case /* Int_si */5 : + return "% i"; + case /* Int_x */6 : + return "%x"; + case /* Int_Cx */7 : + return "%#x"; + case /* Int_X */8 : + return "%X"; + case /* Int_CX */9 : + return "%#X"; + case /* Int_o */10 : + return "%o"; + case /* Int_Co */11 : + return "%#o"; + case /* Int_d */0 : + case /* Int_Cd */13 : + return "%d"; + case /* Int_i */3 : + case /* Int_Ci */14 : + return "%i"; + case /* Int_u */12 : + case /* Int_Cu */15 : + return "%u"; + + } +} + +function format_of_iconvL(param) { + switch (param) { + case /* Int_pd */1 : + return "%+Ld"; + case /* Int_sd */2 : + return "% Ld"; + case /* Int_pi */4 : + return "%+Li"; + case /* Int_si */5 : + return "% Li"; + case /* Int_x */6 : + return "%Lx"; + case /* Int_Cx */7 : + return "%#Lx"; + case /* Int_X */8 : + return "%LX"; + case /* Int_CX */9 : + return "%#LX"; + case /* Int_o */10 : + return "%Lo"; + case /* Int_Co */11 : + return "%#Lo"; + case /* Int_d */0 : + case /* Int_Cd */13 : + return "%Ld"; + case /* Int_i */3 : + case /* Int_Ci */14 : + return "%Li"; + case /* Int_u */12 : + case /* Int_Cu */15 : + return "%Lu"; + + } +} + +function format_of_iconvl(param) { + switch (param) { + case /* Int_pd */1 : + return "%+ld"; + case /* Int_sd */2 : + return "% ld"; + case /* Int_pi */4 : + return "%+li"; + case /* Int_si */5 : + return "% li"; + case /* Int_x */6 : + return "%lx"; + case /* Int_Cx */7 : + return "%#lx"; + case /* Int_X */8 : + return "%lX"; + case /* Int_CX */9 : + return "%#lX"; + case /* Int_o */10 : + return "%lo"; + case /* Int_Co */11 : + return "%#lo"; + case /* Int_d */0 : + case /* Int_Cd */13 : + return "%ld"; + case /* Int_i */3 : + case /* Int_Ci */14 : + return "%li"; + case /* Int_u */12 : + case /* Int_Cu */15 : + return "%lu"; + + } +} + +function format_of_iconvn(param) { + switch (param) { + case /* Int_pd */1 : + return "%+nd"; + case /* Int_sd */2 : + return "% nd"; + case /* Int_pi */4 : + return "%+ni"; + case /* Int_si */5 : + return "% ni"; + case /* Int_x */6 : + return "%nx"; + case /* Int_Cx */7 : + return "%#nx"; + case /* Int_X */8 : + return "%nX"; + case /* Int_CX */9 : + return "%#nX"; + case /* Int_o */10 : + return "%no"; + case /* Int_Co */11 : + return "%#no"; + case /* Int_d */0 : + case /* Int_Cd */13 : + return "%nd"; + case /* Int_i */3 : + case /* Int_Ci */14 : + return "%ni"; + case /* Int_u */12 : + case /* Int_Cu */15 : + return "%nu"; + + } +} + +function format_of_fconv(fconv, prec) { + var prec$1 = Stdlib.abs(prec); + var symb = char_of_fconv(/* 'g' */103, fconv); + var buf = { + ind: 0, + bytes: Caml_bytes.caml_create_bytes(16) + }; + buffer_add_char(buf, /* '%' */37); + bprint_fconv_flag(buf, fconv); + buffer_add_char(buf, /* '.' */46); + buffer_add_string(buf, Caml_format.caml_format_int("%d", prec$1)); + buffer_add_char(buf, symb); + return buffer_contents(buf); +} + +function transform_int_alt(iconv, s) { + if (iconv < 13) { + return s; + } + var n = 0; + for(var i = 0 ,i_finish = s.length; i < i_finish; ++i){ + var match = s.charCodeAt(i); + if (!(match > 57 || match < 48)) { + n = n + 1 | 0; + } + + } + var digits = n; + var buf = Caml_bytes.caml_create_bytes(s.length + ((digits - 1 | 0) / 3 | 0) | 0); + var pos = { + contents: 0 + }; + var put = function (c) { + Caml_bytes.set(buf, pos.contents, c); + pos.contents = pos.contents + 1 | 0; + }; + var left = (digits - 1 | 0) % 3 + 1 | 0; + for(var i$1 = 0 ,i_finish$1 = s.length; i$1 < i_finish$1; ++i$1){ + var c = s.charCodeAt(i$1); + if (c > 57 || c < 48) { + put(c); + } else { + if (left === 0) { + put(/* '_' */95); + left = 3; + } + left = left - 1 | 0; + put(c); + } + } + return Caml_bytes.bytes_to_string(buf); +} + +function convert_int(iconv, n) { + return transform_int_alt(iconv, Caml_format.caml_format_int(format_of_iconv(iconv), n)); +} + +function convert_int32(iconv, n) { + return transform_int_alt(iconv, Caml_format.caml_int32_format(format_of_iconvl(iconv), n)); +} + +function convert_nativeint(iconv, n) { + return transform_int_alt(iconv, Caml_format.caml_nativeint_format(format_of_iconvn(iconv), n)); +} + +function convert_int64(iconv, n) { + return transform_int_alt(iconv, Caml_format.caml_int64_format(format_of_iconvL(iconv), n)); +} + +function convert_float(fconv, prec, x) { + var hex = function (param) { + var match = fconv[0]; + var sign; + switch (match) { + case /* Float_flag_ */0 : + sign = /* '-' */45; + break; + case /* Float_flag_p */1 : + sign = /* '+' */43; + break; + case /* Float_flag_s */2 : + sign = /* ' ' */32; + break; + + } + return Caml_format.caml_hexstring_of_float(x, prec, sign); + }; + var add_dot_if_needed = function (str) { + var len = str.length; + var is_valid = function (_i) { + while(true) { + var i = _i; + if (i === len) { + return false; + } + var match = Caml_string.get(str, i); + if (match > 69 || match < 46) { + if (match === 101) { + return true; + } + _i = i + 1 | 0; + continue ; + } + if (match > 68 || match < 47) { + return true; + } + _i = i + 1 | 0; + continue ; + }; + }; + if (is_valid(0)) { + return str; + } else { + return str + "."; + } + }; + var caml_special_val = function (str) { + var match = Stdlib.classify_float(x); + if (match !== 3) { + if (match >= 4) { + return "nan"; + } else { + return str; + } + } else if (x < 0.0) { + return "neg_infinity"; + } else { + return "infinity"; + } + }; + var match = fconv[1]; + switch (match) { + case /* Float_f */0 : + case /* Float_e */1 : + case /* Float_E */2 : + case /* Float_g */3 : + case /* Float_G */4 : + break; + case /* Float_F */5 : + var str = Caml_format.caml_format_float(format_of_fconv(fconv, prec), x); + return caml_special_val(add_dot_if_needed(str)); + case /* Float_h */6 : + return hex(undefined); + case /* Float_H */7 : + var s = hex(undefined); + return Caml_bytes.bytes_to_string(Stdlib__Bytes.uppercase_ascii(Caml_bytes.bytes_of_string(s))); + case /* Float_CF */8 : + return caml_special_val(hex(undefined)); + + } + return Caml_format.caml_format_float(format_of_fconv(fconv, prec), x); +} + +function format_caml_char(c) { + var str = Stdlib__Char.escaped(c); + var l = str.length; + var res = Stdlib__Bytes.make(l + 2 | 0, /* '\'' */39); + Caml_bytes.caml_blit_string(str, 0, res, 1, l); + return Caml_bytes.bytes_to_string(res); +} + +function string_of_fmtty(fmtty) { + var buf = { + ind: 0, + bytes: Caml_bytes.caml_create_bytes(16) + }; + bprint_fmtty(buf, fmtty); + return buffer_contents(buf); +} + +function make_printf(_k, _acc, _fmt) { + while(true) { + var fmt = _fmt; + var acc = _acc; + var k = _k; + if (typeof fmt === "number") { + return Curry._1(k, acc); + } + switch (fmt.TAG | 0) { + case /* Char */0 : + var rest = fmt._0; + return (function(k,acc,rest){ + return function (c) { + var new_acc = { + TAG: /* Acc_data_char */5, + _0: acc, + _1: c + }; + return make_printf(k, new_acc, rest); + } + }(k,acc,rest)); + case /* Caml_char */1 : + var rest$1 = fmt._0; + return (function(k,acc,rest$1){ + return function (c) { + var new_acc_1 = format_caml_char(c); + var new_acc = { + TAG: /* Acc_data_string */4, + _0: acc, + _1: new_acc_1 + }; + return make_printf(k, new_acc, rest$1); + } + }(k,acc,rest$1)); + case /* String */2 : + return make_padding(k, acc, fmt._1, fmt._0, (function (str) { + return str; + })); + case /* Caml_string */3 : + return make_padding(k, acc, fmt._1, fmt._0, string_to_caml_string); + case /* Int */4 : + return make_int_padding_precision(k, acc, fmt._3, fmt._1, fmt._2, convert_int, fmt._0); + case /* Int32 */5 : + return make_int_padding_precision(k, acc, fmt._3, fmt._1, fmt._2, convert_int32, fmt._0); + case /* Nativeint */6 : + return make_int_padding_precision(k, acc, fmt._3, fmt._1, fmt._2, convert_nativeint, fmt._0); + case /* Int64 */7 : + return make_int_padding_precision(k, acc, fmt._3, fmt._1, fmt._2, convert_int64, fmt._0); + case /* Float */8 : + var fmt$1 = fmt._3; + var pad = fmt._1; + var prec = fmt._2; + var fconv = fmt._0; + if (typeof pad === "number") { + if (typeof prec === "number") { + if (prec) { + return (function(k,acc,fmt$1,fconv){ + return function (p, x) { + var str = convert_float(fconv, p, x); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str + }, fmt$1); + } + }(k,acc,fmt$1,fconv)); + } else { + return (function(k,acc,fmt$1,fconv){ + return function (x) { + var str = convert_float(fconv, default_float_precision(fconv), x); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str + }, fmt$1); + } + }(k,acc,fmt$1,fconv)); + } + } + var p = prec._0; + return (function(k,acc,fmt$1,fconv,p){ + return function (x) { + var str = convert_float(fconv, p, x); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str + }, fmt$1); + } + }(k,acc,fmt$1,fconv,p)); + } + if (pad.TAG === /* Lit_padding */0) { + var w = pad._1; + var padty = pad._0; + if (typeof prec === "number") { + if (prec) { + return (function(k,acc,fmt$1,fconv,padty,w){ + return function (p, x) { + var str = fix_padding(padty, w, convert_float(fconv, p, x)); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str + }, fmt$1); + } + }(k,acc,fmt$1,fconv,padty,w)); + } else { + return (function(k,acc,fmt$1,fconv,padty,w){ + return function (x) { + var str = convert_float(fconv, default_float_precision(fconv), x); + var str$p = fix_padding(padty, w, str); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str$p + }, fmt$1); + } + }(k,acc,fmt$1,fconv,padty,w)); + } + } + var p$1 = prec._0; + return (function(k,acc,fmt$1,fconv,padty,w,p$1){ + return function (x) { + var str = fix_padding(padty, w, convert_float(fconv, p$1, x)); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str + }, fmt$1); + } + }(k,acc,fmt$1,fconv,padty,w,p$1)); + } + var padty$1 = pad._0; + if (typeof prec === "number") { + if (prec) { + return (function(k,acc,fmt$1,fconv,padty$1){ + return function (w, p, x) { + var str = fix_padding(padty$1, w, convert_float(fconv, p, x)); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str + }, fmt$1); + } + }(k,acc,fmt$1,fconv,padty$1)); + } else { + return (function(k,acc,fmt$1,fconv,padty$1){ + return function (w, x) { + var str = convert_float(fconv, default_float_precision(fconv), x); + var str$p = fix_padding(padty$1, w, str); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str$p + }, fmt$1); + } + }(k,acc,fmt$1,fconv,padty$1)); + } + } + var p$2 = prec._0; + return (function(k,acc,fmt$1,fconv,padty$1,p$2){ + return function (w, x) { + var str = fix_padding(padty$1, w, convert_float(fconv, p$2, x)); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str + }, fmt$1); + } + }(k,acc,fmt$1,fconv,padty$1,p$2)); + case /* Bool */9 : + return make_padding(k, acc, fmt._1, fmt._0, Stdlib.string_of_bool); + case /* Flush */10 : + _fmt = fmt._0; + _acc = { + TAG: /* Acc_flush */7, + _0: acc + }; + continue ; + case /* String_literal */11 : + _fmt = fmt._1; + _acc = { + TAG: /* Acc_string_literal */2, + _0: acc, + _1: fmt._0 + }; + continue ; + case /* Char_literal */12 : + _fmt = fmt._1; + _acc = { + TAG: /* Acc_char_literal */3, + _0: acc, + _1: fmt._0 + }; + continue ; + case /* Format_arg */13 : + var rest$2 = fmt._2; + var ty = string_of_fmtty(fmt._1); + return (function(k,acc,rest$2,ty){ + return function (str) { + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: ty + }, rest$2); + } + }(k,acc,rest$2,ty)); + case /* Format_subst */14 : + var rest$3 = fmt._2; + var fmtty = fmt._1; + return (function(k,acc,fmtty,rest$3){ + return function (param) { + return make_printf(k, acc, CamlinternalFormatBasics.concat_fmt(recast(param._0, fmtty), rest$3)); + } + }(k,acc,fmtty,rest$3)); + case /* Alpha */15 : + var rest$4 = fmt._0; + return (function(k,acc,rest$4){ + return function (f, x) { + return make_printf(k, { + TAG: /* Acc_delay */6, + _0: acc, + _1: (function (o) { + return Curry._2(f, o, x); + }) + }, rest$4); + } + }(k,acc,rest$4)); + case /* Theta */16 : + var rest$5 = fmt._0; + return (function(k,acc,rest$5){ + return function (f) { + return make_printf(k, { + TAG: /* Acc_delay */6, + _0: acc, + _1: f + }, rest$5); + } + }(k,acc,rest$5)); + case /* Formatting_lit */17 : + _fmt = fmt._1; + _acc = { + TAG: /* Acc_formatting_lit */0, + _0: acc, + _1: fmt._0 + }; + continue ; + case /* Formatting_gen */18 : + var match = fmt._0; + if (match.TAG === /* Open_tag */0) { + var rest$6 = fmt._1; + var k$p = (function(k,acc,rest$6){ + return function k$p(kacc) { + return make_printf(k, { + TAG: /* Acc_formatting_gen */1, + _0: acc, + _1: { + TAG: /* Acc_open_tag */0, + _0: kacc + } + }, rest$6); + } + }(k,acc,rest$6)); + _fmt = match._0._0; + _acc = /* End_of_acc */0; + _k = k$p; + continue ; + } + var rest$7 = fmt._1; + var k$p$1 = (function(k,acc,rest$7){ + return function k$p$1(kacc) { + return make_printf(k, { + TAG: /* Acc_formatting_gen */1, + _0: acc, + _1: { + TAG: /* Acc_open_box */1, + _0: kacc + } + }, rest$7); + } + }(k,acc,rest$7)); + _fmt = match._0._0; + _acc = /* End_of_acc */0; + _k = k$p$1; + continue ; + case /* Reader */19 : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 1558, + 4 + ], + Error: new Error() + }; + case /* Scan_char_set */20 : + var rest$8 = fmt._2; + var new_acc = { + TAG: /* Acc_invalid_arg */8, + _0: acc, + _1: "Printf: bad conversion %[" + }; + return (function(k,rest$8,new_acc){ + return function (param) { + return make_printf(k, new_acc, rest$8); + } + }(k,rest$8,new_acc)); + case /* Scan_get_counter */21 : + var rest$9 = fmt._1; + return (function(k,acc,rest$9){ + return function (n) { + var new_acc_1 = Caml_format.caml_format_int("%u", n); + var new_acc = { + TAG: /* Acc_data_string */4, + _0: acc, + _1: new_acc_1 + }; + return make_printf(k, new_acc, rest$9); + } + }(k,acc,rest$9)); + case /* Scan_next_char */22 : + var rest$10 = fmt._0; + return (function(k,acc,rest$10){ + return function (c) { + var new_acc = { + TAG: /* Acc_data_char */5, + _0: acc, + _1: c + }; + return make_printf(k, new_acc, rest$10); + } + }(k,acc,rest$10)); + case /* Ignored_param */23 : + return make_ignored_param(k, acc, fmt._0, fmt._1); + case /* Custom */24 : + return make_custom(k, acc, fmt._2, fmt._0, Curry._1(fmt._1, undefined)); + + } + }; +} + +function make_ignored_param(k, acc, ign, fmt) { + if (typeof ign !== "number") { + if (ign.TAG === /* Ignored_format_subst */9) { + return make_from_fmtty(k, acc, ign._1, fmt); + } else { + return make_invalid_arg(k, acc, fmt); + } + } + if (ign !== /* Ignored_reader */2) { + return make_invalid_arg(k, acc, fmt); + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 1626, + 39 + ], + Error: new Error() + }; +} + +function make_from_fmtty(k, acc, fmtty, fmt) { + if (typeof fmtty === "number") { + return make_invalid_arg(k, acc, fmt); + } + switch (fmtty.TAG | 0) { + case /* Char_ty */0 : + var rest = fmtty._0; + return function (param) { + return make_from_fmtty(k, acc, rest, fmt); + }; + case /* String_ty */1 : + var rest$1 = fmtty._0; + return function (param) { + return make_from_fmtty(k, acc, rest$1, fmt); + }; + case /* Int_ty */2 : + var rest$2 = fmtty._0; + return function (param) { + return make_from_fmtty(k, acc, rest$2, fmt); + }; + case /* Int32_ty */3 : + var rest$3 = fmtty._0; + return function (param) { + return make_from_fmtty(k, acc, rest$3, fmt); + }; + case /* Nativeint_ty */4 : + var rest$4 = fmtty._0; + return function (param) { + return make_from_fmtty(k, acc, rest$4, fmt); + }; + case /* Int64_ty */5 : + var rest$5 = fmtty._0; + return function (param) { + return make_from_fmtty(k, acc, rest$5, fmt); + }; + case /* Float_ty */6 : + var rest$6 = fmtty._0; + return function (param) { + return make_from_fmtty(k, acc, rest$6, fmt); + }; + case /* Bool_ty */7 : + var rest$7 = fmtty._0; + return function (param) { + return make_from_fmtty(k, acc, rest$7, fmt); + }; + case /* Format_arg_ty */8 : + var rest$8 = fmtty._1; + return function (param) { + return make_from_fmtty(k, acc, rest$8, fmt); + }; + case /* Format_subst_ty */9 : + var rest$9 = fmtty._2; + var ty = trans(symm(fmtty._0), fmtty._1); + return function (param) { + return make_from_fmtty(k, acc, CamlinternalFormatBasics.concat_fmtty(ty, rest$9), fmt); + }; + case /* Alpha_ty */10 : + var rest$10 = fmtty._0; + return function (param, param$1) { + return make_from_fmtty(k, acc, rest$10, fmt); + }; + case /* Theta_ty */11 : + var rest$11 = fmtty._0; + return function (param) { + return make_from_fmtty(k, acc, rest$11, fmt); + }; + case /* Any_ty */12 : + var rest$12 = fmtty._0; + return function (param) { + return make_from_fmtty(k, acc, rest$12, fmt); + }; + case /* Reader_ty */13 : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 1649, + 31 + ], + Error: new Error() + }; + case /* Ignored_reader_ty */14 : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 1650, + 31 + ], + Error: new Error() + }; + + } +} + +function make_invalid_arg(k, acc, fmt) { + return make_printf(k, { + TAG: /* Acc_invalid_arg */8, + _0: acc, + _1: "Printf: bad conversion %_" + }, fmt); +} + +function make_padding(k, acc, fmt, pad, trans) { + if (typeof pad === "number") { + return function (x) { + var new_acc_1 = Curry._1(trans, x); + var new_acc = { + TAG: /* Acc_data_string */4, + _0: acc, + _1: new_acc_1 + }; + return make_printf(k, new_acc, fmt); + }; + } + if (pad.TAG === /* Lit_padding */0) { + var width = pad._1; + var padty = pad._0; + return function (x) { + var new_acc_1 = fix_padding(padty, width, Curry._1(trans, x)); + var new_acc = { + TAG: /* Acc_data_string */4, + _0: acc, + _1: new_acc_1 + }; + return make_printf(k, new_acc, fmt); + }; + } + var padty$1 = pad._0; + return function (w, x) { + var new_acc_1 = fix_padding(padty$1, w, Curry._1(trans, x)); + var new_acc = { + TAG: /* Acc_data_string */4, + _0: acc, + _1: new_acc_1 + }; + return make_printf(k, new_acc, fmt); + }; +} + +function make_int_padding_precision(k, acc, fmt, pad, prec, trans, iconv) { + if (typeof pad === "number") { + if (typeof prec === "number") { + if (prec) { + return function (p, x) { + var str = fix_int_precision(p, Curry._2(trans, iconv, x)); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str + }, fmt); + }; + } else { + return function (x) { + var str = Curry._2(trans, iconv, x); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str + }, fmt); + }; + } + } + var p = prec._0; + return function (x) { + var str = fix_int_precision(p, Curry._2(trans, iconv, x)); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str + }, fmt); + }; + } + if (pad.TAG === /* Lit_padding */0) { + var w = pad._1; + var padty = pad._0; + if (typeof prec === "number") { + if (prec) { + return function (p, x) { + var str = fix_padding(padty, w, fix_int_precision(p, Curry._2(trans, iconv, x))); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str + }, fmt); + }; + } else { + return function (x) { + var str = fix_padding(padty, w, Curry._2(trans, iconv, x)); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str + }, fmt); + }; + } + } + var p$1 = prec._0; + return function (x) { + var str = fix_padding(padty, w, fix_int_precision(p$1, Curry._2(trans, iconv, x))); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str + }, fmt); + }; + } + var padty$1 = pad._0; + if (typeof prec === "number") { + if (prec) { + return function (w, p, x) { + var str = fix_padding(padty$1, w, fix_int_precision(p, Curry._2(trans, iconv, x))); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str + }, fmt); + }; + } else { + return function (w, x) { + var str = fix_padding(padty$1, w, Curry._2(trans, iconv, x)); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str + }, fmt); + }; + } + } + var p$2 = prec._0; + return function (w, x) { + var str = fix_padding(padty$1, w, fix_int_precision(p$2, Curry._2(trans, iconv, x))); + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: str + }, fmt); + }; +} + +function make_custom(k, acc, rest, arity, f) { + if (!arity) { + return make_printf(k, { + TAG: /* Acc_data_string */4, + _0: acc, + _1: f + }, rest); + } + var arity$1 = arity._0; + return function (x) { + return make_custom(k, acc, rest, arity$1, Curry._1(f, x)); + }; +} + +function make_iprintf(_k, o, _fmt) { + while(true) { + var fmt = _fmt; + var k = _k; + var exit = 0; + if (typeof fmt === "number") { + return Curry._1(k, o); + } + switch (fmt.TAG | 0) { + case /* String */2 : + var exit$1 = 0; + var tmp = fmt._0; + if (typeof tmp === "number" || tmp.TAG === /* Lit_padding */0) { + exit$1 = 4; + } else { + var partial_arg = make_iprintf(k, o, fmt._1); + var partial_arg$1 = (function(partial_arg){ + return function partial_arg$1(param) { + return partial_arg; + } + }(partial_arg)); + return function (param) { + return partial_arg$1; + }; + } + if (exit$1 === 4) { + var partial_arg$2 = make_iprintf(k, o, fmt._1); + return (function(partial_arg$2){ + return function (param) { + return partial_arg$2; + } + }(partial_arg$2)); + } + break; + case /* Caml_string */3 : + var exit$2 = 0; + var tmp$1 = fmt._0; + if (typeof tmp$1 === "number" || tmp$1.TAG === /* Lit_padding */0) { + exit$2 = 4; + } else { + var partial_arg$3 = make_iprintf(k, o, fmt._1); + var partial_arg$4 = (function(partial_arg$3){ + return function partial_arg$4(param) { + return partial_arg$3; + } + }(partial_arg$3)); + return function (param) { + return partial_arg$4; + }; + } + if (exit$2 === 4) { + var partial_arg$5 = make_iprintf(k, o, fmt._1); + return (function(partial_arg$5){ + return function (param) { + return partial_arg$5; + } + }(partial_arg$5)); + } + break; + case /* Bool */9 : + var exit$3 = 0; + var tmp$2 = fmt._0; + if (typeof tmp$2 === "number" || tmp$2.TAG === /* Lit_padding */0) { + exit$3 = 4; + } else { + var partial_arg$6 = make_iprintf(k, o, fmt._1); + var partial_arg$7 = (function(partial_arg$6){ + return function partial_arg$7(param) { + return partial_arg$6; + } + }(partial_arg$6)); + return function (param) { + return partial_arg$7; + }; + } + if (exit$3 === 4) { + var partial_arg$8 = make_iprintf(k, o, fmt._1); + return (function(partial_arg$8){ + return function (param) { + return partial_arg$8; + } + }(partial_arg$8)); + } + break; + case /* Flush */10 : + _fmt = fmt._0; + continue ; + case /* Format_subst */14 : + var rest = fmt._2; + var fmtty = fmt._1; + return (function(k,fmtty,rest){ + return function (param) { + return make_iprintf(k, o, CamlinternalFormatBasics.concat_fmt(recast(param._0, fmtty), rest)); + } + }(k,fmtty,rest)); + case /* Alpha */15 : + var partial_arg$9 = make_iprintf(k, o, fmt._0); + var partial_arg$10 = (function(partial_arg$9){ + return function partial_arg$10(param) { + return partial_arg$9; + } + }(partial_arg$9)); + return function (param) { + return partial_arg$10; + }; + case /* String_literal */11 : + case /* Char_literal */12 : + case /* Formatting_lit */17 : + exit = 2; + break; + case /* Formatting_gen */18 : + var match = fmt._0; + if (match.TAG === /* Open_tag */0) { + var rest$1 = fmt._1; + _fmt = match._0._0; + _k = (function(k,rest$1){ + return function (koc) { + return make_iprintf(k, koc, rest$1); + } + }(k,rest$1)); + continue ; + } + var rest$2 = fmt._1; + _fmt = match._0._0; + _k = (function(k,rest$2){ + return function (koc) { + return make_iprintf(k, koc, rest$2); + } + }(k,rest$2)); + continue ; + case /* Reader */19 : + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 1830, + 8 + ], + Error: new Error() + }; + case /* Format_arg */13 : + case /* Scan_char_set */20 : + exit = 3; + break; + case /* Scan_get_counter */21 : + var partial_arg$11 = make_iprintf(k, o, fmt._1); + return (function(partial_arg$11){ + return function (param) { + return partial_arg$11; + } + }(partial_arg$11)); + case /* Char */0 : + case /* Caml_char */1 : + case /* Theta */16 : + case /* Scan_next_char */22 : + exit = 1; + break; + case /* Ignored_param */23 : + return make_ignored_param((function(k){ + return function (param) { + return Curry._1(k, o); + } + }(k)), /* End_of_acc */0, fmt._0, fmt._1); + case /* Custom */24 : + return fn_of_custom_arity(k, o, fmt._2, fmt._0); + default: + var fmt$1 = fmt._3; + var pad = fmt._1; + var prec = fmt._2; + if (typeof pad === "number") { + if (typeof prec === "number") { + if (prec) { + var partial_arg$12 = make_iprintf(k, o, fmt$1); + var partial_arg$13 = (function(partial_arg$12){ + return function partial_arg$13(param) { + return partial_arg$12; + } + }(partial_arg$12)); + return function (param) { + return partial_arg$13; + }; + } + var partial_arg$14 = make_iprintf(k, o, fmt$1); + return (function(partial_arg$14){ + return function (param) { + return partial_arg$14; + } + }(partial_arg$14)); + } + var partial_arg$15 = make_iprintf(k, o, fmt$1); + return (function(partial_arg$15){ + return function (param) { + return partial_arg$15; + } + }(partial_arg$15)); + } + if (pad.TAG === /* Lit_padding */0) { + if (typeof prec === "number") { + if (prec) { + var partial_arg$16 = make_iprintf(k, o, fmt$1); + var partial_arg$17 = (function(partial_arg$16){ + return function partial_arg$17(param) { + return partial_arg$16; + } + }(partial_arg$16)); + return function (param) { + return partial_arg$17; + }; + } + var partial_arg$18 = make_iprintf(k, o, fmt$1); + return (function(partial_arg$18){ + return function (param) { + return partial_arg$18; + } + }(partial_arg$18)); + } + var partial_arg$19 = make_iprintf(k, o, fmt$1); + return (function(partial_arg$19){ + return function (param) { + return partial_arg$19; + } + }(partial_arg$19)); + } + if (typeof prec === "number") { + if (prec) { + var partial_arg$20 = make_iprintf(k, o, fmt$1); + var partial_arg$21 = (function(partial_arg$20){ + return function partial_arg$21(param) { + return partial_arg$20; + } + }(partial_arg$20)); + var partial_arg$22 = function (param) { + return partial_arg$21; + }; + return function (param) { + return partial_arg$22; + }; + } + var partial_arg$23 = make_iprintf(k, o, fmt$1); + var partial_arg$24 = (function(partial_arg$23){ + return function partial_arg$24(param) { + return partial_arg$23; + } + }(partial_arg$23)); + return function (param) { + return partial_arg$24; + }; + } + var partial_arg$25 = make_iprintf(k, o, fmt$1); + var partial_arg$26 = (function(partial_arg$25){ + return function partial_arg$26(param) { + return partial_arg$25; + } + }(partial_arg$25)); + return function (param) { + return partial_arg$26; + }; + } + switch (exit) { + case 1 : + var partial_arg$27 = make_iprintf(k, o, fmt._0); + return (function(partial_arg$27){ + return function (param) { + return partial_arg$27; + } + }(partial_arg$27)); + case 2 : + _fmt = fmt._1; + continue ; + case 3 : + var partial_arg$28 = make_iprintf(k, o, fmt._2); + return (function(partial_arg$28){ + return function (param) { + return partial_arg$28; + } + }(partial_arg$28)); + + } + }; +} + +function fn_of_custom_arity(k, o, fmt, param) { + if (!param) { + return make_iprintf(k, o, fmt); + } + var partial_arg = fn_of_custom_arity(k, o, fmt, param._0); + return function (param) { + return partial_arg; + }; +} + +function output_acc(o, _acc) { + while(true) { + var acc = _acc; + var exit = 0; + if (typeof acc === "number") { + return ; + } + switch (acc.TAG | 0) { + case /* Acc_formatting_lit */0 : + var s = string_of_formatting_lit(acc._1); + output_acc(o, acc._0); + return Stdlib.output_string(o, s); + case /* Acc_formatting_gen */1 : + var acc$p = acc._1; + var p = acc._0; + if (acc$p.TAG === /* Acc_open_tag */0) { + output_acc(o, p); + Stdlib.output_string(o, "@{"); + _acc = acc$p._0; + continue ; + } + output_acc(o, p); + Stdlib.output_string(o, "@["); + _acc = acc$p._0; + continue ; + case /* Acc_string_literal */2 : + case /* Acc_data_string */4 : + exit = 1; + break; + case /* Acc_char_literal */3 : + case /* Acc_data_char */5 : + exit = 2; + break; + case /* Acc_delay */6 : + output_acc(o, acc._0); + return Curry._1(acc._1, o); + case /* Acc_flush */7 : + output_acc(o, acc._0); + return Caml_io.caml_ml_flush(o); + case /* Acc_invalid_arg */8 : + output_acc(o, acc._0); + throw { + RE_EXN_ID: "Invalid_argument", + _1: acc._1, + Error: new Error() + }; + + } + switch (exit) { + case 1 : + output_acc(o, acc._0); + return Stdlib.output_string(o, acc._1); + case 2 : + output_acc(o, acc._0); + return Caml_io.caml_ml_output_char(o, acc._1); + + } + }; +} + +function bufput_acc(b, _acc) { + while(true) { + var acc = _acc; + var exit = 0; + if (typeof acc === "number") { + return ; + } + switch (acc.TAG | 0) { + case /* Acc_formatting_lit */0 : + var s = string_of_formatting_lit(acc._1); + bufput_acc(b, acc._0); + return Stdlib__Buffer.add_string(b, s); + case /* Acc_formatting_gen */1 : + var acc$p = acc._1; + var p = acc._0; + if (acc$p.TAG === /* Acc_open_tag */0) { + bufput_acc(b, p); + Stdlib__Buffer.add_string(b, "@{"); + _acc = acc$p._0; + continue ; + } + bufput_acc(b, p); + Stdlib__Buffer.add_string(b, "@["); + _acc = acc$p._0; + continue ; + case /* Acc_string_literal */2 : + case /* Acc_data_string */4 : + exit = 1; + break; + case /* Acc_char_literal */3 : + case /* Acc_data_char */5 : + exit = 2; + break; + case /* Acc_delay */6 : + bufput_acc(b, acc._0); + return Curry._1(acc._1, b); + case /* Acc_flush */7 : + _acc = acc._0; + continue ; + case /* Acc_invalid_arg */8 : + bufput_acc(b, acc._0); + throw { + RE_EXN_ID: "Invalid_argument", + _1: acc._1, + Error: new Error() + }; + + } + switch (exit) { + case 1 : + bufput_acc(b, acc._0); + return Stdlib__Buffer.add_string(b, acc._1); + case 2 : + bufput_acc(b, acc._0); + return Stdlib__Buffer.add_char(b, acc._1); + + } + }; +} + +function strput_acc(b, _acc) { + while(true) { + var acc = _acc; + var exit = 0; + if (typeof acc === "number") { + return ; + } + switch (acc.TAG | 0) { + case /* Acc_formatting_lit */0 : + var s = string_of_formatting_lit(acc._1); + strput_acc(b, acc._0); + return Stdlib__Buffer.add_string(b, s); + case /* Acc_formatting_gen */1 : + var acc$p = acc._1; + var p = acc._0; + if (acc$p.TAG === /* Acc_open_tag */0) { + strput_acc(b, p); + Stdlib__Buffer.add_string(b, "@{"); + _acc = acc$p._0; + continue ; + } + strput_acc(b, p); + Stdlib__Buffer.add_string(b, "@["); + _acc = acc$p._0; + continue ; + case /* Acc_string_literal */2 : + case /* Acc_data_string */4 : + exit = 1; + break; + case /* Acc_char_literal */3 : + case /* Acc_data_char */5 : + exit = 2; + break; + case /* Acc_delay */6 : + strput_acc(b, acc._0); + return Stdlib__Buffer.add_string(b, Curry._1(acc._1, undefined)); + case /* Acc_flush */7 : + _acc = acc._0; + continue ; + case /* Acc_invalid_arg */8 : + strput_acc(b, acc._0); + throw { + RE_EXN_ID: "Invalid_argument", + _1: acc._1, + Error: new Error() + }; + + } + switch (exit) { + case 1 : + strput_acc(b, acc._0); + return Stdlib__Buffer.add_string(b, acc._1); + case 2 : + strput_acc(b, acc._0); + return Stdlib__Buffer.add_char(b, acc._1); + + } + }; +} + +function failwith_message(param) { + var buf = Stdlib__Buffer.create(256); + var k = function (acc) { + strput_acc(buf, acc); + var s = Stdlib__Buffer.contents(buf); + throw { + RE_EXN_ID: "Failure", + _1: s, + Error: new Error() + }; + }; + return make_printf(k, /* End_of_acc */0, param._0); +} + +function open_box_of_string(str) { + if (str === "") { + return [ + 0, + /* Pp_box */4 + ]; + } + var len = str.length; + var invalid_box = function (param) { + return Curry._1(failwith_message(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "invalid box description ", + _1: { + TAG: /* Caml_string */3, + _0: /* No_padding */0, + _1: /* End_of_format */0 + } + }, + _1: "invalid box description %S" + }), str); + }; + var parse_spaces = function (_i) { + while(true) { + var i = _i; + if (i === len) { + return i; + } + var match = Caml_string.get(str, i); + if (match !== 9) { + if (match !== 32) { + return i; + } + _i = i + 1 | 0; + continue ; + } + _i = i + 1 | 0; + continue ; + }; + }; + var parse_lword = function (i, _j) { + while(true) { + var j = _j; + if (j === len) { + return j; + } + var match = Caml_string.get(str, j); + if (match > 122 || match < 97) { + return j; + } + _j = j + 1 | 0; + continue ; + }; + }; + var parse_int = function (i, _j) { + while(true) { + var j = _j; + if (j === len) { + return j; + } + var match = Caml_string.get(str, j); + if (match >= 48) { + if (match >= 58) { + return j; + } + _j = j + 1 | 0; + continue ; + } + if (match !== 45) { + return j; + } + _j = j + 1 | 0; + continue ; + }; + }; + var wstart = parse_spaces(0); + var wend = parse_lword(wstart, wstart); + var box_name = Stdlib__String.sub(str, wstart, wend - wstart | 0); + var nstart = parse_spaces(wend); + var nend = parse_int(nstart, nstart); + var indent; + if (nstart === nend) { + indent = 0; + } else { + try { + indent = Caml_format.caml_int_of_string(Stdlib__String.sub(str, nstart, nend - nstart | 0)); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Failure) { + indent = invalid_box(undefined); + } else { + throw exn; + } + } + } + var exp_end = parse_spaces(nend); + if (exp_end !== len) { + invalid_box(undefined); + } + var box_type; + switch (box_name) { + case "" : + case "b" : + box_type = /* Pp_box */4; + break; + case "h" : + box_type = /* Pp_hbox */0; + break; + case "hov" : + box_type = /* Pp_hovbox */3; + break; + case "hv" : + box_type = /* Pp_hvbox */2; + break; + case "v" : + box_type = /* Pp_vbox */1; + break; + default: + box_type = invalid_box(undefined); + } + return [ + indent, + box_type + ]; +} + +function make_padding_fmt_ebb(pad, fmt) { + if (typeof pad === "number") { + return /* Padding_fmt_EBB */{ + _0: /* No_padding */0, + _1: fmt + }; + } else if (pad.TAG === /* Lit_padding */0) { + return /* Padding_fmt_EBB */{ + _0: { + TAG: /* Lit_padding */0, + _0: pad._0, + _1: pad._1 + }, + _1: fmt + }; + } else { + return /* Padding_fmt_EBB */{ + _0: { + TAG: /* Arg_padding */1, + _0: pad._0 + }, + _1: fmt + }; + } +} + +function make_precision_fmt_ebb(prec, fmt) { + if (typeof prec === "number") { + if (prec) { + return /* Precision_fmt_EBB */{ + _0: /* Arg_precision */1, + _1: fmt + }; + } else { + return /* Precision_fmt_EBB */{ + _0: /* No_precision */0, + _1: fmt + }; + } + } else { + return /* Precision_fmt_EBB */{ + _0: /* Lit_precision */{ + _0: prec._0 + }, + _1: fmt + }; + } +} + +function make_padprec_fmt_ebb(pad, prec, fmt) { + var match = make_precision_fmt_ebb(prec, fmt); + var fmt$p = match._1; + var prec$1 = match._0; + if (typeof pad === "number") { + return /* Padprec_fmt_EBB */{ + _0: /* No_padding */0, + _1: prec$1, + _2: fmt$p + }; + } else if (pad.TAG === /* Lit_padding */0) { + return /* Padprec_fmt_EBB */{ + _0: { + TAG: /* Lit_padding */0, + _0: pad._0, + _1: pad._1 + }, + _1: prec$1, + _2: fmt$p + }; + } else { + return /* Padprec_fmt_EBB */{ + _0: { + TAG: /* Arg_padding */1, + _0: pad._0 + }, + _1: prec$1, + _2: fmt$p + }; + } +} + +function fmt_ebb_of_string(legacy_behavior, str) { + var legacy_behavior$1 = legacy_behavior !== undefined ? legacy_behavior : true; + var invalid_format_message = function (str_ind, msg) { + return Curry._3(failwith_message(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "invalid format ", + _1: { + TAG: /* Caml_string */3, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: ": at character number ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* String_literal */11, + _0: ", ", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: /* End_of_format */0 + } + } + } + } + } + }, + _1: "invalid format %S: at character number %d, %s" + }), str, str_ind, msg); + }; + var invalid_format_without = function (str_ind, c, s) { + return Curry._4(failwith_message(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "invalid format ", + _1: { + TAG: /* Caml_string */3, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: ": at character number ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* String_literal */11, + _0: ", '", + _1: { + TAG: /* Char */0, + _0: { + TAG: /* String_literal */11, + _0: "' without ", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: /* End_of_format */0 + } + } + } + } + } + } + } + }, + _1: "invalid format %S: at character number %d, '%c' without %s" + }), str, str_ind, c, s); + }; + var expected_character = function (str_ind, expected, read) { + return Curry._4(failwith_message(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "invalid format ", + _1: { + TAG: /* Caml_string */3, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: ": at character number ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* String_literal */11, + _0: ", ", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: " expected, read ", + _1: { + TAG: /* Caml_char */1, + _0: /* End_of_format */0 + } + } + } + } + } + } + } + }, + _1: "invalid format %S: at character number %d, %s expected, read %C" + }), str, str_ind, expected, read); + }; + var parse_flags = function (pct_ind, str_ind, end_ind, ign) { + var zero = { + contents: false + }; + var minus = { + contents: false + }; + var plus = { + contents: false + }; + var space = { + contents: false + }; + var hash = { + contents: false + }; + var set_flag = function (str_ind, flag) { + if (flag.contents && !legacy_behavior$1) { + Curry._3(failwith_message(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "invalid format ", + _1: { + TAG: /* Caml_string */3, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: ": at character number ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* String_literal */11, + _0: ", duplicate flag ", + _1: { + TAG: /* Caml_char */1, + _0: /* End_of_format */0 + } + } + } + } + } + }, + _1: "invalid format %S: at character number %d, duplicate flag %C" + }), str, str_ind, Caml_string.get(str, str_ind)); + } + flag.contents = true; + }; + var _str_ind = str_ind; + while(true) { + var str_ind$1 = _str_ind; + if (str_ind$1 === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var match = Caml_string.get(str, str_ind$1); + switch (match) { + case 32 : + set_flag(str_ind$1, space); + _str_ind = str_ind$1 + 1 | 0; + continue ; + case 35 : + set_flag(str_ind$1, hash); + _str_ind = str_ind$1 + 1 | 0; + continue ; + case 43 : + set_flag(str_ind$1, plus); + _str_ind = str_ind$1 + 1 | 0; + continue ; + case 45 : + set_flag(str_ind$1, minus); + _str_ind = str_ind$1 + 1 | 0; + continue ; + case 33 : + case 34 : + case 36 : + case 37 : + case 38 : + case 39 : + case 40 : + case 41 : + case 42 : + case 44 : + case 46 : + case 47 : + break; + case 48 : + set_flag(str_ind$1, zero); + _str_ind = str_ind$1 + 1 | 0; + continue ; + default: + + } + var zero$1 = zero.contents; + var minus$1 = minus.contents; + var plus$1 = plus.contents; + var hash$1 = hash.contents; + var space$1 = space.contents; + if (str_ind$1 === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var padty = zero$1 ? ( + minus$1 ? ( + legacy_behavior$1 ? /* Left */0 : incompatible_flag(pct_ind, str_ind$1, /* '-' */45, "0") + ) : /* Zeros */2 + ) : ( + minus$1 ? /* Left */0 : /* Right */1 + ); + var match$1 = Caml_string.get(str, str_ind$1); + if (match$1 >= 48) { + if (match$1 < 58) { + var match$2 = parse_positive(str_ind$1, end_ind, 0); + return parse_after_padding(pct_ind, match$2[0], end_ind, minus$1, plus$1, hash$1, space$1, ign, { + TAG: /* Lit_padding */0, + _0: padty, + _1: match$2[1] + }); + } + + } else if (match$1 === 42) { + return parse_after_padding(pct_ind, str_ind$1 + 1 | 0, end_ind, minus$1, plus$1, hash$1, space$1, ign, { + TAG: /* Arg_padding */1, + _0: padty + }); + } + switch (padty) { + case /* Left */0 : + if (!legacy_behavior$1) { + invalid_format_without(str_ind$1 - 1 | 0, /* '-' */45, "padding"); + } + return parse_after_padding(pct_ind, str_ind$1, end_ind, minus$1, plus$1, hash$1, space$1, ign, /* No_padding */0); + case /* Right */1 : + return parse_after_padding(pct_ind, str_ind$1, end_ind, minus$1, plus$1, hash$1, space$1, ign, /* No_padding */0); + case /* Zeros */2 : + return parse_after_padding(pct_ind, str_ind$1, end_ind, minus$1, plus$1, hash$1, space$1, ign, { + TAG: /* Lit_padding */0, + _0: /* Right */1, + _1: 0 + }); + + } + }; + }; + var parse_literal = function (lit_start, _str_ind, end_ind) { + while(true) { + var str_ind = _str_ind; + if (str_ind === end_ind) { + return add_literal(lit_start, str_ind, /* End_of_format */0); + } + var match = Caml_string.get(str, str_ind); + if (match !== 37) { + if (match !== 64) { + _str_ind = str_ind + 1 | 0; + continue ; + } + var fmt_rest = parse_after_at(str_ind + 1 | 0, end_ind); + return add_literal(lit_start, str_ind, fmt_rest._0); + } + var fmt_rest$1 = parse_format(str_ind, end_ind); + return add_literal(lit_start, str_ind, fmt_rest$1._0); + }; + }; + var parse_tag = function (is_open_tag, str_ind, end_ind) { + try { + if (str_ind === end_ind) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + var match = Caml_string.get(str, str_ind); + if (match !== 60) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + var ind = Stdlib__String.index_from(str, str_ind + 1 | 0, /* '>' */62); + if (ind >= end_ind) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + var sub_str = Stdlib__String.sub(str, str_ind, (ind - str_ind | 0) + 1 | 0); + var beg_ind = ind + 1 | 0; + var fmt_rest = parse_literal(beg_ind, beg_ind, end_ind); + var sub_fmt = parse_literal(str_ind, str_ind, ind + 1 | 0); + var sub_format_0 = sub_fmt._0; + var sub_format = /* Format */{ + _0: sub_format_0, + _1: sub_str + }; + var formatting = is_open_tag ? ({ + TAG: /* Open_tag */0, + _0: sub_format + }) : ({ + TAG: /* Open_box */1, + _0: sub_format + }); + return /* Fmt_EBB */{ + _0: { + TAG: /* Formatting_gen */18, + _0: formatting, + _1: fmt_rest._0 + } + }; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + var fmt_rest$1 = parse_literal(str_ind, str_ind, end_ind); + var sub_format$1 = /* Format */{ + _0: /* End_of_format */0, + _1: "" + }; + var formatting$1 = is_open_tag ? ({ + TAG: /* Open_tag */0, + _0: sub_format$1 + }) : ({ + TAG: /* Open_box */1, + _0: sub_format$1 + }); + return /* Fmt_EBB */{ + _0: { + TAG: /* Formatting_gen */18, + _0: formatting$1, + _1: fmt_rest$1._0 + } + }; + } + throw exn; + } + }; + var compute_int_conv = function (pct_ind, str_ind, _plus, _hash, _space, symb) { + while(true) { + var space = _space; + var hash = _hash; + var plus = _plus; + var exit = 0; + if (plus) { + if (hash) { + exit = 2; + } else if (!space) { + if (symb === 100) { + return /* Int_pd */1; + } + if (symb === 105) { + return /* Int_pi */4; + } + + } + + } else if (hash) { + if (space) { + exit = 2; + } else { + switch (symb) { + case 88 : + return /* Int_CX */9; + case 100 : + return /* Int_Cd */13; + case 105 : + return /* Int_Ci */14; + case 111 : + return /* Int_Co */11; + case 117 : + return /* Int_Cu */15; + case 89 : + case 90 : + case 91 : + case 92 : + case 93 : + case 94 : + case 95 : + case 96 : + case 97 : + case 98 : + case 99 : + case 101 : + case 102 : + case 103 : + case 104 : + case 106 : + case 107 : + case 108 : + case 109 : + case 110 : + case 112 : + case 113 : + case 114 : + case 115 : + case 116 : + case 118 : + case 119 : + exit = 2; + break; + case 120 : + return /* Int_Cx */7; + default: + exit = 2; + } + } + } else if (space) { + if (symb === 100) { + return /* Int_sd */2; + } + if (symb === 105) { + return /* Int_si */5; + } + + } else { + switch (symb) { + case 88 : + return /* Int_X */8; + case 100 : + return /* Int_d */0; + case 105 : + return /* Int_i */3; + case 111 : + return /* Int_o */10; + case 117 : + return /* Int_u */12; + case 89 : + case 90 : + case 91 : + case 92 : + case 93 : + case 94 : + case 95 : + case 96 : + case 97 : + case 98 : + case 99 : + case 101 : + case 102 : + case 103 : + case 104 : + case 106 : + case 107 : + case 108 : + case 109 : + case 110 : + case 112 : + case 113 : + case 114 : + case 115 : + case 116 : + case 118 : + case 119 : + break; + case 120 : + return /* Int_x */6; + default: + + } + } + if (exit === 2) { + var exit$1 = 0; + switch (symb) { + case 88 : + if (legacy_behavior$1) { + return /* Int_CX */9; + } + break; + case 111 : + if (legacy_behavior$1) { + return /* Int_Co */11; + } + break; + case 100 : + case 105 : + case 117 : + exit$1 = 3; + break; + case 89 : + case 90 : + case 91 : + case 92 : + case 93 : + case 94 : + case 95 : + case 96 : + case 97 : + case 98 : + case 99 : + case 101 : + case 102 : + case 103 : + case 104 : + case 106 : + case 107 : + case 108 : + case 109 : + case 110 : + case 112 : + case 113 : + case 114 : + case 115 : + case 116 : + case 118 : + case 119 : + break; + case 120 : + if (legacy_behavior$1) { + return /* Int_Cx */7; + } + break; + default: + + } + if (exit$1 === 3) { + if (!legacy_behavior$1) { + return incompatible_flag(pct_ind, str_ind, symb, "'#'"); + } + _hash = false; + continue ; + } + + } + if (plus) { + if (space) { + if (!legacy_behavior$1) { + return incompatible_flag(pct_ind, str_ind, /* ' ' */32, "'+'"); + } + _space = false; + continue ; + } + if (!legacy_behavior$1) { + return incompatible_flag(pct_ind, str_ind, symb, "'+'"); + } + _plus = false; + continue ; + } + if (space) { + if (!legacy_behavior$1) { + return incompatible_flag(pct_ind, str_ind, symb, "' '"); + } + _space = false; + continue ; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 2938, + 28 + ], + Error: new Error() + }; + }; + }; + var incompatible_flag = function (pct_ind, str_ind, symb, option) { + var subfmt = Stdlib__String.sub(str, pct_ind, str_ind - pct_ind | 0); + return Curry._5(failwith_message(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "invalid format ", + _1: { + TAG: /* Caml_string */3, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: ": at character number ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* String_literal */11, + _0: ", ", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: " is incompatible with '", + _1: { + TAG: /* Char */0, + _0: { + TAG: /* String_literal */11, + _0: "' in sub-format ", + _1: { + TAG: /* Caml_string */3, + _0: /* No_padding */0, + _1: /* End_of_format */0 + } + } + } + } + } + } + } + } + } + }, + _1: "invalid format %S: at character number %d, %s is incompatible with '%c' in sub-format %S" + }), str, pct_ind, option, symb, subfmt); + }; + var parse_positive = function (_str_ind, end_ind, _acc) { + while(true) { + var acc = _acc; + var str_ind = _str_ind; + if (str_ind === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var c = Caml_string.get(str, str_ind); + if (c > 57 || c < 48) { + return [ + str_ind, + acc + ]; + } + var new_acc = Math.imul(acc, 10) + (c - /* '0' */48 | 0) | 0; + _acc = new_acc; + _str_ind = str_ind + 1 | 0; + continue ; + }; + }; + var parse_char_set = function (str_ind, end_ind) { + if (str_ind === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var char_set = Stdlib__Bytes.make(32, /* '\000' */0); + var add_range = function (c, c$p) { + for(var i = c; i <= c$p; ++i){ + add_in_char_set(char_set, Stdlib.char_of_int(i)); + } + }; + var fail_single_percent = function (str_ind) { + return Curry._2(failwith_message(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "invalid format ", + _1: { + TAG: /* Caml_string */3, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: ": '", + _1: { + TAG: /* Char_literal */12, + _0: /* '%' */37, + _1: { + TAG: /* String_literal */11, + _0: "' alone is not accepted in character sets, use ", + _1: { + TAG: /* Char_literal */12, + _0: /* '%' */37, + _1: { + TAG: /* Char_literal */12, + _0: /* '%' */37, + _1: { + TAG: /* String_literal */11, + _0: " instead at position ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* Char_literal */12, + _0: /* '.' */46, + _1: /* End_of_format */0 + } + } + } + } + } + } + } + } + } + }, + _1: "invalid format %S: '%%' alone is not accepted in character sets, use %%%% instead at position %d." + }), str, str_ind); + }; + var parse_char_set_after_char = function (_str_ind, end_ind, _c) { + while(true) { + var c = _c; + var str_ind = _str_ind; + if (str_ind === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var c$p = Caml_string.get(str, str_ind); + var exit = 0; + if (c$p >= 46) { + if (c$p !== 64) { + if (c$p === 93) { + add_in_char_set(char_set, c); + return str_ind + 1 | 0; + } + + } else { + exit = 2; + } + } else if (c$p !== 37) { + if (c$p >= 45) { + var str_ind$1 = str_ind + 1 | 0; + if (str_ind$1 === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var c$p$1 = Caml_string.get(str, str_ind$1); + if (c$p$1 !== 37) { + if (c$p$1 !== 93) { + add_range(c, c$p$1); + return parse_char_set_content(str_ind$1 + 1 | 0, end_ind); + } else { + add_in_char_set(char_set, c); + add_in_char_set(char_set, /* '-' */45); + return str_ind$1 + 1 | 0; + } + } + if ((str_ind$1 + 1 | 0) === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var c$p$2 = Caml_string.get(str, str_ind$1 + 1 | 0); + if (c$p$2 !== 37 && c$p$2 !== 64) { + return fail_single_percent(str_ind$1); + } + add_range(c, c$p$2); + return parse_char_set_content(str_ind$1 + 2 | 0, end_ind); + } + + } else { + exit = 2; + } + if (exit === 2 && c === /* '%' */37) { + add_in_char_set(char_set, c$p); + return parse_char_set_content(str_ind + 1 | 0, end_ind); + } + if (c === /* '%' */37) { + fail_single_percent(str_ind); + } + add_in_char_set(char_set, c); + _c = c$p; + _str_ind = str_ind + 1 | 0; + continue ; + }; + }; + var parse_char_set_content = function (_str_ind, end_ind) { + while(true) { + var str_ind = _str_ind; + if (str_ind === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var c = Caml_string.get(str, str_ind); + if (c !== 45) { + if (c !== 93) { + return parse_char_set_after_char(str_ind + 1 | 0, end_ind, c); + } else { + return str_ind + 1 | 0; + } + } + add_in_char_set(char_set, /* '-' */45); + _str_ind = str_ind + 1 | 0; + continue ; + }; + }; + var parse_char_set_start = function (str_ind, end_ind) { + if (str_ind === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var c = Caml_string.get(str, str_ind); + return parse_char_set_after_char(str_ind + 1 | 0, end_ind, c); + }; + if (str_ind === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var match = Caml_string.get(str, str_ind); + var match$1 = match !== 94 ? [ + str_ind, + false + ] : [ + str_ind + 1 | 0, + true + ]; + var next_ind = parse_char_set_start(match$1[0], end_ind); + var char_set$1 = Stdlib__Bytes.to_string(char_set); + return [ + next_ind, + match$1[1] ? rev_char_set(char_set$1) : char_set$1 + ]; + }; + var is_int_base = function (symb) { + switch (symb) { + case 89 : + case 90 : + case 91 : + case 92 : + case 93 : + case 94 : + case 95 : + case 96 : + case 97 : + case 98 : + case 99 : + case 101 : + case 102 : + case 103 : + case 104 : + case 106 : + case 107 : + case 108 : + case 109 : + case 110 : + case 112 : + case 113 : + case 114 : + case 115 : + case 116 : + case 118 : + case 119 : + return false; + case 88 : + case 100 : + case 105 : + case 111 : + case 117 : + case 120 : + return true; + default: + return false; + } + }; + var compute_float_conv = function (pct_ind, str_ind, plus, hash, space, symb) { + var flag = plus ? ( + space && !legacy_behavior$1 ? incompatible_flag(pct_ind, str_ind, /* ' ' */32, "'+'") : /* Float_flag_p */1 + ) : ( + space ? /* Float_flag_s */2 : /* Float_flag_ */0 + ); + var kind; + var exit = 0; + if (symb >= 73) { + switch (symb) { + case 101 : + kind = /* Float_e */1; + break; + case 102 : + kind = /* Float_f */0; + break; + case 103 : + kind = /* Float_g */3; + break; + case 104 : + kind = /* Float_h */6; + break; + default: + exit = 1; + } + } else if (symb >= 69) { + switch (symb) { + case 69 : + kind = /* Float_E */2; + break; + case 70 : + exit = 1; + break; + case 71 : + kind = /* Float_G */4; + break; + case 72 : + kind = /* Float_H */7; + break; + + } + } else { + exit = 1; + } + if (exit === 1) { + if (hash) { + if (symb !== 70) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 2960, + 11 + ], + Error: new Error() + }; + } + kind = /* Float_CF */8; + } else { + if (symb !== 70) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 2960, + 11 + ], + Error: new Error() + }; + } + kind = /* Float_F */5; + } + } + return [ + flag, + kind + ]; + }; + var counter_of_char = function (symb) { + if (symb >= 108) { + if (symb < 111) { + switch (symb) { + case 108 : + return /* Line_counter */0; + case 109 : + break; + case 110 : + return /* Char_counter */1; + + } + } + + } else if (symb === 76) { + return /* Token_counter */2; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 2902, + 34 + ], + Error: new Error() + }; + }; + var search_subformat_end = function (_str_ind, end_ind, c) { + while(true) { + var str_ind = _str_ind; + if (str_ind === end_ind) { + Curry._3(failwith_message(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "invalid format ", + _1: { + TAG: /* Caml_string */3, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: ": unclosed sub-format, expected \"", + _1: { + TAG: /* Char_literal */12, + _0: /* '%' */37, + _1: { + TAG: /* Char */0, + _0: { + TAG: /* String_literal */11, + _0: "\" at character number ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: /* End_of_format */0 + } + } + } + } + } + } + }, + _1: "invalid format %S: unclosed sub-format, expected \"%%%c\" at character number %d" + }), str, c, end_ind); + } + var match = Caml_string.get(str, str_ind); + if (match !== 37) { + _str_ind = str_ind + 1 | 0; + continue ; + } + if ((str_ind + 1 | 0) === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + if (Caml_string.get(str, str_ind + 1 | 0) === c) { + return str_ind; + } + var match$1 = Caml_string.get(str, str_ind + 1 | 0); + if (match$1 >= 95) { + if (match$1 >= 123) { + if (match$1 < 126) { + switch (match$1) { + case 123 : + var sub_end = search_subformat_end(str_ind + 2 | 0, end_ind, /* '}' */125); + _str_ind = sub_end + 2 | 0; + continue ; + case 124 : + break; + case 125 : + return expected_character(str_ind + 1 | 0, "character ')'", /* '}' */125); + + } + } + + } else if (match$1 < 96) { + if ((str_ind + 2 | 0) === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var match$2 = Caml_string.get(str, str_ind + 2 | 0); + if (match$2 !== 40) { + if (match$2 !== 123) { + _str_ind = str_ind + 3 | 0; + continue ; + } + var sub_end$1 = search_subformat_end(str_ind + 3 | 0, end_ind, /* '}' */125); + _str_ind = sub_end$1 + 2 | 0; + continue ; + } + var sub_end$2 = search_subformat_end(str_ind + 3 | 0, end_ind, /* ')' */41); + _str_ind = sub_end$2 + 2 | 0; + continue ; + } + + } else if (match$1 !== 40) { + if (match$1 === 41) { + return expected_character(str_ind + 1 | 0, "character '}'", /* ')' */41); + } + + } else { + var sub_end$3 = search_subformat_end(str_ind + 2 | 0, end_ind, /* ')' */41); + _str_ind = sub_end$3 + 2 | 0; + continue ; + } + _str_ind = str_ind + 2 | 0; + continue ; + }; + }; + var parse_spaces = function (_str_ind, end_ind) { + while(true) { + var str_ind = _str_ind; + if (str_ind === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + if (Caml_string.get(str, str_ind) !== /* ' ' */32) { + return str_ind; + } + _str_ind = str_ind + 1 | 0; + continue ; + }; + }; + var parse_integer = function (str_ind, end_ind) { + if (str_ind === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var match = Caml_string.get(str, str_ind); + if (match >= 48) { + if (match >= 58) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 2840, + 11 + ], + Error: new Error() + }; + } + return parse_positive(str_ind, end_ind, 0); + } + if (match !== 45) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalFormat.cppo.ml", + 2840, + 11 + ], + Error: new Error() + }; + } + if ((str_ind + 1 | 0) === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var c = Caml_string.get(str, str_ind + 1 | 0); + if (c > 57 || c < 48) { + return expected_character(str_ind + 1 | 0, "digit", c); + } + var match$1 = parse_positive(str_ind + 1 | 0, end_ind, 0); + return [ + match$1[0], + -match$1[1] | 0 + ]; + }; + var parse_conversion = function (pct_ind, str_ind, end_ind, plus, hash, space, ign, pad, prec, padprec, symb) { + var plus_used = false; + var hash_used = false; + var space_used = false; + var ign_used = { + contents: false + }; + var pad_used = { + contents: false + }; + var prec_used = { + contents: false + }; + var get_int_pad = function (param) { + pad_used.contents = true; + prec_used.contents = true; + if (typeof prec === "number" && !prec) { + return pad; + } + if (typeof pad === "number") { + return /* No_padding */0; + } else if (pad.TAG === /* Lit_padding */0) { + if (pad._0 >= 2) { + if (legacy_behavior$1) { + return { + TAG: /* Lit_padding */0, + _0: /* Right */1, + _1: pad._1 + }; + } else { + return incompatible_flag(pct_ind, str_ind, /* '0' */48, "precision"); + } + } else { + return pad; + } + } else if (pad._0 >= 2) { + if (legacy_behavior$1) { + return { + TAG: /* Arg_padding */1, + _0: /* Right */1 + }; + } else { + return incompatible_flag(pct_ind, str_ind, /* '0' */48, "precision"); + } + } else { + return pad; + } + }; + var check_no_0 = function (symb, pad) { + if (typeof pad === "number") { + return pad; + } else if (pad.TAG === /* Lit_padding */0) { + if (pad._0 >= 2) { + if (legacy_behavior$1) { + return { + TAG: /* Lit_padding */0, + _0: /* Right */1, + _1: pad._1 + }; + } else { + return incompatible_flag(pct_ind, str_ind, symb, "0"); + } + } else { + return pad; + } + } else if (pad._0 >= 2) { + if (legacy_behavior$1) { + return { + TAG: /* Arg_padding */1, + _0: /* Right */1 + }; + } else { + return incompatible_flag(pct_ind, str_ind, symb, "0"); + } + } else { + return pad; + } + }; + var opt_of_pad = function (c, pad) { + if (typeof pad === "number") { + return ; + } + if (pad.TAG !== /* Lit_padding */0) { + return incompatible_flag(pct_ind, str_ind, c, "'*'"); + } + switch (pad._0) { + case /* Left */0 : + if (legacy_behavior$1) { + return pad._1; + } else { + return incompatible_flag(pct_ind, str_ind, c, "'-'"); + } + case /* Right */1 : + return pad._1; + case /* Zeros */2 : + if (legacy_behavior$1) { + return pad._1; + } else { + return incompatible_flag(pct_ind, str_ind, c, "'0'"); + } + + } + }; + var get_prec_opt = function (param) { + prec_used.contents = true; + if (typeof prec === "number") { + if (prec) { + return incompatible_flag(pct_ind, str_ind, /* '_' */95, "'*'"); + } else { + return ; + } + } else { + return prec._0; + } + }; + var fmt_result; + var exit = 0; + var exit$1 = 0; + var exit$2 = 0; + if (symb >= 124) { + exit$1 = 6; + } else { + switch (symb) { + case 33 : + var fmt_rest = parse_literal(str_ind, str_ind, end_ind); + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Flush */10, + _0: fmt_rest._0 + } + }; + break; + case 40 : + var sub_end = search_subformat_end(str_ind, end_ind, /* ')' */41); + var beg_ind = sub_end + 2 | 0; + var fmt_rest$1 = parse_literal(beg_ind, beg_ind, end_ind); + var fmt_rest$2 = fmt_rest$1._0; + var sub_fmt = parse_literal(str_ind, str_ind, sub_end); + var sub_fmtty = fmtty_of_fmt(sub_fmt._0); + if (ign_used.contents = true, ign) { + var ignored_0 = opt_of_pad(/* '_' */95, (pad_used.contents = true, pad)); + var ignored = { + TAG: /* Ignored_format_subst */9, + _0: ignored_0, + _1: sub_fmtty + }; + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: ignored, + _1: fmt_rest$2 + } + }; + } else { + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Format_subst */14, + _0: opt_of_pad(/* '(' */40, (pad_used.contents = true, pad)), + _1: sub_fmtty, + _2: fmt_rest$2 + } + }; + } + break; + case 44 : + fmt_result = parse_literal(str_ind, str_ind, end_ind); + break; + case 37 : + case 64 : + exit$1 = 4; + break; + case 67 : + var fmt_rest$3 = parse_literal(str_ind, str_ind, end_ind); + var fmt_rest$4 = fmt_rest$3._0; + fmt_result = (ign_used.contents = true, ign) ? /* Fmt_EBB */({ + _0: { + TAG: /* Ignored_param */23, + _0: /* Ignored_caml_char */1, + _1: fmt_rest$4 + } + }) : /* Fmt_EBB */({ + _0: { + TAG: /* Caml_char */1, + _0: fmt_rest$4 + } + }); + break; + case 78 : + var fmt_rest$5 = parse_literal(str_ind, str_ind, end_ind); + var fmt_rest$6 = fmt_rest$5._0; + if (ign_used.contents = true, ign) { + var ignored$1 = { + TAG: /* Ignored_scan_get_counter */11, + _0: /* Token_counter */2 + }; + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: ignored$1, + _1: fmt_rest$6 + } + }; + } else { + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Scan_get_counter */21, + _0: /* Token_counter */2, + _1: fmt_rest$6 + } + }; + } + break; + case 83 : + var pad$1 = check_no_0(symb, (pad_used.contents = true, padprec)); + var fmt_rest$7 = parse_literal(str_ind, str_ind, end_ind); + var fmt_rest$8 = fmt_rest$7._0; + if (ign_used.contents = true, ign) { + var ignored$2 = { + TAG: /* Ignored_caml_string */1, + _0: opt_of_pad(/* '_' */95, (pad_used.contents = true, padprec)) + }; + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: ignored$2, + _1: fmt_rest$8 + } + }; + } else { + var match = make_padding_fmt_ebb(pad$1, fmt_rest$8); + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Caml_string */3, + _0: match._0, + _1: match._1 + } + }; + } + break; + case 91 : + var match$1 = parse_char_set(str_ind, end_ind); + var char_set = match$1[1]; + var next_ind = match$1[0]; + var fmt_rest$9 = parse_literal(next_ind, next_ind, end_ind); + var fmt_rest$10 = fmt_rest$9._0; + if (ign_used.contents = true, ign) { + var ignored_0$1 = opt_of_pad(/* '_' */95, (pad_used.contents = true, pad)); + var ignored$3 = { + TAG: /* Ignored_scan_char_set */10, + _0: ignored_0$1, + _1: char_set + }; + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: ignored$3, + _1: fmt_rest$10 + } + }; + } else { + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Scan_char_set */20, + _0: opt_of_pad(/* '[' */91, (pad_used.contents = true, pad)), + _1: char_set, + _2: fmt_rest$10 + } + }; + } + break; + case 32 : + case 35 : + case 43 : + case 45 : + case 95 : + exit$1 = 5; + break; + case 97 : + var fmt_rest$11 = parse_literal(str_ind, str_ind, end_ind); + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Alpha */15, + _0: fmt_rest$11._0 + } + }; + break; + case 66 : + case 98 : + exit$1 = 3; + break; + case 99 : + var char_format = function (fmt_rest) { + if (ign_used.contents = true, ign) { + return /* Fmt_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: /* Ignored_char */0, + _1: fmt_rest + } + }; + } else { + return /* Fmt_EBB */{ + _0: { + TAG: /* Char */0, + _0: fmt_rest + } + }; + } + }; + var scan_format = function (fmt_rest) { + if (ign_used.contents = true, ign) { + return /* Fmt_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: /* Ignored_scan_next_char */3, + _1: fmt_rest + } + }; + } else { + return /* Fmt_EBB */{ + _0: { + TAG: /* Scan_next_char */22, + _0: fmt_rest + } + }; + } + }; + var fmt_rest$12 = parse_literal(str_ind, str_ind, end_ind); + var fmt_rest$13 = fmt_rest$12._0; + var _n = opt_of_pad(/* 'c' */99, (pad_used.contents = true, pad)); + fmt_result = _n !== undefined ? ( + _n !== 0 ? ( + legacy_behavior$1 ? char_format(fmt_rest$13) : invalid_format_message(str_ind, "non-zero widths are unsupported for %c conversions") + ) : scan_format(fmt_rest$13) + ) : char_format(fmt_rest$13); + break; + case 69 : + case 70 : + case 71 : + case 72 : + case 101 : + case 102 : + case 103 : + case 104 : + exit$1 = 2; + break; + case 76 : + case 108 : + case 110 : + exit$2 = 8; + break; + case 114 : + var fmt_rest$14 = parse_literal(str_ind, str_ind, end_ind); + var fmt_rest$15 = fmt_rest$14._0; + fmt_result = (ign_used.contents = true, ign) ? /* Fmt_EBB */({ + _0: { + TAG: /* Ignored_param */23, + _0: /* Ignored_reader */2, + _1: fmt_rest$15 + } + }) : /* Fmt_EBB */({ + _0: { + TAG: /* Reader */19, + _0: fmt_rest$15 + } + }); + break; + case 115 : + var pad$2 = check_no_0(symb, (pad_used.contents = true, padprec)); + var fmt_rest$16 = parse_literal(str_ind, str_ind, end_ind); + var fmt_rest$17 = fmt_rest$16._0; + if (ign_used.contents = true, ign) { + var ignored$4 = { + TAG: /* Ignored_string */0, + _0: opt_of_pad(/* '_' */95, (pad_used.contents = true, padprec)) + }; + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: ignored$4, + _1: fmt_rest$17 + } + }; + } else { + var match$2 = make_padding_fmt_ebb(pad$2, fmt_rest$17); + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* String */2, + _0: match$2._0, + _1: match$2._1 + } + }; + } + break; + case 116 : + var fmt_rest$18 = parse_literal(str_ind, str_ind, end_ind); + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Theta */16, + _0: fmt_rest$18._0 + } + }; + break; + case 88 : + case 100 : + case 105 : + case 111 : + case 117 : + case 120 : + exit$2 = 7; + break; + case 0 : + case 1 : + case 2 : + case 3 : + case 4 : + case 5 : + case 6 : + case 7 : + case 8 : + case 9 : + case 10 : + case 11 : + case 12 : + case 13 : + case 14 : + case 15 : + case 16 : + case 17 : + case 18 : + case 19 : + case 20 : + case 21 : + case 22 : + case 23 : + case 24 : + case 25 : + case 26 : + case 27 : + case 28 : + case 29 : + case 30 : + case 31 : + case 34 : + case 36 : + case 38 : + case 39 : + case 41 : + case 42 : + case 46 : + case 47 : + case 48 : + case 49 : + case 50 : + case 51 : + case 52 : + case 53 : + case 54 : + case 55 : + case 56 : + case 57 : + case 58 : + case 59 : + case 60 : + case 61 : + case 62 : + case 63 : + case 65 : + case 68 : + case 73 : + case 74 : + case 75 : + case 77 : + case 79 : + case 80 : + case 81 : + case 82 : + case 84 : + case 85 : + case 86 : + case 87 : + case 89 : + case 90 : + case 92 : + case 93 : + case 94 : + case 96 : + case 106 : + case 107 : + case 109 : + case 112 : + case 113 : + case 118 : + case 119 : + case 121 : + case 122 : + exit$1 = 6; + break; + case 123 : + var sub_end$1 = search_subformat_end(str_ind, end_ind, /* '}' */125); + var sub_fmt$1 = parse_literal(str_ind, str_ind, sub_end$1); + var beg_ind$1 = sub_end$1 + 2 | 0; + var fmt_rest$19 = parse_literal(beg_ind$1, beg_ind$1, end_ind); + var fmt_rest$20 = fmt_rest$19._0; + var sub_fmtty$1 = fmtty_of_fmt(sub_fmt$1._0); + if (ign_used.contents = true, ign) { + var ignored_0$2 = opt_of_pad(/* '_' */95, (pad_used.contents = true, pad)); + var ignored$5 = { + TAG: /* Ignored_format_arg */8, + _0: ignored_0$2, + _1: sub_fmtty$1 + }; + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: ignored$5, + _1: fmt_rest$20 + } + }; + } else { + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Format_arg */13, + _0: opt_of_pad(/* '{' */123, (pad_used.contents = true, pad)), + _1: sub_fmtty$1, + _2: fmt_rest$20 + } + }; + } + break; + + } + } + switch (exit$2) { + case 7 : + plus_used = true; + hash_used = true; + space_used = true; + var iconv = compute_int_conv(pct_ind, str_ind, plus, hash, space, symb); + var fmt_rest$21 = parse_literal(str_ind, str_ind, end_ind); + var fmt_rest$22 = fmt_rest$21._0; + if (ign_used.contents = true, ign) { + var ignored_1 = opt_of_pad(/* '_' */95, (pad_used.contents = true, pad)); + var ignored$6 = { + TAG: /* Ignored_int */2, + _0: iconv, + _1: ignored_1 + }; + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: ignored$6, + _1: fmt_rest$22 + } + }; + } else { + var match$3 = make_padprec_fmt_ebb(get_int_pad(undefined), (prec_used.contents = true, prec), fmt_rest$22); + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Int */4, + _0: iconv, + _1: match$3._0, + _2: match$3._1, + _3: match$3._2 + } + }; + } + break; + case 8 : + if (str_ind === end_ind || !is_int_base(Caml_string.get(str, str_ind))) { + var fmt_rest$23 = parse_literal(str_ind, str_ind, end_ind); + var fmt_rest$24 = fmt_rest$23._0; + var counter = counter_of_char(symb); + if (ign_used.contents = true, ign) { + var ignored$7 = { + TAG: /* Ignored_scan_get_counter */11, + _0: counter + }; + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: ignored$7, + _1: fmt_rest$24 + } + }; + } else { + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Scan_get_counter */21, + _0: counter, + _1: fmt_rest$24 + } + }; + } + } else { + exit$1 = 6; + } + break; + + } + switch (exit$1) { + case 2 : + plus_used = true; + hash_used = true; + space_used = true; + var fconv = compute_float_conv(pct_ind, str_ind, plus, hash, space, symb); + var fmt_rest$25 = parse_literal(str_ind, str_ind, end_ind); + var fmt_rest$26 = fmt_rest$25._0; + if (ign_used.contents = true, ign) { + var ignored_0$3 = opt_of_pad(/* '_' */95, (pad_used.contents = true, pad)); + var ignored_1$1 = get_prec_opt(undefined); + var ignored$8 = { + TAG: /* Ignored_float */6, + _0: ignored_0$3, + _1: ignored_1$1 + }; + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: ignored$8, + _1: fmt_rest$26 + } + }; + } else { + var match$4 = make_padprec_fmt_ebb((pad_used.contents = true, pad), (prec_used.contents = true, prec), fmt_rest$26); + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Float */8, + _0: fconv, + _1: match$4._0, + _2: match$4._1, + _3: match$4._2 + } + }; + } + break; + case 3 : + var pad$3 = check_no_0(symb, (pad_used.contents = true, padprec)); + var fmt_rest$27 = parse_literal(str_ind, str_ind, end_ind); + var fmt_rest$28 = fmt_rest$27._0; + if (ign_used.contents = true, ign) { + var ignored$9 = { + TAG: /* Ignored_bool */7, + _0: opt_of_pad(/* '_' */95, (pad_used.contents = true, padprec)) + }; + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: ignored$9, + _1: fmt_rest$28 + } + }; + } else { + var match$5 = make_padding_fmt_ebb(pad$3, fmt_rest$28); + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Bool */9, + _0: match$5._0, + _1: match$5._1 + } + }; + } + break; + case 4 : + var fmt_rest$29 = parse_literal(str_ind, str_ind, end_ind); + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Char_literal */12, + _0: symb, + _1: fmt_rest$29._0 + } + }; + break; + case 5 : + fmt_result = Curry._3(failwith_message(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "invalid format ", + _1: { + TAG: /* Caml_string */3, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: ": at character number ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* String_literal */11, + _0: ", flag ", + _1: { + TAG: /* Caml_char */1, + _0: { + TAG: /* String_literal */11, + _0: " is only allowed after the '", + _1: { + TAG: /* Char_literal */12, + _0: /* '%' */37, + _1: { + TAG: /* String_literal */11, + _0: "', before padding and precision", + _1: /* End_of_format */0 + } + } + } + } + } + } + } + } + }, + _1: "invalid format %S: at character number %d, flag %C is only allowed after the '%%', before padding and precision" + }), str, pct_ind, symb); + break; + case 6 : + if (symb >= 108) { + if (symb >= 111) { + exit = 1; + } else { + switch (symb) { + case 108 : + plus_used = true; + hash_used = true; + space_used = true; + var iconv$1 = compute_int_conv(pct_ind, str_ind + 1 | 0, plus, hash, space, Caml_string.get(str, str_ind)); + var beg_ind$2 = str_ind + 1 | 0; + var fmt_rest$30 = parse_literal(beg_ind$2, beg_ind$2, end_ind); + var fmt_rest$31 = fmt_rest$30._0; + if (ign_used.contents = true, ign) { + var ignored_1$2 = opt_of_pad(/* '_' */95, (pad_used.contents = true, pad)); + var ignored$10 = { + TAG: /* Ignored_int32 */3, + _0: iconv$1, + _1: ignored_1$2 + }; + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: ignored$10, + _1: fmt_rest$31 + } + }; + } else { + var match$6 = make_padprec_fmt_ebb(get_int_pad(undefined), (prec_used.contents = true, prec), fmt_rest$31); + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Int32 */5, + _0: iconv$1, + _1: match$6._0, + _2: match$6._1, + _3: match$6._2 + } + }; + } + break; + case 109 : + exit = 1; + break; + case 110 : + plus_used = true; + hash_used = true; + space_used = true; + var iconv$2 = compute_int_conv(pct_ind, str_ind + 1 | 0, plus, hash, space, Caml_string.get(str, str_ind)); + var beg_ind$3 = str_ind + 1 | 0; + var fmt_rest$32 = parse_literal(beg_ind$3, beg_ind$3, end_ind); + var fmt_rest$33 = fmt_rest$32._0; + if (ign_used.contents = true, ign) { + var ignored_1$3 = opt_of_pad(/* '_' */95, (pad_used.contents = true, pad)); + var ignored$11 = { + TAG: /* Ignored_nativeint */4, + _0: iconv$2, + _1: ignored_1$3 + }; + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: ignored$11, + _1: fmt_rest$33 + } + }; + } else { + var match$7 = make_padprec_fmt_ebb(get_int_pad(undefined), (prec_used.contents = true, prec), fmt_rest$33); + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Nativeint */6, + _0: iconv$2, + _1: match$7._0, + _2: match$7._1, + _3: match$7._2 + } + }; + } + break; + + } + } + } else if (symb !== 76) { + exit = 1; + } else { + plus_used = true; + hash_used = true; + space_used = true; + var iconv$3 = compute_int_conv(pct_ind, str_ind + 1 | 0, plus, hash, space, Caml_string.get(str, str_ind)); + var beg_ind$4 = str_ind + 1 | 0; + var fmt_rest$34 = parse_literal(beg_ind$4, beg_ind$4, end_ind); + var fmt_rest$35 = fmt_rest$34._0; + if (ign_used.contents = true, ign) { + var ignored_1$4 = opt_of_pad(/* '_' */95, (pad_used.contents = true, pad)); + var ignored$12 = { + TAG: /* Ignored_int64 */5, + _0: iconv$3, + _1: ignored_1$4 + }; + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Ignored_param */23, + _0: ignored$12, + _1: fmt_rest$35 + } + }; + } else { + var match$8 = make_padprec_fmt_ebb(get_int_pad(undefined), (prec_used.contents = true, prec), fmt_rest$35); + fmt_result = /* Fmt_EBB */{ + _0: { + TAG: /* Int64 */7, + _0: iconv$3, + _1: match$8._0, + _2: match$8._1, + _3: match$8._2 + } + }; + } + } + break; + + } + if (exit === 1) { + fmt_result = Curry._3(failwith_message(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "invalid format ", + _1: { + TAG: /* Caml_string */3, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: ": at character number ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* String_literal */11, + _0: ", invalid conversion \"", + _1: { + TAG: /* Char_literal */12, + _0: /* '%' */37, + _1: { + TAG: /* Char */0, + _0: { + TAG: /* Char_literal */12, + _0: /* '"' */34, + _1: /* End_of_format */0 + } + } + } + } + } + } + } + }, + _1: "invalid format %S: at character number %d, invalid conversion \"%%%c\"" + }), str, str_ind - 1 | 0, symb); + } + if (!legacy_behavior$1) { + if (!plus_used && plus) { + incompatible_flag(pct_ind, str_ind, symb, "'+'"); + } + if (!hash_used && hash) { + incompatible_flag(pct_ind, str_ind, symb, "'#'"); + } + if (!space_used && space) { + incompatible_flag(pct_ind, str_ind, symb, "' '"); + } + if (!pad_used.contents && Caml_obj.caml_notequal(/* Padding_EBB */{ + _0: pad + }, /* Padding_EBB */{ + _0: /* No_padding */0 + })) { + incompatible_flag(pct_ind, str_ind, symb, "`padding'"); + } + if (!prec_used.contents && Caml_obj.caml_notequal(/* Precision_EBB */{ + _0: prec + }, /* Precision_EBB */{ + _0: /* No_precision */0 + })) { + incompatible_flag(pct_ind, str_ind, ign ? /* '_' */95 : symb, "`precision'"); + } + if (ign && plus) { + incompatible_flag(pct_ind, str_ind, /* '_' */95, "'+'"); + } + + } + if (!ign_used.contents && ign) { + var exit$3 = 0; + if (symb >= 38) { + if (symb !== 44) { + if (symb !== 64 || !legacy_behavior$1) { + exit$3 = 1; + } + + } else if (!legacy_behavior$1) { + exit$3 = 1; + } + + } else if (symb !== 33) { + if (!(symb >= 37 && legacy_behavior$1)) { + exit$3 = 1; + } + + } else if (!legacy_behavior$1) { + exit$3 = 1; + } + if (exit$3 === 1) { + incompatible_flag(pct_ind, str_ind, symb, "'_'"); + } + + } + return fmt_result; + }; + var parse_after_precision = function (pct_ind, str_ind, end_ind, minus, plus, hash, space, ign, pad, prec) { + if (str_ind === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var parse_conv = function (padprec) { + return parse_conversion(pct_ind, str_ind + 1 | 0, end_ind, plus, hash, space, ign, pad, prec, padprec, Caml_string.get(str, str_ind)); + }; + if (typeof pad !== "number") { + return parse_conv(pad); + } + if (typeof prec === "number" && !prec) { + return parse_conv(/* No_padding */0); + } + if (minus) { + if (typeof prec === "number") { + return parse_conv({ + TAG: /* Arg_padding */1, + _0: /* Left */0 + }); + } else { + return parse_conv({ + TAG: /* Lit_padding */0, + _0: /* Left */0, + _1: prec._0 + }); + } + } else if (typeof prec === "number") { + return parse_conv({ + TAG: /* Arg_padding */1, + _0: /* Right */1 + }); + } else { + return parse_conv({ + TAG: /* Lit_padding */0, + _0: /* Right */1, + _1: prec._0 + }); + } + }; + var parse_after_at = function (str_ind, end_ind) { + if (str_ind === end_ind) { + return /* Fmt_EBB */{ + _0: { + TAG: /* Char_literal */12, + _0: /* '@' */64, + _1: /* End_of_format */0 + } + }; + } + var c = Caml_string.get(str, str_ind); + if (c >= 65) { + if (c >= 94) { + switch (c) { + case 123 : + return parse_tag(true, str_ind + 1 | 0, end_ind); + case 124 : + break; + case 125 : + var beg_ind = str_ind + 1 | 0; + var fmt_rest = parse_literal(beg_ind, beg_ind, end_ind); + return /* Fmt_EBB */{ + _0: { + TAG: /* Formatting_lit */17, + _0: /* Close_tag */1, + _1: fmt_rest._0 + } + }; + default: + + } + } else if (c >= 91) { + switch (c) { + case 91 : + return parse_tag(false, str_ind + 1 | 0, end_ind); + case 92 : + break; + case 93 : + var beg_ind$1 = str_ind + 1 | 0; + var fmt_rest$1 = parse_literal(beg_ind$1, beg_ind$1, end_ind); + return /* Fmt_EBB */{ + _0: { + TAG: /* Formatting_lit */17, + _0: /* Close_box */0, + _1: fmt_rest$1._0 + } + }; + + } + } + + } else if (c !== 10) { + if (c >= 32) { + switch (c) { + case 32 : + var beg_ind$2 = str_ind + 1 | 0; + var fmt_rest$2 = parse_literal(beg_ind$2, beg_ind$2, end_ind); + return /* Fmt_EBB */{ + _0: { + TAG: /* Formatting_lit */17, + _0: { + TAG: /* Break */0, + _0: "@ ", + _1: 1, + _2: 0 + }, + _1: fmt_rest$2._0 + } + }; + case 37 : + if ((str_ind + 1 | 0) < end_ind && Caml_string.get(str, str_ind + 1 | 0) === /* '%' */37) { + var beg_ind$3 = str_ind + 2 | 0; + var fmt_rest$3 = parse_literal(beg_ind$3, beg_ind$3, end_ind); + return /* Fmt_EBB */{ + _0: { + TAG: /* Formatting_lit */17, + _0: /* Escaped_percent */6, + _1: fmt_rest$3._0 + } + }; + } + var fmt_rest$4 = parse_literal(str_ind, str_ind, end_ind); + return /* Fmt_EBB */{ + _0: { + TAG: /* Char_literal */12, + _0: /* '@' */64, + _1: fmt_rest$4._0 + } + }; + case 44 : + var beg_ind$4 = str_ind + 1 | 0; + var fmt_rest$5 = parse_literal(beg_ind$4, beg_ind$4, end_ind); + return /* Fmt_EBB */{ + _0: { + TAG: /* Formatting_lit */17, + _0: { + TAG: /* Break */0, + _0: "@,", + _1: 0, + _2: 0 + }, + _1: fmt_rest$5._0 + } + }; + case 46 : + var beg_ind$5 = str_ind + 1 | 0; + var fmt_rest$6 = parse_literal(beg_ind$5, beg_ind$5, end_ind); + return /* Fmt_EBB */{ + _0: { + TAG: /* Formatting_lit */17, + _0: /* Flush_newline */4, + _1: fmt_rest$6._0 + } + }; + case 59 : + var str_ind$1 = str_ind + 1 | 0; + var match; + try { + if (str_ind$1 === end_ind || Caml_string.get(str, str_ind$1) !== /* '<' */60) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + var str_ind_1 = parse_spaces(str_ind$1 + 1 | 0, end_ind); + var match$1 = Caml_string.get(str, str_ind_1); + var exit = 0; + if (match$1 >= 48) { + if (match$1 >= 58) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + exit = 1; + } else { + if (match$1 !== 45) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + exit = 1; + } + if (exit === 1) { + var match$2 = parse_integer(str_ind_1, end_ind); + var width = match$2[1]; + var str_ind_3 = parse_spaces(match$2[0], end_ind); + var match$3 = Caml_string.get(str, str_ind_3); + if (match$3 > 57 || match$3 < 45) { + if (match$3 !== 62) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + var s = Stdlib__String.sub(str, str_ind$1 - 2 | 0, (str_ind_3 - str_ind$1 | 0) + 3 | 0); + match = [ + str_ind_3 + 1 | 0, + { + TAG: /* Break */0, + _0: s, + _1: width, + _2: 0 + } + ]; + } else { + if (match$3 === 47 || match$3 === 46) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + var match$4 = parse_integer(str_ind_3, end_ind); + var str_ind_5 = parse_spaces(match$4[0], end_ind); + if (Caml_string.get(str, str_ind_5) !== /* '>' */62) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + var s$1 = Stdlib__String.sub(str, str_ind$1 - 2 | 0, (str_ind_5 - str_ind$1 | 0) + 3 | 0); + match = [ + str_ind_5 + 1 | 0, + { + TAG: /* Break */0, + _0: s$1, + _1: width, + _2: match$4[1] + } + ]; + } + } + + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found || exn.RE_EXN_ID === Stdlib.Failure) { + match = [ + str_ind$1, + { + TAG: /* Break */0, + _0: "@;", + _1: 1, + _2: 0 + } + ]; + } else { + throw exn; + } + } + var next_ind = match[0]; + var fmt_rest$7 = parse_literal(next_ind, next_ind, end_ind); + return /* Fmt_EBB */{ + _0: { + TAG: /* Formatting_lit */17, + _0: match[1], + _1: fmt_rest$7._0 + } + }; + case 60 : + var str_ind$2 = str_ind + 1 | 0; + var match$5; + try { + var str_ind_1$1 = parse_spaces(str_ind$2, end_ind); + var match$6 = Caml_string.get(str, str_ind_1$1); + var exit$1 = 0; + if (match$6 >= 48) { + if (match$6 >= 58) { + match$5 = undefined; + } else { + exit$1 = 1; + } + } else if (match$6 !== 45) { + match$5 = undefined; + } else { + exit$1 = 1; + } + if (exit$1 === 1) { + var match$7 = parse_integer(str_ind_1$1, end_ind); + var str_ind_3$1 = parse_spaces(match$7[0], end_ind); + if (Caml_string.get(str, str_ind_3$1) !== /* '>' */62) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + var s$2 = Stdlib__String.sub(str, str_ind$2 - 2 | 0, (str_ind_3$1 - str_ind$2 | 0) + 3 | 0); + match$5 = [ + str_ind_3$1 + 1 | 0, + { + TAG: /* Magic_size */1, + _0: s$2, + _1: match$7[1] + } + ]; + } + + } + catch (raw_exn$1){ + var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); + if (exn$1.RE_EXN_ID === Stdlib.Not_found || exn$1.RE_EXN_ID === Stdlib.Failure) { + match$5 = undefined; + } else { + throw exn$1; + } + } + if (match$5 !== undefined) { + var next_ind$1 = match$5[0]; + var fmt_rest$8 = parse_literal(next_ind$1, next_ind$1, end_ind); + return /* Fmt_EBB */{ + _0: { + TAG: /* Formatting_lit */17, + _0: match$5[1], + _1: fmt_rest$8._0 + } + }; + } + var fmt_rest$9 = parse_literal(str_ind$2, str_ind$2, end_ind); + return /* Fmt_EBB */{ + _0: { + TAG: /* Formatting_lit */17, + _0: { + TAG: /* Scan_indic */2, + _0: /* '<' */60 + }, + _1: fmt_rest$9._0 + } + }; + case 33 : + case 34 : + case 35 : + case 36 : + case 38 : + case 39 : + case 40 : + case 41 : + case 42 : + case 43 : + case 45 : + case 47 : + case 48 : + case 49 : + case 50 : + case 51 : + case 52 : + case 53 : + case 54 : + case 55 : + case 56 : + case 57 : + case 58 : + case 61 : + case 62 : + break; + case 63 : + var beg_ind$6 = str_ind + 1 | 0; + var fmt_rest$10 = parse_literal(beg_ind$6, beg_ind$6, end_ind); + return /* Fmt_EBB */{ + _0: { + TAG: /* Formatting_lit */17, + _0: /* FFlush */2, + _1: fmt_rest$10._0 + } + }; + case 64 : + var beg_ind$7 = str_ind + 1 | 0; + var fmt_rest$11 = parse_literal(beg_ind$7, beg_ind$7, end_ind); + return /* Fmt_EBB */{ + _0: { + TAG: /* Formatting_lit */17, + _0: /* Escaped_at */5, + _1: fmt_rest$11._0 + } + }; + + } + } + + } else { + var beg_ind$8 = str_ind + 1 | 0; + var fmt_rest$12 = parse_literal(beg_ind$8, beg_ind$8, end_ind); + return /* Fmt_EBB */{ + _0: { + TAG: /* Formatting_lit */17, + _0: /* Force_newline */3, + _1: fmt_rest$12._0 + } + }; + } + var beg_ind$9 = str_ind + 1 | 0; + var fmt_rest$13 = parse_literal(beg_ind$9, beg_ind$9, end_ind); + return /* Fmt_EBB */{ + _0: { + TAG: /* Formatting_lit */17, + _0: { + TAG: /* Scan_indic */2, + _0: c + }, + _1: fmt_rest$13._0 + } + }; + }; + var add_literal = function (lit_start, str_ind, fmt) { + var size = str_ind - lit_start | 0; + if (size !== 0) { + if (size !== 1) { + return /* Fmt_EBB */{ + _0: { + TAG: /* String_literal */11, + _0: Stdlib__String.sub(str, lit_start, size), + _1: fmt + } + }; + } else { + return /* Fmt_EBB */{ + _0: { + TAG: /* Char_literal */12, + _0: Caml_string.get(str, lit_start), + _1: fmt + } + }; + } + } else { + return /* Fmt_EBB */{ + _0: fmt + }; + } + }; + var parse_format = function (pct_ind, end_ind) { + var str_ind = pct_ind + 1 | 0; + if (str_ind === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var match = Caml_string.get(str, str_ind); + if (match !== 95) { + return parse_flags(pct_ind, str_ind, end_ind, false); + } else { + return parse_flags(pct_ind, str_ind + 1 | 0, end_ind, true); + } + }; + var parse_after_padding = function (pct_ind, str_ind, end_ind, minus, plus, hash, space, ign, pad) { + if (str_ind === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var symb = Caml_string.get(str, str_ind); + if (symb !== 46) { + return parse_conversion(pct_ind, str_ind + 1 | 0, end_ind, plus, hash, space, ign, pad, /* No_precision */0, pad, symb); + } else { + var str_ind$1 = str_ind + 1 | 0; + if (str_ind$1 === end_ind) { + invalid_format_message(end_ind, "unexpected end of format"); + } + var parse_literal = function (minus, str_ind) { + var match = parse_positive(str_ind, end_ind, 0); + return parse_after_precision(pct_ind, match[0], end_ind, minus, plus, hash, space, ign, pad, /* Lit_precision */{ + _0: match[1] + }); + }; + var symb$1 = Caml_string.get(str, str_ind$1); + var exit = 0; + if (symb$1 >= 48) { + if (symb$1 < 58) { + return parse_literal(minus, str_ind$1); + } + + } else if (symb$1 >= 42) { + switch (symb$1) { + case 42 : + return parse_after_precision(pct_ind, str_ind$1 + 1 | 0, end_ind, minus, plus, hash, space, ign, pad, /* Arg_precision */1); + case 43 : + case 45 : + exit = 2; + break; + case 44 : + case 46 : + case 47 : + break; + + } + } + if (exit === 2 && legacy_behavior$1) { + return parse_literal(minus || symb$1 === /* '-' */45, str_ind$1 + 1 | 0); + } + if (legacy_behavior$1) { + return parse_after_precision(pct_ind, str_ind$1, end_ind, minus, plus, hash, space, ign, pad, /* Lit_precision */{ + _0: 0 + }); + } else { + return invalid_format_without(str_ind$1 - 1 | 0, /* '.' */46, "precision"); + } + } + }; + return parse_literal(0, 0, str.length); +} + +function format_of_string_fmtty(str, fmtty) { + var fmt = fmt_ebb_of_string(undefined, str); + try { + return /* Format */{ + _0: type_format(fmt._0, fmtty), + _1: str + }; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Type_mismatch) { + return Curry._2(failwith_message(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "bad input: format type mismatch between ", + _1: { + TAG: /* Caml_string */3, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: " and ", + _1: { + TAG: /* Caml_string */3, + _0: /* No_padding */0, + _1: /* End_of_format */0 + } + } + } + }, + _1: "bad input: format type mismatch between %S and %S" + }), str, string_of_fmtty(fmtty)); + } + throw exn; + } +} + +function format_of_string_format(str, param) { + var fmt = fmt_ebb_of_string(undefined, str); + try { + return /* Format */{ + _0: type_format(fmt._0, fmtty_of_fmt(param._0)), + _1: str + }; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Type_mismatch) { + return Curry._2(failwith_message(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "bad input: format type mismatch between ", + _1: { + TAG: /* Caml_string */3, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: " and ", + _1: { + TAG: /* Caml_string */3, + _0: /* No_padding */0, + _1: /* End_of_format */0 + } + } + } + }, + _1: "bad input: format type mismatch between %S and %S" + }), str, param._1); + } + throw exn; + } +} + +export { + is_in_char_set , + rev_char_set , + create_char_set , + add_in_char_set , + freeze_char_set , + param_format_of_ignored_format , + make_printf , + make_iprintf , + output_acc , + bufput_acc , + strput_acc , + type_format , + fmt_ebb_of_string , + format_of_string_fmtty , + format_of_string_format , + char_of_iconv , + string_of_formatting_lit , + string_of_fmtty , + string_of_fmt , + open_box_of_string , + symm , + trans , + recast , +} +/* No side effect */ diff --git a/melange-node-modules/melange/camlinternalFormatBasics.js b/melange-node-modules/melange/camlinternalFormatBasics.js new file mode 100644 index 0000000..ca7a75c --- /dev/null +++ b/melange-node-modules/melange/camlinternalFormatBasics.js @@ -0,0 +1,350 @@ +// Generated by Melange + + +function erase_rel(param) { + if (typeof param === "number") { + return /* End_of_fmtty */0; + } + switch (param.TAG | 0) { + case /* Char_ty */0 : + return { + TAG: /* Char_ty */0, + _0: erase_rel(param._0) + }; + case /* String_ty */1 : + return { + TAG: /* String_ty */1, + _0: erase_rel(param._0) + }; + case /* Int_ty */2 : + return { + TAG: /* Int_ty */2, + _0: erase_rel(param._0) + }; + case /* Int32_ty */3 : + return { + TAG: /* Int32_ty */3, + _0: erase_rel(param._0) + }; + case /* Nativeint_ty */4 : + return { + TAG: /* Nativeint_ty */4, + _0: erase_rel(param._0) + }; + case /* Int64_ty */5 : + return { + TAG: /* Int64_ty */5, + _0: erase_rel(param._0) + }; + case /* Float_ty */6 : + return { + TAG: /* Float_ty */6, + _0: erase_rel(param._0) + }; + case /* Bool_ty */7 : + return { + TAG: /* Bool_ty */7, + _0: erase_rel(param._0) + }; + case /* Format_arg_ty */8 : + return { + TAG: /* Format_arg_ty */8, + _0: param._0, + _1: erase_rel(param._1) + }; + case /* Format_subst_ty */9 : + var ty1 = param._0; + return { + TAG: /* Format_subst_ty */9, + _0: ty1, + _1: ty1, + _2: erase_rel(param._2) + }; + case /* Alpha_ty */10 : + return { + TAG: /* Alpha_ty */10, + _0: erase_rel(param._0) + }; + case /* Theta_ty */11 : + return { + TAG: /* Theta_ty */11, + _0: erase_rel(param._0) + }; + case /* Any_ty */12 : + return { + TAG: /* Any_ty */12, + _0: erase_rel(param._0) + }; + case /* Reader_ty */13 : + return { + TAG: /* Reader_ty */13, + _0: erase_rel(param._0) + }; + case /* Ignored_reader_ty */14 : + return { + TAG: /* Ignored_reader_ty */14, + _0: erase_rel(param._0) + }; + + } +} + +function concat_fmtty(fmtty1, fmtty2) { + if (typeof fmtty1 === "number") { + return fmtty2; + } + switch (fmtty1.TAG | 0) { + case /* Char_ty */0 : + return { + TAG: /* Char_ty */0, + _0: concat_fmtty(fmtty1._0, fmtty2) + }; + case /* String_ty */1 : + return { + TAG: /* String_ty */1, + _0: concat_fmtty(fmtty1._0, fmtty2) + }; + case /* Int_ty */2 : + return { + TAG: /* Int_ty */2, + _0: concat_fmtty(fmtty1._0, fmtty2) + }; + case /* Int32_ty */3 : + return { + TAG: /* Int32_ty */3, + _0: concat_fmtty(fmtty1._0, fmtty2) + }; + case /* Nativeint_ty */4 : + return { + TAG: /* Nativeint_ty */4, + _0: concat_fmtty(fmtty1._0, fmtty2) + }; + case /* Int64_ty */5 : + return { + TAG: /* Int64_ty */5, + _0: concat_fmtty(fmtty1._0, fmtty2) + }; + case /* Float_ty */6 : + return { + TAG: /* Float_ty */6, + _0: concat_fmtty(fmtty1._0, fmtty2) + }; + case /* Bool_ty */7 : + return { + TAG: /* Bool_ty */7, + _0: concat_fmtty(fmtty1._0, fmtty2) + }; + case /* Format_arg_ty */8 : + return { + TAG: /* Format_arg_ty */8, + _0: fmtty1._0, + _1: concat_fmtty(fmtty1._1, fmtty2) + }; + case /* Format_subst_ty */9 : + return { + TAG: /* Format_subst_ty */9, + _0: fmtty1._0, + _1: fmtty1._1, + _2: concat_fmtty(fmtty1._2, fmtty2) + }; + case /* Alpha_ty */10 : + return { + TAG: /* Alpha_ty */10, + _0: concat_fmtty(fmtty1._0, fmtty2) + }; + case /* Theta_ty */11 : + return { + TAG: /* Theta_ty */11, + _0: concat_fmtty(fmtty1._0, fmtty2) + }; + case /* Any_ty */12 : + return { + TAG: /* Any_ty */12, + _0: concat_fmtty(fmtty1._0, fmtty2) + }; + case /* Reader_ty */13 : + return { + TAG: /* Reader_ty */13, + _0: concat_fmtty(fmtty1._0, fmtty2) + }; + case /* Ignored_reader_ty */14 : + return { + TAG: /* Ignored_reader_ty */14, + _0: concat_fmtty(fmtty1._0, fmtty2) + }; + + } +} + +function concat_fmt(fmt1, fmt2) { + if (typeof fmt1 === "number") { + return fmt2; + } + switch (fmt1.TAG | 0) { + case /* Char */0 : + return { + TAG: /* Char */0, + _0: concat_fmt(fmt1._0, fmt2) + }; + case /* Caml_char */1 : + return { + TAG: /* Caml_char */1, + _0: concat_fmt(fmt1._0, fmt2) + }; + case /* String */2 : + return { + TAG: /* String */2, + _0: fmt1._0, + _1: concat_fmt(fmt1._1, fmt2) + }; + case /* Caml_string */3 : + return { + TAG: /* Caml_string */3, + _0: fmt1._0, + _1: concat_fmt(fmt1._1, fmt2) + }; + case /* Int */4 : + return { + TAG: /* Int */4, + _0: fmt1._0, + _1: fmt1._1, + _2: fmt1._2, + _3: concat_fmt(fmt1._3, fmt2) + }; + case /* Int32 */5 : + return { + TAG: /* Int32 */5, + _0: fmt1._0, + _1: fmt1._1, + _2: fmt1._2, + _3: concat_fmt(fmt1._3, fmt2) + }; + case /* Nativeint */6 : + return { + TAG: /* Nativeint */6, + _0: fmt1._0, + _1: fmt1._1, + _2: fmt1._2, + _3: concat_fmt(fmt1._3, fmt2) + }; + case /* Int64 */7 : + return { + TAG: /* Int64 */7, + _0: fmt1._0, + _1: fmt1._1, + _2: fmt1._2, + _3: concat_fmt(fmt1._3, fmt2) + }; + case /* Float */8 : + return { + TAG: /* Float */8, + _0: fmt1._0, + _1: fmt1._1, + _2: fmt1._2, + _3: concat_fmt(fmt1._3, fmt2) + }; + case /* Bool */9 : + return { + TAG: /* Bool */9, + _0: fmt1._0, + _1: concat_fmt(fmt1._1, fmt2) + }; + case /* Flush */10 : + return { + TAG: /* Flush */10, + _0: concat_fmt(fmt1._0, fmt2) + }; + case /* String_literal */11 : + return { + TAG: /* String_literal */11, + _0: fmt1._0, + _1: concat_fmt(fmt1._1, fmt2) + }; + case /* Char_literal */12 : + return { + TAG: /* Char_literal */12, + _0: fmt1._0, + _1: concat_fmt(fmt1._1, fmt2) + }; + case /* Format_arg */13 : + return { + TAG: /* Format_arg */13, + _0: fmt1._0, + _1: fmt1._1, + _2: concat_fmt(fmt1._2, fmt2) + }; + case /* Format_subst */14 : + return { + TAG: /* Format_subst */14, + _0: fmt1._0, + _1: fmt1._1, + _2: concat_fmt(fmt1._2, fmt2) + }; + case /* Alpha */15 : + return { + TAG: /* Alpha */15, + _0: concat_fmt(fmt1._0, fmt2) + }; + case /* Theta */16 : + return { + TAG: /* Theta */16, + _0: concat_fmt(fmt1._0, fmt2) + }; + case /* Formatting_lit */17 : + return { + TAG: /* Formatting_lit */17, + _0: fmt1._0, + _1: concat_fmt(fmt1._1, fmt2) + }; + case /* Formatting_gen */18 : + return { + TAG: /* Formatting_gen */18, + _0: fmt1._0, + _1: concat_fmt(fmt1._1, fmt2) + }; + case /* Reader */19 : + return { + TAG: /* Reader */19, + _0: concat_fmt(fmt1._0, fmt2) + }; + case /* Scan_char_set */20 : + return { + TAG: /* Scan_char_set */20, + _0: fmt1._0, + _1: fmt1._1, + _2: concat_fmt(fmt1._2, fmt2) + }; + case /* Scan_get_counter */21 : + return { + TAG: /* Scan_get_counter */21, + _0: fmt1._0, + _1: concat_fmt(fmt1._1, fmt2) + }; + case /* Scan_next_char */22 : + return { + TAG: /* Scan_next_char */22, + _0: concat_fmt(fmt1._0, fmt2) + }; + case /* Ignored_param */23 : + return { + TAG: /* Ignored_param */23, + _0: fmt1._0, + _1: concat_fmt(fmt1._1, fmt2) + }; + case /* Custom */24 : + return { + TAG: /* Custom */24, + _0: fmt1._0, + _1: fmt1._1, + _2: concat_fmt(fmt1._2, fmt2) + }; + + } +} + +export { + concat_fmtty , + erase_rel , + concat_fmt , +} +/* No side effect */ diff --git a/melange-node-modules/melange/camlinternalLazy.js b/melange-node-modules/melange/camlinternalLazy.js new file mode 100644 index 0000000..095367f --- /dev/null +++ b/melange-node-modules/melange/camlinternalLazy.js @@ -0,0 +1,69 @@ +// Generated by Melange + +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; + +var Undefined = /* @__PURE__ */Caml_exceptions.create("CamlinternalLazy.Undefined"); + +function is_val(l) { + return l.LAZY_DONE; +} + +function forward_with_closure(blk, closure) { + var result = closure(); + blk.VAL = result; + blk.LAZY_DONE = true; + return result; +} + +function raise_undefined() { + throw { + RE_EXN_ID: Undefined, + Error: new Error() + }; +} + +function force_lazy_block(blk) { + var closure = blk.VAL; + blk.VAL = raise_undefined; + try { + return forward_with_closure(blk, closure); + } + catch (e){ + blk.VAL = (function () { + throw e; + }); + throw e; + } +} + +function force_val_lazy_block(blk) { + var closure = blk.VAL; + blk.VAL = raise_undefined; + return forward_with_closure(blk, closure); +} + +function force(lzv) { + if (lzv.LAZY_DONE) { + return lzv.VAL; + } else { + return force_lazy_block(lzv); + } +} + +function force_val(lzv) { + if (lzv.LAZY_DONE) { + return lzv.VAL; + } else { + return force_val_lazy_block(lzv); + } +} + +export { + Undefined , + force_lazy_block , + force_val_lazy_block , + force , + force_val , + is_val , +} +/* No side effect */ diff --git a/melange-node-modules/melange/camlinternalMod.js b/melange-node-modules/melange/camlinternalMod.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange/camlinternalMod.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange/camlinternalOO.js b/melange-node-modules/melange/camlinternalOO.js new file mode 100644 index 0000000..69eed15 --- /dev/null +++ b/melange-node-modules/melange/camlinternalOO.js @@ -0,0 +1,810 @@ +// Generated by Melange + +import * as Belt__Belt_MapInt from "melange.belt/belt_MapInt.js"; +import * as Belt__Belt_MapString from "melange.belt/belt_MapString.js"; +import * as Caml_array from "melange.js/caml_array.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Caml_obj from "melange.js/caml_obj.js"; +import * as Caml_oo from "melange.js/caml_oo.js"; +import * as Caml_string from "melange.js/caml_string.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Array from "./array.js"; +import * as Stdlib__List from "./list.js"; + +var new_object_tag_block = (function(size){ + var v = new Array(size) + v.TAG = 248 // tag + return v +}); + +function copy(o) { + return Caml_oo.caml_set_oo_id(Caml_obj.caml_obj_dup(o)); +} + +var params = { + compact_table: true, + copy_parent: true, + clean_when_copying: true, + retry_count: 3, + bucket_small_size: 16 +}; + +function public_method_label(s) { + var accu = 0; + for(var i = 0 ,i_finish = s.length; i < i_finish; ++i){ + accu = Math.imul(223, accu) + Caml_string.get(s, i) | 0; + } + accu = accu & 2147483647; + if (accu > 1073741823) { + return accu - -2147483648 | 0; + } else { + return accu; + } +} + +var dummy_table = { + size: 0, + methods: [undefined], + methods_by_name: undefined, + methods_by_label: undefined, + previous_states: /* [] */0, + hidden_meths: /* [] */0, + vars: undefined, + initializers: /* [] */0 +}; + +var table_count = { + contents: 0 +}; + +function fit_size(n) { + if (n <= 2) { + return n; + } else { + return (fit_size((n + 1 | 0) / 2 | 0) << 1); + } +} + +function new_table(pub_labels) { + table_count.contents = table_count.contents + 1 | 0; + var len = pub_labels.length; + var methods = Caml_array.make((len << 1) + 2 | 0, /* DummyA */0); + Caml_array.set(methods, 0, len); + Caml_array.set(methods, 1, ((fit_size(len) << 5) / 8 | 0) - 1 | 0); + for(var i = 0; i < len; ++i){ + Caml_array.set(methods, (i << 1) + 3 | 0, Caml_array.get(pub_labels, i)); + } + return { + size: 2, + methods: methods, + methods_by_name: undefined, + methods_by_label: undefined, + previous_states: /* [] */0, + hidden_meths: /* [] */0, + vars: undefined, + initializers: /* [] */0 + }; +} + +function resize(array, new_size) { + var old_size = array.methods.length; + if (new_size <= old_size) { + return ; + } + var new_buck = Caml_array.make(new_size, /* DummyA */0); + Stdlib__Array.blit(array.methods, 0, new_buck, 0, old_size); + array.methods = new_buck; +} + +var method_count = { + contents: 0 +}; + +var inst_var_count = { + contents: 0 +}; + +function new_method(table) { + var index = table.methods.length; + resize(table, index + 1 | 0); + return index; +} + +function get_method_label(table, name) { + var x = Belt__Belt_MapString.getUndefined(table.methods_by_name, name); + if (x !== undefined) { + return x; + } + var label = new_method(table); + table.methods_by_name = Belt__Belt_MapString.set(table.methods_by_name, name, label); + table.methods_by_label = Belt__Belt_MapInt.set(table.methods_by_label, label, true); + return label; +} + +function get_method_labels(table, names) { + return Stdlib__Array.map((function (param) { + return get_method_label(table, param); + }), names); +} + +function set_method(table, label, element) { + method_count.contents = method_count.contents + 1 | 0; + if (Belt__Belt_MapInt.getExn(table.methods_by_label, label)) { + resize(table, label + 1 | 0); + return Caml_array.set(table.methods, label, element); + } else { + table.hidden_meths = { + hd: [ + label, + element + ], + tl: table.hidden_meths + }; + return ; + } +} + +function get_method(table, label) { + try { + return Stdlib__List.assoc(label, table.hidden_meths); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + return Caml_array.get(table.methods, label); + } + throw exn; + } +} + +function to_list(arr) { + if (arr === 0) { + return /* [] */0; + } else { + return Stdlib__Array.to_list(arr); + } +} + +function narrow(table, vars, virt_meths, concr_meths) { + var vars$1 = to_list(vars); + var virt_meths$1 = to_list(virt_meths); + var concr_meths$1 = to_list(concr_meths); + var virt_meth_labs = Stdlib__List.map((function (param) { + return get_method_label(table, param); + }), virt_meths$1); + var concr_meth_labs = Stdlib__List.map((function (param) { + return get_method_label(table, param); + }), concr_meths$1); + table.previous_states = { + hd: [ + table.methods_by_name, + table.methods_by_label, + table.hidden_meths, + table.vars, + virt_meth_labs, + vars$1 + ], + tl: table.previous_states + }; + table.vars = Belt__Belt_MapString.reduceU(table.vars, undefined, (function (tvars, lab, info) { + if (Stdlib__List.mem(lab, vars$1)) { + return Belt__Belt_MapString.set(tvars, lab, info); + } else { + return tvars; + } + })); + var by_name = { + contents: undefined + }; + var by_label = { + contents: undefined + }; + Stdlib__List.iter2((function (met, label) { + by_name.contents = Belt__Belt_MapString.set(by_name.contents, met, label); + by_label.contents = Belt__Belt_MapInt.set(by_label.contents, label, Belt__Belt_MapInt.getWithDefault(table.methods_by_label, label, true)); + }), concr_meths$1, concr_meth_labs); + Stdlib__List.iter2((function (met, label) { + by_name.contents = Belt__Belt_MapString.set(by_name.contents, met, label); + by_label.contents = Belt__Belt_MapInt.set(by_label.contents, label, false); + }), virt_meths$1, virt_meth_labs); + table.methods_by_name = by_name.contents; + table.methods_by_label = by_label.contents; + table.hidden_meths = Stdlib__List.fold_right((function (met, hm) { + if (Stdlib__List.mem(met[0], virt_meth_labs)) { + return hm; + } else { + return { + hd: met, + tl: hm + }; + } + }), table.hidden_meths, /* [] */0); +} + +function widen(table) { + var match = Stdlib__List.hd(table.previous_states); + var virt_meths = match[4]; + table.previous_states = Stdlib__List.tl(table.previous_states); + table.vars = Stdlib__List.fold_left((function (s, v) { + return Belt__Belt_MapString.set(s, v, Belt__Belt_MapString.getExn(table.vars, v)); + }), match[3], match[5]); + table.methods_by_name = match[0]; + table.methods_by_label = match[1]; + table.hidden_meths = Stdlib__List.fold_right((function (met, hm) { + if (Stdlib__List.mem(met[0], virt_meths)) { + return hm; + } else { + return { + hd: met, + tl: hm + }; + } + }), table.hidden_meths, match[2]); +} + +function new_slot(table) { + var index = table.size; + table.size = index + 1 | 0; + return index; +} + +function new_variable(table, name) { + var x = Belt__Belt_MapString.getUndefined(table.vars, name); + if (x !== undefined) { + return x; + } + var index = new_slot(table); + if (name !== "") { + table.vars = Belt__Belt_MapString.set(table.vars, name, index); + } + return index; +} + +function to_array(arr) { + if (Caml_obj.caml_equal(arr, 0)) { + return []; + } else { + return arr; + } +} + +function new_methods_variables(table, meths, vals) { + var meths$1 = to_array(meths); + var nmeths = meths$1.length; + var nvals = vals.length; + var res = Caml_array.make(nmeths + nvals | 0, 0); + for(var i = 0; i < nmeths; ++i){ + Caml_array.set(res, i, get_method_label(table, Caml_array.get(meths$1, i))); + } + for(var i$1 = 0; i$1 < nvals; ++i$1){ + Caml_array.set(res, i$1 + nmeths | 0, new_variable(table, Caml_array.get(vals, i$1))); + } + return res; +} + +function get_variable(table, name) { + try { + return Belt__Belt_MapString.getExn(table.vars, name); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalOO.cppo.ml", + 365, + 20 + ], + Error: new Error() + }; + } + throw exn; + } +} + +function get_variables(table, names) { + return Stdlib__Array.map((function (param) { + return get_variable(table, param); + }), names); +} + +function add_initializer(table, f) { + table.initializers = { + hd: f, + tl: table.initializers + }; +} + +function create_table(public_methods) { + if (public_methods === 0) { + return new_table([]); + } + var tags = Stdlib__Array.map(public_method_label, public_methods); + var table = new_table(tags); + Stdlib__Array.iteri((function (i, met) { + var lab = (i << 1) + 2 | 0; + table.methods_by_name = Belt__Belt_MapString.set(table.methods_by_name, met, lab); + table.methods_by_label = Belt__Belt_MapInt.set(table.methods_by_label, lab, true); + }), public_methods); + return table; +} + +function init_class(table) { + inst_var_count.contents = (inst_var_count.contents + table.size | 0) - 1 | 0; + table.initializers = Stdlib__List.rev(table.initializers); + resize(table, 3 + ((Caml_array.get(table.methods, 1) << 4) / 32 | 0) | 0); +} + +function inherits(cla, vals, virt_meths, concr_meths, param, top) { + var $$super = param[1]; + narrow(cla, vals, virt_meths, concr_meths); + var init = top ? Curry._2($$super, cla, param[3]) : Curry._1($$super, cla); + widen(cla); + return Caml_array.concat({ + hd: [init], + tl: { + hd: Stdlib__Array.map((function (param) { + return get_variable(cla, param); + }), to_array(vals)), + tl: { + hd: Stdlib__Array.map((function (nm) { + return get_method(cla, get_method_label(cla, nm)); + }), to_array(concr_meths)), + tl: /* [] */0 + } + } + }); +} + +function make_class(pub_meths, class_init) { + var table = create_table(pub_meths); + var env_init = Curry._1(class_init, table); + init_class(table); + return [ + Curry._1(env_init, 0), + class_init, + env_init, + 0 + ]; +} + +function make_class_store(pub_meths, class_init, init_table) { + var table = create_table(pub_meths); + var env_init = Curry._1(class_init, table); + init_class(table); + init_table.class_init = class_init; + init_table.env_init = env_init; +} + +function create_object(table) { + var obj = new_object_tag_block(table.size); + obj[0] = table.methods; + return Caml_oo.caml_set_oo_id(obj); +} + +function create_object_opt(obj_0, table) { + if (obj_0) { + return obj_0; + } + var obj = new_object_tag_block(table.size); + obj[0] = table.methods; + return Caml_oo.caml_set_oo_id(obj); +} + +function iter_f(obj, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + Curry._1(param.hd, obj); + _param = param.tl; + continue ; + }; +} + +function run_initializers(obj, table) { + var inits = table.initializers; + if (Caml_obj.caml_notequal(inits, /* [] */0)) { + return iter_f(obj, inits); + } + +} + +function run_initializers_opt(obj_0, obj, table) { + if (obj_0) { + return obj; + } + var inits = table.initializers; + if (Caml_obj.caml_notequal(inits, /* [] */0)) { + iter_f(obj, inits); + } + return obj; +} + +function create_object_and_run_initializers(obj_0, table) { + if (obj_0) { + return obj_0; + } + var obj = create_object(table); + run_initializers(obj, table); + return obj; +} + +function set_data(tables, v) { + if (tables) { + tables.data = v; + return ; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalOO.cppo.ml", + 505, + 13 + ], + Error: new Error() + }; +} + +function set_next(tables, v) { + if (tables) { + tables.next = v; + return ; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalOO.cppo.ml", + 508, + 13 + ], + Error: new Error() + }; +} + +function get_key(param) { + if (param) { + return param.key; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalOO.cppo.ml", + 511, + 13 + ], + Error: new Error() + }; +} + +function get_data(param) { + if (param) { + return param.data; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalOO.cppo.ml", + 514, + 13 + ], + Error: new Error() + }; +} + +function get_next(param) { + if (param) { + return param.next; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalOO.cppo.ml", + 517, + 13 + ], + Error: new Error() + }; +} + +function build_path(n, keys, tables) { + var res = /* Cons */{ + key: 0, + data: /* Empty */0, + next: /* Empty */0 + }; + var r = res; + for(var i = 0; i <= n; ++i){ + r = /* Cons */{ + key: Caml_array.get(keys, i), + data: r, + next: /* Empty */0 + }; + } + set_data(tables, r); + return res; +} + +function lookup_keys(i, keys, tables) { + if (i < 0) { + return tables; + } + var key = Caml_array.get(keys, i); + var _tables = tables; + while(true) { + var tables$1 = _tables; + if (get_key(tables$1) === key) { + var tables_data = get_data(tables$1); + if (tables_data) { + return lookup_keys(i - 1 | 0, keys, tables_data); + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "camlinternalOO.cppo.ml", + 535, + 17 + ], + Error: new Error() + }; + } + var next = get_next(tables$1); + if (next) { + _tables = next; + continue ; + } + var next$1 = /* Cons */{ + key: key, + data: /* Empty */0, + next: /* Empty */0 + }; + set_next(tables$1, next$1); + return build_path(i - 1 | 0, keys, next$1); + }; +} + +function lookup_tables(root, keys) { + var root_data = get_data(root); + if (root_data) { + return lookup_keys(keys.length - 1 | 0, keys, root_data); + } else { + return build_path(keys.length - 1 | 0, keys, root); + } +} + +function new_cache(table) { + var n = new_method(table); + var n$1 = n % 2 === 0 || n > (2 + ((Caml_array.get(table.methods, 1) << 4) / 32 | 0) | 0) ? n : new_method(table); + Caml_array.set(table.methods, n$1, 0); + return n$1; +} + +function method_impl(table, i, arr) { + var next = function (param) { + i.contents = i.contents + 1 | 0; + return Caml_array.get(arr, i.contents); + }; + var clo = next(undefined); + if (typeof clo !== "number") { + return clo; + } + switch (clo) { + case /* GetConst */0 : + var x = next(undefined); + return function (_obj) { + return x; + }; + case /* GetVar */1 : + var n = next(undefined); + return function (obj) { + return obj[n]; + }; + case /* GetEnv */2 : + var e = next(undefined); + var n$1 = next(undefined); + return function (obj) { + return obj[e][n$1]; + }; + case /* GetMeth */3 : + var n$2 = next(undefined); + return function (obj) { + return Curry._1(obj[0][n$2], obj); + }; + case /* SetVar */4 : + var n$3 = next(undefined); + return function (obj, x) { + obj[n$3] = x; + }; + case /* AppConst */5 : + var f = next(undefined); + var x$1 = next(undefined); + return function (_obj) { + return Curry._1(f, x$1); + }; + case /* AppVar */6 : + var f$1 = next(undefined); + var n$4 = next(undefined); + return function (obj) { + return Curry._1(f$1, obj[n$4]); + }; + case /* AppEnv */7 : + var f$2 = next(undefined); + var e$1 = next(undefined); + var n$5 = next(undefined); + return function (obj) { + return Curry._1(f$2, obj[e$1][n$5]); + }; + case /* AppMeth */8 : + var f$3 = next(undefined); + var n$6 = next(undefined); + return function (obj) { + return Curry._1(f$3, Curry._1(obj[0][n$6], obj)); + }; + case /* AppConstConst */9 : + var f$4 = next(undefined); + var x$2 = next(undefined); + var y = next(undefined); + return function (_obj) { + return Curry._2(f$4, x$2, y); + }; + case /* AppConstVar */10 : + var f$5 = next(undefined); + var x$3 = next(undefined); + var n$7 = next(undefined); + return function (obj) { + return Curry._2(f$5, x$3, obj[n$7]); + }; + case /* AppConstEnv */11 : + var f$6 = next(undefined); + var x$4 = next(undefined); + var e$2 = next(undefined); + var n$8 = next(undefined); + return function (obj) { + return Curry._2(f$6, x$4, obj[e$2][n$8]); + }; + case /* AppConstMeth */12 : + var f$7 = next(undefined); + var x$5 = next(undefined); + var n$9 = next(undefined); + return function (obj) { + return Curry._2(f$7, x$5, Curry._1(obj[0][n$9], obj)); + }; + case /* AppVarConst */13 : + var f$8 = next(undefined); + var n$10 = next(undefined); + var x$6 = next(undefined); + return function (obj) { + return Curry._2(f$8, obj[n$10], x$6); + }; + case /* AppEnvConst */14 : + var f$9 = next(undefined); + var e$3 = next(undefined); + var n$11 = next(undefined); + var x$7 = next(undefined); + return function (obj) { + return Curry._2(f$9, obj[e$3][n$11], x$7); + }; + case /* AppMethConst */15 : + var f$10 = next(undefined); + var n$12 = next(undefined); + var x$8 = next(undefined); + return function (obj) { + return Curry._2(f$10, Curry._1(obj[0][n$12], obj), x$8); + }; + case /* MethAppConst */16 : + var n$13 = next(undefined); + var x$9 = next(undefined); + return function (obj) { + return Curry._2(obj[0][n$13], obj, x$9); + }; + case /* MethAppVar */17 : + var n$14 = next(undefined); + var m = next(undefined); + return function (obj) { + return Curry._2(obj[0][n$14], obj, obj[m]); + }; + case /* MethAppEnv */18 : + var n$15 = next(undefined); + var e$4 = next(undefined); + var m$1 = next(undefined); + return function (obj) { + return Curry._2(obj[0][n$15], obj, obj[e$4][m$1]); + }; + case /* MethAppMeth */19 : + var n$16 = next(undefined); + var m$2 = next(undefined); + return function (obj) { + return Curry._2(obj[0][n$16], obj, Curry._1(obj[0][m$2], obj)); + }; + case /* SendConst */20 : + var m$3 = next(undefined); + var x$10 = next(undefined); + var c = new_cache(table); + return function (obj) { + return Curry._3(Curry._3(Caml_oo.caml_get_public_method, x$10, m$3, 1), x$10, obj[0], c); + }; + case /* SendVar */21 : + var m$4 = next(undefined); + var n$17 = next(undefined); + var c$1 = new_cache(table); + return function (obj) { + var tmp = obj[n$17]; + return Curry._3(Curry._3(Caml_oo.caml_get_public_method, tmp, m$4, 2), tmp, obj[0], c$1); + }; + case /* SendEnv */22 : + var m$5 = next(undefined); + var e$5 = next(undefined); + var n$18 = next(undefined); + var c$2 = new_cache(table); + return function (obj) { + var tmp = obj[e$5][n$18]; + return Curry._3(Curry._3(Caml_oo.caml_get_public_method, tmp, m$5, 3), tmp, obj[0], c$2); + }; + case /* SendMeth */23 : + var m$6 = next(undefined); + var n$19 = next(undefined); + var c$3 = new_cache(table); + return function (obj) { + var tmp = Curry._1(obj[0][n$19], obj); + return Curry._3(Curry._3(Caml_oo.caml_get_public_method, tmp, m$6, 4), tmp, obj[0], c$3); + }; + + } +} + +function set_methods(table, methods) { + var len = methods.length; + var i = { + contents: 0 + }; + while(i.contents < len) { + var label = Caml_array.get(methods, i.contents); + var clo = method_impl(table, i, methods); + set_method(table, label, clo); + i.contents = i.contents + 1 | 0; + }; +} + +function stats(param) { + return { + classes: table_count.contents, + methods: method_count.contents, + inst_vars: inst_var_count.contents + }; +} + +export { + public_method_label , + new_method , + new_variable , + new_methods_variables , + get_variable , + get_variables , + get_method_label , + get_method_labels , + get_method , + set_method , + set_methods , + narrow , + widen , + add_initializer , + dummy_table , + create_table , + init_class , + inherits , + make_class , + make_class_store , + copy , + create_object , + create_object_opt , + run_initializers , + run_initializers_opt , + create_object_and_run_initializers , + lookup_tables , + params , + stats , +} +/* No side effect */ diff --git a/melange-node-modules/melange/char.js b/melange-node-modules/melange/char.js new file mode 100644 index 0000000..1cdde37 --- /dev/null +++ b/melange-node-modules/melange/char.js @@ -0,0 +1,119 @@ +// Generated by Melange + +import * as Caml_bytes from "melange.js/caml_bytes.js"; +import * as Caml_hash from "melange.js/caml_hash.js"; + +function chr(n) { + if (n < 0 || n > 255) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Char.chr", + Error: new Error() + }; + } + return n; +} + +function escaped(c) { + var exit = 0; + if (c >= 40) { + if (c === 92) { + return "\\\\"; + } + exit = c >= 127 ? 1 : 2; + } else if (c >= 32) { + if (c >= 39) { + return "\\'"; + } + exit = 2; + } else if (c >= 14) { + exit = 1; + } else { + switch (c) { + case 8 : + return "\\b"; + case 9 : + return "\\t"; + case 10 : + return "\\n"; + case 0 : + case 1 : + case 2 : + case 3 : + case 4 : + case 5 : + case 6 : + case 7 : + case 11 : + case 12 : + exit = 1; + break; + case 13 : + return "\\r"; + + } + } + switch (exit) { + case 1 : + var s = [ + 0, + 0, + 0, + 0 + ]; + s[0] = /* '\\' */92; + s[1] = 48 + (c / 100 | 0) | 0; + s[2] = 48 + (c / 10 | 0) % 10 | 0; + s[3] = 48 + c % 10 | 0; + return Caml_bytes.bytes_to_string(s); + case 2 : + var s$1 = [0]; + s$1[0] = c; + return Caml_bytes.bytes_to_string(s$1); + + } +} + +function lowercase_ascii(c) { + if (c > 90 || c < 65) { + return c; + } else { + return c + 32 | 0; + } +} + +function uppercase_ascii(c) { + if (c > 122 || c < 97) { + return c; + } else { + return c - 32 | 0; + } +} + +function compare(c1, c2) { + return c1 - c2 | 0; +} + +function equal(c1, c2) { + return (c1 - c2 | 0) === 0; +} + +function seeded_hash(seed, x) { + return Caml_hash.caml_hash(10, 100, seed, x); +} + +function hash(x) { + return Caml_hash.caml_hash(10, 100, 0, x); +} + +export { + chr , + escaped , + lowercase_ascii , + uppercase_ascii , + compare , + equal , + seeded_hash , + hash , +} +/* No side effect */ diff --git a/melange-node-modules/melange/complex.js b/melange-node-modules/melange/complex.js new file mode 100644 index 0000000..a97a886 --- /dev/null +++ b/melange-node-modules/melange/complex.js @@ -0,0 +1,164 @@ +// Generated by Melange + +import * as Caml_float from "melange.js/caml_float.js"; + +var one = { + re: 1.0, + im: 0.0 +}; + +function add(x, y) { + return { + re: x.re + y.re, + im: x.im + y.im + }; +} + +function sub(x, y) { + return { + re: x.re - y.re, + im: x.im - y.im + }; +} + +function neg(x) { + return { + re: - x.re, + im: - x.im + }; +} + +function conj(x) { + return { + re: x.re, + im: - x.im + }; +} + +function mul(x, y) { + return { + re: x.re * y.re - x.im * y.im, + im: x.re * y.im + x.im * y.re + }; +} + +function div(x, y) { + if (Math.abs(y.re) >= Math.abs(y.im)) { + var r = y.im / y.re; + var d = y.re + r * y.im; + return { + re: (x.re + r * x.im) / d, + im: (x.im - r * x.re) / d + }; + } + var r$1 = y.re / y.im; + var d$1 = y.im + r$1 * y.re; + return { + re: (r$1 * x.re + x.im) / d$1, + im: (r$1 * x.im - x.re) / d$1 + }; +} + +function inv(x) { + return div(one, x); +} + +function norm2(x) { + return x.re * x.re + x.im * x.im; +} + +function norm(x) { + return Caml_float.caml_hypot_float(x.re, x.im); +} + +function arg(x) { + return Math.atan2(x.im, x.re); +} + +function polar(n, a) { + return { + re: Math.cos(a) * n, + im: Math.sin(a) * n + }; +} + +function sqrt(x) { + if (x.re === 0.0 && x.im === 0.0) { + return { + re: 0.0, + im: 0.0 + }; + } + var r = Math.abs(x.re); + var i = Math.abs(x.im); + var w; + if (r >= i) { + var q = i / r; + w = Math.sqrt(r) * Math.sqrt(0.5 * (1.0 + Math.sqrt(1.0 + q * q))); + } else { + var q$1 = r / i; + w = Math.sqrt(i) * Math.sqrt(0.5 * (q$1 + Math.sqrt(1.0 + q$1 * q$1))); + } + if (x.re >= 0.0) { + return { + re: w, + im: 0.5 * x.im / w + }; + } else { + return { + re: 0.5 * i / w, + im: x.im >= 0.0 ? w : - w + }; + } +} + +function exp(x) { + var e = Math.exp(x.re); + return { + re: e * Math.cos(x.im), + im: e * Math.sin(x.im) + }; +} + +function log(x) { + return { + re: Math.log(norm(x)), + im: Math.atan2(x.im, x.re) + }; +} + +function pow(x, y) { + return exp(mul(y, log(x))); +} + +var zero = { + re: 0.0, + im: 0.0 +}; + +var i = { + re: 0.0, + im: 1.0 +}; + +export { + zero , + one , + i , + neg , + conj , + add , + sub , + mul , + inv , + div , + sqrt , + norm2 , + norm , + arg , + polar , + exp , + log , + pow , +} +/* No side effect */ diff --git a/melange-node-modules/melange/digest.js b/melange-node-modules/melange/digest.js new file mode 100644 index 0000000..afb9a53 --- /dev/null +++ b/melange-node-modules/melange/digest.js @@ -0,0 +1,142 @@ +// Generated by Melange + +import * as Caml_bytes from "melange.js/caml_bytes.js"; +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Caml_md5 from "melange.js/caml_md5.js"; +import * as Caml_string from "melange.js/caml_string.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Char from "./char.js"; +import * as Stdlib__String from "./string.js"; + +function string(str) { + return Caml_md5.caml_md5_string(str, 0, str.length); +} + +function bytes(b) { + return string(Caml_bytes.bytes_to_string(b)); +} + +function substring(str, ofs, len) { + if (ofs < 0 || len < 0 || ofs > (str.length - len | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Digest.substring", + Error: new Error() + }; + } + return Caml_md5.caml_md5_string(str, ofs, len); +} + +function subbytes(b, ofs, len) { + return substring(Caml_bytes.bytes_to_string(b), ofs, len); +} + +function file(filename) { + var ic = Stdlib.open_in_bin(filename); + var d; + try { + d = Caml_external_polyfill.resolve("caml_md5_chan")(ic, -1); + } + catch (e){ + Caml_external_polyfill.resolve("caml_ml_close_channel")(ic); + throw e; + } + Caml_external_polyfill.resolve("caml_ml_close_channel")(ic); + return d; +} + +var output = Stdlib.output_string; + +function input(chan) { + return Stdlib.really_input_string(chan, 16); +} + +function char_hex(n) { + return n + ( + n < 10 ? /* '0' */48 : 87 + ) | 0; +} + +function to_hex(d) { + if (d.length !== 16) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Digest.to_hex", + Error: new Error() + }; + } + var result = Caml_bytes.caml_create_bytes(32); + for(var i = 0; i <= 15; ++i){ + var x = Caml_string.get(d, i); + result[(i << 1)] = char_hex((x >>> 4)); + result[(i << 1) + 1 | 0] = char_hex(x & 15); + } + return Caml_bytes.bytes_to_string(result); +} + +function from_hex(s) { + if (s.length !== 32) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Digest.from_hex", + Error: new Error() + }; + } + var digit = function (c) { + if (c >= 65) { + if (c >= 97) { + if (c >= 103) { + throw { + RE_EXN_ID: Stdlib.Invalid_argument, + _1: "Digest.from_hex", + Error: new Error() + }; + } + return (c - /* 'a' */97 | 0) + 10 | 0; + } + if (c >= 71) { + throw { + RE_EXN_ID: Stdlib.Invalid_argument, + _1: "Digest.from_hex", + Error: new Error() + }; + } + return (c - /* 'A' */65 | 0) + 10 | 0; + } + if (c > 57 || c < 48) { + throw { + RE_EXN_ID: Stdlib.Invalid_argument, + _1: "Digest.from_hex", + Error: new Error() + }; + } + return c - /* '0' */48 | 0; + }; + var $$byte = function (i) { + return (digit(Caml_string.get(s, i)) << 4) + digit(Caml_string.get(s, i + 1 | 0)) | 0; + }; + var result = Caml_bytes.caml_create_bytes(16); + for(var i = 0; i <= 15; ++i){ + Caml_bytes.set(result, i, Stdlib__Char.chr($$byte((i << 1)))); + } + return Caml_bytes.bytes_to_string(result); +} + +var compare = Stdlib__String.compare; + +var equal = Stdlib__String.equal; + +export { + compare , + equal , + string , + bytes , + substring , + subbytes , + file , + output , + input , + to_hex , + from_hex , +} +/* No side effect */ diff --git a/melange-node-modules/melange/domain.js b/melange-node-modules/melange/domain.js new file mode 100644 index 0000000..03a34ac --- /dev/null +++ b/melange-node-modules/melange/domain.js @@ -0,0 +1,299 @@ +// Generated by Melange + +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib__Fun from "./fun.js"; +import * as Stdlib__List from "./list.js"; +import * as Stdlib__Printexc from "./printexc.js"; +import * as Stdlib__Queue from "./queue.js"; + +var atomic_lock = { + contents: false +}; + +function atomically(f) { + atomic_lock.contents = true; + return Stdlib__Fun.protect((function (param) { + atomic_lock.contents = false; + }), f); +} + +var first_spawn_queue = { + length: 0, + first: /* Nil */0, + last: /* Nil */0 +}; + +var first_spawn_occurred = { + contents: false +}; + +function before_first_spawn(f) { + atomically(function (param) { + if (first_spawn_occurred.contents) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Domain.before_first_spawn", + Error: new Error() + }; + } + Stdlib__Queue.push(f, first_spawn_queue); + }); +} + +function maybe_first_spawn(param) { + atomically(function (param) { + if (first_spawn_occurred.contents) { + return ; + } + first_spawn_occurred.contents = true; + while(first_spawn_queue.length !== 0) { + var f = Stdlib__Queue.take(first_spawn_queue); + Curry._1(f, undefined); + }; + }); +} + +var at_exit_table = { + contents: /* [] */0 +}; + +function at_exit(f) { + atomically(function (param) { + at_exit_table.contents = { + hd: f, + tl: at_exit_table.contents + }; + }); +} + +function get_id(t) { + return t.id; +} + +function self(param) { + return 0; +} + +function cpu_relax(param) { + +} + +function is_main_domain(param) { + return true; +} + +function recommended_domain_count(param) { + return 1; +} + +var all_keys = { + contents: /* [] */0 +}; + +function new_key(split_from_parent, init) { + var key = { + table: undefined, + split_from_parent: split_from_parent, + init: init + }; + atomically(function (param) { + all_keys.contents = { + hd: /* Key */{ + _0: key + }, + tl: all_keys.contents + }; + }); + return key; +} + +function get(key) { + var v = key.table; + if (v !== undefined) { + return Caml_option.valFromOption(v); + } + var v$1 = Curry._1(key.init, undefined); + atomically(function (param) { + key.table = Caml_option.some(v$1); + }); + return v$1; +} + +function set(key, v) { + atomically(function (param) { + key.table = Caml_option.some(v); + }); +} + +function prepare_split_keys_before_spawn(param) { + return Stdlib__List.filter_map((function (param) { + var key = param._0; + var split = key.split_from_parent; + if (split === undefined) { + return ; + } + var current = get(key); + var child = Curry._1(split, current); + return /* Key_value */{ + _0: key, + _1: child + }; + }), all_keys.contents); +} + +function perform_split_after_spawn(split_keys) { + var perform_split = function (param) { + set(param._0, param._1); + }; + Stdlib__List.iter(perform_split, split_keys); +} + +var next_id = { + contents: 0 +}; + +function spawn(f) { + maybe_first_spawn(undefined); + var status = { + contents: /* Running */0 + }; + var split_keys = prepare_split_keys_before_spawn(undefined); + var handle = new Promise((function (resolve, reject) { + var param = [ + split_keys, + status + ]; + var status$1 = param[1]; + perform_split_after_spawn(param[0]); + var exit = 0; + var v; + try { + v = Curry._1(f, undefined); + exit = 1; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + var bt; + status$1.contents = { + TAG: /* Error */1, + _0: exn, + _1: bt + }; + reject(exn); + } + if (exit === 1) { + status$1.contents = { + TAG: /* Return */0, + _0: v + }; + resolve(v); + } + var at_exit_callbacks = atomically(function (param) { + return at_exit_table.contents; + }); + try { + Stdlib__List.iter((function (f) { + Curry._1(f, undefined); + }), at_exit_callbacks); + return ; + } + catch (raw_exn$1){ + var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); + var match = status$1.contents; + if (typeof match === "number") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/domain.ml", + 77, + 19 + ], + Error: new Error() + }; + } + if (match.TAG !== /* Return */0) { + return ; + } + var bt$1; + status$1.contents = { + TAG: /* Error */1, + _0: exn$1, + _1: bt$1 + }; + return ; + } + })); + return { + id: (next_id.contents = next_id.contents + 1 | 0, next_id.contents), + handle: handle, + status: status + }; +} + +function join(t) { + return t.handle.then(function (param) { + var v = t.status.contents; + if (typeof v === "number") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/domain.ml", + 179, + 17 + ], + Error: new Error() + }; + } + if (v.TAG === /* Return */0) { + return Promise.resolve(v._0); + } + throw v._0; + }).catch(function (param) { + var match = t.status.contents; + if (typeof match === "number") { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/domain.ml", + 186, + 30 + ], + Error: new Error() + }; + } + if (match.TAG === /* Return */0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/domain.ml", + 186, + 30 + ], + Error: new Error() + }; + } + throw match._0; + }); +} + +var DLS = { + new_key: new_key, + get: get, + set: set +}; + +export { + spawn , + join , + get_id , + self , + before_first_spawn , + at_exit , + cpu_relax , + is_main_domain , + recommended_domain_count , + DLS , +} +/* Stdlib__Fun Not a pure module */ diff --git a/melange-node-modules/melange/either.js b/melange-node-modules/melange/either.js new file mode 100644 index 0000000..8ffbb02 --- /dev/null +++ b/melange-node-modules/melange/either.js @@ -0,0 +1,143 @@ +// Generated by Melange + +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; + +function left(v) { + return { + TAG: /* Left */0, + _0: v + }; +} + +function right(v) { + return { + TAG: /* Right */1, + _0: v + }; +} + +function is_left(param) { + if (param.TAG === /* Left */0) { + return true; + } else { + return false; + } +} + +function is_right(param) { + if (param.TAG === /* Left */0) { + return false; + } else { + return true; + } +} + +function find_left(param) { + if (param.TAG === /* Left */0) { + return Caml_option.some(param._0); + } + +} + +function find_right(param) { + if (param.TAG === /* Left */0) { + return ; + } else { + return Caml_option.some(param._0); + } +} + +function map_left(f, e) { + if (e.TAG === /* Left */0) { + return { + TAG: /* Left */0, + _0: Curry._1(f, e._0) + }; + } else { + return e; + } +} + +function map_right(f, e) { + if (e.TAG === /* Left */0) { + return e; + } else { + return { + TAG: /* Right */1, + _0: Curry._1(f, e._0) + }; + } +} + +function map(left, right, param) { + if (param.TAG === /* Left */0) { + return { + TAG: /* Left */0, + _0: Curry._1(left, param._0) + }; + } else { + return { + TAG: /* Right */1, + _0: Curry._1(right, param._0) + }; + } +} + +function fold(left, right, param) { + if (param.TAG === /* Left */0) { + return Curry._1(left, param._0); + } else { + return Curry._1(right, param._0); + } +} + +function equal(left, right, e1, e2) { + if (e1.TAG === /* Left */0) { + if (e2.TAG === /* Left */0) { + return Curry._2(left, e1._0, e2._0); + } else { + return false; + } + } else if (e2.TAG === /* Left */0) { + return false; + } else { + return Curry._2(right, e1._0, e2._0); + } +} + +function compare(left, right, e1, e2) { + if (e1.TAG === /* Left */0) { + if (e2.TAG === /* Left */0) { + return Curry._2(left, e1._0, e2._0); + } else { + return -1; + } + } else if (e2.TAG === /* Left */0) { + return 1; + } else { + return Curry._2(right, e1._0, e2._0); + } +} + +var iter = fold; + +var for_all = fold; + +export { + left , + right , + is_left , + is_right , + find_left , + find_right , + map_left , + map_right , + map , + fold , + iter , + for_all , + equal , + compare , +} +/* No side effect */ diff --git a/melange-node-modules/melange/ephemeron.js b/melange-node-modules/melange/ephemeron.js new file mode 100644 index 0000000..7ea77ca --- /dev/null +++ b/melange-node-modules/melange/ephemeron.js @@ -0,0 +1,3199 @@ +// Generated by Melange + +import * as Caml_array from "melange.js/caml_array.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as CamlinternalLazy from "./camlinternalLazy.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Array from "./array.js"; +import * as Stdlib__Hashtbl from "./hashtbl.js"; +import * as Stdlib__Int from "./int.js"; +import * as Stdlib__List from "./list.js"; +import * as Stdlib__Obj from "./obj.js"; +import * as Stdlib__Random from "./random.js"; +import * as Stdlib__Seq from "./seq.js"; +import * as Stdlib__Sys from "./sys.js"; + +function set_key(t, k) { + Stdlib__Obj.Ephemeron.set_key(t, 0, k); +} + +function check_key(t) { + return Stdlib__Obj.Ephemeron.check_key(t, 0); +} + +function get_data(t) { + return Stdlib__Obj.Ephemeron.get_data(t); +} + +function make(key, data) { + var eph = Stdlib__Obj.Ephemeron.create(1); + Stdlib__Obj.Ephemeron.set_data(eph, data); + set_key(eph, key); + return eph; +} + +function query(eph, key) { + var k = Stdlib__Obj.Ephemeron.get_key(eph, 0); + if (k !== undefined && Caml_option.valFromOption(k) === key) { + return Stdlib__Obj.Ephemeron.get_data(eph); + } + +} + +function MakeSeeded(H) { + var create = function (k, d) { + var c = Stdlib__Obj.Ephemeron.create(1); + Stdlib__Obj.Ephemeron.set_data(c, d); + set_key(c, k); + return c; + }; + var seeded_hash = H.seeded_hash; + var equal = function (c, k) { + var k$p = Stdlib__Obj.Ephemeron.get_key(c, 0); + if (k$p !== undefined) { + if (Curry._2(H.equal, k, Caml_option.valFromOption(k$p))) { + return /* ETrue */0; + } else { + return /* EFalse */1; + } + } else { + return /* EDead */2; + } + }; + var power_2_above = function (_x, n) { + while(true) { + var x = _x; + if (x >= n) { + return x; + } + if ((x << 1) > Stdlib__Sys.max_array_length) { + return x; + } + _x = (x << 1); + continue ; + }; + }; + var prng = { + LAZY_DONE: false, + VAL: (function () { + return Stdlib__Random.State.make_self_init(undefined); + }) + }; + var create$1 = function (randomOpt, initial_size) { + var random = randomOpt !== undefined ? randomOpt : Stdlib__Hashtbl.is_randomized(undefined); + var s = power_2_above(16, initial_size); + var seed = random ? Stdlib__Random.State.bits(CamlinternalLazy.force(prng)) : 0; + return { + size: 0, + data: Caml_array.make(s, /* Empty */0), + seed: seed, + initial_size: s + }; + }; + var clear = function (h) { + h.size = 0; + var len = h.data.length; + for(var i = 0; i < len; ++i){ + Caml_array.set(h.data, i, /* Empty */0); + } + }; + var reset = function (h) { + var len = h.data.length; + if (len === h.initial_size) { + return clear(h); + } else { + h.size = 0; + h.data = Caml_array.make(h.initial_size, /* Empty */0); + return ; + } + }; + var copy = function (h) { + return { + size: h.size, + data: Stdlib__Array.copy(h.data), + seed: h.seed, + initial_size: h.initial_size + }; + }; + var key_index = function (h, hkey) { + return hkey & (h.data.length - 1 | 0); + }; + var clean = function (h) { + var do_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* Empty */0; + } + if (check_key(param._1)) { + return /* Cons */{ + _0: param._0, + _1: param._1, + _2: do_bucket(param._2) + }; + } + h.size = h.size - 1 | 0; + _param = param._2; + continue ; + }; + }; + var d = h.data; + for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ + Caml_array.set(d, i, do_bucket(Caml_array.get(d, i))); + } + }; + var resize = function (h) { + var odata = h.data; + var osize = odata.length; + var nsize = (osize << 1); + clean(h); + if (!(nsize < Stdlib__Sys.max_array_length && h.size >= (osize >>> 1))) { + return ; + } + var ndata = Caml_array.make(nsize, /* Empty */0); + h.data = ndata; + var insert_bucket = function (param) { + if (!param) { + return ; + } + var hkey = param._0; + insert_bucket(param._2); + var nidx = key_index(h, hkey); + Caml_array.set(ndata, nidx, /* Cons */{ + _0: hkey, + _1: param._1, + _2: Caml_array.get(ndata, nidx) + }); + }; + for(var i = 0; i < osize; ++i){ + insert_bucket(Caml_array.get(odata, i)); + } + }; + var add = function (h, key, info) { + var hkey = Curry._2(seeded_hash, h.seed, key); + var i = key_index(h, hkey); + var container = create(key, info); + var bucket_2 = Caml_array.get(h.data, i); + var bucket = /* Cons */{ + _0: hkey, + _1: container, + _2: bucket_2 + }; + Caml_array.set(h.data, i, bucket); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(h); + } + + }; + var remove = function (h, key) { + var hkey = Curry._2(seeded_hash, h.seed, key); + var remove_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* Empty */0; + } + var hk = param._0; + if (hkey !== hk) { + return /* Cons */{ + _0: hk, + _1: param._1, + _2: remove_bucket(param._2) + }; + } + var next = param._2; + var c = param._1; + var match = equal(c, key); + switch (match) { + case /* ETrue */0 : + h.size = h.size - 1 | 0; + return next; + case /* EFalse */1 : + return /* Cons */{ + _0: hk, + _1: c, + _2: remove_bucket(next) + }; + case /* EDead */2 : + h.size = h.size - 1 | 0; + _param = next; + continue ; + + } + }; + }; + var i = key_index(h, hkey); + Caml_array.set(h.data, i, remove_bucket(Caml_array.get(h.data, i))); + }; + var find = function (h, key) { + var hkey = Curry._2(seeded_hash, h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (param) { + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data(c); + if (d !== undefined) { + return Caml_option.valFromOption(d); + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + }; + var find_opt = function (h, key) { + var hkey = Curry._2(seeded_hash, h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (!param) { + return ; + } + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data(c); + if (d !== undefined) { + return d; + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + }; + }; + var find_all = function (h, key) { + var hkey = Curry._2(seeded_hash, h.seed, key); + var find_in_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* [] */0; + } + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data(c); + if (d !== undefined) { + return { + hd: Caml_option.valFromOption(d), + tl: find_in_bucket(rest) + }; + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + }; + }; + return find_in_bucket(Caml_array.get(h.data, key_index(h, hkey))); + }; + var replace = function (h, key, info) { + var hkey = Curry._2(seeded_hash, h.seed, key); + var i = key_index(h, hkey); + var l = Caml_array.get(h.data, i); + try { + var _param = l; + while(true) { + var param = _param; + if (param) { + if (hkey === param._0) { + var c = param._1; + var match = equal(c, key); + if (!match) { + Stdlib__Obj.Ephemeron.unset_data(c); + set_key(c, key); + return Stdlib__Obj.Ephemeron.set_data(c, info); + } + _param = param._2; + continue ; + } + _param = param._2; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + var container = create(key, info); + Caml_array.set(h.data, i, /* Cons */{ + _0: hkey, + _1: container, + _2: l + }); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(h); + } else { + return ; + } + } + throw exn; + } + }; + var mem = function (h, key) { + var hkey = Curry._2(seeded_hash, h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (!param) { + return false; + } + if (param._0 === hkey) { + var match = equal(param._1, key); + if (!match) { + return true; + } + _param = param._2; + continue ; + } + _param = param._2; + continue ; + }; + }; + var length = function (h) { + return h.size; + }; + var bucket_length = function (_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + _param = param._2; + _accu = accu + 1 | 0; + continue ; + }; + }; + var stats = function (h) { + var mbl = Stdlib__Array.fold_left((function (m, b) { + return Stdlib__Int.max(m, bucket_length(0, b)); + }), 0, h.data); + var histo = Caml_array.make(mbl + 1 | 0, 0); + Stdlib__Array.iter((function (b) { + var l = bucket_length(0, b); + Caml_array.set(histo, l, Caml_array.get(histo, l) + 1 | 0); + }), h.data); + return { + num_bindings: h.size, + num_buckets: h.data.length, + max_bucket_length: mbl, + bucket_histogram: histo + }; + }; + var bucket_length_alive = function (_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + if (check_key(param._1)) { + _param = param._2; + _accu = accu + 1 | 0; + continue ; + } + _param = param._2; + continue ; + }; + }; + var stats_alive = function (h) { + var size = { + contents: 0 + }; + var mbl = Stdlib__Array.fold_left((function (m, b) { + return Stdlib__Int.max(m, bucket_length_alive(0, b)); + }), 0, h.data); + var histo = Caml_array.make(mbl + 1 | 0, 0); + Stdlib__Array.iter((function (b) { + var l = bucket_length_alive(0, b); + size.contents = size.contents + l | 0; + Caml_array.set(histo, l, Caml_array.get(histo, l) + 1 | 0); + }), h.data); + return { + num_bindings: size.contents, + num_buckets: h.data.length, + max_bucket_length: mbl, + bucket_histogram: histo + }; + }; + var add_seq = function (tbl, i) { + Stdlib__Seq.iter((function (param) { + add(tbl, param[0], param[1]); + }), i); + }; + var replace_seq = function (tbl, i) { + Stdlib__Seq.iter((function (param) { + replace(tbl, param[0], param[1]); + }), i); + }; + var of_seq = function (i) { + var tbl = create$1(undefined, 16); + replace_seq(tbl, i); + return tbl; + }; + return { + create: create$1, + clear: clear, + reset: reset, + copy: copy, + add: add, + remove: remove, + find: find, + find_opt: find_opt, + find_all: find_all, + replace: replace, + mem: mem, + length: length, + stats: stats, + add_seq: add_seq, + replace_seq: replace_seq, + of_seq: of_seq, + clean: clean, + stats_alive: stats_alive + }; +} + +function Make(H) { + var equal = H.equal; + var seeded_hash = function (_seed, x) { + return Curry._1(H.hash, x); + }; + var create = function (k, d) { + var c = Stdlib__Obj.Ephemeron.create(1); + Stdlib__Obj.Ephemeron.set_data(c, d); + set_key(c, k); + return c; + }; + var equal$1 = function (c, k) { + var k$p = Stdlib__Obj.Ephemeron.get_key(c, 0); + if (k$p !== undefined) { + if (Curry._2(equal, k, Caml_option.valFromOption(k$p))) { + return /* ETrue */0; + } else { + return /* EFalse */1; + } + } else { + return /* EDead */2; + } + }; + var power_2_above = function (_x, n) { + while(true) { + var x = _x; + if (x >= n) { + return x; + } + if ((x << 1) > Stdlib__Sys.max_array_length) { + return x; + } + _x = (x << 1); + continue ; + }; + }; + var prng = { + LAZY_DONE: false, + VAL: (function () { + return Stdlib__Random.State.make_self_init(undefined); + }) + }; + var create$1 = function (randomOpt, initial_size) { + var random = randomOpt !== undefined ? randomOpt : Stdlib__Hashtbl.is_randomized(undefined); + var s = power_2_above(16, initial_size); + var seed = random ? Stdlib__Random.State.bits(CamlinternalLazy.force(prng)) : 0; + return { + size: 0, + data: Caml_array.make(s, /* Empty */0), + seed: seed, + initial_size: s + }; + }; + var clear = function (h) { + h.size = 0; + var len = h.data.length; + for(var i = 0; i < len; ++i){ + Caml_array.set(h.data, i, /* Empty */0); + } + }; + var reset = function (h) { + var len = h.data.length; + if (len === h.initial_size) { + return clear(h); + } else { + h.size = 0; + h.data = Caml_array.make(h.initial_size, /* Empty */0); + return ; + } + }; + var copy = function (h) { + return { + size: h.size, + data: Stdlib__Array.copy(h.data), + seed: h.seed, + initial_size: h.initial_size + }; + }; + var key_index = function (h, hkey) { + return hkey & (h.data.length - 1 | 0); + }; + var clean = function (h) { + var do_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* Empty */0; + } + if (check_key(param._1)) { + return /* Cons */{ + _0: param._0, + _1: param._1, + _2: do_bucket(param._2) + }; + } + h.size = h.size - 1 | 0; + _param = param._2; + continue ; + }; + }; + var d = h.data; + for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ + Caml_array.set(d, i, do_bucket(Caml_array.get(d, i))); + } + }; + var resize = function (h) { + var odata = h.data; + var osize = odata.length; + var nsize = (osize << 1); + clean(h); + if (!(nsize < Stdlib__Sys.max_array_length && h.size >= (osize >>> 1))) { + return ; + } + var ndata = Caml_array.make(nsize, /* Empty */0); + h.data = ndata; + var insert_bucket = function (param) { + if (!param) { + return ; + } + var hkey = param._0; + insert_bucket(param._2); + var nidx = key_index(h, hkey); + Caml_array.set(ndata, nidx, /* Cons */{ + _0: hkey, + _1: param._1, + _2: Caml_array.get(ndata, nidx) + }); + }; + for(var i = 0; i < osize; ++i){ + insert_bucket(Caml_array.get(odata, i)); + } + }; + var add = function (h, key, info) { + var hkey = seeded_hash(h.seed, key); + var i = key_index(h, hkey); + var container = create(key, info); + var bucket_2 = Caml_array.get(h.data, i); + var bucket = /* Cons */{ + _0: hkey, + _1: container, + _2: bucket_2 + }; + Caml_array.set(h.data, i, bucket); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(h); + } + + }; + var remove = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var remove_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* Empty */0; + } + var hk = param._0; + if (hkey !== hk) { + return /* Cons */{ + _0: hk, + _1: param._1, + _2: remove_bucket(param._2) + }; + } + var next = param._2; + var c = param._1; + var match = equal$1(c, key); + switch (match) { + case /* ETrue */0 : + h.size = h.size - 1 | 0; + return next; + case /* EFalse */1 : + return /* Cons */{ + _0: hk, + _1: c, + _2: remove_bucket(next) + }; + case /* EDead */2 : + h.size = h.size - 1 | 0; + _param = next; + continue ; + + } + }; + }; + var i = key_index(h, hkey); + Caml_array.set(h.data, i, remove_bucket(Caml_array.get(h.data, i))); + }; + var find = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (param) { + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal$1(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data(c); + if (d !== undefined) { + return Caml_option.valFromOption(d); + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + }; + var find_opt = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (!param) { + return ; + } + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal$1(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data(c); + if (d !== undefined) { + return d; + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + }; + }; + var find_all = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var find_in_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* [] */0; + } + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal$1(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data(c); + if (d !== undefined) { + return { + hd: Caml_option.valFromOption(d), + tl: find_in_bucket(rest) + }; + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + }; + }; + return find_in_bucket(Caml_array.get(h.data, key_index(h, hkey))); + }; + var replace = function (h, key, info) { + var hkey = seeded_hash(h.seed, key); + var i = key_index(h, hkey); + var l = Caml_array.get(h.data, i); + try { + var _param = l; + while(true) { + var param = _param; + if (param) { + if (hkey === param._0) { + var c = param._1; + var match = equal$1(c, key); + if (!match) { + Stdlib__Obj.Ephemeron.unset_data(c); + set_key(c, key); + return Stdlib__Obj.Ephemeron.set_data(c, info); + } + _param = param._2; + continue ; + } + _param = param._2; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + var container = create(key, info); + Caml_array.set(h.data, i, /* Cons */{ + _0: hkey, + _1: container, + _2: l + }); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(h); + } else { + return ; + } + } + throw exn; + } + }; + var mem = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (!param) { + return false; + } + if (param._0 === hkey) { + var match = equal$1(param._1, key); + if (!match) { + return true; + } + _param = param._2; + continue ; + } + _param = param._2; + continue ; + }; + }; + var length = function (h) { + return h.size; + }; + var bucket_length = function (_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + _param = param._2; + _accu = accu + 1 | 0; + continue ; + }; + }; + var stats = function (h) { + var mbl = Stdlib__Array.fold_left((function (m, b) { + return Stdlib__Int.max(m, bucket_length(0, b)); + }), 0, h.data); + var histo = Caml_array.make(mbl + 1 | 0, 0); + Stdlib__Array.iter((function (b) { + var l = bucket_length(0, b); + Caml_array.set(histo, l, Caml_array.get(histo, l) + 1 | 0); + }), h.data); + return { + num_bindings: h.size, + num_buckets: h.data.length, + max_bucket_length: mbl, + bucket_histogram: histo + }; + }; + var bucket_length_alive = function (_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + if (check_key(param._1)) { + _param = param._2; + _accu = accu + 1 | 0; + continue ; + } + _param = param._2; + continue ; + }; + }; + var stats_alive = function (h) { + var size = { + contents: 0 + }; + var mbl = Stdlib__Array.fold_left((function (m, b) { + return Stdlib__Int.max(m, bucket_length_alive(0, b)); + }), 0, h.data); + var histo = Caml_array.make(mbl + 1 | 0, 0); + Stdlib__Array.iter((function (b) { + var l = bucket_length_alive(0, b); + size.contents = size.contents + l | 0; + Caml_array.set(histo, l, Caml_array.get(histo, l) + 1 | 0); + }), h.data); + return { + num_bindings: size.contents, + num_buckets: h.data.length, + max_bucket_length: mbl, + bucket_histogram: histo + }; + }; + var add_seq = function (tbl, i) { + Stdlib__Seq.iter((function (param) { + add(tbl, param[0], param[1]); + }), i); + }; + var replace_seq = function (tbl, i) { + Stdlib__Seq.iter((function (param) { + replace(tbl, param[0], param[1]); + }), i); + }; + var create$2 = function (sz) { + return create$1(false, sz); + }; + var of_seq = function (i) { + var tbl = create$1(false, 16); + replace_seq(tbl, i); + return tbl; + }; + return { + create: create$2, + clear: clear, + reset: reset, + copy: copy, + add: add, + remove: remove, + find: find, + find_opt: find_opt, + find_all: find_all, + replace: replace, + mem: mem, + length: length, + stats: stats, + add_seq: add_seq, + replace_seq: replace_seq, + of_seq: of_seq, + clean: clean, + stats_alive: stats_alive + }; +} + +function make$1(param) { + return { + contents: /* [] */0 + }; +} + +function add(b, k, d) { + b.contents = { + hd: make(k, d), + tl: b.contents + }; +} + +function test_key(k, e) { + var x = Stdlib__Obj.Ephemeron.get_key(e, 0); + if (x !== undefined) { + return Caml_option.valFromOption(x) === k; + } else { + return false; + } +} + +function remove(b, k) { + var _l = b.contents; + var _acc = /* [] */0; + while(true) { + var acc = _acc; + var l = _l; + if (!l) { + return ; + } + var h = l.hd; + if (test_key(k, h)) { + b.contents = Stdlib__List.rev_append(acc, l.tl); + return ; + } + _acc = { + hd: h, + tl: acc + }; + _l = l.tl; + continue ; + }; +} + +function find(b, k) { + var e = Stdlib__List.find_opt((function (param) { + return test_key(k, param); + }), b.contents); + if (e !== undefined) { + return Stdlib__Obj.Ephemeron.get_data(Caml_option.valFromOption(e)); + } + +} + +function length(b) { + return Stdlib__List.length(b.contents); +} + +function clear(b) { + b.contents = /* [] */0; +} + +function set_key1(t, k) { + Stdlib__Obj.Ephemeron.set_key(t, 0, k); +} + +function set_key2(t, k) { + Stdlib__Obj.Ephemeron.set_key(t, 1, k); +} + +function get_data$1(t) { + return Stdlib__Obj.Ephemeron.get_data(t); +} + +function make$2(key1, key2, data) { + var eph = Stdlib__Obj.Ephemeron.create(2); + Stdlib__Obj.Ephemeron.set_data(eph, data); + set_key1(eph, key1); + set_key2(eph, key2); + return eph; +} + +function query$1(eph, key1, key2) { + var k = Stdlib__Obj.Ephemeron.get_key(eph, 0); + if (k === undefined) { + return ; + } + if (Caml_option.valFromOption(k) !== key1) { + return ; + } + var k$1 = Stdlib__Obj.Ephemeron.get_key(eph, 1); + if (k$1 !== undefined && Caml_option.valFromOption(k$1) === key2) { + return Stdlib__Obj.Ephemeron.get_data(eph); + } + +} + +function MakeSeeded$1(H1, H2) { + var create = function (param, d) { + var c = Stdlib__Obj.Ephemeron.create(2); + Stdlib__Obj.Ephemeron.set_data(c, d); + set_key1(c, param[0]); + set_key2(c, param[1]); + return c; + }; + var seeded_hash = function (seed, param) { + return Curry._2(H1.seeded_hash, seed, param[0]) + Math.imul(Curry._2(H2.seeded_hash, seed, param[1]), 65599) | 0; + }; + var equal = function (c, param) { + var match = Stdlib__Obj.Ephemeron.get_key(c, 0); + var match$1 = Stdlib__Obj.Ephemeron.get_key(c, 1); + if (match !== undefined && match$1 !== undefined) { + if (Curry._2(H1.equal, param[0], Caml_option.valFromOption(match)) && Curry._2(H2.equal, param[1], Caml_option.valFromOption(match$1))) { + return /* ETrue */0; + } else { + return /* EFalse */1; + } + } else { + return /* EDead */2; + } + }; + var check_key = function (c) { + if (Stdlib__Obj.Ephemeron.check_key(c, 0)) { + return Stdlib__Obj.Ephemeron.check_key(c, 1); + } else { + return false; + } + }; + var power_2_above = function (_x, n) { + while(true) { + var x = _x; + if (x >= n) { + return x; + } + if ((x << 1) > Stdlib__Sys.max_array_length) { + return x; + } + _x = (x << 1); + continue ; + }; + }; + var prng = { + LAZY_DONE: false, + VAL: (function () { + return Stdlib__Random.State.make_self_init(undefined); + }) + }; + var create$1 = function (randomOpt, initial_size) { + var random = randomOpt !== undefined ? randomOpt : Stdlib__Hashtbl.is_randomized(undefined); + var s = power_2_above(16, initial_size); + var seed = random ? Stdlib__Random.State.bits(CamlinternalLazy.force(prng)) : 0; + return { + size: 0, + data: Caml_array.make(s, /* Empty */0), + seed: seed, + initial_size: s + }; + }; + var clear = function (h) { + h.size = 0; + var len = h.data.length; + for(var i = 0; i < len; ++i){ + Caml_array.set(h.data, i, /* Empty */0); + } + }; + var reset = function (h) { + var len = h.data.length; + if (len === h.initial_size) { + return clear(h); + } else { + h.size = 0; + h.data = Caml_array.make(h.initial_size, /* Empty */0); + return ; + } + }; + var copy = function (h) { + return { + size: h.size, + data: Stdlib__Array.copy(h.data), + seed: h.seed, + initial_size: h.initial_size + }; + }; + var key_index = function (h, hkey) { + return hkey & (h.data.length - 1 | 0); + }; + var clean = function (h) { + var do_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* Empty */0; + } + if (check_key(param._1)) { + return /* Cons */{ + _0: param._0, + _1: param._1, + _2: do_bucket(param._2) + }; + } + h.size = h.size - 1 | 0; + _param = param._2; + continue ; + }; + }; + var d = h.data; + for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ + Caml_array.set(d, i, do_bucket(Caml_array.get(d, i))); + } + }; + var resize = function (h) { + var odata = h.data; + var osize = odata.length; + var nsize = (osize << 1); + clean(h); + if (!(nsize < Stdlib__Sys.max_array_length && h.size >= (osize >>> 1))) { + return ; + } + var ndata = Caml_array.make(nsize, /* Empty */0); + h.data = ndata; + var insert_bucket = function (param) { + if (!param) { + return ; + } + var hkey = param._0; + insert_bucket(param._2); + var nidx = key_index(h, hkey); + Caml_array.set(ndata, nidx, /* Cons */{ + _0: hkey, + _1: param._1, + _2: Caml_array.get(ndata, nidx) + }); + }; + for(var i = 0; i < osize; ++i){ + insert_bucket(Caml_array.get(odata, i)); + } + }; + var add = function (h, key, info) { + var hkey = seeded_hash(h.seed, key); + var i = key_index(h, hkey); + var container = create(key, info); + var bucket_2 = Caml_array.get(h.data, i); + var bucket = /* Cons */{ + _0: hkey, + _1: container, + _2: bucket_2 + }; + Caml_array.set(h.data, i, bucket); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(h); + } + + }; + var remove = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var remove_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* Empty */0; + } + var hk = param._0; + if (hkey !== hk) { + return /* Cons */{ + _0: hk, + _1: param._1, + _2: remove_bucket(param._2) + }; + } + var next = param._2; + var c = param._1; + var match = equal(c, key); + switch (match) { + case /* ETrue */0 : + h.size = h.size - 1 | 0; + return next; + case /* EFalse */1 : + return /* Cons */{ + _0: hk, + _1: c, + _2: remove_bucket(next) + }; + case /* EDead */2 : + h.size = h.size - 1 | 0; + _param = next; + continue ; + + } + }; + }; + var i = key_index(h, hkey); + Caml_array.set(h.data, i, remove_bucket(Caml_array.get(h.data, i))); + }; + var find = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (param) { + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data$1(c); + if (d !== undefined) { + return Caml_option.valFromOption(d); + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + }; + var find_opt = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (!param) { + return ; + } + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data$1(c); + if (d !== undefined) { + return d; + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + }; + }; + var find_all = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var find_in_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* [] */0; + } + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data$1(c); + if (d !== undefined) { + return { + hd: Caml_option.valFromOption(d), + tl: find_in_bucket(rest) + }; + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + }; + }; + return find_in_bucket(Caml_array.get(h.data, key_index(h, hkey))); + }; + var replace = function (h, key, info) { + var hkey = seeded_hash(h.seed, key); + var i = key_index(h, hkey); + var l = Caml_array.get(h.data, i); + try { + var _param = l; + while(true) { + var param = _param; + if (param) { + if (hkey === param._0) { + var c = param._1; + var match = equal(c, key); + if (!match) { + Stdlib__Obj.Ephemeron.unset_data(c); + set_key1(c, key[0]); + set_key2(c, key[1]); + return Stdlib__Obj.Ephemeron.set_data(c, info); + } + _param = param._2; + continue ; + } + _param = param._2; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + var container = create(key, info); + Caml_array.set(h.data, i, /* Cons */{ + _0: hkey, + _1: container, + _2: l + }); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(h); + } else { + return ; + } + } + throw exn; + } + }; + var mem = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (!param) { + return false; + } + if (param._0 === hkey) { + var match = equal(param._1, key); + if (!match) { + return true; + } + _param = param._2; + continue ; + } + _param = param._2; + continue ; + }; + }; + var length = function (h) { + return h.size; + }; + var bucket_length = function (_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + _param = param._2; + _accu = accu + 1 | 0; + continue ; + }; + }; + var stats = function (h) { + var mbl = Stdlib__Array.fold_left((function (m, b) { + return Stdlib__Int.max(m, bucket_length(0, b)); + }), 0, h.data); + var histo = Caml_array.make(mbl + 1 | 0, 0); + Stdlib__Array.iter((function (b) { + var l = bucket_length(0, b); + Caml_array.set(histo, l, Caml_array.get(histo, l) + 1 | 0); + }), h.data); + return { + num_bindings: h.size, + num_buckets: h.data.length, + max_bucket_length: mbl, + bucket_histogram: histo + }; + }; + var bucket_length_alive = function (_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + if (check_key(param._1)) { + _param = param._2; + _accu = accu + 1 | 0; + continue ; + } + _param = param._2; + continue ; + }; + }; + var stats_alive = function (h) { + var size = { + contents: 0 + }; + var mbl = Stdlib__Array.fold_left((function (m, b) { + return Stdlib__Int.max(m, bucket_length_alive(0, b)); + }), 0, h.data); + var histo = Caml_array.make(mbl + 1 | 0, 0); + Stdlib__Array.iter((function (b) { + var l = bucket_length_alive(0, b); + size.contents = size.contents + l | 0; + Caml_array.set(histo, l, Caml_array.get(histo, l) + 1 | 0); + }), h.data); + return { + num_bindings: size.contents, + num_buckets: h.data.length, + max_bucket_length: mbl, + bucket_histogram: histo + }; + }; + var add_seq = function (tbl, i) { + Stdlib__Seq.iter((function (param) { + add(tbl, param[0], param[1]); + }), i); + }; + var replace_seq = function (tbl, i) { + Stdlib__Seq.iter((function (param) { + replace(tbl, param[0], param[1]); + }), i); + }; + var of_seq = function (i) { + var tbl = create$1(undefined, 16); + replace_seq(tbl, i); + return tbl; + }; + return { + create: create$1, + clear: clear, + reset: reset, + copy: copy, + add: add, + remove: remove, + find: find, + find_opt: find_opt, + find_all: find_all, + replace: replace, + mem: mem, + length: length, + stats: stats, + add_seq: add_seq, + replace_seq: replace_seq, + of_seq: of_seq, + clean: clean, + stats_alive: stats_alive + }; +} + +function Make$1(H1, H2) { + var equal = H2.equal; + var equal$1 = H1.equal; + var create = function (param, d) { + var c = Stdlib__Obj.Ephemeron.create(2); + Stdlib__Obj.Ephemeron.set_data(c, d); + set_key1(c, param[0]); + set_key2(c, param[1]); + return c; + }; + var seeded_hash = function (seed, param) { + return Curry._1(H1.hash, param[0]) + Math.imul(Curry._1(H2.hash, param[1]), 65599) | 0; + }; + var equal$2 = function (c, param) { + var match = Stdlib__Obj.Ephemeron.get_key(c, 0); + var match$1 = Stdlib__Obj.Ephemeron.get_key(c, 1); + if (match !== undefined && match$1 !== undefined) { + if (Curry._2(equal$1, param[0], Caml_option.valFromOption(match)) && Curry._2(equal, param[1], Caml_option.valFromOption(match$1))) { + return /* ETrue */0; + } else { + return /* EFalse */1; + } + } else { + return /* EDead */2; + } + }; + var check_key = function (c) { + if (Stdlib__Obj.Ephemeron.check_key(c, 0)) { + return Stdlib__Obj.Ephemeron.check_key(c, 1); + } else { + return false; + } + }; + var power_2_above = function (_x, n) { + while(true) { + var x = _x; + if (x >= n) { + return x; + } + if ((x << 1) > Stdlib__Sys.max_array_length) { + return x; + } + _x = (x << 1); + continue ; + }; + }; + var prng = { + LAZY_DONE: false, + VAL: (function () { + return Stdlib__Random.State.make_self_init(undefined); + }) + }; + var create$1 = function (randomOpt, initial_size) { + var random = randomOpt !== undefined ? randomOpt : Stdlib__Hashtbl.is_randomized(undefined); + var s = power_2_above(16, initial_size); + var seed = random ? Stdlib__Random.State.bits(CamlinternalLazy.force(prng)) : 0; + return { + size: 0, + data: Caml_array.make(s, /* Empty */0), + seed: seed, + initial_size: s + }; + }; + var clear = function (h) { + h.size = 0; + var len = h.data.length; + for(var i = 0; i < len; ++i){ + Caml_array.set(h.data, i, /* Empty */0); + } + }; + var reset = function (h) { + var len = h.data.length; + if (len === h.initial_size) { + return clear(h); + } else { + h.size = 0; + h.data = Caml_array.make(h.initial_size, /* Empty */0); + return ; + } + }; + var copy = function (h) { + return { + size: h.size, + data: Stdlib__Array.copy(h.data), + seed: h.seed, + initial_size: h.initial_size + }; + }; + var key_index = function (h, hkey) { + return hkey & (h.data.length - 1 | 0); + }; + var clean = function (h) { + var do_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* Empty */0; + } + if (check_key(param._1)) { + return /* Cons */{ + _0: param._0, + _1: param._1, + _2: do_bucket(param._2) + }; + } + h.size = h.size - 1 | 0; + _param = param._2; + continue ; + }; + }; + var d = h.data; + for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ + Caml_array.set(d, i, do_bucket(Caml_array.get(d, i))); + } + }; + var resize = function (h) { + var odata = h.data; + var osize = odata.length; + var nsize = (osize << 1); + clean(h); + if (!(nsize < Stdlib__Sys.max_array_length && h.size >= (osize >>> 1))) { + return ; + } + var ndata = Caml_array.make(nsize, /* Empty */0); + h.data = ndata; + var insert_bucket = function (param) { + if (!param) { + return ; + } + var hkey = param._0; + insert_bucket(param._2); + var nidx = key_index(h, hkey); + Caml_array.set(ndata, nidx, /* Cons */{ + _0: hkey, + _1: param._1, + _2: Caml_array.get(ndata, nidx) + }); + }; + for(var i = 0; i < osize; ++i){ + insert_bucket(Caml_array.get(odata, i)); + } + }; + var add = function (h, key, info) { + var hkey = seeded_hash(h.seed, key); + var i = key_index(h, hkey); + var container = create(key, info); + var bucket_2 = Caml_array.get(h.data, i); + var bucket = /* Cons */{ + _0: hkey, + _1: container, + _2: bucket_2 + }; + Caml_array.set(h.data, i, bucket); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(h); + } + + }; + var remove = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var remove_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* Empty */0; + } + var hk = param._0; + if (hkey !== hk) { + return /* Cons */{ + _0: hk, + _1: param._1, + _2: remove_bucket(param._2) + }; + } + var next = param._2; + var c = param._1; + var match = equal$2(c, key); + switch (match) { + case /* ETrue */0 : + h.size = h.size - 1 | 0; + return next; + case /* EFalse */1 : + return /* Cons */{ + _0: hk, + _1: c, + _2: remove_bucket(next) + }; + case /* EDead */2 : + h.size = h.size - 1 | 0; + _param = next; + continue ; + + } + }; + }; + var i = key_index(h, hkey); + Caml_array.set(h.data, i, remove_bucket(Caml_array.get(h.data, i))); + }; + var find = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (param) { + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal$2(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data$1(c); + if (d !== undefined) { + return Caml_option.valFromOption(d); + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + }; + var find_opt = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (!param) { + return ; + } + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal$2(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data$1(c); + if (d !== undefined) { + return d; + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + }; + }; + var find_all = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var find_in_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* [] */0; + } + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal$2(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data$1(c); + if (d !== undefined) { + return { + hd: Caml_option.valFromOption(d), + tl: find_in_bucket(rest) + }; + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + }; + }; + return find_in_bucket(Caml_array.get(h.data, key_index(h, hkey))); + }; + var replace = function (h, key, info) { + var hkey = seeded_hash(h.seed, key); + var i = key_index(h, hkey); + var l = Caml_array.get(h.data, i); + try { + var _param = l; + while(true) { + var param = _param; + if (param) { + if (hkey === param._0) { + var c = param._1; + var match = equal$2(c, key); + if (!match) { + Stdlib__Obj.Ephemeron.unset_data(c); + set_key1(c, key[0]); + set_key2(c, key[1]); + return Stdlib__Obj.Ephemeron.set_data(c, info); + } + _param = param._2; + continue ; + } + _param = param._2; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + var container = create(key, info); + Caml_array.set(h.data, i, /* Cons */{ + _0: hkey, + _1: container, + _2: l + }); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(h); + } else { + return ; + } + } + throw exn; + } + }; + var mem = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (!param) { + return false; + } + if (param._0 === hkey) { + var match = equal$2(param._1, key); + if (!match) { + return true; + } + _param = param._2; + continue ; + } + _param = param._2; + continue ; + }; + }; + var length = function (h) { + return h.size; + }; + var bucket_length = function (_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + _param = param._2; + _accu = accu + 1 | 0; + continue ; + }; + }; + var stats = function (h) { + var mbl = Stdlib__Array.fold_left((function (m, b) { + return Stdlib__Int.max(m, bucket_length(0, b)); + }), 0, h.data); + var histo = Caml_array.make(mbl + 1 | 0, 0); + Stdlib__Array.iter((function (b) { + var l = bucket_length(0, b); + Caml_array.set(histo, l, Caml_array.get(histo, l) + 1 | 0); + }), h.data); + return { + num_bindings: h.size, + num_buckets: h.data.length, + max_bucket_length: mbl, + bucket_histogram: histo + }; + }; + var bucket_length_alive = function (_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + if (check_key(param._1)) { + _param = param._2; + _accu = accu + 1 | 0; + continue ; + } + _param = param._2; + continue ; + }; + }; + var stats_alive = function (h) { + var size = { + contents: 0 + }; + var mbl = Stdlib__Array.fold_left((function (m, b) { + return Stdlib__Int.max(m, bucket_length_alive(0, b)); + }), 0, h.data); + var histo = Caml_array.make(mbl + 1 | 0, 0); + Stdlib__Array.iter((function (b) { + var l = bucket_length_alive(0, b); + size.contents = size.contents + l | 0; + Caml_array.set(histo, l, Caml_array.get(histo, l) + 1 | 0); + }), h.data); + return { + num_bindings: size.contents, + num_buckets: h.data.length, + max_bucket_length: mbl, + bucket_histogram: histo + }; + }; + var add_seq = function (tbl, i) { + Stdlib__Seq.iter((function (param) { + add(tbl, param[0], param[1]); + }), i); + }; + var replace_seq = function (tbl, i) { + Stdlib__Seq.iter((function (param) { + replace(tbl, param[0], param[1]); + }), i); + }; + var create$2 = function (sz) { + return create$1(false, sz); + }; + var of_seq = function (i) { + var tbl = create$1(false, 16); + replace_seq(tbl, i); + return tbl; + }; + return { + create: create$2, + clear: clear, + reset: reset, + copy: copy, + add: add, + remove: remove, + find: find, + find_opt: find_opt, + find_all: find_all, + replace: replace, + mem: mem, + length: length, + stats: stats, + add_seq: add_seq, + replace_seq: replace_seq, + of_seq: of_seq, + clean: clean, + stats_alive: stats_alive + }; +} + +function make$3(param) { + return { + contents: /* [] */0 + }; +} + +function add$1(b, k1, k2, d) { + b.contents = { + hd: make$2(k1, k2, d), + tl: b.contents + }; +} + +function test_keys(k1, k2, e) { + var match = Stdlib__Obj.Ephemeron.get_key(e, 0); + var match$1 = Stdlib__Obj.Ephemeron.get_key(e, 1); + if (match !== undefined && match$1 !== undefined && Caml_option.valFromOption(match) === k1) { + return Caml_option.valFromOption(match$1) === k2; + } else { + return false; + } +} + +function remove$1(b, k1, k2) { + var _l = b.contents; + var _acc = /* [] */0; + while(true) { + var acc = _acc; + var l = _l; + if (!l) { + return ; + } + var h = l.hd; + if (test_keys(k1, k2, h)) { + b.contents = Stdlib__List.rev_append(acc, l.tl); + return ; + } + _acc = { + hd: h, + tl: acc + }; + _l = l.tl; + continue ; + }; +} + +function find$1(b, k1, k2) { + var e = Stdlib__List.find_opt((function (param) { + return test_keys(k1, k2, param); + }), b.contents); + if (e !== undefined) { + return Stdlib__Obj.Ephemeron.get_data(Caml_option.valFromOption(e)); + } + +} + +function length$1(b) { + return Stdlib__List.length(b.contents); +} + +function clear$1(b) { + b.contents = /* [] */0; +} + +function set_key$1(t, n, k) { + Stdlib__Obj.Ephemeron.set_key(t, n, k); +} + +function get_data$2(t) { + return Stdlib__Obj.Ephemeron.get_data(t); +} + +function make$4(keys, data) { + var l = keys.length; + var eph = Stdlib__Obj.Ephemeron.create(l); + Stdlib__Obj.Ephemeron.set_data(eph, data); + for(var i = 0; i < l; ++i){ + set_key$1(eph, i, Caml_array.get(keys, i)); + } + return eph; +} + +function query$2(eph, keys) { + var l = Stdlib__Obj.Ephemeron.length(eph); + try { + if (l !== keys.length) { + throw { + RE_EXN_ID: Stdlib.Exit, + Error: new Error() + }; + } + for(var i = 0; i < l; ++i){ + var k = Stdlib__Obj.Ephemeron.get_key(eph, i); + if (k !== undefined) { + if (Caml_option.valFromOption(k) !== Caml_array.get(keys, i)) { + throw { + RE_EXN_ID: Stdlib.Exit, + Error: new Error() + }; + } + + } else { + throw { + RE_EXN_ID: Stdlib.Exit, + Error: new Error() + }; + } + } + return Stdlib__Obj.Ephemeron.get_data(eph); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Exit) { + return ; + } + throw exn; + } +} + +function MakeSeeded$2(H) { + var create = function (k, d) { + var c = Stdlib__Obj.Ephemeron.create(k.length); + Stdlib__Obj.Ephemeron.set_data(c, d); + for(var i = 0 ,i_finish = k.length; i < i_finish; ++i){ + set_key$1(c, i, Caml_array.get(k, i)); + } + return c; + }; + var seeded_hash = function (seed, k) { + var h = 0; + for(var i = 0 ,i_finish = k.length; i < i_finish; ++i){ + h = Math.imul(Curry._2(H.seeded_hash, seed, Caml_array.get(k, i)), 65599) + h | 0; + } + return h; + }; + var equal = function (c, k) { + var len = k.length; + var len$p = Stdlib__Obj.Ephemeron.length(c); + if (len !== len$p) { + return /* EFalse */1; + } + var _i = len - 1 | 0; + while(true) { + var i = _i; + if (i < 0) { + return /* ETrue */0; + } + var ki = Stdlib__Obj.Ephemeron.get_key(c, i); + if (ki === undefined) { + return /* EDead */2; + } + if (!Curry._2(H.equal, Caml_array.get(k, i), Caml_option.valFromOption(ki))) { + return /* EFalse */1; + } + _i = i - 1 | 0; + continue ; + }; + }; + var check_key = function (c) { + var _i = Stdlib__Obj.Ephemeron.length(c) - 1 | 0; + while(true) { + var i = _i; + if (i < 0) { + return true; + } + if (!Stdlib__Obj.Ephemeron.check_key(c, i)) { + return false; + } + _i = i - 1 | 0; + continue ; + }; + }; + var power_2_above = function (_x, n) { + while(true) { + var x = _x; + if (x >= n) { + return x; + } + if ((x << 1) > Stdlib__Sys.max_array_length) { + return x; + } + _x = (x << 1); + continue ; + }; + }; + var prng = { + LAZY_DONE: false, + VAL: (function () { + return Stdlib__Random.State.make_self_init(undefined); + }) + }; + var create$1 = function (randomOpt, initial_size) { + var random = randomOpt !== undefined ? randomOpt : Stdlib__Hashtbl.is_randomized(undefined); + var s = power_2_above(16, initial_size); + var seed = random ? Stdlib__Random.State.bits(CamlinternalLazy.force(prng)) : 0; + return { + size: 0, + data: Caml_array.make(s, /* Empty */0), + seed: seed, + initial_size: s + }; + }; + var clear = function (h) { + h.size = 0; + var len = h.data.length; + for(var i = 0; i < len; ++i){ + Caml_array.set(h.data, i, /* Empty */0); + } + }; + var reset = function (h) { + var len = h.data.length; + if (len === h.initial_size) { + return clear(h); + } else { + h.size = 0; + h.data = Caml_array.make(h.initial_size, /* Empty */0); + return ; + } + }; + var copy = function (h) { + return { + size: h.size, + data: Stdlib__Array.copy(h.data), + seed: h.seed, + initial_size: h.initial_size + }; + }; + var key_index = function (h, hkey) { + return hkey & (h.data.length - 1 | 0); + }; + var clean = function (h) { + var do_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* Empty */0; + } + if (check_key(param._1)) { + return /* Cons */{ + _0: param._0, + _1: param._1, + _2: do_bucket(param._2) + }; + } + h.size = h.size - 1 | 0; + _param = param._2; + continue ; + }; + }; + var d = h.data; + for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ + Caml_array.set(d, i, do_bucket(Caml_array.get(d, i))); + } + }; + var resize = function (h) { + var odata = h.data; + var osize = odata.length; + var nsize = (osize << 1); + clean(h); + if (!(nsize < Stdlib__Sys.max_array_length && h.size >= (osize >>> 1))) { + return ; + } + var ndata = Caml_array.make(nsize, /* Empty */0); + h.data = ndata; + var insert_bucket = function (param) { + if (!param) { + return ; + } + var hkey = param._0; + insert_bucket(param._2); + var nidx = key_index(h, hkey); + Caml_array.set(ndata, nidx, /* Cons */{ + _0: hkey, + _1: param._1, + _2: Caml_array.get(ndata, nidx) + }); + }; + for(var i = 0; i < osize; ++i){ + insert_bucket(Caml_array.get(odata, i)); + } + }; + var add = function (h, key, info) { + var hkey = seeded_hash(h.seed, key); + var i = key_index(h, hkey); + var container = create(key, info); + var bucket_2 = Caml_array.get(h.data, i); + var bucket = /* Cons */{ + _0: hkey, + _1: container, + _2: bucket_2 + }; + Caml_array.set(h.data, i, bucket); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(h); + } + + }; + var remove = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var remove_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* Empty */0; + } + var hk = param._0; + if (hkey !== hk) { + return /* Cons */{ + _0: hk, + _1: param._1, + _2: remove_bucket(param._2) + }; + } + var next = param._2; + var c = param._1; + var match = equal(c, key); + switch (match) { + case /* ETrue */0 : + h.size = h.size - 1 | 0; + return next; + case /* EFalse */1 : + return /* Cons */{ + _0: hk, + _1: c, + _2: remove_bucket(next) + }; + case /* EDead */2 : + h.size = h.size - 1 | 0; + _param = next; + continue ; + + } + }; + }; + var i = key_index(h, hkey); + Caml_array.set(h.data, i, remove_bucket(Caml_array.get(h.data, i))); + }; + var find = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (param) { + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data$2(c); + if (d !== undefined) { + return Caml_option.valFromOption(d); + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + }; + var find_opt = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (!param) { + return ; + } + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data$2(c); + if (d !== undefined) { + return d; + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + }; + }; + var find_all = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var find_in_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* [] */0; + } + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data$2(c); + if (d !== undefined) { + return { + hd: Caml_option.valFromOption(d), + tl: find_in_bucket(rest) + }; + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + }; + }; + return find_in_bucket(Caml_array.get(h.data, key_index(h, hkey))); + }; + var replace = function (h, key, info) { + var hkey = seeded_hash(h.seed, key); + var i = key_index(h, hkey); + var l = Caml_array.get(h.data, i); + try { + var _param = l; + while(true) { + var param = _param; + if (param) { + if (hkey === param._0) { + var c = param._1; + var match = equal(c, key); + if (!match) { + Stdlib__Obj.Ephemeron.unset_data(c); + for(var i$1 = 0 ,i_finish = key.length; i$1 < i_finish; ++i$1){ + set_key$1(c, i$1, Caml_array.get(key, i$1)); + } + return Stdlib__Obj.Ephemeron.set_data(c, info); + } + _param = param._2; + continue ; + } + _param = param._2; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + var container = create(key, info); + Caml_array.set(h.data, i, /* Cons */{ + _0: hkey, + _1: container, + _2: l + }); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(h); + } else { + return ; + } + } + throw exn; + } + }; + var mem = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (!param) { + return false; + } + if (param._0 === hkey) { + var match = equal(param._1, key); + if (!match) { + return true; + } + _param = param._2; + continue ; + } + _param = param._2; + continue ; + }; + }; + var length = function (h) { + return h.size; + }; + var bucket_length = function (_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + _param = param._2; + _accu = accu + 1 | 0; + continue ; + }; + }; + var stats = function (h) { + var mbl = Stdlib__Array.fold_left((function (m, b) { + return Stdlib__Int.max(m, bucket_length(0, b)); + }), 0, h.data); + var histo = Caml_array.make(mbl + 1 | 0, 0); + Stdlib__Array.iter((function (b) { + var l = bucket_length(0, b); + Caml_array.set(histo, l, Caml_array.get(histo, l) + 1 | 0); + }), h.data); + return { + num_bindings: h.size, + num_buckets: h.data.length, + max_bucket_length: mbl, + bucket_histogram: histo + }; + }; + var bucket_length_alive = function (_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + if (check_key(param._1)) { + _param = param._2; + _accu = accu + 1 | 0; + continue ; + } + _param = param._2; + continue ; + }; + }; + var stats_alive = function (h) { + var size = { + contents: 0 + }; + var mbl = Stdlib__Array.fold_left((function (m, b) { + return Stdlib__Int.max(m, bucket_length_alive(0, b)); + }), 0, h.data); + var histo = Caml_array.make(mbl + 1 | 0, 0); + Stdlib__Array.iter((function (b) { + var l = bucket_length_alive(0, b); + size.contents = size.contents + l | 0; + Caml_array.set(histo, l, Caml_array.get(histo, l) + 1 | 0); + }), h.data); + return { + num_bindings: size.contents, + num_buckets: h.data.length, + max_bucket_length: mbl, + bucket_histogram: histo + }; + }; + var add_seq = function (tbl, i) { + Stdlib__Seq.iter((function (param) { + add(tbl, param[0], param[1]); + }), i); + }; + var replace_seq = function (tbl, i) { + Stdlib__Seq.iter((function (param) { + replace(tbl, param[0], param[1]); + }), i); + }; + var of_seq = function (i) { + var tbl = create$1(undefined, 16); + replace_seq(tbl, i); + return tbl; + }; + return { + create: create$1, + clear: clear, + reset: reset, + copy: copy, + add: add, + remove: remove, + find: find, + find_opt: find_opt, + find_all: find_all, + replace: replace, + mem: mem, + length: length, + stats: stats, + add_seq: add_seq, + replace_seq: replace_seq, + of_seq: of_seq, + clean: clean, + stats_alive: stats_alive + }; +} + +function Make$2(H) { + var equal = H.equal; + var create = function (k, d) { + var c = Stdlib__Obj.Ephemeron.create(k.length); + Stdlib__Obj.Ephemeron.set_data(c, d); + for(var i = 0 ,i_finish = k.length; i < i_finish; ++i){ + set_key$1(c, i, Caml_array.get(k, i)); + } + return c; + }; + var seeded_hash = function (seed, k) { + var h = 0; + for(var i = 0 ,i_finish = k.length; i < i_finish; ++i){ + h = Math.imul(Curry._1(H.hash, Caml_array.get(k, i)), 65599) + h | 0; + } + return h; + }; + var equal$1 = function (c, k) { + var len = k.length; + var len$p = Stdlib__Obj.Ephemeron.length(c); + if (len !== len$p) { + return /* EFalse */1; + } + var _i = len - 1 | 0; + while(true) { + var i = _i; + if (i < 0) { + return /* ETrue */0; + } + var ki = Stdlib__Obj.Ephemeron.get_key(c, i); + if (ki === undefined) { + return /* EDead */2; + } + if (!Curry._2(equal, Caml_array.get(k, i), Caml_option.valFromOption(ki))) { + return /* EFalse */1; + } + _i = i - 1 | 0; + continue ; + }; + }; + var check_key = function (c) { + var _i = Stdlib__Obj.Ephemeron.length(c) - 1 | 0; + while(true) { + var i = _i; + if (i < 0) { + return true; + } + if (!Stdlib__Obj.Ephemeron.check_key(c, i)) { + return false; + } + _i = i - 1 | 0; + continue ; + }; + }; + var power_2_above = function (_x, n) { + while(true) { + var x = _x; + if (x >= n) { + return x; + } + if ((x << 1) > Stdlib__Sys.max_array_length) { + return x; + } + _x = (x << 1); + continue ; + }; + }; + var prng = { + LAZY_DONE: false, + VAL: (function () { + return Stdlib__Random.State.make_self_init(undefined); + }) + }; + var create$1 = function (randomOpt, initial_size) { + var random = randomOpt !== undefined ? randomOpt : Stdlib__Hashtbl.is_randomized(undefined); + var s = power_2_above(16, initial_size); + var seed = random ? Stdlib__Random.State.bits(CamlinternalLazy.force(prng)) : 0; + return { + size: 0, + data: Caml_array.make(s, /* Empty */0), + seed: seed, + initial_size: s + }; + }; + var clear = function (h) { + h.size = 0; + var len = h.data.length; + for(var i = 0; i < len; ++i){ + Caml_array.set(h.data, i, /* Empty */0); + } + }; + var reset = function (h) { + var len = h.data.length; + if (len === h.initial_size) { + return clear(h); + } else { + h.size = 0; + h.data = Caml_array.make(h.initial_size, /* Empty */0); + return ; + } + }; + var copy = function (h) { + return { + size: h.size, + data: Stdlib__Array.copy(h.data), + seed: h.seed, + initial_size: h.initial_size + }; + }; + var key_index = function (h, hkey) { + return hkey & (h.data.length - 1 | 0); + }; + var clean = function (h) { + var do_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* Empty */0; + } + if (check_key(param._1)) { + return /* Cons */{ + _0: param._0, + _1: param._1, + _2: do_bucket(param._2) + }; + } + h.size = h.size - 1 | 0; + _param = param._2; + continue ; + }; + }; + var d = h.data; + for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ + Caml_array.set(d, i, do_bucket(Caml_array.get(d, i))); + } + }; + var resize = function (h) { + var odata = h.data; + var osize = odata.length; + var nsize = (osize << 1); + clean(h); + if (!(nsize < Stdlib__Sys.max_array_length && h.size >= (osize >>> 1))) { + return ; + } + var ndata = Caml_array.make(nsize, /* Empty */0); + h.data = ndata; + var insert_bucket = function (param) { + if (!param) { + return ; + } + var hkey = param._0; + insert_bucket(param._2); + var nidx = key_index(h, hkey); + Caml_array.set(ndata, nidx, /* Cons */{ + _0: hkey, + _1: param._1, + _2: Caml_array.get(ndata, nidx) + }); + }; + for(var i = 0; i < osize; ++i){ + insert_bucket(Caml_array.get(odata, i)); + } + }; + var add = function (h, key, info) { + var hkey = seeded_hash(h.seed, key); + var i = key_index(h, hkey); + var container = create(key, info); + var bucket_2 = Caml_array.get(h.data, i); + var bucket = /* Cons */{ + _0: hkey, + _1: container, + _2: bucket_2 + }; + Caml_array.set(h.data, i, bucket); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(h); + } + + }; + var remove = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var remove_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* Empty */0; + } + var hk = param._0; + if (hkey !== hk) { + return /* Cons */{ + _0: hk, + _1: param._1, + _2: remove_bucket(param._2) + }; + } + var next = param._2; + var c = param._1; + var match = equal$1(c, key); + switch (match) { + case /* ETrue */0 : + h.size = h.size - 1 | 0; + return next; + case /* EFalse */1 : + return /* Cons */{ + _0: hk, + _1: c, + _2: remove_bucket(next) + }; + case /* EDead */2 : + h.size = h.size - 1 | 0; + _param = next; + continue ; + + } + }; + }; + var i = key_index(h, hkey); + Caml_array.set(h.data, i, remove_bucket(Caml_array.get(h.data, i))); + }; + var find = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (param) { + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal$1(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data$2(c); + if (d !== undefined) { + return Caml_option.valFromOption(d); + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + }; + var find_opt = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (!param) { + return ; + } + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal$1(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data$2(c); + if (d !== undefined) { + return d; + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + }; + }; + var find_all = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var find_in_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return /* [] */0; + } + if (hkey === param._0) { + var rest = param._2; + var c = param._1; + var match = equal$1(c, key); + if (match) { + _param = rest; + continue ; + } + var d = get_data$2(c); + if (d !== undefined) { + return { + hd: Caml_option.valFromOption(d), + tl: find_in_bucket(rest) + }; + } + _param = rest; + continue ; + } + _param = param._2; + continue ; + }; + }; + return find_in_bucket(Caml_array.get(h.data, key_index(h, hkey))); + }; + var replace = function (h, key, info) { + var hkey = seeded_hash(h.seed, key); + var i = key_index(h, hkey); + var l = Caml_array.get(h.data, i); + try { + var _param = l; + while(true) { + var param = _param; + if (param) { + if (hkey === param._0) { + var c = param._1; + var match = equal$1(c, key); + if (!match) { + Stdlib__Obj.Ephemeron.unset_data(c); + for(var i$1 = 0 ,i_finish = key.length; i$1 < i_finish; ++i$1){ + set_key$1(c, i$1, Caml_array.get(key, i$1)); + } + return Stdlib__Obj.Ephemeron.set_data(c, info); + } + _param = param._2; + continue ; + } + _param = param._2; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + var container = create(key, info); + Caml_array.set(h.data, i, /* Cons */{ + _0: hkey, + _1: container, + _2: l + }); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(h); + } else { + return ; + } + } + throw exn; + } + }; + var mem = function (h, key) { + var hkey = seeded_hash(h.seed, key); + var _param = Caml_array.get(h.data, key_index(h, hkey)); + while(true) { + var param = _param; + if (!param) { + return false; + } + if (param._0 === hkey) { + var match = equal$1(param._1, key); + if (!match) { + return true; + } + _param = param._2; + continue ; + } + _param = param._2; + continue ; + }; + }; + var length = function (h) { + return h.size; + }; + var bucket_length = function (_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + _param = param._2; + _accu = accu + 1 | 0; + continue ; + }; + }; + var stats = function (h) { + var mbl = Stdlib__Array.fold_left((function (m, b) { + return Stdlib__Int.max(m, bucket_length(0, b)); + }), 0, h.data); + var histo = Caml_array.make(mbl + 1 | 0, 0); + Stdlib__Array.iter((function (b) { + var l = bucket_length(0, b); + Caml_array.set(histo, l, Caml_array.get(histo, l) + 1 | 0); + }), h.data); + return { + num_bindings: h.size, + num_buckets: h.data.length, + max_bucket_length: mbl, + bucket_histogram: histo + }; + }; + var bucket_length_alive = function (_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + if (check_key(param._1)) { + _param = param._2; + _accu = accu + 1 | 0; + continue ; + } + _param = param._2; + continue ; + }; + }; + var stats_alive = function (h) { + var size = { + contents: 0 + }; + var mbl = Stdlib__Array.fold_left((function (m, b) { + return Stdlib__Int.max(m, bucket_length_alive(0, b)); + }), 0, h.data); + var histo = Caml_array.make(mbl + 1 | 0, 0); + Stdlib__Array.iter((function (b) { + var l = bucket_length_alive(0, b); + size.contents = size.contents + l | 0; + Caml_array.set(histo, l, Caml_array.get(histo, l) + 1 | 0); + }), h.data); + return { + num_bindings: size.contents, + num_buckets: h.data.length, + max_bucket_length: mbl, + bucket_histogram: histo + }; + }; + var add_seq = function (tbl, i) { + Stdlib__Seq.iter((function (param) { + add(tbl, param[0], param[1]); + }), i); + }; + var replace_seq = function (tbl, i) { + Stdlib__Seq.iter((function (param) { + replace(tbl, param[0], param[1]); + }), i); + }; + var create$2 = function (sz) { + return create$1(false, sz); + }; + var of_seq = function (i) { + var tbl = create$1(false, 16); + replace_seq(tbl, i); + return tbl; + }; + return { + create: create$2, + clear: clear, + reset: reset, + copy: copy, + add: add, + remove: remove, + find: find, + find_opt: find_opt, + find_all: find_all, + replace: replace, + mem: mem, + length: length, + stats: stats, + add_seq: add_seq, + replace_seq: replace_seq, + of_seq: of_seq, + clean: clean, + stats_alive: stats_alive + }; +} + +function make$5(param) { + return { + contents: /* [] */0 + }; +} + +function add$2(b, k, d) { + b.contents = { + hd: make$4(k, d), + tl: b.contents + }; +} + +function test_keys$1(k, e) { + try { + if (Stdlib__Obj.Ephemeron.length(e) !== k.length) { + throw { + RE_EXN_ID: Stdlib.Exit, + Error: new Error() + }; + } + for(var i = 0 ,i_finish = k.length; i < i_finish; ++i){ + var x = Stdlib__Obj.Ephemeron.get_key(e, i); + if (x !== undefined) { + if (Caml_option.valFromOption(x) !== Caml_array.get(k, i)) { + throw { + RE_EXN_ID: Stdlib.Exit, + Error: new Error() + }; + } + + } else { + throw { + RE_EXN_ID: Stdlib.Exit, + Error: new Error() + }; + } + } + return true; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Exit) { + return false; + } + throw exn; + } +} + +function remove$2(b, k) { + var _l = b.contents; + var _acc = /* [] */0; + while(true) { + var acc = _acc; + var l = _l; + if (!l) { + return ; + } + var h = l.hd; + if (test_keys$1(k, h)) { + b.contents = Stdlib__List.rev_append(acc, l.tl); + return ; + } + _acc = { + hd: h, + tl: acc + }; + _l = l.tl; + continue ; + }; +} + +function find$2(b, k) { + var e = Stdlib__List.find_opt((function (param) { + return test_keys$1(k, param); + }), b.contents); + if (e !== undefined) { + return Stdlib__Obj.Ephemeron.get_data(Caml_option.valFromOption(e)); + } + +} + +function length$2(b) { + return Stdlib__List.length(b.contents); +} + +function clear$2(b) { + b.contents = /* [] */0; +} + +var K1_Bucket = { + make: make$1, + add: add, + remove: remove, + find: find, + length: length, + clear: clear +}; + +var K1 = { + make: make, + query: query, + Make: Make, + MakeSeeded: MakeSeeded, + Bucket: K1_Bucket +}; + +var K2_Bucket = { + make: make$3, + add: add$1, + remove: remove$1, + find: find$1, + length: length$1, + clear: clear$1 +}; + +var K2 = { + make: make$2, + query: query$1, + Make: Make$1, + MakeSeeded: MakeSeeded$1, + Bucket: K2_Bucket +}; + +var Kn_Bucket = { + make: make$5, + add: add$2, + remove: remove$2, + find: find$2, + length: length$2, + clear: clear$2 +}; + +var Kn = { + make: make$4, + query: query$2, + Make: Make$2, + MakeSeeded: MakeSeeded$2, + Bucket: Kn_Bucket +}; + +export { + K1 , + K2 , + Kn , +} +/* Stdlib__Hashtbl Not a pure module */ diff --git a/melange-node-modules/melange/filename.js b/melange-node-modules/melange/filename.js new file mode 100644 index 0000000..1b8a763 --- /dev/null +++ b/melange-node-modules/melange/filename.js @@ -0,0 +1,802 @@ +// Generated by Melange + +import * as Caml_bytes from "melange.js/caml_bytes.js"; +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Caml_obj from "melange.js/caml_obj.js"; +import * as Caml_string from "melange.js/caml_string.js"; +import * as Caml_sys from "melange.js/caml_sys.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Buffer from "./buffer.js"; +import * as Stdlib__Bytes from "./bytes.js"; +import * as Stdlib__Domain from "./domain.js"; +import * as Stdlib__List from "./list.js"; +import * as Stdlib__Printf from "./printf.js"; +import * as Stdlib__Random from "./random.js"; +import * as Stdlib__String from "./string.js"; +import * as Stdlib__Sys from "./sys.js"; + +function generic_quote(quotequote, s) { + var l = s.length; + var b = Stdlib__Buffer.create(l + 20 | 0); + Stdlib__Buffer.add_char(b, /* '\'' */39); + for(var i = 0; i < l; ++i){ + if (Caml_string.get(s, i) === /* '\'' */39) { + Stdlib__Buffer.add_string(b, quotequote); + } else { + Stdlib__Buffer.add_char(b, Caml_string.get(s, i)); + } + } + Stdlib__Buffer.add_char(b, /* '\'' */39); + return Stdlib__Buffer.contents(b); +} + +function generic_basename(is_dir_sep, current_dir_name, name) { + if (name === "") { + return current_dir_name; + } else { + var _n = name.length - 1 | 0; + while(true) { + var n = _n; + if (n < 0) { + return Stdlib__String.sub(name, 0, 1); + } + if (!Curry._2(is_dir_sep, name, n)) { + var _n$1 = n; + var p = n + 1 | 0; + while(true) { + var n$1 = _n$1; + if (n$1 < 0) { + return Stdlib__String.sub(name, 0, p); + } + if (Curry._2(is_dir_sep, name, n$1)) { + return Stdlib__String.sub(name, n$1 + 1 | 0, (p - n$1 | 0) - 1 | 0); + } + _n$1 = n$1 - 1 | 0; + continue ; + }; + } + _n = n - 1 | 0; + continue ; + }; + } +} + +function generic_dirname(is_dir_sep, current_dir_name, name) { + if (name === "") { + return current_dir_name; + } else { + var _n = name.length - 1 | 0; + while(true) { + var n = _n; + if (n < 0) { + return Stdlib__String.sub(name, 0, 1); + } + if (!Curry._2(is_dir_sep, name, n)) { + var _n$1 = n; + while(true) { + var n$1 = _n$1; + if (n$1 < 0) { + return current_dir_name; + } + if (Curry._2(is_dir_sep, name, n$1)) { + var _n$2 = n$1; + while(true) { + var n$2 = _n$2; + if (n$2 < 0) { + return Stdlib__String.sub(name, 0, 1); + } + if (!Curry._2(is_dir_sep, name, n$2)) { + return Stdlib__String.sub(name, 0, n$2 + 1 | 0); + } + _n$2 = n$2 - 1 | 0; + continue ; + }; + } + _n$1 = n$1 - 1 | 0; + continue ; + }; + } + _n = n - 1 | 0; + continue ; + }; + } +} + +var current_dir_name = "."; + +function is_dir_sep(s, i) { + return Caml_string.get(s, i) === /* '/' */47; +} + +function is_relative(n) { + if (n.length < 1) { + return true; + } else { + return Caml_string.get(n, 0) !== /* '/' */47; + } +} + +function is_implicit(n) { + if (is_relative(n) && (n.length < 2 || Stdlib__String.sub(n, 0, 2) !== "./")) { + if (n.length < 3) { + return true; + } else { + return Stdlib__String.sub(n, 0, 3) !== "../"; + } + } else { + return false; + } +} + +function check_suffix(name, suff) { + return Stdlib__String.ends_with(suff, name); +} + +function chop_suffix_opt(suffix, filename) { + var len_s = suffix.length; + var len_f = filename.length; + if (len_f < len_s) { + return ; + } + var r = Stdlib__String.sub(filename, len_f - len_s | 0, len_s); + if (r === suffix) { + return Stdlib__String.sub(filename, 0, len_f - len_s | 0); + } + +} + +var temp_dir_name; + +try { + temp_dir_name = Caml_sys.caml_sys_getenv("TMPDIR"); +} +catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + temp_dir_name = "/tmp"; + } else { + throw exn; + } +} + +function quote(param) { + return generic_quote("'\\''", param); +} + +function quote_command(cmd, stdin, stdout, stderr, args) { + return Stdlib__String.concat(" ", Stdlib__List.map(quote, { + hd: cmd, + tl: args + })) + (( + stdin !== undefined ? " <" + generic_quote("'\\''", stdin) : "" + ) + (( + stdout !== undefined ? " >" + generic_quote("'\\''", stdout) : "" + ) + ( + stderr !== undefined ? ( + Caml_obj.caml_equal(stderr, stdout) ? " 2>&1" : " 2>" + generic_quote("'\\''", stderr) + ) : "" + ))); +} + +function basename(param) { + return generic_basename(is_dir_sep, current_dir_name, param); +} + +function dirname(param) { + return generic_dirname(is_dir_sep, current_dir_name, param); +} + +var Unix = { + $$null: "/dev/null", + current_dir_name: current_dir_name, + parent_dir_name: "..", + dir_sep: "/", + is_dir_sep: is_dir_sep, + is_relative: is_relative, + is_implicit: is_implicit, + check_suffix: check_suffix, + chop_suffix_opt: chop_suffix_opt, + temp_dir_name: temp_dir_name, + quote: quote, + quote_command: quote_command, + basename: basename, + dirname: dirname +}; + +var current_dir_name$1 = "."; + +function is_dir_sep$1(s, i) { + var c = Caml_string.get(s, i); + if (c === /* '/' */47 || c === /* '\\' */92) { + return true; + } else { + return c === /* ':' */58; + } +} + +function is_relative$1(n) { + if ((n.length < 1 || Caml_string.get(n, 0) !== /* '/' */47) && (n.length < 1 || Caml_string.get(n, 0) !== /* '\\' */92)) { + if (n.length < 2) { + return true; + } else { + return Caml_string.get(n, 1) !== /* ':' */58; + } + } else { + return false; + } +} + +function is_implicit$1(n) { + if (is_relative$1(n) && (n.length < 2 || Stdlib__String.sub(n, 0, 2) !== "./") && (n.length < 2 || Stdlib__String.sub(n, 0, 2) !== ".\\") && (n.length < 3 || Stdlib__String.sub(n, 0, 3) !== "../")) { + if (n.length < 3) { + return true; + } else { + return Stdlib__String.sub(n, 0, 3) !== "..\\"; + } + } else { + return false; + } +} + +function check_suffix$1(name, suff) { + if (name.length < suff.length) { + return false; + } + var s = Stdlib__String.sub(name, name.length - suff.length | 0, suff.length); + return Caml_bytes.bytes_to_string(Stdlib__Bytes.lowercase_ascii(Caml_bytes.bytes_of_string(s))) === Caml_bytes.bytes_to_string(Stdlib__Bytes.lowercase_ascii(Caml_bytes.bytes_of_string(suff))); +} + +function chop_suffix_opt$1(suffix, filename) { + var len_s = suffix.length; + var len_f = filename.length; + if (len_f < len_s) { + return ; + } + var r = Stdlib__String.sub(filename, len_f - len_s | 0, len_s); + if (Caml_bytes.bytes_to_string(Stdlib__Bytes.lowercase_ascii(Caml_bytes.bytes_of_string(r))) === Caml_bytes.bytes_to_string(Stdlib__Bytes.lowercase_ascii(Caml_bytes.bytes_of_string(suffix)))) { + return Stdlib__String.sub(filename, 0, len_f - len_s | 0); + } + +} + +var temp_dir_name$1; + +try { + temp_dir_name$1 = Caml_sys.caml_sys_getenv("TEMP"); +} +catch (raw_exn$1){ + var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); + if (exn$1.RE_EXN_ID === Stdlib.Not_found) { + temp_dir_name$1 = "."; + } else { + throw exn$1; + } +} + +function quote$1(s) { + var l = s.length; + var b = Stdlib__Buffer.create(l + 20 | 0); + Stdlib__Buffer.add_char(b, /* '"' */34); + var loop = function (_i) { + while(true) { + var i = _i; + if (i === l) { + return Stdlib__Buffer.add_char(b, /* '"' */34); + } + var c = Caml_string.get(s, i); + if (c === 34) { + return loop_bs(0, i); + } + if (c === 92) { + return loop_bs(0, i); + } + Stdlib__Buffer.add_char(b, c); + _i = i + 1 | 0; + continue ; + }; + }; + var loop_bs = function (_n, _i) { + while(true) { + var i = _i; + var n = _n; + if (i === l) { + Stdlib__Buffer.add_char(b, /* '"' */34); + return add_bs(n); + } + var match = Caml_string.get(s, i); + if (match !== 34) { + if (match !== 92) { + add_bs(n); + return loop(i); + } + _i = i + 1 | 0; + _n = n + 1 | 0; + continue ; + } + add_bs((n << 1) + 1 | 0); + Stdlib__Buffer.add_char(b, /* '"' */34); + return loop(i + 1 | 0); + }; + }; + var add_bs = function (n) { + for(var _j = 1; _j <= n; ++_j){ + Stdlib__Buffer.add_char(b, /* '\\' */92); + } + }; + loop(0); + return Stdlib__Buffer.contents(b); +} + +function quote_cmd(s) { + var b = Stdlib__Buffer.create(s.length + 20 | 0); + Stdlib__String.iter((function (c) { + if (c >= 62) { + if (c > 123 || c < 63) { + if (c >= 125) { + return Stdlib__Buffer.add_char(b, c); + } + + } else if (c !== 94) { + return Stdlib__Buffer.add_char(b, c); + } + + } else if (c >= 42) { + if (c !== 60) { + return Stdlib__Buffer.add_char(b, c); + } + + } else { + if (c < 33) { + return Stdlib__Buffer.add_char(b, c); + } + switch (c) { + case 35 : + case 36 : + case 39 : + return Stdlib__Buffer.add_char(b, c); + case 33 : + case 34 : + case 37 : + case 38 : + case 40 : + case 41 : + break; + + } + } + Stdlib__Buffer.add_char(b, /* '^' */94); + Stdlib__Buffer.add_char(b, c); + }), s); + return Stdlib__Buffer.contents(b); +} + +function quote_cmd_filename(f) { + if (!Stdlib__Bytes.exists((function (param) { + if (param !== 34) { + return param === 37; + } else { + return true; + } + }), Caml_bytes.bytes_of_string(f))) { + if (Stdlib__String.contains(f, /* ' ' */32)) { + return Stdlib__String.concat("", { + hd: "\"", + tl: { + hd: f, + tl: { + hd: "\"", + tl: /* [] */0 + } + } + }); + } else { + return f; + } + } + var s = "Filename.quote_command: bad file name " + f; + throw { + RE_EXN_ID: "Failure", + _1: s, + Error: new Error() + }; +} + +function quote_command$1(cmd, stdin, stdout, stderr, args) { + return Stdlib__String.concat("", { + hd: "\"", + tl: { + hd: quote_cmd_filename(cmd), + tl: { + hd: " ", + tl: { + hd: quote_cmd(Stdlib__String.concat(" ", Stdlib__List.map(quote$1, args))), + tl: { + hd: stdin !== undefined ? " <" + quote_cmd_filename(stdin) : "", + tl: { + hd: stdout !== undefined ? " >" + quote_cmd_filename(stdout) : "", + tl: { + hd: stderr !== undefined ? ( + Caml_obj.caml_equal(stderr, stdout) ? " 2>&1" : " 2>" + quote_cmd_filename(stderr) + ) : "", + tl: { + hd: "\"", + tl: /* [] */0 + } + } + } + } + } + } + } + }); +} + +function has_drive(s) { + var is_letter = function (param) { + if (param >= 91) { + return !(param > 122 || param < 97); + } else { + return param >= 65; + } + }; + if (s.length >= 2 && is_letter(Caml_string.get(s, 0))) { + return Caml_string.get(s, 1) === /* ':' */58; + } else { + return false; + } +} + +function drive_and_path(s) { + if (has_drive(s)) { + return [ + Stdlib__String.sub(s, 0, 2), + Stdlib__String.sub(s, 2, s.length - 2 | 0) + ]; + } else { + return [ + "", + s + ]; + } +} + +function dirname$1(s) { + var match = drive_and_path(s); + var dir = generic_dirname(is_dir_sep$1, current_dir_name$1, match[1]); + return match[0] + dir; +} + +function basename$1(s) { + var match = drive_and_path(s); + return generic_basename(is_dir_sep$1, current_dir_name$1, match[1]); +} + +var Win32 = { + $$null: "NUL", + current_dir_name: current_dir_name$1, + parent_dir_name: "..", + dir_sep: "\\", + is_dir_sep: is_dir_sep$1, + is_relative: is_relative$1, + is_implicit: is_implicit$1, + check_suffix: check_suffix$1, + chop_suffix_opt: chop_suffix_opt$1, + temp_dir_name: temp_dir_name$1, + quote: quote$1, + quote_command: quote_command$1, + basename: basename$1, + dirname: dirname$1 +}; + +var current_dir_name$2 = "."; + +function basename$2(param) { + return generic_basename(is_dir_sep$1, current_dir_name$2, param); +} + +function dirname$2(param) { + return generic_dirname(is_dir_sep$1, current_dir_name$2, param); +} + +var Cygwin = { + $$null: "/dev/null", + current_dir_name: current_dir_name$2, + parent_dir_name: "..", + dir_sep: "/", + is_dir_sep: is_dir_sep$1, + is_relative: is_relative$1, + is_implicit: is_implicit$1, + check_suffix: check_suffix$1, + chop_suffix_opt: chop_suffix_opt$1, + temp_dir_name: temp_dir_name, + quote: quote, + quote_command: quote_command, + basename: basename$2, + dirname: dirname$2 +}; + +var Sysdeps; + +switch (Stdlib__Sys.os_type) { + case "Cygwin" : + Sysdeps = Cygwin; + break; + case "Win32" : + Sysdeps = Win32; + break; + default: + Sysdeps = Unix; +} + +var dir_sep = Sysdeps.dir_sep; + +var is_dir_sep$2 = Sysdeps.is_dir_sep; + +var check_suffix$2 = Sysdeps.check_suffix; + +var temp_dir_name$2 = Sysdeps.temp_dir_name; + +function concat(dirname, filename) { + var l = dirname.length; + if (l === 0 || Curry._2(is_dir_sep$2, dirname, l - 1 | 0)) { + return dirname + filename; + } else { + return dirname + (dir_sep + filename); + } +} + +function chop_suffix(name, suff) { + if (Curry._2(check_suffix$2, name, suff)) { + return Stdlib__String.sub(name, 0, name.length - suff.length | 0); + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Filename.chop_suffix", + Error: new Error() + }; +} + +function extension_len(name) { + var _i = name.length - 1 | 0; + while(true) { + var i = _i; + if (i < 0 || Curry._2(is_dir_sep$2, name, i)) { + return 0; + } + if (Caml_string.get(name, i) === /* '.' */46) { + var _i$1 = i - 1 | 0; + while(true) { + var i$1 = _i$1; + if (i$1 < 0 || Curry._2(is_dir_sep$2, name, i$1)) { + return 0; + } + if (Caml_string.get(name, i$1) !== /* '.' */46) { + return name.length - i | 0; + } + _i$1 = i$1 - 1 | 0; + continue ; + }; + } + _i = i - 1 | 0; + continue ; + }; +} + +function extension(name) { + var l = extension_len(name); + if (l === 0) { + return ""; + } else { + return Stdlib__String.sub(name, name.length - l | 0, l); + } +} + +function chop_extension(name) { + var l = extension_len(name); + if (l === 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Filename.chop_extension", + Error: new Error() + }; + } + return Stdlib__String.sub(name, 0, name.length - l | 0); +} + +function remove_extension(name) { + var l = extension_len(name); + if (l === 0) { + return name; + } else { + return Stdlib__String.sub(name, 0, name.length - l | 0); + } +} + +var prng_key = Stdlib__Domain.DLS.new_key(undefined, Stdlib__Random.State.make_self_init); + +function temp_file_name(temp_dir, prefix, suffix) { + var random_state = Stdlib__Domain.DLS.get(prng_key); + var rnd = Stdlib__Random.State.bits(random_state) & 16777215; + return concat(temp_dir, Curry._3(Stdlib__Printf.sprintf(/* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* Int */4, + _0: /* Int_x */6, + _1: { + TAG: /* Lit_padding */0, + _0: /* Zeros */2, + _1: 6 + }, + _2: /* No_precision */0, + _3: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: /* End_of_format */0 + } + } + }, + _1: "%s%06x%s" + }), prefix, rnd, suffix)); +} + +var current_temp_dir_name = Stdlib__Domain.DLS.new_key((function (prim) { + return prim; + }), (function (param) { + return temp_dir_name$2; + })); + +function set_temp_dir_name(s) { + Stdlib__Domain.DLS.set(current_temp_dir_name, s); +} + +function get_temp_dir_name(param) { + return Stdlib__Domain.DLS.get(current_temp_dir_name); +} + +function temp_file(temp_dirOpt, prefix, suffix) { + var temp_dir = temp_dirOpt !== undefined ? temp_dirOpt : Stdlib__Domain.DLS.get(current_temp_dir_name); + var _counter = 0; + while(true) { + var counter = _counter; + var name = temp_file_name(temp_dir, prefix, suffix); + try { + Caml_external_polyfill.resolve("caml_sys_close")(Caml_external_polyfill.resolve("caml_sys_open")(name, { + hd: /* Open_wronly */1, + tl: { + hd: /* Open_creat */3, + tl: { + hd: /* Open_excl */5, + tl: /* [] */0 + } + } + }, 384)); + return name; + } + catch (raw_e){ + var e = Caml_js_exceptions.internalToOCamlException(raw_e); + if (e.RE_EXN_ID === Stdlib.Sys_error) { + if (counter >= 20) { + throw e; + } + _counter = counter + 1 | 0; + continue ; + } + throw e; + } + }; +} + +function open_temp_file(modeOpt, permsOpt, temp_dirOpt, prefix, suffix) { + var mode = modeOpt !== undefined ? modeOpt : ({ + hd: /* Open_text */7, + tl: /* [] */0 + }); + var perms = permsOpt !== undefined ? permsOpt : 384; + var temp_dir = temp_dirOpt !== undefined ? temp_dirOpt : Stdlib__Domain.DLS.get(current_temp_dir_name); + var _counter = 0; + while(true) { + var counter = _counter; + var name = temp_file_name(temp_dir, prefix, suffix); + try { + return [ + name, + Stdlib.open_out_gen({ + hd: /* Open_wronly */1, + tl: { + hd: /* Open_creat */3, + tl: { + hd: /* Open_excl */5, + tl: mode + } + } + }, perms, name) + ]; + } + catch (raw_e){ + var e = Caml_js_exceptions.internalToOCamlException(raw_e); + if (e.RE_EXN_ID === Stdlib.Sys_error) { + if (counter >= 20) { + throw e; + } + _counter = counter + 1 | 0; + continue ; + } + throw e; + } + }; +} + +function temp_dir(temp_dirOpt, permsOpt, prefix, suffix) { + var temp_dir$1 = temp_dirOpt !== undefined ? temp_dirOpt : Stdlib__Domain.DLS.get(current_temp_dir_name); + var perms = permsOpt !== undefined ? permsOpt : 448; + var _counter = 0; + while(true) { + var counter = _counter; + var name = temp_file_name(temp_dir$1, prefix, suffix); + try { + Caml_external_polyfill.resolve("caml_sys_mkdir")(name, perms); + return name; + } + catch (raw_e){ + var e = Caml_js_exceptions.internalToOCamlException(raw_e); + if (e.RE_EXN_ID === Stdlib.Sys_error) { + if (counter >= 20) { + throw e; + } + _counter = counter + 1 | 0; + continue ; + } + throw e; + } + }; +} + +var current_dir_name$3 = Sysdeps.current_dir_name; + +var parent_dir_name = Sysdeps.parent_dir_name; + +var is_relative$2 = Sysdeps.is_relative; + +var is_implicit$2 = Sysdeps.is_implicit; + +var chop_suffix_opt$2 = Sysdeps.chop_suffix_opt; + +var basename$3 = Sysdeps.basename; + +var dirname$3 = Sysdeps.dirname; + +var $$null = Sysdeps.$$null; + +var quote$2 = Sysdeps.quote; + +var quote_command$2 = Sysdeps.quote_command; + +export { + current_dir_name$3 as current_dir_name, + parent_dir_name , + dir_sep , + concat , + is_relative$2 as is_relative, + is_implicit$2 as is_implicit, + check_suffix$2 as check_suffix, + chop_suffix , + chop_suffix_opt$2 as chop_suffix_opt, + extension , + remove_extension , + chop_extension , + basename$3 as basename, + dirname$3 as dirname, + $$null , + temp_file , + open_temp_file , + temp_dir , + get_temp_dir_name , + set_temp_dir_name , + quote$2 as quote, + quote_command$2 as quote_command, +} +/* temp_dir_name Not a pure module */ diff --git a/melange-node-modules/melange/float.js b/melange-node-modules/melange/float.js new file mode 100644 index 0000000..16eaca5 --- /dev/null +++ b/melange-node-modules/melange/float.js @@ -0,0 +1,911 @@ +// Generated by Melange + +import * as Caml from "melange.js/caml.js"; +import * as Caml_array from "melange.js/caml_array.js"; +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Caml_hash from "melange.js/caml_hash.js"; +import * as Caml_int64 from "melange.js/caml_int64.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__List from "./list.js"; +import * as Stdlib__Seq from "./seq.js"; + +var nan = Number.NaN; + +var signaling_nan = Caml_int64.float_of_bits([ + 2146435072, + 1 + ]); + +function is_finite(x) { + return x - x === 0; +} + +function is_infinite(x) { + return 1 / x === 0; +} + +function is_nan(x) { + return x !== x; +} + +function is_integer(x) { + if (x === Caml_external_polyfill.resolve("caml_trunc_float")(x)) { + return is_finite(x); + } else { + return false; + } +} + +function succ(x) { + return Caml_external_polyfill.resolve("caml_nextafter_float")(x, Stdlib.infinity); +} + +function pred(x) { + return Caml_external_polyfill.resolve("caml_nextafter_float")(x, Stdlib.neg_infinity); +} + +function equal(x, y) { + return Caml.caml_float_compare(x, y) === 0; +} + +function min(x, y) { + if (y > x || !Caml_external_polyfill.resolve("caml_signbit_float")(y) && Caml_external_polyfill.resolve("caml_signbit_float")(x)) { + if (y !== y) { + return y; + } else { + return x; + } + } else if (x !== x) { + return x; + } else { + return y; + } +} + +function max(x, y) { + if (y > x || !Caml_external_polyfill.resolve("caml_signbit_float")(y) && Caml_external_polyfill.resolve("caml_signbit_float")(x)) { + if (x !== x) { + return x; + } else { + return y; + } + } else if (y !== y) { + return y; + } else { + return x; + } +} + +function min_max(x, y) { + if (x !== x || y !== y) { + return [ + nan, + nan + ]; + } else if (y > x || !Caml_external_polyfill.resolve("caml_signbit_float")(y) && Caml_external_polyfill.resolve("caml_signbit_float")(x)) { + return [ + x, + y + ]; + } else { + return [ + y, + x + ]; + } +} + +function min_num(x, y) { + if (y > x || !Caml_external_polyfill.resolve("caml_signbit_float")(y) && Caml_external_polyfill.resolve("caml_signbit_float")(x)) { + if (x !== x) { + return y; + } else { + return x; + } + } else if (y !== y) { + return x; + } else { + return y; + } +} + +function max_num(x, y) { + if (y > x || !Caml_external_polyfill.resolve("caml_signbit_float")(y) && Caml_external_polyfill.resolve("caml_signbit_float")(x)) { + if (y !== y) { + return x; + } else { + return y; + } + } else if (x !== x) { + return y; + } else { + return x; + } +} + +function min_max_num(x, y) { + if (x !== x) { + return [ + y, + y + ]; + } else if (y !== y) { + return [ + x, + x + ]; + } else if (y > x || !Caml_external_polyfill.resolve("caml_signbit_float")(y) && Caml_external_polyfill.resolve("caml_signbit_float")(x)) { + return [ + x, + y + ]; + } else { + return [ + y, + x + ]; + } +} + +function seeded_hash(seed, x) { + return Caml_hash.caml_hash(10, 100, seed, x); +} + +function hash(x) { + return Caml_hash.caml_hash(10, 100, 0, x); +} + +function unsafe_fill(a, ofs, len, v) { + for(var i = ofs ,i_finish = ofs + len | 0; i < i_finish; ++i){ + a[i] = v; + } +} + +function check(a, ofs, len, msg) { + if (!(ofs < 0 || len < 0 || (ofs + len | 0) < 0 || (ofs + len | 0) > a.length)) { + return ; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: msg, + Error: new Error() + }; +} + +function make(n, v) { + var result = Caml_array.make_float(n); + unsafe_fill(result, 0, n, v); + return result; +} + +function init(l, f) { + if (l < 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Float.Array.init", + Error: new Error() + }; + } + var res = Caml_array.make_float(l); + for(var i = 0; i < l; ++i){ + res[i] = Curry._1(f, i); + } + return res; +} + +function append(a1, a2) { + var l1 = a1.length; + var l2 = a2.length; + var result = Caml_array.make_float(l1 + l2 | 0); + Caml_external_polyfill.resolve("caml_floatarray_blit")(a1, 0, result, 0, l1); + Caml_external_polyfill.resolve("caml_floatarray_blit")(a2, 0, result, l1, l2); + return result; +} + +function ensure_ge(x, y) { + if (x >= y) { + return x; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Float.Array.concat", + Error: new Error() + }; +} + +function sum_lengths(_acc, _param) { + while(true) { + var param = _param; + var acc = _acc; + if (!param) { + return acc; + } + _param = param.tl; + _acc = ensure_ge(param.hd.length + acc | 0, acc); + continue ; + }; +} + +function concat(l) { + var len = sum_lengths(0, l); + var result = Caml_array.make_float(len); + var loop = function (_l, _i) { + while(true) { + var i = _i; + var l = _l; + if (l) { + var hd = l.hd; + var hlen = hd.length; + Caml_external_polyfill.resolve("caml_floatarray_blit")(hd, 0, result, i, hlen); + _i = i + hlen | 0; + _l = l.tl; + continue ; + } + if (i === len) { + return ; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "float.cppo.ml", + 278, + 14 + ], + Error: new Error() + }; + }; + }; + loop(l, 0); + return result; +} + +function sub(a, ofs, len) { + check(a, ofs, len, "Float.Array.sub"); + var result = Caml_array.make_float(len); + Caml_external_polyfill.resolve("caml_floatarray_blit")(a, ofs, result, 0, len); + return result; +} + +function copy(a) { + var l = a.length; + var result = Caml_array.make_float(l); + Caml_external_polyfill.resolve("caml_floatarray_blit")(a, 0, result, 0, l); + return result; +} + +function fill(a, ofs, len, v) { + check(a, ofs, len, "Float.Array.fill"); + unsafe_fill(a, ofs, len, v); +} + +function blit(src, sofs, dst, dofs, len) { + check(src, sofs, len, "Float.array.blit"); + check(dst, dofs, len, "Float.array.blit"); + Caml_external_polyfill.resolve("caml_floatarray_blit")(src, sofs, dst, dofs, len); +} + +function to_list(a) { + return Stdlib__List.init(a.length, (function (param) { + return a[param]; + })); +} + +function of_list(l) { + var result = Caml_array.make_float(Stdlib__List.length(l)); + var _i = 0; + var _l = l; + while(true) { + var l$1 = _l; + var i = _i; + if (!l$1) { + return result; + } + result[i] = l$1.hd; + _l = l$1.tl; + _i = i + 1 | 0; + continue ; + }; +} + +function iter(f, a) { + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + Curry._1(f, a[i]); + } +} + +function iter2(f, a, b) { + if (a.length !== b.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Float.Array.iter2: arrays must have the same length", + Error: new Error() + }; + } + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + Curry._2(f, a[i], b[i]); + } +} + +function map(f, a) { + var l = a.length; + var r = Caml_array.make_float(l); + for(var i = 0; i < l; ++i){ + r[i] = Curry._1(f, a[i]); + } + return r; +} + +function map_inplace(f, a) { + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + a[i] = Curry._1(f, a[i]); + } +} + +function map2(f, a, b) { + var la = a.length; + var lb = b.length; + if (la !== lb) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Float.Array.map2: arrays must have the same length", + Error: new Error() + }; + } + var r = Caml_array.make_float(la); + for(var i = 0; i < la; ++i){ + r[i] = Curry._2(f, a[i], b[i]); + } + return r; +} + +function iteri(f, a) { + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + Curry._2(f, i, a[i]); + } +} + +function mapi(f, a) { + var l = a.length; + var r = Caml_array.make_float(l); + for(var i = 0; i < l; ++i){ + r[i] = Curry._2(f, i, a[i]); + } + return r; +} + +function mapi_inplace(f, a) { + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + a[i] = Curry._2(f, i, a[i]); + } +} + +function fold_left(f, x, a) { + var r = x; + for(var i = 0 ,i_finish = a.length; i < i_finish; ++i){ + r = Curry._2(f, r, a[i]); + } + return r; +} + +function fold_right(f, a, x) { + var r = x; + for(var i = a.length - 1 | 0; i >= 0; --i){ + r = Curry._2(f, a[i], r); + } + return r; +} + +function exists(p, a) { + var n = a.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return false; + } + if (Curry._1(p, a[i])) { + return true; + } + _i = i + 1 | 0; + continue ; + }; +} + +function for_all(p, a) { + var n = a.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return true; + } + if (!Curry._1(p, a[i])) { + return false; + } + _i = i + 1 | 0; + continue ; + }; +} + +function mem(x, a) { + var n = a.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return false; + } + if (Caml.caml_float_compare(a[i], x) === 0) { + return true; + } + _i = i + 1 | 0; + continue ; + }; +} + +function mem_ieee(x, a) { + var n = a.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return false; + } + if (x === a[i]) { + return true; + } + _i = i + 1 | 0; + continue ; + }; +} + +function find_opt(p, a) { + var n = a.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return ; + } + var x = a[i]; + if (Curry._1(p, x)) { + return x; + } + _i = i + 1 | 0; + continue ; + }; +} + +function find_index(p, a) { + var n = a.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return ; + } + if (Curry._1(p, a[i])) { + return i; + } + _i = i + 1 | 0; + continue ; + }; +} + +function find_map(f, a) { + var n = a.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return ; + } + var r = Curry._1(f, a[i]); + if (r !== undefined) { + return r; + } + _i = i + 1 | 0; + continue ; + }; +} + +function find_mapi(f, a) { + var n = a.length; + var _i = 0; + while(true) { + var i = _i; + if (i === n) { + return ; + } + var r = Curry._2(f, i, a[i]); + if (r !== undefined) { + return r; + } + _i = i + 1 | 0; + continue ; + }; +} + +var Bottom = /* @__PURE__ */Caml_exceptions.create("Stdlib.Float.Array.Bottom"); + +function sort(cmp, a) { + var maxson = function (l, i) { + var i31 = ((i + i | 0) + i | 0) + 1 | 0; + var x = i31; + if ((i31 + 2 | 0) < l) { + if (Curry._2(cmp, Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { + x = i31 + 1 | 0; + } + if (Curry._2(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 && Curry._2(cmp, Caml_array.get(a, i31), Caml_array.get(a, i31 + 1 | 0)) < 0) { + return i31 + 1 | 0; + } + if (i31 < l) { + return i31; + } + throw { + RE_EXN_ID: Bottom, + _1: i, + Error: new Error() + }; + }; + var trickle = function (l, i, e) { + try { + var _i = i; + while(true) { + var i$1 = _i; + var j = maxson(l, i$1); + if (Curry._2(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_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Bottom) { + return Caml_array.set(a, exn._1, e); + } + throw exn; + } + }; + var bubble = function (l, i) { + try { + var _i = i; + while(true) { + var i$1 = _i; + var j = maxson(l, i$1); + Caml_array.set(a, i$1, Caml_array.get(a, j)); + _i = j; + continue ; + }; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Bottom) { + return exn._1; + } + throw exn; + } + }; + var trickleup = function (_i, e) { + while(true) { + var i = _i; + var father = (i - 1 | 0) / 3 | 0; + if (i === father) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "float.cppo.ml", + 508, + 6 + ], + Error: new Error() + }; + } + if (Curry._2(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 ; + }; + }; + var l = a.length; + for(var i = ((l + 1 | 0) / 3 | 0) - 1 | 0; i >= 0; --i){ + trickle(l, i, Caml_array.get(a, i)); + } + for(var i$1 = l - 1 | 0; i$1 >= 2; --i$1){ + var 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 ; + } + var 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) { + var merge = function (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { + var src1r = src1ofs + src1len | 0; + var src2r = src2ofs + src2len | 0; + var _i1 = src1ofs; + var _s1 = Caml_array.get(a, src1ofs); + var _i2 = src2ofs; + var _s2 = Caml_array.get(src2, src2ofs); + var _d = dstofs; + while(true) { + var d = _d; + var s2 = _s2; + var i2 = _i2; + var s1 = _s1; + var i1 = _i1; + if (Curry._2(cmp, s1, s2) <= 0) { + Caml_array.set(dst, d, s1); + var 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); + var 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 ; + }; + }; + var isortto = function (srcofs, dst, dstofs, len) { + for(var i = 0; i < len; ++i){ + var e = Caml_array.get(a, srcofs + i | 0); + var j = (dstofs + i | 0) - 1 | 0; + while(j >= dstofs && Curry._2(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); + } + }; + var sortto = function (srcofs, dst, dstofs, len) { + if (len <= 5) { + return isortto(srcofs, dst, dstofs, len); + } + var l1 = len / 2 | 0; + var 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); + }; + var l = a.length; + if (l <= 5) { + return isortto(0, a, 0, l); + } + var l1 = l / 2 | 0; + var l2 = l - l1 | 0; + var t = Caml_array.make_float(l2); + sortto(l1, t, 0, l2); + sortto(0, a, l2, l1); + merge(l2, l1, t, 0, l2, a, 0); +} + +function to_seq(a) { + var aux = function (i, param) { + if (i >= a.length) { + return /* Nil */0; + } + var x = a[i]; + var partial_arg = i + 1 | 0; + return /* Cons */{ + _0: x, + _1: (function (param) { + return aux(partial_arg, param); + }) + }; + }; + return function (param) { + return aux(0, param); + }; +} + +function to_seqi(a) { + var aux = function (i, param) { + if (i >= a.length) { + return /* Nil */0; + } + var x = a[i]; + var partial_arg = i + 1 | 0; + return /* Cons */{ + _0: [ + i, + x + ], + _1: (function (param) { + return aux(partial_arg, param); + }) + }; + }; + return function (param) { + return aux(0, param); + }; +} + +function of_seq(i) { + var l = Stdlib__Seq.fold_left((function (acc, x) { + return { + hd: x, + tl: acc + }; + }), /* [] */0, i); + var len = Stdlib__List.length(l); + var a = Caml_array.make_float(len); + var _i = len - 1 | 0; + var _param = l; + while(true) { + var param = _param; + var i$1 = _i; + if (!param) { + return a; + } + a[i$1] = param.hd; + _param = param.tl; + _i = i$1 - 1 | 0; + continue ; + }; +} + +function map_to_array(f, a) { + var l = a.length; + if (l === 0) { + return []; + } + var r = Caml_array.make(l, Curry._1(f, a[0])); + for(var i = 1; i < l; ++i){ + r[i] = Curry._1(f, a[i]); + } + return r; +} + +function map_from_array(f, a) { + var l = a.length; + var r = Caml_array.make_float(l); + for(var i = 0; i < l; ++i){ + r[i] = Curry._1(f, a[i]); + } + return r; +} + +var zero = 0; + +var one = 1; + +var minus_one = -1; + +var infinity = Stdlib.infinity; + +var neg_infinity = Stdlib.neg_infinity; + +var quiet_nan = nan; + +var pi = 3.14159265358979312; + +var max_float = Stdlib.max_float; + +var min_float = Stdlib.min_float; + +var epsilon = Stdlib.epsilon_float; + +var of_string_opt = Stdlib.float_of_string_opt; + +var to_string = Stdlib.string_of_float; + +var compare = Caml.caml_float_compare; + +function Array_length(prim) { + return prim.length; +} + +var Array_get = Caml_array.get; + +var Array_set = Caml_array.set; + +var Array_create = Caml_array.make_float; + +var $$Array = { + length: Array_length, + get: Array_get, + set: Array_set, + make: make, + create: Array_create, + init: init, + append: append, + concat: concat, + sub: sub, + copy: copy, + fill: fill, + blit: blit, + to_list: to_list, + of_list: of_list, + iter: iter, + iteri: iteri, + map: map, + map_inplace: map_inplace, + mapi: mapi, + mapi_inplace: mapi_inplace, + fold_left: fold_left, + fold_right: fold_right, + iter2: iter2, + map2: map2, + for_all: for_all, + exists: exists, + mem: mem, + mem_ieee: mem_ieee, + find_opt: find_opt, + find_index: find_index, + find_map: find_map, + find_mapi: find_mapi, + sort: sort, + stable_sort: stable_sort, + fast_sort: stable_sort, + to_seq: to_seq, + to_seqi: to_seqi, + of_seq: of_seq, + map_to_array: map_to_array, + map_from_array: map_from_array +}; + +export { + zero , + one , + minus_one , + succ , + pred , + infinity , + neg_infinity , + nan , + signaling_nan , + quiet_nan , + pi , + max_float , + min_float , + epsilon , + is_finite , + is_infinite , + is_nan , + is_integer , + of_string_opt , + to_string , + compare , + equal , + min , + max , + min_max , + min_num , + max_num , + min_max_num , + seeded_hash , + hash , + $$Array , +} +/* nan Not a pure module */ diff --git a/melange-node-modules/melange/format.js b/melange-node-modules/melange/format.js new file mode 100644 index 0000000..b2e7ff4 --- /dev/null +++ b/melange-node-modules/melange/format.js @@ -0,0 +1,2164 @@ +// Generated by Melange + +import * as Caml_bytes from "melange.js/caml_bytes.js"; +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; +import * as Caml_format from "melange.js/caml_format.js"; +import * as Caml_io from "melange.js/caml_io.js"; +import * as Caml_obj from "melange.js/caml_obj.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Caml_string from "melange.js/caml_string.js"; +import * as CamlinternalFormat from "./camlinternalFormat.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Array from "./array.js"; +import * as Stdlib__Buffer from "./buffer.js"; +import * as Stdlib__Bytes from "./bytes.js"; +import * as Stdlib__Domain from "./domain.js"; +import * as Stdlib__Int from "./int.js"; +import * as Stdlib__List from "./list.js"; +import * as Stdlib__Queue from "./queue.js"; +import * as Stdlib__Seq from "./seq.js"; +import * as Stdlib__Stack from "./stack.js"; +import * as Stdlib__String from "./string.js"; + +function id(x) { + return x; +} + +var String_tag = /* @__PURE__ */Caml_exceptions.create("Stdlib.Format.String_tag"); + +function pp_enqueue(state, token) { + state.pp_right_total = state.pp_right_total + token.length | 0; + Stdlib__Queue.add(token, state.pp_queue); +} + +function pp_clear_queue(state) { + state.pp_left_total = 1; + state.pp_right_total = 1; + Stdlib__Queue.clear(state.pp_queue); +} + +function pp_output_string(state, s) { + Curry._3(state.pp_out_string, s, 0, s.length); +} + +function format_pp_text(state, size, text) { + state.pp_space_left = state.pp_space_left - size | 0; + pp_output_string(state, text); + state.pp_is_new_line = false; +} + +function format_string(state, s) { + if (s !== "") { + return format_pp_text(state, s.length, s); + } + +} + +function break_new_line(state, param, width) { + format_string(state, param[0]); + Curry._1(state.pp_out_newline, undefined); + state.pp_is_new_line = true; + var indent = (state.pp_margin - width | 0) + param[1] | 0; + var real_indent = Stdlib__Int.min(state.pp_max_indent, indent); + state.pp_current_indent = real_indent; + state.pp_space_left = state.pp_margin - state.pp_current_indent | 0; + Curry._1(state.pp_out_indent, state.pp_current_indent); + format_string(state, param[2]); +} + +function break_line(state, width) { + break_new_line(state, [ + "", + 0, + "" + ], width); +} + +function break_same_line(state, param) { + var width = param[1]; + format_string(state, param[0]); + state.pp_space_left = state.pp_space_left - width | 0; + Curry._1(state.pp_out_spaces, width); + format_string(state, param[2]); +} + +function pp_force_break_line(state) { + var match = Stdlib__Stack.top_opt(state.pp_format_stack); + if (match === undefined) { + return Curry._1(state.pp_out_newline, undefined); + } + var width = match.width; + if (width > state.pp_space_left && (match.box_type - 1 >>> 0) <= 3) { + return break_line(state, width); + } + +} + +function format_pp_token(state, size, param) { + if (typeof param === "number") { + switch (param) { + case /* Pp_stab */0 : + var match = Stdlib__Stack.top_opt(state.pp_tbox_stack); + if (match === undefined) { + return ; + } + var tabs = match._0; + var add_tab = function (n, ls) { + if (!ls) { + return { + hd: n, + tl: /* [] */0 + }; + } + var x = ls.hd; + if (Caml_obj.caml_lessthan(n, x)) { + return { + hd: n, + tl: ls + }; + } else { + return { + hd: x, + tl: add_tab(n, ls.tl) + }; + } + }; + tabs.contents = add_tab(state.pp_margin - state.pp_space_left | 0, tabs.contents); + return ; + case /* Pp_end */1 : + Stdlib__Stack.pop_opt(state.pp_format_stack); + return ; + case /* Pp_tend */2 : + Stdlib__Stack.pop_opt(state.pp_tbox_stack); + return ; + case /* Pp_newline */3 : + var match$1 = Stdlib__Stack.top_opt(state.pp_format_stack); + if (match$1 !== undefined) { + return break_line(state, match$1.width); + } else { + return Curry._1(state.pp_out_newline, undefined); + } + case /* Pp_if_newline */4 : + if (state.pp_current_indent !== (state.pp_margin - state.pp_space_left | 0)) { + var match$2 = Stdlib__Queue.take_opt(state.pp_queue); + if (match$2 === undefined) { + return ; + } + var size$1 = match$2.size; + state.pp_left_total = state.pp_left_total - match$2.length | 0; + state.pp_space_left = state.pp_space_left + size$1 | 0; + return ; + } else { + return ; + } + case /* Pp_close_tag */5 : + var tag_name = Stdlib__Stack.pop_opt(state.pp_mark_stack); + if (tag_name === undefined) { + return ; + } + var marker = Curry._1(state.pp_mark_close_tag, Caml_option.valFromOption(tag_name)); + return pp_output_string(state, marker); + + } + } else { + switch (param.TAG | 0) { + case /* Pp_text */0 : + return format_pp_text(state, size, param._0); + case /* Pp_break */1 : + var breaks = param.breaks; + var before = breaks[0]; + var fits = param.fits; + var match$3 = Stdlib__Stack.top_opt(state.pp_format_stack); + if (match$3 === undefined) { + return ; + } + var width = match$3.width; + switch (match$3.box_type) { + case /* Pp_vbox */1 : + case /* Pp_hvbox */2 : + return break_new_line(state, breaks, width); + case /* Pp_hovbox */3 : + if ((size + before.length | 0) > state.pp_space_left) { + return break_new_line(state, breaks, width); + } else { + return break_same_line(state, fits); + } + case /* Pp_box */4 : + if (state.pp_is_new_line || !((size + before.length | 0) > state.pp_space_left || state.pp_current_indent > ((state.pp_margin - width | 0) + breaks[1] | 0))) { + return break_same_line(state, fits); + } else { + return break_new_line(state, breaks, width); + } + case /* Pp_hbox */0 : + case /* Pp_fits */5 : + return break_same_line(state, fits); + + } + case /* Pp_tbreak */2 : + var insertion_point = state.pp_margin - state.pp_space_left | 0; + var match$4 = Stdlib__Stack.top_opt(state.pp_tbox_stack); + if (match$4 === undefined) { + return ; + } + var tabs$1 = match$4._0; + var match$5 = tabs$1.contents; + var tab; + if (match$5) { + var first = match$5.hd; + var find = function (_param) { + while(true) { + var param = _param; + if (!param) { + return first; + } + var head = param.hd; + if (head >= insertion_point) { + return head; + } + _param = param.tl; + continue ; + }; + }; + tab = find(tabs$1.contents); + } else { + tab = insertion_point; + } + var offset = tab - insertion_point | 0; + if (offset >= 0) { + return break_same_line(state, [ + "", + offset + param._0 | 0, + "" + ]); + } else { + return break_new_line(state, [ + "", + tab + param._1 | 0, + "" + ], state.pp_margin); + } + case /* Pp_begin */3 : + var ty = param._1; + var insertion_point$1 = state.pp_margin - state.pp_space_left | 0; + if (insertion_point$1 > state.pp_max_indent) { + pp_force_break_line(state); + } + var width$1 = state.pp_space_left - param._0 | 0; + var box_type = ty !== 1 ? ( + size > state.pp_space_left ? ty : /* Pp_fits */5 + ) : /* Pp_vbox */1; + return Stdlib__Stack.push({ + box_type: box_type, + width: width$1 + }, state.pp_format_stack); + case /* Pp_tbegin */4 : + return Stdlib__Stack.push(param._0, state.pp_tbox_stack); + case /* Pp_open_tag */5 : + var tag_name$1 = param._0; + var marker$1 = Curry._1(state.pp_mark_open_tag, tag_name$1); + pp_output_string(state, marker$1); + return Stdlib__Stack.push(tag_name$1, state.pp_mark_stack); + + } + } +} + +function advance_left(state) { + while(true) { + var match = Stdlib__Queue.peek_opt(state.pp_queue); + if (match === undefined) { + return ; + } + var size = match.size; + var pending_count = state.pp_right_total - state.pp_left_total | 0; + if (!(size >= 0 || pending_count >= state.pp_space_left)) { + return ; + } + Stdlib__Queue.take(state.pp_queue); + var size$1 = size >= 0 ? size : 1000000010; + format_pp_token(state, size$1, match.token); + state.pp_left_total = match.length + state.pp_left_total | 0; + continue ; + }; +} + +function enqueue_advance(state, tok) { + pp_enqueue(state, tok); + advance_left(state); +} + +function enqueue_string_as(state, size, s) { + enqueue_advance(state, { + size: size, + token: { + TAG: /* Pp_text */0, + _0: s + }, + length: size + }); +} + +function initialize_scan_stack(stack) { + Stdlib__Stack.clear(stack); + var queue_elem = { + size: -1, + token: { + TAG: /* Pp_text */0, + _0: "" + }, + length: 0 + }; + Stdlib__Stack.push({ + left_total: -1, + queue_elem: queue_elem + }, stack); +} + +function set_size(state, ty) { + var match = Stdlib__Stack.top_opt(state.pp_scan_stack); + if (match === undefined) { + return ; + } + var queue_elem = match.queue_elem; + var size = queue_elem.size; + if (match.left_total < state.pp_left_total) { + return initialize_scan_stack(state.pp_scan_stack); + } + var match$1 = queue_elem.token; + if (typeof match$1 === "number") { + return ; + } + switch (match$1.TAG | 0) { + case /* Pp_break */1 : + case /* Pp_tbreak */2 : + break; + case /* Pp_begin */3 : + if (!ty) { + queue_elem.size = state.pp_right_total + size | 0; + Stdlib__Stack.pop_opt(state.pp_scan_stack); + return ; + } else { + return ; + } + default: + return ; + } + if (ty) { + queue_elem.size = state.pp_right_total + size | 0; + Stdlib__Stack.pop_opt(state.pp_scan_stack); + return ; + } + +} + +function scan_push(state, b, token) { + pp_enqueue(state, token); + if (b) { + set_size(state, true); + } + var elem_left_total = state.pp_right_total; + var elem = { + left_total: elem_left_total, + queue_elem: token + }; + Stdlib__Stack.push(elem, state.pp_scan_stack); +} + +function pp_open_box_gen(state, indent, br_ty) { + state.pp_curr_depth = state.pp_curr_depth + 1 | 0; + if (state.pp_curr_depth >= state.pp_max_boxes) { + if (state.pp_curr_depth === state.pp_max_boxes) { + var s = state.pp_ellipsis; + return enqueue_string_as(state, s.length, s); + } else { + return ; + } + } + var size = -state.pp_right_total | 0; + var elem = { + size: size, + token: { + TAG: /* Pp_begin */3, + _0: indent, + _1: br_ty + }, + length: 0 + }; + scan_push(state, false, elem); +} + +function pp_close_box(state, param) { + if (state.pp_curr_depth > 1) { + if (state.pp_curr_depth < state.pp_max_boxes) { + pp_enqueue(state, { + size: 0, + token: /* Pp_end */1, + length: 0 + }); + set_size(state, true); + set_size(state, false); + } + state.pp_curr_depth = state.pp_curr_depth - 1 | 0; + return ; + } + +} + +function pp_open_stag(state, tag_name) { + if (state.pp_print_tags) { + Stdlib__Stack.push(tag_name, state.pp_tag_stack); + Curry._1(state.pp_print_open_tag, tag_name); + } + if (!state.pp_mark_tags) { + return ; + } + var token = { + TAG: /* Pp_open_tag */5, + _0: tag_name + }; + pp_enqueue(state, { + size: 0, + token: token, + length: 0 + }); +} + +function pp_close_stag(state, param) { + if (state.pp_mark_tags) { + pp_enqueue(state, { + size: 0, + token: /* Pp_close_tag */5, + length: 0 + }); + } + if (!state.pp_print_tags) { + return ; + } + var tag_name = Stdlib__Stack.pop_opt(state.pp_tag_stack); + if (tag_name !== undefined) { + return Curry._1(state.pp_print_close_tag, Caml_option.valFromOption(tag_name)); + } + +} + +function pp_set_print_tags(state, b) { + state.pp_print_tags = b; +} + +function pp_set_mark_tags(state, b) { + state.pp_mark_tags = b; +} + +function pp_get_print_tags(state, param) { + return state.pp_print_tags; +} + +function pp_get_mark_tags(state, param) { + return state.pp_mark_tags; +} + +function pp_set_tags(state, b) { + state.pp_print_tags = b; + state.pp_mark_tags = b; +} + +function pp_get_formatter_stag_functions(state, param) { + return { + mark_open_stag: state.pp_mark_open_tag, + mark_close_stag: state.pp_mark_close_tag, + print_open_stag: state.pp_print_open_tag, + print_close_stag: state.pp_print_close_tag + }; +} + +function pp_set_formatter_stag_functions(state, param) { + state.pp_mark_open_tag = param.mark_open_stag; + state.pp_mark_close_tag = param.mark_close_stag; + state.pp_print_open_tag = param.print_open_stag; + state.pp_print_close_tag = param.print_close_stag; +} + +function pp_rinit(state) { + pp_clear_queue(state); + initialize_scan_stack(state.pp_scan_stack); + Stdlib__Stack.clear(state.pp_format_stack); + Stdlib__Stack.clear(state.pp_tbox_stack); + Stdlib__Stack.clear(state.pp_tag_stack); + Stdlib__Stack.clear(state.pp_mark_stack); + state.pp_current_indent = 0; + state.pp_curr_depth = 0; + state.pp_space_left = state.pp_margin; + pp_open_box_gen(state, 0, /* Pp_hovbox */3); +} + +function clear_tag_stack(state) { + var s = state.pp_tag_stack; + var f = function (param) { + pp_close_stag(state, undefined); + }; + Stdlib__List.iter(f, s.c); +} + +function pp_flush_queue(state, end_with_newline) { + clear_tag_stack(state); + while(state.pp_curr_depth > 1) { + pp_close_box(state, undefined); + }; + state.pp_right_total = 1000000010; + advance_left(state); + if (end_with_newline) { + Curry._1(state.pp_out_newline, undefined); + } + pp_rinit(state); +} + +function pp_print_as_size(state, size, s) { + if (state.pp_curr_depth < state.pp_max_boxes) { + return enqueue_string_as(state, size, s); + } + +} + +var pp_print_as = pp_print_as_size; + +function pp_print_string(state, s) { + pp_print_as(state, s.length, s); +} + +function pp_print_bytes(state, s) { + pp_print_as(state, s.length, Stdlib__Bytes.to_string(s)); +} + +function pp_print_int(state, i) { + pp_print_string(state, Caml_format.caml_format_int("%d", i)); +} + +function pp_print_float(state, f) { + pp_print_string(state, Stdlib.string_of_float(f)); +} + +function pp_print_bool(state, b) { + pp_print_string(state, b ? "true" : "false"); +} + +function pp_print_char(state, c) { + pp_print_as(state, 1, Caml_bytes.bytes_to_string(Stdlib__Bytes.make(1, c))); +} + +function pp_open_hbox(state, param) { + pp_open_box_gen(state, 0, /* Pp_hbox */0); +} + +function pp_open_vbox(state, indent) { + pp_open_box_gen(state, indent, /* Pp_vbox */1); +} + +function pp_open_hvbox(state, indent) { + pp_open_box_gen(state, indent, /* Pp_hvbox */2); +} + +function pp_open_hovbox(state, indent) { + pp_open_box_gen(state, indent, /* Pp_hovbox */3); +} + +function pp_open_box(state, indent) { + pp_open_box_gen(state, indent, /* Pp_box */4); +} + +function pp_print_newline(state, param) { + pp_flush_queue(state, true); + Curry._1(state.pp_out_flush, undefined); +} + +function pp_print_flush(state, param) { + pp_flush_queue(state, false); + Curry._1(state.pp_out_flush, undefined); +} + +function pp_force_newline(state, param) { + if (state.pp_curr_depth < state.pp_max_boxes) { + return enqueue_advance(state, { + size: 0, + token: /* Pp_newline */3, + length: 0 + }); + } + +} + +function pp_print_if_newline(state, param) { + if (state.pp_curr_depth < state.pp_max_boxes) { + return enqueue_advance(state, { + size: 0, + token: /* Pp_if_newline */4, + length: 0 + }); + } + +} + +function pp_print_custom_break(state, fits, breaks) { + if (state.pp_curr_depth >= state.pp_max_boxes) { + return ; + } + var size = -state.pp_right_total | 0; + var token = { + TAG: /* Pp_break */1, + fits: fits, + breaks: breaks + }; + var length = (fits[0].length + fits[1] | 0) + fits[2].length | 0; + var elem = { + size: size, + token: token, + length: length + }; + scan_push(state, true, elem); +} + +function pp_print_break(state, width, offset) { + pp_print_custom_break(state, [ + "", + width, + "" + ], [ + "", + offset, + "" + ]); +} + +function pp_print_space(state, param) { + pp_print_break(state, 1, 0); +} + +function pp_print_cut(state, param) { + pp_print_break(state, 0, 0); +} + +function pp_open_tbox(state, param) { + state.pp_curr_depth = state.pp_curr_depth + 1 | 0; + if (state.pp_curr_depth >= state.pp_max_boxes) { + return ; + } + var elem = { + size: 0, + token: { + TAG: /* Pp_tbegin */4, + _0: /* Pp_tbox */{ + _0: { + contents: /* [] */0 + } + } + }, + length: 0 + }; + enqueue_advance(state, elem); +} + +function pp_close_tbox(state, param) { + if (state.pp_curr_depth <= 1) { + return ; + } + if (state.pp_curr_depth >= state.pp_max_boxes) { + return ; + } + var elem = { + size: 0, + token: /* Pp_tend */2, + length: 0 + }; + enqueue_advance(state, elem); + state.pp_curr_depth = state.pp_curr_depth - 1 | 0; +} + +function pp_print_tbreak(state, width, offset) { + if (state.pp_curr_depth >= state.pp_max_boxes) { + return ; + } + var size = -state.pp_right_total | 0; + var elem = { + size: size, + token: { + TAG: /* Pp_tbreak */2, + _0: width, + _1: offset + }, + length: width + }; + scan_push(state, true, elem); +} + +function pp_print_tab(state, param) { + pp_print_tbreak(state, 0, 0); +} + +function pp_set_tab(state, param) { + if (state.pp_curr_depth >= state.pp_max_boxes) { + return ; + } + var elem = { + size: 0, + token: /* Pp_stab */0, + length: 0 + }; + enqueue_advance(state, elem); +} + +function pp_set_max_boxes(state, n) { + if (n > 1) { + state.pp_max_boxes = n; + return ; + } + +} + +function pp_get_max_boxes(state, param) { + return state.pp_max_boxes; +} + +function pp_over_max_boxes(state, param) { + return state.pp_curr_depth === state.pp_max_boxes; +} + +function pp_set_ellipsis_text(state, s) { + state.pp_ellipsis = s; +} + +function pp_get_ellipsis_text(state, param) { + return state.pp_ellipsis; +} + +function pp_limit(n) { + if (n < 1000000010) { + return n; + } else { + return 1000000009; + } +} + +function pp_set_max_indent(state, n) { + if (n > 1) { + var n$1 = state.pp_margin - n | 0; + if (n$1 < 1) { + return ; + } + var n$2 = pp_limit(n$1); + state.pp_min_space_left = n$2; + state.pp_max_indent = state.pp_margin - state.pp_min_space_left | 0; + return pp_rinit(state); + } + +} + +function pp_get_max_indent(state, param) { + return state.pp_max_indent; +} + +function pp_set_margin(state, n) { + if (n < 1) { + return ; + } + var n$1 = pp_limit(n); + state.pp_margin = n$1; + var new_max_indent = state.pp_max_indent <= state.pp_margin ? state.pp_max_indent : Stdlib__Int.max(Stdlib__Int.max(state.pp_margin - state.pp_min_space_left | 0, state.pp_margin / 2 | 0), 1); + pp_set_max_indent(state, new_max_indent); +} + +function validate_geometry(param) { + var max_indent = param.max_indent; + if (max_indent < 2) { + return { + TAG: /* Error */1, + _0: "max_indent < 2" + }; + } else if (param.margin <= max_indent) { + return { + TAG: /* Error */1, + _0: "margin <= max_indent" + }; + } else { + return { + TAG: /* Ok */0, + _0: undefined + }; + } +} + +function check_geometry(geometry) { + var match = validate_geometry(geometry); + if (match.TAG === /* Ok */0) { + return true; + } else { + return false; + } +} + +function pp_get_margin(state, param) { + return state.pp_margin; +} + +function pp_set_full_geometry(state, param) { + pp_set_margin(state, param.margin); + pp_set_max_indent(state, param.max_indent); +} + +function pp_set_geometry(state, max_indent, margin) { + var geometry = { + max_indent: max_indent, + margin: margin + }; + var msg = validate_geometry(geometry); + if (msg.TAG === /* Ok */0) { + return pp_set_full_geometry(state, geometry); + } + throw { + RE_EXN_ID: Stdlib.Invalid_argument, + _1: "Format.pp_set_geometry: " + msg._0, + Error: new Error() + }; +} + +function pp_safe_set_geometry(state, max_indent, margin) { + var geometry = { + max_indent: max_indent, + margin: margin + }; + var _msg = validate_geometry(geometry); + if (_msg.TAG === /* Ok */0) { + return pp_set_full_geometry(state, geometry); + } + +} + +function pp_get_geometry(state, param) { + return { + max_indent: state.pp_max_indent, + margin: state.pp_margin + }; +} + +function pp_update_geometry(state, update) { + var geometry = pp_get_geometry(state, undefined); + pp_set_full_geometry(state, Curry._1(update, geometry)); +} + +function pp_set_formatter_out_functions(state, param) { + state.pp_out_string = param.out_string; + state.pp_out_flush = param.out_flush; + state.pp_out_newline = param.out_newline; + state.pp_out_spaces = param.out_spaces; + state.pp_out_indent = param.out_indent; +} + +function pp_get_formatter_out_functions(state, param) { + return { + out_string: state.pp_out_string, + out_flush: state.pp_out_flush, + out_newline: state.pp_out_newline, + out_spaces: state.pp_out_spaces, + out_indent: state.pp_out_indent + }; +} + +function pp_set_formatter_output_functions(state, f, g) { + state.pp_out_string = f; + state.pp_out_flush = g; +} + +function pp_get_formatter_output_functions(state, param) { + return [ + state.pp_out_string, + state.pp_out_flush + ]; +} + +function display_newline(state, param) { + Curry._3(state.pp_out_string, "\n", 0, 1); +} + +var blank_line = Caml_bytes.bytes_to_string(Stdlib__Bytes.make(80, /* ' ' */32)); + +function display_blanks(state, _n) { + while(true) { + var n = _n; + if (n <= 0) { + return ; + } + if (n <= 80) { + return Curry._3(state.pp_out_string, blank_line, 0, n); + } + Curry._3(state.pp_out_string, blank_line, 0, 80); + _n = n - 80 | 0; + continue ; + }; +} + +function pp_set_formatter_out_channel(state, oc) { + state.pp_out_string = (function (param, param$1, param$2) { + return Stdlib.output_substring(oc, param, param$1, param$2); + }); + state.pp_out_flush = (function (param) { + Caml_io.caml_ml_flush(oc); + }); + state.pp_out_newline = (function (param) { + return display_newline(state, param); + }); + state.pp_out_spaces = (function (param) { + return display_blanks(state, param); + }); + state.pp_out_indent = (function (param) { + return display_blanks(state, param); + }); +} + +function default_pp_mark_open_tag(param) { + if (param.RE_EXN_ID === String_tag) { + return "<" + (param._1 + ">"); + } else { + return ""; + } +} + +function default_pp_mark_close_tag(param) { + if (param.RE_EXN_ID === String_tag) { + return ""); + } else { + return ""; + } +} + +function default_pp_print_open_tag(prim) { + +} + +function default_pp_print_close_tag(prim) { + +} + +function pp_make_formatter(f, g, h, i, j) { + var pp_queue = { + length: 0, + first: /* Nil */0, + last: /* Nil */0 + }; + var sys_tok = { + size: -1, + token: { + TAG: /* Pp_begin */3, + _0: 0, + _1: /* Pp_hovbox */3 + }, + length: 0 + }; + Stdlib__Queue.add(sys_tok, pp_queue); + var scan_stack = { + c: /* [] */0, + len: 0 + }; + initialize_scan_stack(scan_stack); + Stdlib__Stack.push({ + left_total: 1, + queue_elem: sys_tok + }, scan_stack); + return { + pp_scan_stack: scan_stack, + pp_format_stack: { + c: /* [] */0, + len: 0 + }, + pp_tbox_stack: { + c: /* [] */0, + len: 0 + }, + pp_tag_stack: { + c: /* [] */0, + len: 0 + }, + pp_mark_stack: { + c: /* [] */0, + len: 0 + }, + pp_margin: 78, + pp_min_space_left: 10, + pp_max_indent: 68, + pp_space_left: 78, + pp_current_indent: 0, + pp_is_new_line: true, + pp_left_total: 1, + pp_right_total: 1, + pp_curr_depth: 1, + pp_max_boxes: Stdlib.max_int, + pp_ellipsis: ".", + pp_out_string: f, + pp_out_flush: g, + pp_out_newline: h, + pp_out_spaces: i, + pp_out_indent: j, + pp_print_tags: false, + pp_mark_tags: false, + pp_mark_open_tag: default_pp_mark_open_tag, + pp_mark_close_tag: default_pp_mark_close_tag, + pp_print_open_tag: default_pp_print_open_tag, + pp_print_close_tag: default_pp_print_close_tag, + pp_queue: pp_queue + }; +} + +function formatter_of_out_functions(out_funs) { + return pp_make_formatter(out_funs.out_string, out_funs.out_flush, out_funs.out_newline, out_funs.out_spaces, out_funs.out_indent); +} + +function make_formatter(output, flush) { + var ppf = pp_make_formatter(output, flush, (function (prim) { + + }), (function (prim) { + + }), (function (prim) { + + })); + ppf.pp_out_newline = (function (param) { + return display_newline(ppf, param); + }); + ppf.pp_out_spaces = (function (param) { + return display_blanks(ppf, param); + }); + ppf.pp_out_indent = (function (param) { + return display_blanks(ppf, param); + }); + return ppf; +} + +function formatter_of_out_channel(oc) { + return make_formatter((function (param, param$1, param$2) { + return Stdlib.output_substring(oc, param, param$1, param$2); + }), (function (param) { + Caml_io.caml_ml_flush(oc); + })); +} + +function formatter_of_buffer(b) { + return make_formatter((function (param, param$1, param$2) { + return Stdlib__Buffer.add_substring(b, param, param$1, param$2); + }), (function (prim) { + + })); +} + +function pp_make_buffer(param) { + return Stdlib__Buffer.create(512); +} + +var stdbuf = Stdlib__Buffer.create(512); + +var std_formatter = formatter_of_out_channel(Stdlib.stdout); + +var err_formatter = formatter_of_out_channel(Stdlib.stderr); + +var str_formatter = formatter_of_buffer(stdbuf); + +var stdbuf_key = Stdlib__Domain.DLS.new_key(undefined, pp_make_buffer); + +Stdlib__Domain.DLS.set(stdbuf_key, stdbuf); + +var str_formatter_key = Stdlib__Domain.DLS.new_key(undefined, (function (param) { + return formatter_of_buffer(Stdlib__Domain.DLS.get(stdbuf_key)); + })); + +Stdlib__Domain.DLS.set(str_formatter_key, str_formatter); + +function buffered_out_string(key, str, ofs, len) { + Stdlib__Buffer.add_substring(Stdlib__Domain.DLS.get(key), str, ofs, len); +} + +function buffered_out_flush(oc, key, param) { + var buf = Stdlib__Domain.DLS.get(key); + var len = buf.position; + var str = Stdlib__Buffer.contents(buf); + Stdlib.output_substring(oc, str, 0, len); + Caml_io.caml_ml_flush(oc); + buf.position = 0; +} + +var std_buf_key = Stdlib__Domain.DLS.new_key(undefined, (function (param) { + return Stdlib__Buffer.create(512); + })); + +var err_buf_key = Stdlib__Domain.DLS.new_key(undefined, (function (param) { + return Stdlib__Buffer.create(512); + })); + +var std_formatter_key = Stdlib__Domain.DLS.new_key(undefined, (function (param) { + var ppf = pp_make_formatter((function (param, param$1, param$2) { + return buffered_out_string(std_buf_key, param, param$1, param$2); + }), (function (param) { + return buffered_out_flush(Stdlib.stdout, std_buf_key, param); + }), (function (prim) { + + }), (function (prim) { + + }), (function (prim) { + + })); + ppf.pp_out_newline = (function (param) { + return display_newline(ppf, param); + }); + ppf.pp_out_spaces = (function (param) { + return display_blanks(ppf, param); + }); + ppf.pp_out_indent = (function (param) { + return display_blanks(ppf, param); + }); + Stdlib__Domain.at_exit(function (param) { + return pp_print_flush(ppf, param); + }); + return ppf; + })); + +Stdlib__Domain.DLS.set(std_formatter_key, std_formatter); + +var err_formatter_key = Stdlib__Domain.DLS.new_key(undefined, (function (param) { + var ppf = pp_make_formatter((function (param, param$1, param$2) { + return buffered_out_string(err_buf_key, param, param$1, param$2); + }), (function (param) { + return buffered_out_flush(Stdlib.stderr, err_buf_key, param); + }), (function (prim) { + + }), (function (prim) { + + }), (function (prim) { + + })); + ppf.pp_out_newline = (function (param) { + return display_newline(ppf, param); + }); + ppf.pp_out_spaces = (function (param) { + return display_blanks(ppf, param); + }); + ppf.pp_out_indent = (function (param) { + return display_blanks(ppf, param); + }); + Stdlib__Domain.at_exit(function (param) { + return pp_print_flush(ppf, param); + }); + return ppf; + })); + +Stdlib__Domain.DLS.set(err_formatter_key, err_formatter); + +function get_std_formatter(param) { + return Stdlib__Domain.DLS.get(std_formatter_key); +} + +function get_err_formatter(param) { + return Stdlib__Domain.DLS.get(err_formatter_key); +} + +function get_str_formatter(param) { + return Stdlib__Domain.DLS.get(str_formatter_key); +} + +function get_stdbuf(param) { + return Stdlib__Domain.DLS.get(stdbuf_key); +} + +function flush_buffer_formatter(buf, ppf) { + pp_flush_queue(ppf, false); + var s = Stdlib__Buffer.contents(buf); + Stdlib__Buffer.reset(buf); + return s; +} + +function flush_str_formatter(param) { + var stdbuf = Stdlib__Domain.DLS.get(stdbuf_key); + var str_formatter = Stdlib__Domain.DLS.get(str_formatter_key); + return flush_buffer_formatter(stdbuf, str_formatter); +} + +function make_synchronized_formatter(output, flush) { + return Stdlib__Domain.DLS.new_key(undefined, (function (param) { + var buf = Stdlib__Buffer.create(512); + var output$p = function (param, param$1, param$2) { + return Stdlib__Buffer.add_substring(buf, param, param$1, param$2); + }; + var flush$p = function (param) { + Curry._3(output, Stdlib__Buffer.contents(buf), 0, buf.position); + buf.position = 0; + Curry._1(flush, undefined); + }; + return make_formatter(output$p, flush$p); + })); +} + +function synchronized_formatter_of_out_channel(oc) { + return make_synchronized_formatter((function (param, param$1, param$2) { + return Stdlib.output_substring(oc, param, param$1, param$2); + }), (function (param) { + Caml_io.caml_ml_flush(oc); + })); +} + +function make_symbolic_output_buffer(param) { + return { + symbolic_output_contents: /* [] */0 + }; +} + +function clear_symbolic_output_buffer(sob) { + sob.symbolic_output_contents = /* [] */0; +} + +function get_symbolic_output_buffer(sob) { + return Stdlib__List.rev(sob.symbolic_output_contents); +} + +function flush_symbolic_output_buffer(sob) { + var items = Stdlib__List.rev(sob.symbolic_output_contents); + sob.symbolic_output_contents = /* [] */0; + return items; +} + +function add_symbolic_output_item(sob, item) { + sob.symbolic_output_contents = { + hd: item, + tl: sob.symbolic_output_contents + }; +} + +function formatter_of_symbolic_output_buffer(sob) { + var f = function (param, param$1, param$2) { + return add_symbolic_output_item(sob, { + TAG: /* Output_string */0, + _0: Stdlib__String.sub(param, param$1, param$2) + }); + }; + var g = function (param) { + return add_symbolic_output_item(sob, /* Output_flush */0); + }; + var h = function (param) { + return add_symbolic_output_item(sob, /* Output_newline */1); + }; + var i = function (param) { + return add_symbolic_output_item(sob, { + TAG: /* Output_spaces */1, + _0: param + }); + }; + var j = function (param) { + return add_symbolic_output_item(sob, { + TAG: /* Output_indent */2, + _0: param + }); + }; + return pp_make_formatter(f, g, h, i, j); +} + +function open_hbox(v) { + pp_open_hbox(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function open_vbox(v) { + pp_open_vbox(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function open_hvbox(v) { + pp_open_hvbox(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function open_hovbox(v) { + pp_open_hovbox(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function open_box(v) { + pp_open_box(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function close_box(v) { + pp_close_box(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function open_stag(v) { + pp_open_stag(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function close_stag(v) { + pp_close_stag(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function print_as(v, w) { + pp_print_as(Stdlib__Domain.DLS.get(std_formatter_key), v, w); +} + +function print_string(v) { + pp_print_string(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function print_bytes(v) { + pp_print_bytes(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function print_int(v) { + var state = Stdlib__Domain.DLS.get(std_formatter_key); + pp_print_string(state, Caml_format.caml_format_int("%d", v)); +} + +function print_float(v) { + var state = Stdlib__Domain.DLS.get(std_formatter_key); + pp_print_string(state, Stdlib.string_of_float(v)); +} + +function print_char(v) { + pp_print_char(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function print_bool(v) { + var state = Stdlib__Domain.DLS.get(std_formatter_key); + pp_print_string(state, v ? "true" : "false"); +} + +function print_break(v, w) { + pp_print_break(Stdlib__Domain.DLS.get(std_formatter_key), v, w); +} + +function print_cut(v) { + pp_print_break(Stdlib__Domain.DLS.get(std_formatter_key), 0, 0); +} + +function print_space(v) { + pp_print_break(Stdlib__Domain.DLS.get(std_formatter_key), 1, 0); +} + +function force_newline(v) { + pp_force_newline(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function print_flush(v) { + pp_print_flush(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function print_newline(v) { + pp_print_newline(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function print_if_newline(v) { + pp_print_if_newline(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function open_tbox(v) { + pp_open_tbox(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function close_tbox(v) { + pp_close_tbox(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function print_tbreak(v, w) { + pp_print_tbreak(Stdlib__Domain.DLS.get(std_formatter_key), v, w); +} + +function set_tab(v) { + pp_set_tab(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function print_tab(v) { + pp_print_tbreak(Stdlib__Domain.DLS.get(std_formatter_key), 0, 0); +} + +function set_margin(v) { + pp_set_margin(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function get_margin(v) { + return Stdlib__Domain.DLS.get(std_formatter_key).pp_margin; +} + +function set_max_indent(v) { + pp_set_max_indent(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function get_max_indent(v) { + return Stdlib__Domain.DLS.get(std_formatter_key).pp_max_indent; +} + +function set_geometry(max_indent, margin) { + pp_set_geometry(Stdlib__Domain.DLS.get(std_formatter_key), max_indent, margin); +} + +function safe_set_geometry(max_indent, margin) { + pp_safe_set_geometry(Stdlib__Domain.DLS.get(std_formatter_key), max_indent, margin); +} + +function get_geometry(v) { + return pp_get_geometry(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function update_geometry(v) { + pp_update_geometry(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function set_max_boxes(v) { + pp_set_max_boxes(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function get_max_boxes(v) { + return Stdlib__Domain.DLS.get(std_formatter_key).pp_max_boxes; +} + +function over_max_boxes(v) { + return pp_over_max_boxes(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function set_ellipsis_text(v) { + Stdlib__Domain.DLS.get(std_formatter_key).pp_ellipsis = v; +} + +function get_ellipsis_text(v) { + return Stdlib__Domain.DLS.get(std_formatter_key).pp_ellipsis; +} + +function set_formatter_out_channel(v) { + pp_set_formatter_out_channel(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function set_formatter_out_functions(v) { + pp_set_formatter_out_functions(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function get_formatter_out_functions(v) { + return pp_get_formatter_out_functions(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function set_formatter_output_functions(v, w) { + pp_set_formatter_output_functions(Stdlib__Domain.DLS.get(std_formatter_key), v, w); +} + +function get_formatter_output_functions(v) { + return pp_get_formatter_output_functions(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function set_formatter_stag_functions(v) { + pp_set_formatter_stag_functions(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function get_formatter_stag_functions(v) { + return pp_get_formatter_stag_functions(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function set_print_tags(v) { + Stdlib__Domain.DLS.get(std_formatter_key).pp_print_tags = v; +} + +function get_print_tags(v) { + return Stdlib__Domain.DLS.get(std_formatter_key).pp_print_tags; +} + +function set_mark_tags(v) { + Stdlib__Domain.DLS.get(std_formatter_key).pp_mark_tags = v; +} + +function get_mark_tags(v) { + return Stdlib__Domain.DLS.get(std_formatter_key).pp_mark_tags; +} + +function set_tags(v) { + pp_set_tags(Stdlib__Domain.DLS.get(std_formatter_key), v); +} + +function pp_print_iter(pp_sepOpt, iter, pp_v, ppf, v) { + var pp_sep = pp_sepOpt !== undefined ? pp_sepOpt : pp_print_cut; + var is_first = { + contents: true + }; + var pp_v$1 = function (v) { + if (is_first.contents) { + is_first.contents = false; + } else { + Curry._2(pp_sep, ppf, undefined); + } + return Curry._2(pp_v, ppf, v); + }; + return Curry._2(iter, pp_v$1, v); +} + +function pp_print_list(pp_sepOpt, pp_v, ppf, v) { + var pp_sep = pp_sepOpt !== undefined ? pp_sepOpt : pp_print_cut; + pp_print_iter(pp_sep, Stdlib__List.iter, pp_v, ppf, v); +} + +function pp_print_array(pp_sepOpt, pp_v, ppf, v) { + var pp_sep = pp_sepOpt !== undefined ? pp_sepOpt : pp_print_cut; + pp_print_iter(pp_sep, Stdlib__Array.iter, pp_v, ppf, v); +} + +function pp_print_seq(pp_sepOpt, pp_v, ppf, seq) { + var pp_sep = pp_sepOpt !== undefined ? pp_sepOpt : pp_print_cut; + pp_print_iter(pp_sep, Stdlib__Seq.iter, pp_v, ppf, seq); +} + +function pp_print_text(ppf, s) { + var len = s.length; + var left = { + contents: 0 + }; + var right = { + contents: 0 + }; + var flush = function (param) { + pp_print_string(ppf, Stdlib__String.sub(s, left.contents, right.contents - left.contents | 0)); + right.contents = right.contents + 1 | 0; + left.contents = right.contents; + }; + while(right.contents !== len) { + var match = Caml_string.get(s, right.contents); + if (match !== 10) { + if (match !== 32) { + right.contents = right.contents + 1 | 0; + } else { + flush(undefined); + pp_print_break(ppf, 1, 0); + } + } else { + flush(undefined); + pp_force_newline(ppf, undefined); + } + }; + if (left.contents !== len) { + return flush(undefined); + } + +} + +function pp_print_option(noneOpt, pp_v, ppf, param) { + var none = noneOpt !== undefined ? noneOpt : (function (param, param$1) { + + }); + if (param !== undefined) { + return Curry._2(pp_v, ppf, Caml_option.valFromOption(param)); + } else { + return Curry._2(none, ppf, undefined); + } +} + +function pp_print_result(ok, error, ppf, param) { + if (param.TAG === /* Ok */0) { + return Curry._2(ok, ppf, param._0); + } else { + return Curry._2(error, ppf, param._0); + } +} + +function pp_print_either(left, right, ppf, param) { + if (param.TAG === /* Left */0) { + return Curry._2(left, ppf, param._0); + } else { + return Curry._2(right, ppf, param._0); + } +} + +function compute_tag(output, tag_acc) { + var buf = Stdlib__Buffer.create(16); + var ppf = formatter_of_buffer(buf); + Curry._2(output, ppf, tag_acc); + pp_print_flush(ppf, undefined); + var len = buf.position; + if (len < 2) { + return Stdlib__Buffer.contents(buf); + } else { + return Stdlib__Buffer.sub(buf, 1, len - 2 | 0); + } +} + +function output_formatting_lit(ppf, fmting_lit) { + if (typeof fmting_lit === "number") { + switch (fmting_lit) { + case /* Close_box */0 : + return pp_close_box(ppf, undefined); + case /* Close_tag */1 : + return pp_close_stag(ppf, undefined); + case /* FFlush */2 : + return pp_print_flush(ppf, undefined); + case /* Force_newline */3 : + return pp_force_newline(ppf, undefined); + case /* Flush_newline */4 : + return pp_print_newline(ppf, undefined); + case /* Escaped_at */5 : + return pp_print_char(ppf, /* '@' */64); + case /* Escaped_percent */6 : + return pp_print_char(ppf, /* '%' */37); + + } + } else { + switch (fmting_lit.TAG | 0) { + case /* Break */0 : + return pp_print_break(ppf, fmting_lit._1, fmting_lit._2); + case /* Magic_size */1 : + return ; + case /* Scan_indic */2 : + pp_print_char(ppf, /* '@' */64); + return pp_print_char(ppf, fmting_lit._0); + + } + } +} + +function output_acc(ppf, acc) { + var exit = 0; + var p; + var size; + var s; + var p$1; + var size$1; + var c; + if (typeof acc === "number") { + return ; + } + switch (acc.TAG | 0) { + case /* Acc_formatting_lit */0 : + output_acc(ppf, acc._0); + return output_formatting_lit(ppf, acc._1); + case /* Acc_formatting_gen */1 : + var acc$p = acc._1; + var p$2 = acc._0; + if (acc$p.TAG === /* Acc_open_tag */0) { + output_acc(ppf, p$2); + return pp_open_stag(ppf, { + RE_EXN_ID: String_tag, + _1: compute_tag(output_acc, acc$p._0) + }); + } + output_acc(ppf, p$2); + var match = CamlinternalFormat.open_box_of_string(compute_tag(output_acc, acc$p._0)); + return pp_open_box_gen(ppf, match[0], match[1]); + case /* Acc_string_literal */2 : + var p$3 = acc._0; + var exit$1 = 0; + if (typeof p$3 === "number" || p$3.TAG !== /* Acc_formatting_lit */0) { + exit$1 = 3; + } else { + var match$1 = p$3._1; + if (typeof match$1 === "number" || match$1.TAG !== /* Magic_size */1) { + exit$1 = 3; + } else { + p = p$3._0; + size = match$1._1; + s = acc._1; + exit = 1; + } + } + if (exit$1 === 3) { + output_acc(ppf, p$3); + return pp_print_string(ppf, acc._1); + } + break; + case /* Acc_char_literal */3 : + var p$4 = acc._0; + var exit$2 = 0; + if (typeof p$4 === "number" || p$4.TAG !== /* Acc_formatting_lit */0) { + exit$2 = 3; + } else { + var match$2 = p$4._1; + if (typeof match$2 === "number" || match$2.TAG !== /* Magic_size */1) { + exit$2 = 3; + } else { + p$1 = p$4._0; + size$1 = match$2._1; + c = acc._1; + exit = 2; + } + } + if (exit$2 === 3) { + output_acc(ppf, p$4); + return pp_print_char(ppf, acc._1); + } + break; + case /* Acc_data_string */4 : + var p$5 = acc._0; + var exit$3 = 0; + if (typeof p$5 === "number" || p$5.TAG !== /* Acc_formatting_lit */0) { + exit$3 = 3; + } else { + var match$3 = p$5._1; + if (typeof match$3 === "number" || match$3.TAG !== /* Magic_size */1) { + exit$3 = 3; + } else { + p = p$5._0; + size = match$3._1; + s = acc._1; + exit = 1; + } + } + if (exit$3 === 3) { + output_acc(ppf, p$5); + return pp_print_string(ppf, acc._1); + } + break; + case /* Acc_data_char */5 : + var p$6 = acc._0; + var exit$4 = 0; + if (typeof p$6 === "number" || p$6.TAG !== /* Acc_formatting_lit */0) { + exit$4 = 3; + } else { + var match$4 = p$6._1; + if (typeof match$4 === "number" || match$4.TAG !== /* Magic_size */1) { + exit$4 = 3; + } else { + p$1 = p$6._0; + size$1 = match$4._1; + c = acc._1; + exit = 2; + } + } + if (exit$4 === 3) { + output_acc(ppf, p$6); + return pp_print_char(ppf, acc._1); + } + break; + case /* Acc_delay */6 : + output_acc(ppf, acc._0); + return Curry._1(acc._1, ppf); + case /* Acc_flush */7 : + output_acc(ppf, acc._0); + return pp_print_flush(ppf, undefined); + case /* Acc_invalid_arg */8 : + output_acc(ppf, acc._0); + throw { + RE_EXN_ID: "Invalid_argument", + _1: acc._1, + Error: new Error() + }; + + } + switch (exit) { + case 1 : + output_acc(ppf, p); + return pp_print_as_size(ppf, size, s); + case 2 : + output_acc(ppf, p$1); + return pp_print_as_size(ppf, size$1, Caml_bytes.bytes_to_string(Stdlib__Bytes.make(1, c))); + + } +} + +function strput_acc(ppf, acc) { + var exit = 0; + var p; + var size; + var s; + var p$1; + var size$1; + var c; + if (typeof acc === "number") { + return ; + } + switch (acc.TAG | 0) { + case /* Acc_formatting_lit */0 : + strput_acc(ppf, acc._0); + return output_formatting_lit(ppf, acc._1); + case /* Acc_formatting_gen */1 : + var acc$p = acc._1; + var p$2 = acc._0; + if (acc$p.TAG === /* Acc_open_tag */0) { + strput_acc(ppf, p$2); + return pp_open_stag(ppf, { + RE_EXN_ID: String_tag, + _1: compute_tag(strput_acc, acc$p._0) + }); + } + strput_acc(ppf, p$2); + var match = CamlinternalFormat.open_box_of_string(compute_tag(strput_acc, acc$p._0)); + return pp_open_box_gen(ppf, match[0], match[1]); + case /* Acc_string_literal */2 : + var p$3 = acc._0; + var exit$1 = 0; + if (typeof p$3 === "number" || p$3.TAG !== /* Acc_formatting_lit */0) { + exit$1 = 3; + } else { + var match$1 = p$3._1; + if (typeof match$1 === "number" || match$1.TAG !== /* Magic_size */1) { + exit$1 = 3; + } else { + p = p$3._0; + size = match$1._1; + s = acc._1; + exit = 1; + } + } + if (exit$1 === 3) { + strput_acc(ppf, p$3); + return pp_print_string(ppf, acc._1); + } + break; + case /* Acc_char_literal */3 : + var p$4 = acc._0; + var exit$2 = 0; + if (typeof p$4 === "number" || p$4.TAG !== /* Acc_formatting_lit */0) { + exit$2 = 3; + } else { + var match$2 = p$4._1; + if (typeof match$2 === "number" || match$2.TAG !== /* Magic_size */1) { + exit$2 = 3; + } else { + p$1 = p$4._0; + size$1 = match$2._1; + c = acc._1; + exit = 2; + } + } + if (exit$2 === 3) { + strput_acc(ppf, p$4); + return pp_print_char(ppf, acc._1); + } + break; + case /* Acc_data_string */4 : + var p$5 = acc._0; + var exit$3 = 0; + if (typeof p$5 === "number" || p$5.TAG !== /* Acc_formatting_lit */0) { + exit$3 = 3; + } else { + var match$3 = p$5._1; + if (typeof match$3 === "number" || match$3.TAG !== /* Magic_size */1) { + exit$3 = 3; + } else { + p = p$5._0; + size = match$3._1; + s = acc._1; + exit = 1; + } + } + if (exit$3 === 3) { + strput_acc(ppf, p$5); + return pp_print_string(ppf, acc._1); + } + break; + case /* Acc_data_char */5 : + var p$6 = acc._0; + var exit$4 = 0; + if (typeof p$6 === "number" || p$6.TAG !== /* Acc_formatting_lit */0) { + exit$4 = 3; + } else { + var match$4 = p$6._1; + if (typeof match$4 === "number" || match$4.TAG !== /* Magic_size */1) { + exit$4 = 3; + } else { + p$1 = p$6._0; + size$1 = match$4._1; + c = acc._1; + exit = 2; + } + } + if (exit$4 === 3) { + strput_acc(ppf, p$6); + return pp_print_char(ppf, acc._1); + } + break; + case /* Acc_delay */6 : + var p$7 = acc._0; + var exit$5 = 0; + if (typeof p$7 === "number" || p$7.TAG !== /* Acc_formatting_lit */0) { + exit$5 = 3; + } else { + var match$5 = p$7._1; + if (typeof match$5 === "number") { + exit$5 = 3; + } else { + if (match$5.TAG === /* Magic_size */1) { + strput_acc(ppf, p$7._0); + return pp_print_as_size(ppf, match$5._1, Curry._1(acc._1, undefined)); + } + exit$5 = 3; + } + } + if (exit$5 === 3) { + strput_acc(ppf, p$7); + return pp_print_string(ppf, Curry._1(acc._1, undefined)); + } + break; + case /* Acc_flush */7 : + strput_acc(ppf, acc._0); + return pp_print_flush(ppf, undefined); + case /* Acc_invalid_arg */8 : + strput_acc(ppf, acc._0); + throw { + RE_EXN_ID: "Invalid_argument", + _1: acc._1, + Error: new Error() + }; + + } + switch (exit) { + case 1 : + strput_acc(ppf, p); + return pp_print_as_size(ppf, size, s); + case 2 : + strput_acc(ppf, p$1); + return pp_print_as_size(ppf, size$1, Caml_bytes.bytes_to_string(Stdlib__Bytes.make(1, c))); + + } +} + +function kfprintf(k, ppf, param) { + return CamlinternalFormat.make_printf((function (acc) { + output_acc(ppf, acc); + return Curry._1(k, ppf); + }), /* End_of_acc */0, param._0); +} + +function ikfprintf(k, ppf, param) { + return CamlinternalFormat.make_iprintf(k, ppf, param._0); +} + +function ifprintf(_ppf, param) { + return CamlinternalFormat.make_iprintf((function (prim) { + + }), undefined, param._0); +} + +function fprintf(ppf) { + return function (param) { + return kfprintf((function (prim) { + + }), ppf, param); + }; +} + +function printf(param) { + return CamlinternalFormat.make_printf((function (acc) { + output_acc(Stdlib__Domain.DLS.get(std_formatter_key), acc); + }), /* End_of_acc */0, param._0); +} + +function eprintf(param) { + return CamlinternalFormat.make_printf((function (acc) { + output_acc(Stdlib__Domain.DLS.get(err_formatter_key), acc); + }), /* End_of_acc */0, param._0); +} + +function kdprintf(k, param) { + return CamlinternalFormat.make_printf((function (acc) { + return Curry._1(k, (function (ppf) { + output_acc(ppf, acc); + })); + }), /* End_of_acc */0, param._0); +} + +function dprintf(fmt) { + return kdprintf((function (i) { + return i; + }), fmt); +} + +function ksprintf(k, param) { + var b = Stdlib__Buffer.create(512); + var ppf = formatter_of_buffer(b); + var k$1 = function (acc) { + strput_acc(ppf, acc); + return Curry._1(k, flush_buffer_formatter(b, ppf)); + }; + return CamlinternalFormat.make_printf(k$1, /* End_of_acc */0, param._0); +} + +function sprintf(fmt) { + return ksprintf(id, fmt); +} + +function kasprintf(k, param) { + var b = Stdlib__Buffer.create(512); + var ppf = formatter_of_buffer(b); + var k$1 = function (acc) { + output_acc(ppf, acc); + return Curry._1(k, flush_buffer_formatter(b, ppf)); + }; + return CamlinternalFormat.make_printf(k$1, /* End_of_acc */0, param._0); +} + +function asprintf(fmt) { + return kasprintf(id, fmt); +} + +function flush_standard_formatters(param) { + pp_print_flush(Stdlib__Domain.DLS.get(std_formatter_key), undefined); + pp_print_flush(Stdlib__Domain.DLS.get(err_formatter_key), undefined); +} + +Stdlib.at_exit(flush_standard_formatters); + +Stdlib__Domain.before_first_spawn(function (param) { + flush_standard_formatters(undefined); + var fs = pp_get_formatter_out_functions(std_formatter, undefined); + pp_set_formatter_out_functions(std_formatter, { + out_string: (function (param, param$1, param$2) { + return buffered_out_string(std_buf_key, param, param$1, param$2); + }), + out_flush: (function (param) { + return buffered_out_flush(Stdlib.stdout, std_buf_key, param); + }), + out_newline: fs.out_newline, + out_spaces: fs.out_spaces, + out_indent: fs.out_indent + }); + var fs$1 = pp_get_formatter_out_functions(err_formatter, undefined); + pp_set_formatter_out_functions(err_formatter, { + out_string: (function (param, param$1, param$2) { + return buffered_out_string(err_buf_key, param, param$1, param$2); + }), + out_flush: (function (param) { + return buffered_out_flush(Stdlib.stderr, err_buf_key, param); + }), + out_newline: fs$1.out_newline, + out_spaces: fs$1.out_spaces, + out_indent: fs$1.out_indent + }); + }); + +export { + pp_open_box , + open_box , + pp_close_box , + close_box , + pp_open_hbox , + open_hbox , + pp_open_vbox , + open_vbox , + pp_open_hvbox , + open_hvbox , + pp_open_hovbox , + open_hovbox , + pp_print_string , + print_string , + pp_print_bytes , + print_bytes , + pp_print_as , + print_as , + pp_print_int , + print_int , + pp_print_float , + print_float , + pp_print_char , + print_char , + pp_print_bool , + print_bool , + pp_print_space , + print_space , + pp_print_cut , + print_cut , + pp_print_break , + print_break , + pp_print_custom_break , + pp_force_newline , + force_newline , + pp_print_if_newline , + print_if_newline , + pp_print_flush , + print_flush , + pp_print_newline , + print_newline , + pp_set_margin , + set_margin , + pp_get_margin , + get_margin , + pp_set_max_indent , + set_max_indent , + pp_get_max_indent , + get_max_indent , + check_geometry , + pp_set_geometry , + set_geometry , + pp_safe_set_geometry , + safe_set_geometry , + pp_update_geometry , + update_geometry , + pp_get_geometry , + get_geometry , + pp_set_max_boxes , + set_max_boxes , + pp_get_max_boxes , + get_max_boxes , + pp_over_max_boxes , + over_max_boxes , + pp_open_tbox , + open_tbox , + pp_close_tbox , + close_tbox , + pp_set_tab , + set_tab , + pp_print_tab , + print_tab , + pp_print_tbreak , + print_tbreak , + pp_set_ellipsis_text , + set_ellipsis_text , + pp_get_ellipsis_text , + get_ellipsis_text , + String_tag , + pp_open_stag , + open_stag , + pp_close_stag , + close_stag , + pp_set_tags , + set_tags , + pp_set_print_tags , + set_print_tags , + pp_set_mark_tags , + set_mark_tags , + pp_get_print_tags , + get_print_tags , + pp_get_mark_tags , + get_mark_tags , + pp_set_formatter_out_channel , + set_formatter_out_channel , + pp_set_formatter_output_functions , + set_formatter_output_functions , + pp_get_formatter_output_functions , + get_formatter_output_functions , + pp_set_formatter_out_functions , + set_formatter_out_functions , + pp_get_formatter_out_functions , + get_formatter_out_functions , + pp_set_formatter_stag_functions , + set_formatter_stag_functions , + pp_get_formatter_stag_functions , + get_formatter_stag_functions , + formatter_of_out_channel , + synchronized_formatter_of_out_channel , + std_formatter , + get_std_formatter , + err_formatter , + get_err_formatter , + formatter_of_buffer , + stdbuf , + get_stdbuf , + str_formatter , + get_str_formatter , + flush_str_formatter , + make_formatter , + make_synchronized_formatter , + formatter_of_out_functions , + make_symbolic_output_buffer , + clear_symbolic_output_buffer , + get_symbolic_output_buffer , + flush_symbolic_output_buffer , + add_symbolic_output_item , + formatter_of_symbolic_output_buffer , + pp_print_iter , + pp_print_list , + pp_print_array , + pp_print_seq , + pp_print_text , + pp_print_option , + pp_print_result , + pp_print_either , + fprintf , + printf , + eprintf , + sprintf , + asprintf , + dprintf , + ifprintf , + kfprintf , + kdprintf , + ikfprintf , + ksprintf , + kasprintf , +} +/* blank_line Not a pure module */ diff --git a/melange-node-modules/melange/fun.js b/melange-node-modules/melange/fun.js new file mode 100644 index 0000000..e921ab9 --- /dev/null +++ b/melange-node-modules/melange/fun.js @@ -0,0 +1,68 @@ +// Generated by Melange + +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib__Printexc from "./printexc.js"; + +function $$const(c, param) { + return c; +} + +function flip(f, x, y) { + return Curry._2(f, y, x); +} + +function negate(p, v) { + return !Curry._1(p, v); +} + +var Finally_raised = /* @__PURE__ */Caml_exceptions.create("Stdlib.Fun.Finally_raised"); + +Stdlib__Printexc.register_printer(function (param) { + if (param.RE_EXN_ID === Finally_raised) { + return "Fun.Finally_raised: " + Stdlib__Printexc.to_string(param._1); + } + + }); + +function protect($$finally, work) { + var finally_no_exn = function (param) { + try { + return Curry._1($$finally, undefined); + } + catch (raw_e){ + var e = Caml_js_exceptions.internalToOCamlException(raw_e); + var bt; + var exn = { + RE_EXN_ID: Finally_raised, + _1: e + }; + Caml_external_polyfill.resolve("caml_restore_raw_backtrace")(exn, bt); + throw exn; + } + }; + var result; + try { + result = Curry._1(work, undefined); + } + catch (raw_work_exn){ + var work_exn = Caml_js_exceptions.internalToOCamlException(raw_work_exn); + var work_bt; + finally_no_exn(undefined); + Caml_external_polyfill.resolve("caml_restore_raw_backtrace")(work_exn, work_bt); + throw work_exn; + } + finally_no_exn(undefined); + return result; +} + +export { + $$const , + flip , + negate , + protect , + Finally_raised , +} +/* Not a pure module */ diff --git a/melange-node-modules/melange/gc.js b/melange-node-modules/melange/gc.js new file mode 100644 index 0000000..a33af62 --- /dev/null +++ b/melange-node-modules/melange/gc.js @@ -0,0 +1,498 @@ +// Generated by Melange + +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Atomic from "./atomic.js"; +import * as Stdlib__Fun from "./fun.js"; +import * as Stdlib__Printf from "./printf.js"; +import * as Stdlib__Sys from "./sys.js"; + +function eventlog_pause(param) { + +} + +function eventlog_resume(param) { + +} + +function print_stat(c) { + var st = Caml_external_polyfill.resolve("caml_gc_stat")(undefined); + Curry._1(Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "minor_collections: ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "minor_collections: %d\n" + }), st.minor_collections); + Curry._1(Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "major_collections: ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "major_collections: %d\n" + }), st.major_collections); + Curry._1(Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "compactions: ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "compactions: %d\n" + }), st.compactions); + Curry._1(Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "forced_major_collections: ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "forced_major_collections: %d\n" + }), st.forced_major_collections); + Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + }, + _1: "\n" + }); + var l1 = Curry._1(Stdlib__Printf.sprintf(/* Format */{ + _0: { + TAG: /* Float */8, + _0: [ + /* Float_flag_ */0, + /* Float_f */0 + ], + _1: /* No_padding */0, + _2: /* Lit_precision */{ + _0: 0 + }, + _3: /* End_of_format */0 + }, + _1: "%.0f" + }), st.minor_words).length; + Curry._2(Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "minor_words: ", + _1: { + TAG: /* Float */8, + _0: [ + /* Float_flag_ */0, + /* Float_f */0 + ], + _1: { + TAG: /* Arg_padding */1, + _0: /* Right */1 + }, + _2: /* Lit_precision */{ + _0: 0 + }, + _3: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "minor_words: %*.0f\n" + }), l1, st.minor_words); + Curry._2(Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "promoted_words: ", + _1: { + TAG: /* Float */8, + _0: [ + /* Float_flag_ */0, + /* Float_f */0 + ], + _1: { + TAG: /* Arg_padding */1, + _0: /* Right */1 + }, + _2: /* Lit_precision */{ + _0: 0 + }, + _3: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "promoted_words: %*.0f\n" + }), l1, st.promoted_words); + Curry._2(Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "major_words: ", + _1: { + TAG: /* Float */8, + _0: [ + /* Float_flag_ */0, + /* Float_f */0 + ], + _1: { + TAG: /* Arg_padding */1, + _0: /* Right */1 + }, + _2: /* Lit_precision */{ + _0: 0 + }, + _3: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "major_words: %*.0f\n" + }), l1, st.major_words); + Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + }, + _1: "\n" + }); + var l2 = Curry._1(Stdlib__Printf.sprintf(/* Format */{ + _0: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: /* End_of_format */0 + }, + _1: "%d" + }), st.top_heap_words).length; + Curry._2(Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "top_heap_words: ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: { + TAG: /* Arg_padding */1, + _0: /* Right */1 + }, + _2: /* No_precision */0, + _3: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "top_heap_words: %*d\n" + }), l2, st.top_heap_words); + Curry._2(Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "heap_words: ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: { + TAG: /* Arg_padding */1, + _0: /* Right */1 + }, + _2: /* No_precision */0, + _3: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "heap_words: %*d\n" + }), l2, st.heap_words); + Curry._2(Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "live_words: ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: { + TAG: /* Arg_padding */1, + _0: /* Right */1 + }, + _2: /* No_precision */0, + _3: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "live_words: %*d\n" + }), l2, st.live_words); + Curry._2(Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "free_words: ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: { + TAG: /* Arg_padding */1, + _0: /* Right */1 + }, + _2: /* No_precision */0, + _3: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "free_words: %*d\n" + }), l2, st.free_words); + Curry._2(Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "largest_free: ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: { + TAG: /* Arg_padding */1, + _0: /* Right */1 + }, + _2: /* No_precision */0, + _3: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "largest_free: %*d\n" + }), l2, st.largest_free); + Curry._2(Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "fragments: ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: { + TAG: /* Arg_padding */1, + _0: /* Right */1 + }, + _2: /* No_precision */0, + _3: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "fragments: %*d\n" + }), l2, st.fragments); + Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + }, + _1: "\n" + }); + Curry._1(Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "live_blocks: ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "live_blocks: %d\n" + }), st.live_blocks); + Curry._1(Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "free_blocks: ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "free_blocks: %d\n" + }), st.free_blocks); + Curry._1(Stdlib__Printf.fprintf(c, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "heap_chunks: ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "heap_chunks: %d\n" + }), st.heap_chunks); +} + +function allocated_bytes(param) { + var match = Caml_external_polyfill.resolve("caml_gc_counters")(undefined); + return (match[0] + match[2] - match[1]) * (Stdlib__Sys.word_size / 8 | 0); +} + +function call_alarm(arec) { + if (!Stdlib__Atomic.get(arec.active)) { + return ; + } + var $$finally = function (param) { + Caml_external_polyfill.resolve("caml_final_register")(call_alarm, arec); + }; + Stdlib__Fun.protect($$finally, arec.f); +} + +function create_alarm(f) { + var arec_active = Stdlib__Atomic.make(true); + var arec = { + active: arec_active, + f: f + }; + Caml_external_polyfill.resolve("caml_final_register")(call_alarm, arec); + return arec_active; +} + +function delete_alarm(a) { + Stdlib__Atomic.set(a, false); +} + +function null_tracker_alloc_minor(param) { + +} + +function null_tracker_alloc_major(param) { + +} + +function null_tracker_promote(param) { + +} + +function null_tracker_dealloc_minor(param) { + +} + +function null_tracker_dealloc_major(param) { + +} + +var null_tracker = { + alloc_minor: null_tracker_alloc_minor, + alloc_major: null_tracker_alloc_major, + promote: null_tracker_promote, + dealloc_minor: null_tracker_dealloc_minor, + dealloc_major: null_tracker_dealloc_major +}; + +function start(sampling_rate, callstack_sizeOpt, tracker) { + var callstack_size = callstack_sizeOpt !== undefined ? callstack_sizeOpt : Stdlib.max_int; + Caml_external_polyfill.resolve("caml_memprof_start")(sampling_rate, callstack_size, tracker); +} + +function finalise(prim0, prim1) { + return Caml_external_polyfill.resolve("caml_final_register")(prim0, prim1); +} + +function finalise_last(prim0, prim1) { + return Caml_external_polyfill.resolve("caml_final_register_called_without_value")(prim0, prim1); +} + +function finalise_release(prim) { + return Caml_external_polyfill.resolve("caml_final_release")(prim); +} + +function Memprof_stop(prim) { + return Caml_external_polyfill.resolve("caml_memprof_stop")(prim); +} + +var Memprof = { + null_tracker: null_tracker, + start: start, + stop: Memprof_stop +}; + +export { + print_stat , + allocated_bytes , + finalise , + finalise_last , + finalise_release , + create_alarm , + delete_alarm , + eventlog_pause , + eventlog_resume , + Memprof , +} +/* Stdlib__Fun Not a pure module */ diff --git a/melange-node-modules/melange/hashtbl.js b/melange-node-modules/melange/hashtbl.js new file mode 100644 index 0000000..b98b902 --- /dev/null +++ b/melange-node-modules/melange/hashtbl.js @@ -0,0 +1,1337 @@ +// Generated by Melange + +import * as Caml_array from "melange.js/caml_array.js"; +import * as Caml_hash from "melange.js/caml_hash.js"; +import * as Caml_obj from "melange.js/caml_obj.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Array from "./array.js"; +import * as Stdlib__Atomic from "./atomic.js"; +import * as Stdlib__Domain from "./domain.js"; +import * as Stdlib__Int from "./int.js"; +import * as Stdlib__Random from "./random.js"; +import * as Stdlib__Seq from "./seq.js"; + +function flip_ongoing_traversal(h) { + h.initial_size = -h.initial_size | 0; +} + +var randomized = Stdlib__Atomic.make(false); + +function randomize(param) { + Stdlib__Atomic.set(randomized, true); +} + +function is_randomized(param) { + return Stdlib__Atomic.get(randomized); +} + +var prng_key = Stdlib__Domain.DLS.new_key(undefined, Stdlib__Random.State.make_self_init); + +function power_2_above(_x, n) { + while(true) { + var x = _x; + if (x >= n) { + return x; + } + if ((x << 1) < x) { + return x; + } + _x = (x << 1); + continue ; + }; +} + +function create(randomOpt, initial_size) { + var random = randomOpt !== undefined ? randomOpt : Stdlib__Atomic.get(randomized); + var s = power_2_above(16, initial_size); + var seed = random ? Stdlib__Random.State.bits(Stdlib__Domain.DLS.get(prng_key)) : 0; + return { + size: 0, + data: Caml_array.make(s, /* Empty */0), + seed: seed, + initial_size: s + }; +} + +function clear(h) { + if (h.size > 0) { + h.size = 0; + return Stdlib__Array.fill(h.data, 0, h.data.length, /* Empty */0); + } + +} + +function reset(h) { + var len = h.data.length; + if (len === Stdlib.abs(h.initial_size)) { + return clear(h); + } else { + h.size = 0; + h.data = Caml_array.make(Stdlib.abs(h.initial_size), /* Empty */0); + return ; + } +} + +function copy_bucketlist(param) { + if (!param) { + return /* Empty */0; + } + var key = param.key; + var data = param.data; + var next = param.next; + var loop = function (_prec, _param) { + while(true) { + var param = _param; + var prec = _prec; + if (!param) { + return ; + } + var key = param.key; + var data = param.data; + var next = param.next; + var r = /* Cons */{ + key: key, + data: data, + next: next + }; + if (prec) { + prec.next = r; + } else { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "hashtbl.cppo.ml", + 110, + 23 + ], + Error: new Error() + }; + } + _param = next; + _prec = r; + continue ; + }; + }; + var r = /* Cons */{ + key: key, + data: data, + next: next + }; + loop(r, next); + return r; +} + +function copy(h) { + return { + size: h.size, + data: Stdlib__Array.map(copy_bucketlist, h.data), + seed: h.seed, + initial_size: h.initial_size + }; +} + +function length(h) { + return h.size; +} + +function insert_all_buckets(indexfun, inplace, odata, ndata) { + var nsize = ndata.length; + var ndata_tail = Caml_array.make(nsize, /* Empty */0); + var insert_bucket = function (_cell) { + while(true) { + var cell = _cell; + if (!cell) { + return ; + } + var key = cell.key; + var data = cell.data; + var next = cell.next; + var cell$1 = inplace ? cell : /* Cons */({ + key: key, + data: data, + next: /* Empty */0 + }); + var nidx = Curry._1(indexfun, key); + var tail = Caml_array.get(ndata_tail, nidx); + if (tail) { + tail.next = cell$1; + } else { + Caml_array.set(ndata, nidx, cell$1); + } + Caml_array.set(ndata_tail, nidx, cell$1); + _cell = next; + continue ; + }; + }; + for(var i = 0 ,i_finish = odata.length; i < i_finish; ++i){ + insert_bucket(Caml_array.get(odata, i)); + } + if (!inplace) { + return ; + } + for(var i$1 = 0; i$1 < nsize; ++i$1){ + var tail = Caml_array.get(ndata_tail, i$1); + if (tail) { + tail.next = /* Empty */0; + } + + } +} + +function resize(indexfun, h) { + var odata = h.data; + var osize = odata.length; + var nsize = (osize << 1); + if (nsize < osize) { + return ; + } + var ndata = Caml_array.make(nsize, /* Empty */0); + var inplace = h.initial_size >= 0; + h.data = ndata; + insert_all_buckets(Curry._1(indexfun, h), inplace, odata, ndata); +} + +function iter(f, h) { + var do_bucket = function (_param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + var key = param.key; + var data = param.data; + var next = param.next; + Curry._2(f, key, data); + _param = next; + continue ; + }; + }; + var old_trav = h.initial_size < 0; + if (!old_trav) { + flip_ongoing_traversal(h); + } + try { + var d = h.data; + for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ + do_bucket(Caml_array.get(d, i)); + } + if (!old_trav) { + return flip_ongoing_traversal(h); + } else { + return ; + } + } + catch (exn){ + if (old_trav) { + throw exn; + } + flip_ongoing_traversal(h); + throw exn; + } +} + +function filter_map_inplace_bucket(f, h, i, _prec, _slot) { + while(true) { + var slot = _slot; + var prec = _prec; + if (!slot) { + if (prec) { + prec.next = /* Empty */0; + return ; + } else { + return Caml_array.set(h.data, i, /* Empty */0); + } + } + var key = slot.key; + var data = slot.data; + var next = slot.next; + var data$1 = Curry._2(f, key, data); + if (data$1 !== undefined) { + if (prec) { + prec.next = slot; + } else { + Caml_array.set(h.data, i, slot); + } + slot.data = Caml_option.valFromOption(data$1); + _slot = next; + _prec = slot; + continue ; + } + h.size = h.size - 1 | 0; + _slot = next; + continue ; + }; +} + +function filter_map_inplace(f, h) { + var d = h.data; + var old_trav = h.initial_size < 0; + if (!old_trav) { + flip_ongoing_traversal(h); + } + try { + for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ + filter_map_inplace_bucket(f, h, i, /* Empty */0, Caml_array.get(h.data, i)); + } + if (!old_trav) { + return flip_ongoing_traversal(h); + } else { + return ; + } + } + catch (exn){ + if (old_trav) { + throw exn; + } + flip_ongoing_traversal(h); + throw exn; + } +} + +function fold(f, h, init) { + var do_bucket = function (_b, _accu) { + while(true) { + var accu = _accu; + var b = _b; + if (!b) { + return accu; + } + var key = b.key; + var data = b.data; + var next = b.next; + _accu = Curry._3(f, key, data, accu); + _b = next; + continue ; + }; + }; + var old_trav = h.initial_size < 0; + if (!old_trav) { + flip_ongoing_traversal(h); + } + try { + var d = h.data; + var accu = init; + for(var i = 0 ,i_finish = d.length; i < i_finish; ++i){ + accu = do_bucket(Caml_array.get(d, i), accu); + } + if (!old_trav) { + flip_ongoing_traversal(h); + } + return accu; + } + catch (exn){ + if (old_trav) { + throw exn; + } + flip_ongoing_traversal(h); + throw exn; + } +} + +function bucket_length(_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + var next = param.next; + _param = next; + _accu = accu + 1 | 0; + continue ; + }; +} + +function stats(h) { + var mbl = Stdlib__Array.fold_left((function (m, b) { + return Stdlib__Int.max(m, bucket_length(0, b)); + }), 0, h.data); + var histo = Caml_array.make(mbl + 1 | 0, 0); + Stdlib__Array.iter((function (b) { + var l = bucket_length(0, b); + Caml_array.set(histo, l, Caml_array.get(histo, l) + 1 | 0); + }), h.data); + return { + num_bindings: h.size, + num_buckets: h.data.length, + max_bucket_length: mbl, + bucket_histogram: histo + }; +} + +function to_seq(tbl) { + var tbl_data = tbl.data; + var aux = function (_i, _buck, _param) { + while(true) { + var buck = _buck; + var i = _i; + if (buck) { + var key = buck.key; + var data = buck.data; + var next = buck.next; + return /* Cons */{ + _0: [ + key, + data + ], + _1: (function(i,next){ + return function (param) { + return aux(i, next, param); + } + }(i,next)) + }; + } + if (i === tbl_data.length) { + return /* Nil */0; + } + _param = undefined; + _buck = Caml_array.get(tbl_data, i); + _i = i + 1 | 0; + continue ; + }; + }; + return function (param) { + return aux(0, /* Empty */0, param); + }; +} + +function to_seq_keys(m) { + var partial_arg = to_seq(m); + return function (param) { + return Stdlib__Seq.map((function (prim) { + return prim[0]; + }), partial_arg, param); + }; +} + +function to_seq_values(m) { + var partial_arg = to_seq(m); + return function (param) { + return Stdlib__Seq.map((function (prim) { + return prim[1]; + }), partial_arg, param); + }; +} + +function MakeSeeded(H) { + var key_index = function (h, key) { + return Curry._2(H.seeded_hash, h.seed, key) & (h.data.length - 1 | 0); + }; + var add = function (h, key, data) { + var i = key_index(h, key); + var bucket = /* Cons */{ + key: key, + data: data, + next: Caml_array.get(h.data, i) + }; + Caml_array.set(h.data, i, bucket); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(key_index, h); + } + + }; + var remove = function (h, key) { + var i = key_index(h, key); + var _prec = /* Empty */0; + var _c = Caml_array.get(h.data, i); + while(true) { + var c = _c; + var prec = _prec; + if (!c) { + return ; + } + var k = c.key; + var next = c.next; + if (Curry._2(H.equal, k, key)) { + h.size = h.size - 1 | 0; + if (prec) { + prec.next = next; + return ; + } else { + return Caml_array.set(h.data, i, next); + } + } + _c = next; + _prec = c; + continue ; + }; + }; + var find = function (h, key) { + var match = Caml_array.get(h.data, key_index(h, key)); + if (match) { + var k1 = match.key; + var d1 = match.data; + var next1 = match.next; + if (Curry._2(H.equal, key, k1)) { + return d1; + } + if (next1) { + var k2 = next1.key; + var d2 = next1.data; + var next2 = next1.next; + if (Curry._2(H.equal, key, k2)) { + return d2; + } + if (next2) { + var k3 = next2.key; + var d3 = next2.data; + var next3 = next2.next; + if (Curry._2(H.equal, key, k3)) { + return d3; + } else { + var _param = next3; + while(true) { + var param = _param; + if (param) { + var k = param.key; + var data = param.data; + var next = param.next; + if (Curry._2(H.equal, key, k)) { + return data; + } + _param = next; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + } + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + var find_opt = function (h, key) { + var match = Caml_array.get(h.data, key_index(h, key)); + if (!match) { + return ; + } + var k1 = match.key; + var d1 = match.data; + var next1 = match.next; + if (Curry._2(H.equal, key, k1)) { + return Caml_option.some(d1); + } + if (!next1) { + return ; + } + var k2 = next1.key; + var d2 = next1.data; + var next2 = next1.next; + if (Curry._2(H.equal, key, k2)) { + return Caml_option.some(d2); + } + if (!next2) { + return ; + } + var k3 = next2.key; + var d3 = next2.data; + var next3 = next2.next; + if (Curry._2(H.equal, key, k3)) { + return Caml_option.some(d3); + } else { + var _param = next3; + while(true) { + var param = _param; + if (!param) { + return ; + } + var k = param.key; + var data = param.data; + var next = param.next; + if (Curry._2(H.equal, key, k)) { + return Caml_option.some(data); + } + _param = next; + continue ; + }; + } + }; + var find_all = function (h, key) { + var find_in_bucket_dps = function (_dst, _offset, _param) { + while(true) { + var dst = _dst; + var offset = _offset; + var param = _param; + if (!param) { + dst[offset] = /* [] */0; + return ; + } + var k = param.key; + var d = param.data; + var next = param.next; + if (Curry._2(H.equal, k, key)) { + var block = { + hd: d, + tl: 24029 + }; + dst[offset] = block; + _param = next; + _offset = "tl"; + _dst = block; + continue ; + } + _param = next; + continue ; + }; + }; + var _param = Caml_array.get(h.data, key_index(h, key)); + while(true) { + var param = _param; + if (!param) { + return /* [] */0; + } + var k = param.key; + var d = param.data; + var next = param.next; + if (Curry._2(H.equal, k, key)) { + var block = { + hd: d, + tl: 24029 + }; + find_in_bucket_dps(block, "tl", next); + return block; + } + _param = next; + continue ; + }; + }; + var replace_bucket = function (key, data, _param) { + while(true) { + var param = _param; + if (!param) { + return true; + } + var k = param.key; + var next = param.next; + if (Curry._2(H.equal, k, key)) { + param.key = key; + param.data = data; + return false; + } + _param = next; + continue ; + }; + }; + var replace = function (h, key, data) { + var i = key_index(h, key); + var l = Caml_array.get(h.data, i); + if (replace_bucket(key, data, l)) { + Caml_array.set(h.data, i, /* Cons */{ + key: key, + data: data, + next: l + }); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(key_index, h); + } else { + return ; + } + } + + }; + var mem = function (h, key) { + var _param = Caml_array.get(h.data, key_index(h, key)); + while(true) { + var param = _param; + if (!param) { + return false; + } + var k = param.key; + var next = param.next; + if (Curry._2(H.equal, k, key)) { + return true; + } + _param = next; + continue ; + }; + }; + var add_seq = function (tbl, i) { + Stdlib__Seq.iter((function (param) { + add(tbl, param[0], param[1]); + }), i); + }; + var replace_seq = function (tbl, i) { + Stdlib__Seq.iter((function (param) { + replace(tbl, param[0], param[1]); + }), i); + }; + var of_seq = function (i) { + var tbl = create(undefined, 16); + replace_seq(tbl, i); + return tbl; + }; + return { + create: create, + clear: clear, + reset: reset, + copy: copy, + add: add, + remove: remove, + find: find, + find_opt: find_opt, + find_all: find_all, + replace: replace, + mem: mem, + iter: iter, + filter_map_inplace: filter_map_inplace, + fold: fold, + length: length, + stats: stats, + to_seq: to_seq, + to_seq_keys: to_seq_keys, + to_seq_values: to_seq_values, + add_seq: add_seq, + replace_seq: replace_seq, + of_seq: of_seq + }; +} + +function Make(H) { + var equal = H.equal; + var key_index = function (h, key) { + return Curry._1(H.hash, key) & (h.data.length - 1 | 0); + }; + var add = function (h, key, data) { + var i = key_index(h, key); + var bucket = /* Cons */{ + key: key, + data: data, + next: Caml_array.get(h.data, i) + }; + Caml_array.set(h.data, i, bucket); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(key_index, h); + } + + }; + var remove = function (h, key) { + var i = key_index(h, key); + var _prec = /* Empty */0; + var _c = Caml_array.get(h.data, i); + while(true) { + var c = _c; + var prec = _prec; + if (!c) { + return ; + } + var k = c.key; + var next = c.next; + if (Curry._2(equal, k, key)) { + h.size = h.size - 1 | 0; + if (prec) { + prec.next = next; + return ; + } else { + return Caml_array.set(h.data, i, next); + } + } + _c = next; + _prec = c; + continue ; + }; + }; + var find = function (h, key) { + var match = Caml_array.get(h.data, key_index(h, key)); + if (match) { + var k1 = match.key; + var d1 = match.data; + var next1 = match.next; + if (Curry._2(equal, key, k1)) { + return d1; + } + if (next1) { + var k2 = next1.key; + var d2 = next1.data; + var next2 = next1.next; + if (Curry._2(equal, key, k2)) { + return d2; + } + if (next2) { + var k3 = next2.key; + var d3 = next2.data; + var next3 = next2.next; + if (Curry._2(equal, key, k3)) { + return d3; + } else { + var _param = next3; + while(true) { + var param = _param; + if (param) { + var k = param.key; + var data = param.data; + var next = param.next; + if (Curry._2(equal, key, k)) { + return data; + } + _param = next; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + } + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + var find_opt = function (h, key) { + var match = Caml_array.get(h.data, key_index(h, key)); + if (!match) { + return ; + } + var k1 = match.key; + var d1 = match.data; + var next1 = match.next; + if (Curry._2(equal, key, k1)) { + return Caml_option.some(d1); + } + if (!next1) { + return ; + } + var k2 = next1.key; + var d2 = next1.data; + var next2 = next1.next; + if (Curry._2(equal, key, k2)) { + return Caml_option.some(d2); + } + if (!next2) { + return ; + } + var k3 = next2.key; + var d3 = next2.data; + var next3 = next2.next; + if (Curry._2(equal, key, k3)) { + return Caml_option.some(d3); + } else { + var _param = next3; + while(true) { + var param = _param; + if (!param) { + return ; + } + var k = param.key; + var data = param.data; + var next = param.next; + if (Curry._2(equal, key, k)) { + return Caml_option.some(data); + } + _param = next; + continue ; + }; + } + }; + var find_all = function (h, key) { + var find_in_bucket_dps = function (_dst, _offset, _param) { + while(true) { + var param = _param; + var offset = _offset; + var dst = _dst; + if (!param) { + dst[offset] = /* [] */0; + return ; + } + var k = param.key; + var d = param.data; + var next = param.next; + if (Curry._2(equal, k, key)) { + var block = { + hd: d, + tl: 24029 + }; + dst[offset] = block; + _param = next; + _offset = "tl"; + _dst = block; + continue ; + } + _param = next; + continue ; + }; + }; + var _param = Caml_array.get(h.data, key_index(h, key)); + while(true) { + var param = _param; + if (!param) { + return /* [] */0; + } + var k = param.key; + var d = param.data; + var next = param.next; + if (Curry._2(equal, k, key)) { + var block = { + hd: d, + tl: 24029 + }; + find_in_bucket_dps(block, "tl", next); + return block; + } + _param = next; + continue ; + }; + }; + var replace_bucket = function (key, data, _param) { + while(true) { + var param = _param; + if (!param) { + return true; + } + var k = param.key; + var next = param.next; + if (Curry._2(equal, k, key)) { + param.key = key; + param.data = data; + return false; + } + _param = next; + continue ; + }; + }; + var replace = function (h, key, data) { + var i = key_index(h, key); + var l = Caml_array.get(h.data, i); + if (replace_bucket(key, data, l)) { + Caml_array.set(h.data, i, /* Cons */{ + key: key, + data: data, + next: l + }); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(key_index, h); + } else { + return ; + } + } + + }; + var mem = function (h, key) { + var _param = Caml_array.get(h.data, key_index(h, key)); + while(true) { + var param = _param; + if (!param) { + return false; + } + var k = param.key; + var next = param.next; + if (Curry._2(equal, k, key)) { + return true; + } + _param = next; + continue ; + }; + }; + var add_seq = function (tbl, i) { + Stdlib__Seq.iter((function (param) { + add(tbl, param[0], param[1]); + }), i); + }; + var replace_seq = function (tbl, i) { + Stdlib__Seq.iter((function (param) { + replace(tbl, param[0], param[1]); + }), i); + }; + var create$1 = function (sz) { + return create(false, sz); + }; + var of_seq = function (i) { + var tbl = create(false, 16); + replace_seq(tbl, i); + return tbl; + }; + return { + create: create$1, + clear: clear, + reset: reset, + copy: copy, + add: add, + remove: remove, + find: find, + find_opt: find_opt, + find_all: find_all, + replace: replace, + mem: mem, + iter: iter, + filter_map_inplace: filter_map_inplace, + fold: fold, + length: length, + stats: stats, + to_seq: to_seq, + to_seq_keys: to_seq_keys, + to_seq_values: to_seq_values, + add_seq: add_seq, + replace_seq: replace_seq, + of_seq: of_seq + }; +} + +function hash(x) { + return Caml_hash.caml_hash(10, 100, 0, x); +} + +function hash_param(n1, n2, x) { + return Caml_hash.caml_hash(n1, n2, 0, x); +} + +function seeded_hash(seed, x) { + return Caml_hash.caml_hash(10, 100, seed, x); +} + +function key_index(h, key) { + return Caml_hash.caml_hash(10, 100, h.seed, key) & (h.data.length - 1 | 0); +} + +function add(h, key, data) { + var i = key_index(h, key); + var bucket = /* Cons */{ + key: key, + data: data, + next: Caml_array.get(h.data, i) + }; + Caml_array.set(h.data, i, bucket); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(key_index, h); + } + +} + +function remove(h, key) { + var i = key_index(h, key); + var _prec = /* Empty */0; + var _c = Caml_array.get(h.data, i); + while(true) { + var c = _c; + var prec = _prec; + if (!c) { + return ; + } + var k = c.key; + var next = c.next; + if (Caml_obj.caml_equal(k, key)) { + h.size = h.size - 1 | 0; + if (prec) { + prec.next = next; + return ; + } else { + return Caml_array.set(h.data, i, next); + } + } + _c = next; + _prec = c; + continue ; + }; +} + +function find(h, key) { + var match = Caml_array.get(h.data, key_index(h, key)); + if (match) { + var k1 = match.key; + var d1 = match.data; + var next1 = match.next; + if (Caml_obj.caml_equal(key, k1)) { + return d1; + } + if (next1) { + var k2 = next1.key; + var d2 = next1.data; + var next2 = next1.next; + if (Caml_obj.caml_equal(key, k2)) { + return d2; + } + if (next2) { + var k3 = next2.key; + var d3 = next2.data; + var next3 = next2.next; + if (Caml_obj.caml_equal(key, k3)) { + return d3; + } else { + var _param = next3; + while(true) { + var param = _param; + if (param) { + var k = param.key; + var data = param.data; + var next = param.next; + if (Caml_obj.caml_equal(key, k)) { + return data; + } + _param = next; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + } + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; +} + +function find_opt(h, key) { + var match = Caml_array.get(h.data, key_index(h, key)); + if (!match) { + return ; + } + var k1 = match.key; + var d1 = match.data; + var next1 = match.next; + if (Caml_obj.caml_equal(key, k1)) { + return Caml_option.some(d1); + } + if (!next1) { + return ; + } + var k2 = next1.key; + var d2 = next1.data; + var next2 = next1.next; + if (Caml_obj.caml_equal(key, k2)) { + return Caml_option.some(d2); + } + if (!next2) { + return ; + } + var k3 = next2.key; + var d3 = next2.data; + var next3 = next2.next; + if (Caml_obj.caml_equal(key, k3)) { + return Caml_option.some(d3); + } else { + var _param = next3; + while(true) { + var param = _param; + if (!param) { + return ; + } + var k = param.key; + var data = param.data; + var next = param.next; + if (Caml_obj.caml_equal(key, k)) { + return Caml_option.some(data); + } + _param = next; + continue ; + }; + } +} + +function find_all(h, key) { + var find_in_bucket_dps = function (_dst, _offset, _param) { + while(true) { + var dst = _dst; + var offset = _offset; + var param = _param; + if (!param) { + dst[offset] = /* [] */0; + return ; + } + var k = param.key; + var data = param.data; + var next = param.next; + if (Caml_obj.caml_equal(k, key)) { + var block = { + hd: data, + tl: 24029 + }; + dst[offset] = block; + _param = next; + _offset = "tl"; + _dst = block; + continue ; + } + _param = next; + continue ; + }; + }; + var _param = Caml_array.get(h.data, key_index(h, key)); + while(true) { + var param = _param; + if (!param) { + return /* [] */0; + } + var k = param.key; + var data = param.data; + var next = param.next; + if (Caml_obj.caml_equal(k, key)) { + var block = { + hd: data, + tl: 24029 + }; + find_in_bucket_dps(block, "tl", next); + return block; + } + _param = next; + continue ; + }; +} + +function replace_bucket(key, data, _param) { + while(true) { + var param = _param; + if (!param) { + return true; + } + var k = param.key; + var next = param.next; + if (Caml_obj.caml_equal(k, key)) { + param.key = key; + param.data = data; + return false; + } + _param = next; + continue ; + }; +} + +function replace(h, key, data) { + var i = key_index(h, key); + var l = Caml_array.get(h.data, i); + if (replace_bucket(key, data, l)) { + Caml_array.set(h.data, i, /* Cons */{ + key: key, + data: data, + next: l + }); + h.size = h.size + 1 | 0; + if (h.size > (h.data.length << 1)) { + return resize(key_index, h); + } else { + return ; + } + } + +} + +function mem(h, key) { + var _param = Caml_array.get(h.data, key_index(h, key)); + while(true) { + var param = _param; + if (!param) { + return false; + } + var k = param.key; + var next = param.next; + if (Caml_obj.caml_equal(k, key)) { + return true; + } + _param = next; + continue ; + }; +} + +function add_seq(tbl, i) { + Stdlib__Seq.iter((function (param) { + add(tbl, param[0], param[1]); + }), i); +} + +function replace_seq(tbl, i) { + Stdlib__Seq.iter((function (param) { + replace(tbl, param[0], param[1]); + }), i); +} + +function of_seq(i) { + var tbl = create(undefined, 16); + replace_seq(tbl, i); + return tbl; +} + +function rebuild(randomOpt, h) { + var random = randomOpt !== undefined ? randomOpt : Stdlib__Atomic.get(randomized); + var s = power_2_above(16, h.data.length); + var seed = random ? Stdlib__Random.State.bits(Stdlib__Domain.DLS.get(prng_key)) : h.seed; + var h$p = { + size: h.size, + data: Caml_array.make(s, /* Empty */0), + seed: seed, + initial_size: h.initial_size + }; + insert_all_buckets((function (param) { + return key_index(h$p, param); + }), false, h.data, h$p.data); + return h$p; +} + +var seeded_hash_param = Caml_hash.caml_hash; + +export { + create , + clear , + reset , + copy , + add , + find , + find_opt , + find_all , + mem , + remove , + replace , + iter , + filter_map_inplace , + fold , + length , + randomize , + is_randomized , + rebuild , + stats , + to_seq , + to_seq_keys , + to_seq_values , + add_seq , + replace_seq , + of_seq , + Make , + MakeSeeded , + hash , + seeded_hash , + hash_param , + seeded_hash_param , +} +/* randomized Not a pure module */ diff --git a/melange-node-modules/melange/in_channel.js b/melange-node-modules/melange/in_channel.js new file mode 100644 index 0000000..97d82dd --- /dev/null +++ b/melange-node-modules/melange/in_channel.js @@ -0,0 +1,327 @@ +// Generated by Melange + +import * as Caml_bytes from "melange.js/caml_bytes.js"; +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Bytes from "./bytes.js"; +import * as Stdlib__Fun from "./fun.js"; +import * as Stdlib__Sys from "./sys.js"; + +function with_open(openfun, s, f) { + var ic = Curry._1(openfun, s); + return Stdlib__Fun.protect((function (param) { + Stdlib.close_in_noerr(ic); + }), (function (param) { + return Curry._1(f, ic); + })); +} + +function with_open_bin(s, f) { + return with_open(Stdlib.open_in_bin, s, f); +} + +function with_open_text(s, f) { + return with_open(Stdlib.open_in, s, f); +} + +function with_open_gen(flags, perm, s, f) { + return with_open((function (param) { + return Stdlib.open_in_gen(flags, perm, param); + }), s, f); +} + +var seek = Stdlib.LargeFile.seek_in; + +var pos = Stdlib.LargeFile.pos_in; + +var length = Stdlib.LargeFile.in_channel_length; + +function input_char(ic) { + var c; + try { + c = Caml_external_polyfill.resolve("caml_ml_input_char")(ic); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.End_of_file) { + return ; + } + throw exn; + } + return c; +} + +function input_byte(ic) { + var n; + try { + n = Caml_external_polyfill.resolve("caml_ml_input_char")(ic); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.End_of_file) { + return ; + } + throw exn; + } + return n; +} + +function input_line(ic) { + var s; + try { + s = Stdlib.input_line(ic); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.End_of_file) { + return ; + } + throw exn; + } + return s; +} + +function really_input(ic, buf, pos, len) { + try { + Stdlib.really_input(ic, buf, pos, len); + return Caml_option.some(undefined); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.End_of_file) { + return ; + } + throw exn; + } +} + +function really_input_string(ic, len) { + var s; + try { + s = Stdlib.really_input_string(ic, len); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.End_of_file) { + return ; + } + throw exn; + } + return s; +} + +function read_upto(ic, buf, ofs, len) { + var loop = function (_ofs, _len) { + while(true) { + var len = _len; + var ofs = _ofs; + if (len === 0) { + return ofs; + } + var r = Stdlib.input(ic, buf, ofs, len); + if (r === 0) { + return ofs; + } + _len = len - r | 0; + _ofs = ofs + r | 0; + continue ; + }; + }; + return loop(ofs, len) - ofs | 0; +} + +function ensure(buf, ofs, n) { + var len = buf.length; + if (len >= (ofs + n | 0)) { + return buf; + } + var new_len = len; + while(new_len < (ofs + n | 0)) { + new_len = (new_len << 1) + 1 | 0; + }; + var new_len$1 = new_len; + var new_len$2; + if (new_len$1 <= Stdlib__Sys.max_string_length) { + new_len$2 = new_len$1; + } else if (ofs < Stdlib__Sys.max_string_length) { + new_len$2 = Stdlib__Sys.max_string_length; + } else { + throw { + RE_EXN_ID: "Failure", + _1: "In_channel.input_all: channel content is larger than maximum string length", + Error: new Error() + }; + } + var new_buf = Caml_bytes.caml_create_bytes(new_len$2); + Stdlib__Bytes.blit(buf, 0, new_buf, 0, ofs); + return new_buf; +} + +function input_all(ic) { + var initial_size; + try { + initial_size = Caml_external_polyfill.resolve("caml_ml_channel_size")(ic) - Caml_external_polyfill.resolve("caml_ml_pos_in")(ic) | 0; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Sys_error) { + initial_size = -1; + } else { + throw exn; + } + } + var initial_size$1 = initial_size < 0 ? 65536 : initial_size; + var initial_size$2 = initial_size$1 <= Stdlib__Sys.max_string_length ? initial_size$1 : Stdlib__Sys.max_string_length; + var buf = Caml_bytes.caml_create_bytes(initial_size$2); + var nread = read_upto(ic, buf, 0, initial_size$2); + if (nread < initial_size$2) { + return Stdlib__Bytes.sub_string(buf, 0, nread); + } + var c; + try { + c = Caml_external_polyfill.resolve("caml_ml_input_char")(ic); + } + catch (raw_exn$1){ + var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); + if (exn$1.RE_EXN_ID === Stdlib.End_of_file) { + return Caml_bytes.bytes_to_string(buf); + } + throw exn$1; + } + var buf$1 = ensure(buf, nread, 65537); + Caml_bytes.set(buf$1, nread, c); + var _buf = buf$1; + var _ofs = nread + 1 | 0; + while(true) { + var ofs = _ofs; + var buf$2 = _buf; + var buf$3 = ensure(buf$2, ofs, 65536); + var rem = buf$3.length - ofs | 0; + var r = read_upto(ic, buf$3, ofs, rem); + if (r < rem) { + return Stdlib__Bytes.sub_string(buf$3, 0, ofs + r | 0); + } + _ofs = ofs + rem | 0; + _buf = buf$3; + continue ; + }; +} + +function input_lines_dps(_dst, _offset, ic) { + while(true) { + var dst = _dst; + var offset = _offset; + var line; + try { + line = Stdlib.input_line(ic); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.End_of_file) { + dst[offset] = /* [] */0; + return ; + } + throw exn; + dst[offset] = undefined; + dst[offset] = undefined; + return ; + } + var block = { + hd: line, + tl: 24029 + }; + dst[offset] = block; + _offset = "tl"; + _dst = block; + continue ; + }; +} + +function input_lines(ic) { + var line; + try { + line = Stdlib.input_line(ic); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.End_of_file) { + return /* [] */0; + } + throw exn; + } + var block = { + hd: line, + tl: 24029 + }; + input_lines_dps(block, "tl", ic); + return block; +} + +function fold_lines(f, _accu, ic) { + while(true) { + var accu = _accu; + var line; + try { + line = Stdlib.input_line(ic); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.End_of_file) { + return accu; + } + throw exn; + } + _accu = Curry._2(f, accu, line); + continue ; + }; +} + +var stdin = Stdlib.stdin; + +var open_bin = Stdlib.open_in_bin; + +var open_text = Stdlib.open_in; + +var open_gen = Stdlib.open_in_gen; + +var close = Stdlib.close_in; + +var close_noerr = Stdlib.close_in_noerr; + +var input = Stdlib.input; + +var set_binary_mode = Stdlib.set_binary_mode_in; + +function isatty(prim) { + return Caml_external_polyfill.resolve("caml_sys_isatty")(prim); +} + +export { + stdin , + open_bin , + open_text , + open_gen , + with_open_bin , + with_open_text , + with_open_gen , + close , + close_noerr , + input_char , + input_byte , + input_line , + really_input_string , + input_all , + input_lines , + input , + really_input , + fold_lines , + seek , + pos , + length , + set_binary_mode , + isatty , +} +/* Stdlib__Fun Not a pure module */ diff --git a/melange-node-modules/melange/int.js b/melange-node-modules/melange/int.js new file mode 100644 index 0000000..dd8bcb1 --- /dev/null +++ b/melange-node-modules/melange/int.js @@ -0,0 +1,79 @@ +// Generated by Melange + +import * as Caml from "melange.js/caml.js"; +import * as Caml_format from "melange.js/caml_format.js"; +import * as Caml_hash from "melange.js/caml_hash.js"; + +function abs(x) { + if (x >= 0) { + return x; + } else { + return -x | 0; + } +} + +var min_int = -2147483648; + +function lognot(x) { + return x ^ -1; +} + +function equal(prim0, prim1) { + return prim0 === prim1; +} + +var compare = Caml.caml_int_compare; + +function min(x, y) { + if (x <= y) { + return x; + } else { + return y; + } +} + +function max(x, y) { + if (x >= y) { + return x; + } else { + return y; + } +} + +function to_string(x) { + return Caml_format.caml_format_int("%d", x); +} + +function seeded_hash(seed, x) { + return Caml_hash.caml_hash(10, 100, seed, x); +} + +function hash(x) { + return Caml_hash.caml_hash(10, 100, 0, x); +} + +var zero = 0; + +var one = 1; + +var minus_one = -1; + +var max_int = 2147483647; + +export { + zero , + one , + minus_one , + abs , + max_int , + min_int , + lognot , + equal , + compare , + min , + max , + to_string , + seeded_hash , + hash , +} +/* No side effect */ diff --git a/melange-node-modules/melange/int32.js b/melange-node-modules/melange/int32.js new file mode 100644 index 0000000..c986159 --- /dev/null +++ b/melange-node-modules/melange/int32.js @@ -0,0 +1,161 @@ +// Generated by Melange + +import * as Caml from "melange.js/caml.js"; +import * as Caml_format from "melange.js/caml_format.js"; +import * as Caml_hash from "melange.js/caml_hash.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Sys from "./sys.js"; + +function succ(n) { + return n + 1 | 0; +} + +function pred(n) { + return n - 1 | 0; +} + +function abs(n) { + if (n >= 0) { + return n; + } else { + return -n | 0; + } +} + +function lognot(n) { + return n ^ -1; +} + +var unsigned_to_int; + +if (Stdlib__Sys.word_size !== 32) { + if (Stdlib__Sys.word_size !== 64) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/int32.ml", + 69, + 6 + ], + Error: new Error() + }; + } + unsigned_to_int = (function (n) { + return n & -1; + }); +} else { + unsigned_to_int = (function (n) { + if (0 <= n && n <= Stdlib.max_int) { + return n; + } + + }); +} + +function to_string(n) { + return Caml_format.caml_int32_format("%d", n); +} + +function of_string_opt(s) { + try { + return Caml_format.caml_int32_of_string(s); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Failure) { + return ; + } + throw exn; + } +} + +var compare = Caml.caml_int_compare; + +function equal(x, y) { + return x === y; +} + +function unsigned_compare(n, m) { + return Caml.caml_int_compare(n - -2147483648 | 0, m - -2147483648 | 0); +} + +function min(x, y) { + if (x <= y) { + return x; + } else { + return y; + } +} + +function max(x, y) { + if (x >= y) { + return x; + } else { + return y; + } +} + +function unsigned_div(n, d) { + if (d < 0) { + if (unsigned_compare(n, d) < 0) { + return 0; + } else { + return 1; + } + } + var q = (((n >>> 1) / d | 0) << 1); + var r = n - Math.imul(q, d) | 0; + if (unsigned_compare(r, d) >= 0) { + return q + 1 | 0; + } else { + return q; + } +} + +function unsigned_rem(n, d) { + return n - Math.imul(unsigned_div(n, d), d) | 0; +} + +function seeded_hash(seed, x) { + return Caml_hash.caml_hash(10, 100, seed, x); +} + +function hash(x) { + return Caml_hash.caml_hash(10, 100, 0, x); +} + +var zero = 0; + +var one = 1; + +var minus_one = -1; + +var max_int = 2147483647; + +var min_int = -2147483648; + +export { + zero , + one , + minus_one , + unsigned_div , + unsigned_rem , + succ , + pred , + abs , + max_int , + min_int , + lognot , + unsigned_to_int , + of_string_opt , + to_string , + compare , + unsigned_compare , + equal , + min , + max , + seeded_hash , + hash , +} +/* unsigned_to_int Not a pure module */ diff --git a/melange-node-modules/melange/int64.js b/melange-node-modules/melange/int64.js new file mode 100644 index 0000000..21983e7 --- /dev/null +++ b/melange-node-modules/melange/int64.js @@ -0,0 +1,144 @@ +// Generated by Melange + +import * as Caml from "melange.js/caml.js"; +import * as Caml_format from "melange.js/caml_format.js"; +import * as Caml_hash from "melange.js/caml_hash.js"; +import * as Caml_int64 from "melange.js/caml_int64.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Stdlib from "./stdlib.js"; + +var zero = Caml_int64.zero; + +var one = Caml_int64.one; + +function succ(n) { + return Caml_int64.add(n, Caml_int64.one); +} + +function pred(n) { + return Caml_int64.sub(n, Caml_int64.one); +} + +function abs(n) { + if (Caml.i64_ge(n, Caml_int64.zero)) { + return n; + } else { + return Caml_int64.neg(n); + } +} + +var min_int = Caml_int64.min_int; + +function lognot(n) { + return Caml_int64.xor(n, Caml_int64.neg_one); +} + +var max_int = Caml_int64.of_int32(Stdlib.max_int); + +function unsigned_to_int(n) { + if (Caml_int64.compare(zero, n) <= 0 && Caml_int64.compare(n, max_int) <= 0) { + return Caml_int64.to_int32(n); + } + +} + +function to_string(n) { + return Caml_format.caml_int64_format("%d", n); +} + +function of_string_opt(s) { + try { + return Caml_format.caml_int64_of_string(s); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Failure) { + return ; + } + throw exn; + } +} + +var compare = Caml_int64.compare; + +function equal(x, y) { + return Caml_int64.compare(x, y) === 0; +} + +function unsigned_compare(n, m) { + return Caml_int64.compare(Caml_int64.sub(n, min_int), Caml_int64.sub(m, min_int)); +} + +function min(x, y) { + if (Caml.i64_le(x, y)) { + return x; + } else { + return y; + } +} + +function max(x, y) { + if (Caml.i64_ge(x, y)) { + return x; + } else { + return y; + } +} + +function unsigned_div(n, d) { + if (Caml.i64_lt(d, zero)) { + if (unsigned_compare(n, d) < 0) { + return zero; + } else { + return one; + } + } + var q = Caml_int64.lsl_(Caml_int64.div(Caml_int64.lsr_(n, 1), d), 1); + var r = Caml_int64.sub(n, Caml_int64.mul(q, d)); + if (unsigned_compare(r, d) >= 0) { + return Caml_int64.add(q, Caml_int64.one); + } else { + return q; + } +} + +function unsigned_rem(n, d) { + return Caml_int64.sub(n, Caml_int64.mul(unsigned_div(n, d), d)); +} + +function seeded_hash(seed, x) { + return Caml_hash.caml_hash(10, 100, seed, x); +} + +function hash(x) { + return Caml_hash.caml_hash(10, 100, 0, x); +} + +var minus_one = Caml_int64.neg_one; + +var max_int$1 = Caml_int64.max_int; + +export { + zero , + one , + minus_one , + unsigned_div , + unsigned_rem , + succ , + pred , + abs , + max_int$1 as max_int, + min_int , + lognot , + unsigned_to_int , + of_string_opt , + to_string , + compare , + unsigned_compare , + equal , + min , + max , + seeded_hash , + hash , +} +/* No side effect */ diff --git a/melange-node-modules/melange/lazy.js b/melange-node-modules/melange/lazy.js new file mode 100644 index 0000000..08291d6 --- /dev/null +++ b/melange-node-modules/melange/lazy.js @@ -0,0 +1,62 @@ +// Generated by Melange + +import * as CamlinternalLazy from "./camlinternalLazy.js"; +import * as Curry from "melange.js/curry.js"; + +function from_fun(f) { + return { + LAZY_DONE: false, + VAL: (function () { + return Curry._1(f, undefined); + }) + }; +} + +function from_val(v) { + return { + LAZY_DONE: true, + VAL: v + }; +} + +function map(f, x) { + return { + LAZY_DONE: false, + VAL: (function () { + return Curry._1(f, CamlinternalLazy.force(x)); + }) + }; +} + +function map_val(f, x) { + if (CamlinternalLazy.is_val(x)) { + return { + LAZY_DONE: true, + VAL: Curry._1(f, CamlinternalLazy.force(x)) + }; + } else { + return { + LAZY_DONE: false, + VAL: (function () { + return Curry._1(f, CamlinternalLazy.force(x)); + }) + }; + } +} + +var Undefined = CamlinternalLazy.Undefined; + +var is_val = CamlinternalLazy.is_val; + +var force_val = CamlinternalLazy.force_val; + +export { + Undefined , + map , + is_val , + from_val , + map_val , + from_fun , + force_val , +} +/* No side effect */ diff --git a/melange-node-modules/melange/lexing.js b/melange-node-modules/melange/lexing.js new file mode 100644 index 0000000..283ca1e --- /dev/null +++ b/melange-node-modules/melange/lexing.js @@ -0,0 +1,260 @@ +// Generated by Melange + +import * as Caml_array from "melange.js/caml_array.js"; +import * as Caml_bytes from "melange.js/caml_bytes.js"; +import * as Caml_lexer from "melange.js/caml_lexer.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Bytes from "./bytes.js"; + +var dummy_pos = { + pos_fname: "", + pos_lnum: 0, + pos_bol: 0, + pos_cnum: -1 +}; + +function engine(tbl, state, buf) { + var result = Caml_lexer.caml_lex_engine(tbl, state, buf); + if (result >= 0 && buf.lex_curr_p !== dummy_pos) { + buf.lex_start_p = buf.lex_curr_p; + var init = buf.lex_curr_p; + buf.lex_curr_p = { + pos_fname: init.pos_fname, + pos_lnum: init.pos_lnum, + pos_bol: init.pos_bol, + pos_cnum: buf.lex_abs_pos + buf.lex_curr_pos | 0 + }; + } + return result; +} + +function new_engine(tbl, state, buf) { + var result = Caml_lexer.caml_new_lex_engine(tbl, state, buf); + if (result >= 0 && buf.lex_curr_p !== dummy_pos) { + buf.lex_start_p = buf.lex_curr_p; + var init = buf.lex_curr_p; + buf.lex_curr_p = { + pos_fname: init.pos_fname, + pos_lnum: init.pos_lnum, + pos_bol: init.pos_bol, + pos_cnum: buf.lex_abs_pos + buf.lex_curr_pos | 0 + }; + } + return result; +} + +var zero_pos = { + pos_fname: "", + pos_lnum: 1, + pos_bol: 0, + pos_cnum: 0 +}; + +function from_function(with_positionsOpt, f) { + var with_positions = with_positionsOpt !== undefined ? with_positionsOpt : true; + var partial_arg = Caml_bytes.caml_create_bytes(512); + return { + refill_buff: (function (param) { + var read = Curry._2(f, partial_arg, partial_arg.length); + var n = read > 0 ? read : (param.lex_eof_reached = true, 0); + if ((param.lex_buffer_len + n | 0) > param.lex_buffer.length) { + if (((param.lex_buffer_len - param.lex_start_pos | 0) + n | 0) <= param.lex_buffer.length) { + Stdlib__Bytes.blit(param.lex_buffer, param.lex_start_pos, param.lex_buffer, 0, param.lex_buffer_len - param.lex_start_pos | 0); + } else { + var newlen = (param.lex_buffer.length << 1); + if (((param.lex_buffer_len - param.lex_start_pos | 0) + n | 0) > newlen) { + throw { + RE_EXN_ID: "Failure", + _1: "Lexing.lex_refill: cannot grow buffer", + Error: new Error() + }; + } + var newbuf = Caml_bytes.caml_create_bytes(newlen); + Stdlib__Bytes.blit(param.lex_buffer, param.lex_start_pos, newbuf, 0, param.lex_buffer_len - param.lex_start_pos | 0); + param.lex_buffer = newbuf; + } + var s = param.lex_start_pos; + param.lex_abs_pos = param.lex_abs_pos + s | 0; + param.lex_curr_pos = param.lex_curr_pos - s | 0; + param.lex_start_pos = 0; + param.lex_last_pos = param.lex_last_pos - s | 0; + param.lex_buffer_len = param.lex_buffer_len - s | 0; + var t = param.lex_mem; + for(var i = 0 ,i_finish = t.length; i < i_finish; ++i){ + var v = Caml_array.get(t, i); + if (v >= 0) { + Caml_array.set(t, i, v - s | 0); + } + + } + } + Stdlib__Bytes.blit(partial_arg, 0, param.lex_buffer, param.lex_buffer_len, n); + param.lex_buffer_len = param.lex_buffer_len + n | 0; + }), + lex_buffer: Caml_bytes.caml_create_bytes(1024), + lex_buffer_len: 0, + lex_abs_pos: 0, + lex_start_pos: 0, + lex_curr_pos: 0, + lex_last_pos: 0, + lex_last_action: 0, + lex_eof_reached: false, + lex_mem: [], + lex_start_p: with_positions ? zero_pos : dummy_pos, + lex_curr_p: with_positions ? zero_pos : dummy_pos + }; +} + +function from_channel(with_positions, ic) { + return from_function(with_positions, (function (buf, n) { + return Stdlib.input(ic, buf, 0, n); + })); +} + +function from_string(with_positionsOpt, s) { + var with_positions = with_positionsOpt !== undefined ? with_positionsOpt : true; + return { + refill_buff: (function (lexbuf) { + lexbuf.lex_eof_reached = true; + }), + lex_buffer: Stdlib__Bytes.of_string(s), + lex_buffer_len: s.length, + lex_abs_pos: 0, + lex_start_pos: 0, + lex_curr_pos: 0, + lex_last_pos: 0, + lex_last_action: 0, + lex_eof_reached: true, + lex_mem: [], + lex_start_p: with_positions ? zero_pos : dummy_pos, + lex_curr_p: with_positions ? zero_pos : dummy_pos + }; +} + +function set_position(lexbuf, position) { + lexbuf.lex_curr_p = { + pos_fname: lexbuf.lex_curr_p.pos_fname, + pos_lnum: position.pos_lnum, + pos_bol: position.pos_bol, + pos_cnum: position.pos_cnum + }; + lexbuf.lex_abs_pos = position.pos_cnum; +} + +function set_filename(lexbuf, fname) { + var init = lexbuf.lex_curr_p; + lexbuf.lex_curr_p = { + pos_fname: fname, + pos_lnum: init.pos_lnum, + pos_bol: init.pos_bol, + pos_cnum: init.pos_cnum + }; +} + +function with_positions(lexbuf) { + return lexbuf.lex_curr_p !== dummy_pos; +} + +function lexeme(lexbuf) { + var len = lexbuf.lex_curr_pos - lexbuf.lex_start_pos | 0; + return Stdlib__Bytes.sub_string(lexbuf.lex_buffer, lexbuf.lex_start_pos, len); +} + +function sub_lexeme(lexbuf, i1, i2) { + var len = i2 - i1 | 0; + return Stdlib__Bytes.sub_string(lexbuf.lex_buffer, i1, len); +} + +function sub_lexeme_opt(lexbuf, i1, i2) { + if (i1 < 0) { + return ; + } + var len = i2 - i1 | 0; + return Stdlib__Bytes.sub_string(lexbuf.lex_buffer, i1, len); +} + +function sub_lexeme_char(lexbuf, i) { + return Caml_bytes.get(lexbuf.lex_buffer, i); +} + +function sub_lexeme_char_opt(lexbuf, i) { + if (i >= 0) { + return Caml_bytes.get(lexbuf.lex_buffer, i); + } + +} + +function lexeme_char(lexbuf, i) { + return Caml_bytes.get(lexbuf.lex_buffer, lexbuf.lex_start_pos + i | 0); +} + +function lexeme_start(lexbuf) { + return lexbuf.lex_start_p.pos_cnum; +} + +function lexeme_end(lexbuf) { + return lexbuf.lex_curr_p.pos_cnum; +} + +function lexeme_start_p(lexbuf) { + return lexbuf.lex_start_p; +} + +function lexeme_end_p(lexbuf) { + return lexbuf.lex_curr_p; +} + +function new_line(lexbuf) { + var lcp = lexbuf.lex_curr_p; + if (lcp !== dummy_pos) { + lexbuf.lex_curr_p = { + pos_fname: lcp.pos_fname, + pos_lnum: lcp.pos_lnum + 1 | 0, + pos_bol: lcp.pos_cnum, + pos_cnum: lcp.pos_cnum + }; + return ; + } + +} + +function flush_input(lb) { + lb.lex_curr_pos = 0; + lb.lex_abs_pos = 0; + var lcp = lb.lex_curr_p; + if (lcp !== dummy_pos) { + lb.lex_curr_p = { + pos_fname: lcp.pos_fname, + pos_lnum: 1, + pos_bol: 0, + pos_cnum: 0 + }; + } + lb.lex_buffer_len = 0; +} + +export { + dummy_pos , + from_channel , + from_string , + from_function , + set_position , + set_filename , + with_positions , + lexeme , + lexeme_char , + lexeme_start , + lexeme_end , + lexeme_start_p , + lexeme_end_p , + new_line , + flush_input , + sub_lexeme , + sub_lexeme_opt , + sub_lexeme_char , + sub_lexeme_char_opt , + engine , + new_engine , +} +/* No side effect */ diff --git a/melange-node-modules/melange/list.js b/melange-node-modules/melange/list.js new file mode 100644 index 0000000..b0542d9 --- /dev/null +++ b/melange-node-modules/melange/list.js @@ -0,0 +1,2347 @@ +// Generated by Melange + +import * as Caml_obj from "melange.js/caml_obj.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; + +function length(l) { + var _len = 0; + var _param = l; + while(true) { + var param = _param; + var len = _len; + if (!param) { + return len; + } + _param = param.tl; + _len = len + 1 | 0; + continue ; + }; +} + +function cons(a, l) { + return { + hd: a, + tl: l + }; +} + +function hd(param) { + if (param) { + return param.hd; + } + throw { + RE_EXN_ID: "Failure", + _1: "hd", + Error: new Error() + }; +} + +function tl(param) { + if (param) { + return param.tl; + } + throw { + RE_EXN_ID: "Failure", + _1: "tl", + Error: new Error() + }; +} + +function nth(l, n) { + if (n < 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.nth", + Error: new Error() + }; + } + var _l = l; + var _n = n; + while(true) { + var n$1 = _n; + var l$1 = _l; + if (l$1) { + if (n$1 === 0) { + return l$1.hd; + } + _n = n$1 - 1 | 0; + _l = l$1.tl; + continue ; + } + throw { + RE_EXN_ID: "Failure", + _1: "nth", + Error: new Error() + }; + }; +} + +function nth_opt(l, n) { + if (n < 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.nth", + Error: new Error() + }; + } + var _l = l; + var _n = n; + while(true) { + var n$1 = _n; + var l$1 = _l; + if (!l$1) { + return ; + } + if (n$1 === 0) { + return Caml_option.some(l$1.hd); + } + _n = n$1 - 1 | 0; + _l = l$1.tl; + continue ; + }; +} + +function rev_append(_l1, _l2) { + while(true) { + var l2 = _l2; + var l1 = _l1; + if (!l1) { + return l2; + } + _l2 = { + hd: l1.hd, + tl: l2 + }; + _l1 = l1.tl; + continue ; + }; +} + +function rev(l) { + return rev_append(l, /* [] */0); +} + +function init_dps(_dst, _offset, _i, last, f) { + while(true) { + var dst = _dst; + var offset = _offset; + var i = _i; + if (i > last) { + dst[offset] = /* [] */0; + return ; + } + if (i === last) { + dst[offset] = { + hd: Curry._1(f, i), + tl: /* [] */0 + }; + return ; + } + var r1 = Curry._1(f, i); + var r2 = Curry._1(f, i + 1 | 0); + var block = { + hd: r2, + tl: 24029 + }; + dst[offset] = { + hd: r1, + tl: block + }; + _i = i + 2 | 0; + _offset = "tl"; + _dst = block; + continue ; + }; +} + +function init(len, f) { + if (len < 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.init", + Error: new Error() + }; + } + var i = 0; + var last = len - 1 | 0; + if (i > last) { + return /* [] */0; + } + if (i === last) { + return { + hd: Curry._1(f, i), + tl: /* [] */0 + }; + } + var r1 = Curry._1(f, i); + var r2 = Curry._1(f, i + 1 | 0); + var block = { + hd: r2, + tl: 24029 + }; + return { + hd: r1, + tl: (init_dps(block, "tl", i + 2 | 0, last, f), block) + }; +} + +function flatten(param) { + if (param) { + return Stdlib.$at(param.hd, flatten(param.tl)); + } else { + return /* [] */0; + } +} + +function map_dps(_dst, _offset, f, _param) { + while(true) { + var dst = _dst; + var offset = _offset; + var param = _param; + if (!param) { + dst[offset] = /* [] */0; + return ; + } + var match = param.tl; + var a1 = param.hd; + if (match) { + var r1 = Curry._1(f, a1); + var r2 = Curry._1(f, match.hd); + var block = { + hd: r2, + tl: 24029 + }; + dst[offset] = { + hd: r1, + tl: block + }; + _param = match.tl; + _offset = "tl"; + _dst = block; + continue ; + } + var r1$1 = Curry._1(f, a1); + dst[offset] = { + hd: r1$1, + tl: /* [] */0 + }; + return ; + }; +} + +function map(f, param) { + if (!param) { + return /* [] */0; + } + var match = param.tl; + var a1 = param.hd; + if (match) { + var r1 = Curry._1(f, a1); + var r2 = Curry._1(f, match.hd); + var block = { + hd: r2, + tl: 24029 + }; + return { + hd: r1, + tl: (map_dps(block, "tl", f, match.tl), block) + }; + } + var r1$1 = Curry._1(f, a1); + return { + hd: r1$1, + tl: /* [] */0 + }; +} + +function mapi_dps(_dst, _offset, _i, f, _param) { + while(true) { + var dst = _dst; + var offset = _offset; + var i = _i; + var param = _param; + if (!param) { + dst[offset] = /* [] */0; + return ; + } + var match = param.tl; + var a1 = param.hd; + if (match) { + var r1 = Curry._2(f, i, a1); + var r2 = Curry._2(f, i + 1 | 0, match.hd); + var block = { + hd: r2, + tl: 24029 + }; + dst[offset] = { + hd: r1, + tl: block + }; + _param = match.tl; + _i = i + 2 | 0; + _offset = "tl"; + _dst = block; + continue ; + } + var r1$1 = Curry._2(f, i, a1); + dst[offset] = { + hd: r1$1, + tl: /* [] */0 + }; + return ; + }; +} + +function mapi(f, l) { + var i = 0; + if (!l) { + return /* [] */0; + } + var match = l.tl; + var a1 = l.hd; + if (match) { + var r1 = Curry._2(f, i, a1); + var r2 = Curry._2(f, i + 1 | 0, match.hd); + var block = { + hd: r2, + tl: 24029 + }; + return { + hd: r1, + tl: (mapi_dps(block, "tl", i + 2 | 0, f, match.tl), block) + }; + } + var r1$1 = Curry._2(f, i, a1); + return { + hd: r1$1, + tl: /* [] */0 + }; +} + +function rev_map(f, l) { + var _accu = /* [] */0; + var _param = l; + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + _param = param.tl; + _accu = { + hd: Curry._1(f, param.hd), + tl: accu + }; + continue ; + }; +} + +function iter(f, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + Curry._1(f, param.hd); + _param = param.tl; + continue ; + }; +} + +function iteri(f, l) { + var _i = 0; + var _param = l; + while(true) { + var param = _param; + var i = _i; + if (!param) { + return ; + } + Curry._2(f, i, param.hd); + _param = param.tl; + _i = i + 1 | 0; + continue ; + }; +} + +function fold_left(f, _accu, _l) { + while(true) { + var l = _l; + var accu = _accu; + if (!l) { + return accu; + } + _l = l.tl; + _accu = Curry._2(f, accu, l.hd); + continue ; + }; +} + +function fold_right(f, l, accu) { + if (l) { + return Curry._2(f, l.hd, fold_right(f, l.tl, accu)); + } else { + return accu; + } +} + +function map2_dps(_dst, _offset, f, _l1, _l2) { + while(true) { + var dst = _dst; + var offset = _offset; + var l1 = _l1; + var l2 = _l2; + if (l1) { + var match = l1.tl; + var a1 = l1.hd; + if (match) { + if (l2) { + var match$1 = l2.tl; + if (match$1) { + var r1 = Curry._2(f, a1, l2.hd); + var r2 = Curry._2(f, match.hd, match$1.hd); + var block = { + hd: r2, + tl: 24029 + }; + dst[offset] = { + hd: r1, + tl: block + }; + _l2 = match$1.tl; + _l1 = match.tl; + _offset = "tl"; + _dst = block; + continue ; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.map2", + Error: new Error() + }; + dst[offset] = undefined; + return ; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.map2", + Error: new Error() + }; + dst[offset] = undefined; + return ; + } + if (l2) { + if (l2.tl) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.map2", + Error: new Error() + }; + dst[offset] = undefined; + return ; + } + var r1$1 = Curry._2(f, a1, l2.hd); + dst[offset] = { + hd: r1$1, + tl: /* [] */0 + }; + return ; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.map2", + Error: new Error() + }; + dst[offset] = undefined; + return ; + } + if (!l2) { + dst[offset] = /* [] */0; + return ; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.map2", + Error: new Error() + }; + dst[offset] = undefined; + return ; + }; +} + +function map2(f, l1, l2) { + if (l1) { + var match = l1.tl; + var a1 = l1.hd; + if (match) { + if (l2) { + var match$1 = l2.tl; + if (match$1) { + var r1 = Curry._2(f, a1, l2.hd); + var r2 = Curry._2(f, match.hd, match$1.hd); + var block = { + hd: r2, + tl: 24029 + }; + return { + hd: r1, + tl: (map2_dps(block, "tl", f, match.tl, match$1.tl), block) + }; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.map2", + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.map2", + Error: new Error() + }; + } + if (l2) { + if (l2.tl) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.map2", + Error: new Error() + }; + } + var r1$1 = Curry._2(f, a1, l2.hd); + return { + hd: r1$1, + tl: /* [] */0 + }; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.map2", + Error: new Error() + }; + } + if (!l2) { + return /* [] */0; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.map2", + Error: new Error() + }; +} + +function rev_map2(f, l1, l2) { + var _accu = /* [] */0; + var _l1 = l1; + var _l2 = l2; + while(true) { + var l2$1 = _l2; + var l1$1 = _l1; + var accu = _accu; + if (l1$1) { + if (l2$1) { + _l2 = l2$1.tl; + _l1 = l1$1.tl; + _accu = { + hd: Curry._2(f, l1$1.hd, l2$1.hd), + tl: accu + }; + continue ; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.rev_map2", + Error: new Error() + }; + } + if (l2$1) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.rev_map2", + Error: new Error() + }; + } + return accu; + }; +} + +function iter2(f, _l1, _l2) { + while(true) { + var l2 = _l2; + var l1 = _l1; + if (l1) { + if (l2) { + Curry._2(f, l1.hd, l2.hd); + _l2 = l2.tl; + _l1 = l1.tl; + continue ; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.iter2", + Error: new Error() + }; + } + if (!l2) { + return ; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.iter2", + Error: new Error() + }; + }; +} + +function fold_left2(f, _accu, _l1, _l2) { + while(true) { + var l2 = _l2; + var l1 = _l1; + var accu = _accu; + if (l1) { + if (l2) { + _l2 = l2.tl; + _l1 = l1.tl; + _accu = Curry._3(f, accu, l1.hd, l2.hd); + continue ; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_left2", + Error: new Error() + }; + } + if (l2) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_left2", + Error: new Error() + }; + } + return accu; + }; +} + +function fold_right2(f, l1, l2, accu) { + if (l1) { + if (l2) { + return Curry._3(f, l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_right2", + Error: new Error() + }; + } + if (l2) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.fold_right2", + Error: new Error() + }; + } + return accu; +} + +function for_all(p, _param) { + while(true) { + var param = _param; + if (!param) { + return true; + } + if (!Curry._1(p, param.hd)) { + return false; + } + _param = param.tl; + continue ; + }; +} + +function exists(p, _param) { + while(true) { + var param = _param; + if (!param) { + return false; + } + if (Curry._1(p, param.hd)) { + return true; + } + _param = param.tl; + continue ; + }; +} + +function for_all2(p, _l1, _l2) { + while(true) { + var l2 = _l2; + var l1 = _l1; + if (l1) { + if (l2) { + if (!Curry._2(p, l1.hd, l2.hd)) { + return false; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue ; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.for_all2", + Error: new Error() + }; + } + if (!l2) { + return true; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.for_all2", + Error: new Error() + }; + }; +} + +function exists2(p, _l1, _l2) { + while(true) { + var l2 = _l2; + var l1 = _l1; + if (l1) { + if (l2) { + if (Curry._2(p, l1.hd, l2.hd)) { + return true; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue ; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.exists2", + Error: new Error() + }; + } + if (!l2) { + return false; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.exists2", + Error: new Error() + }; + }; +} + +function mem(x, _param) { + while(true) { + var param = _param; + if (!param) { + return false; + } + if (Caml_obj.caml_equal(param.hd, x)) { + return true; + } + _param = param.tl; + continue ; + }; +} + +function memq(x, _param) { + while(true) { + var param = _param; + if (!param) { + return false; + } + if (param.hd === x) { + return true; + } + _param = param.tl; + continue ; + }; +} + +function assoc(x, _param) { + while(true) { + var param = _param; + if (param) { + var match = param.hd; + if (Caml_obj.caml_equal(match[0], x)) { + return match[1]; + } + _param = param.tl; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; +} + +function assoc_opt(x, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + var match = param.hd; + if (Caml_obj.caml_equal(match[0], x)) { + return Caml_option.some(match[1]); + } + _param = param.tl; + continue ; + }; +} + +function assq(x, _param) { + while(true) { + var param = _param; + if (param) { + var match = param.hd; + if (match[0] === x) { + return match[1]; + } + _param = param.tl; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; +} + +function assq_opt(x, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + var match = param.hd; + if (match[0] === x) { + return Caml_option.some(match[1]); + } + _param = param.tl; + continue ; + }; +} + +function mem_assoc(x, _param) { + while(true) { + var param = _param; + if (!param) { + return false; + } + if (Caml_obj.caml_equal(param.hd[0], x)) { + return true; + } + _param = param.tl; + continue ; + }; +} + +function mem_assq(x, _param) { + while(true) { + var param = _param; + if (!param) { + return false; + } + if (param.hd[0] === x) { + return true; + } + _param = param.tl; + continue ; + }; +} + +function remove_assoc(x, param) { + if (!param) { + return /* [] */0; + } + var l = param.tl; + var pair = param.hd; + if (Caml_obj.caml_equal(pair[0], x)) { + return l; + } else { + return { + hd: pair, + tl: remove_assoc(x, l) + }; + } +} + +function remove_assq(x, param) { + if (!param) { + return /* [] */0; + } + var l = param.tl; + var pair = param.hd; + if (pair[0] === x) { + return l; + } else { + return { + hd: pair, + tl: remove_assq(x, l) + }; + } +} + +function find(p, _param) { + while(true) { + var param = _param; + if (param) { + var x = param.hd; + if (Curry._1(p, x)) { + return x; + } + _param = param.tl; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; +} + +function find_opt(p, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + var x = param.hd; + if (Curry._1(p, x)) { + return Caml_option.some(x); + } + _param = param.tl; + continue ; + }; +} + +function find_index(p) { + return function (param) { + var _i = 0; + var _param = param; + while(true) { + var param$1 = _param; + var i = _i; + if (!param$1) { + return ; + } + if (Curry._1(p, param$1.hd)) { + return i; + } + _param = param$1.tl; + _i = i + 1 | 0; + continue ; + }; + }; +} + +function find_map(f, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + var result = Curry._1(f, param.hd); + if (result !== undefined) { + return result; + } + _param = param.tl; + continue ; + }; +} + +function find_mapi(f) { + return function (param) { + var _i = 0; + var _param = param; + while(true) { + var param$1 = _param; + var i = _i; + if (!param$1) { + return ; + } + var result = Curry._2(f, i, param$1.hd); + if (result !== undefined) { + return result; + } + _param = param$1.tl; + _i = i + 1 | 0; + continue ; + }; + }; +} + +function find_all(p, _param) { + while(true) { + var param = _param; + if (!param) { + return /* [] */0; + } + var l = param.tl; + var x = param.hd; + if (Curry._1(p, x)) { + var block = { + hd: x, + tl: 24029 + }; + find_all_dps(block, "tl", p, l); + return block; + } + _param = l; + continue ; + }; +} + +function find_all_dps(_dst, _offset, p, _param) { + while(true) { + var dst = _dst; + var offset = _offset; + var param = _param; + if (!param) { + dst[offset] = /* [] */0; + return ; + } + var l = param.tl; + var x = param.hd; + if (Curry._1(p, x)) { + var block = { + hd: x, + tl: 24029 + }; + dst[offset] = block; + _param = l; + _offset = "tl"; + _dst = block; + continue ; + } + _param = l; + continue ; + }; +} + +function filteri_dps(_dst, _offset, p, _i, _param) { + while(true) { + var dst = _dst; + var offset = _offset; + var i = _i; + var param = _param; + if (!param) { + dst[offset] = /* [] */0; + return ; + } + var l = param.tl; + var x = param.hd; + var i$p = i + 1 | 0; + if (Curry._2(p, i, x)) { + var block = { + hd: x, + tl: 24029 + }; + dst[offset] = block; + _param = l; + _i = i$p; + _offset = "tl"; + _dst = block; + continue ; + } + _param = l; + _i = i$p; + continue ; + }; +} + +function filteri(p, l) { + var _i = 0; + var _param = l; + while(true) { + var param = _param; + var i = _i; + if (!param) { + return /* [] */0; + } + var l$1 = param.tl; + var x = param.hd; + var i$p = i + 1 | 0; + if (Curry._2(p, i, x)) { + var block = { + hd: x, + tl: 24029 + }; + filteri_dps(block, "tl", p, i$p, l$1); + return block; + } + _param = l$1; + _i = i$p; + continue ; + }; +} + +function filter_map(f, _param) { + while(true) { + var param = _param; + if (!param) { + return /* [] */0; + } + var l = param.tl; + var v = Curry._1(f, param.hd); + if (v !== undefined) { + var block = { + hd: Caml_option.valFromOption(v), + tl: 24029 + }; + filter_map_dps(block, "tl", f, l); + return block; + } + _param = l; + continue ; + }; +} + +function filter_map_dps(_dst, _offset, f, _param) { + while(true) { + var dst = _dst; + var offset = _offset; + var param = _param; + if (!param) { + dst[offset] = /* [] */0; + return ; + } + var l = param.tl; + var v = Curry._1(f, param.hd); + if (v !== undefined) { + var block = { + hd: Caml_option.valFromOption(v), + tl: 24029 + }; + dst[offset] = block; + _param = l; + _offset = "tl"; + _dst = block; + continue ; + } + _param = l; + continue ; + }; +} + +function concat_map(f, param) { + if (param) { + var ys = Curry._1(f, param.hd); + var xs = param.tl; + if (!ys) { + return concat_map(f, xs); + } + var block = { + hd: ys.hd, + tl: 24029 + }; + prepend_concat_map_dps(block, "tl", ys.tl, f, xs); + return block; + } else { + return /* [] */0; + } +} + +function prepend_concat_map_dps(_dst, _offset, _ys, f, xs) { + while(true) { + var dst = _dst; + var offset = _offset; + var ys = _ys; + if (!ys) { + if (xs) { + return prepend_concat_map_dps(dst, offset, Curry._1(f, xs.hd), f, xs.tl); + } else { + dst[offset] = /* [] */0; + return ; + } + } + var block = { + hd: ys.hd, + tl: 24029 + }; + dst[offset] = block; + _ys = ys.tl; + _offset = "tl"; + _dst = block; + continue ; + }; +} + +function fold_left_map(f, accu, l) { + var _accu = accu; + var _l_accu = /* [] */0; + var _param = l; + while(true) { + var param = _param; + var l_accu = _l_accu; + var accu$1 = _accu; + if (!param) { + return [ + accu$1, + rev_append(l_accu, /* [] */0) + ]; + } + var match = Curry._2(f, accu$1, param.hd); + _param = param.tl; + _l_accu = { + hd: match[1], + tl: l_accu + }; + _accu = match[0]; + continue ; + }; +} + +function partition(p, l) { + var _yes = /* [] */0; + var _no = /* [] */0; + var _param = l; + while(true) { + var param = _param; + var no = _no; + var yes = _yes; + if (!param) { + return [ + rev_append(yes, /* [] */0), + rev_append(no, /* [] */0) + ]; + } + var l$1 = param.tl; + var x = param.hd; + if (Curry._1(p, x)) { + _param = l$1; + _yes = { + hd: x, + tl: yes + }; + continue ; + } + _param = l$1; + _no = { + hd: x, + tl: no + }; + continue ; + }; +} + +function partition_map(p, l) { + var _left = /* [] */0; + var _right = /* [] */0; + var _param = l; + while(true) { + var param = _param; + var right = _right; + var left = _left; + if (!param) { + return [ + rev_append(left, /* [] */0), + rev_append(right, /* [] */0) + ]; + } + var l$1 = param.tl; + var v = Curry._1(p, param.hd); + if (v.TAG === /* Left */0) { + _param = l$1; + _left = { + hd: v._0, + tl: left + }; + continue ; + } + _param = l$1; + _right = { + hd: v._0, + tl: right + }; + continue ; + }; +} + +function split(param) { + if (!param) { + return [ + /* [] */0, + /* [] */0 + ]; + } + var match = param.hd; + var match$1 = split(param.tl); + return [ + { + hd: match[0], + tl: match$1[0] + }, + { + hd: match[1], + tl: match$1[1] + } + ]; +} + +function combine(l1, l2) { + if (l1) { + if (l2) { + return { + hd: [ + l1.hd, + l2.hd + ], + tl: combine(l1.tl, l2.tl) + }; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.combine", + Error: new Error() + }; + } + if (!l2) { + return /* [] */0; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "List.combine", + Error: new Error() + }; +} + +function merge(cmp, l1, l2) { + if (!l1) { + return l2; + } + if (!l2) { + return l1; + } + var h2 = l2.hd; + var h1 = l1.hd; + if (Curry._2(cmp, h1, h2) <= 0) { + return { + hd: h1, + tl: merge(cmp, l1.tl, l2) + }; + } else { + return { + hd: h2, + tl: merge(cmp, l1, l2.tl) + }; + } +} + +function stable_sort(cmp, l) { + var rev_merge = function (_l1, _l2, _accu) { + while(true) { + var accu = _accu; + var l2 = _l2; + var l1 = _l1; + if (!l1) { + return rev_append(l2, accu); + } + if (!l2) { + return rev_append(l1, accu); + } + var h2 = l2.hd; + var h1 = l1.hd; + if (Curry._2(cmp, h1, h2) <= 0) { + _accu = { + hd: h1, + tl: accu + }; + _l1 = l1.tl; + continue ; + } + _accu = { + hd: h2, + tl: accu + }; + _l2 = l2.tl; + continue ; + }; + }; + var rev_merge_rev = function (_l1, _l2, _accu) { + while(true) { + var accu = _accu; + var l2 = _l2; + var l1 = _l1; + if (!l1) { + return rev_append(l2, accu); + } + if (!l2) { + return rev_append(l1, accu); + } + var h2 = l2.hd; + var h1 = l1.hd; + if (Curry._2(cmp, h1, h2) > 0) { + _accu = { + hd: h1, + tl: accu + }; + _l1 = l1.tl; + continue ; + } + _accu = { + hd: h2, + tl: accu + }; + _l2 = l2.tl; + continue ; + }; + }; + var sort = function (n, l) { + if (n !== 2) { + if (n === 3 && l) { + var match = l.tl; + if (match) { + var match$1 = match.tl; + if (match$1) { + var x3 = match$1.hd; + var x2 = match.hd; + var x1 = l.hd; + var s = Curry._2(cmp, x1, x2) <= 0 ? ( + Curry._2(cmp, x2, x3) <= 0 ? ({ + hd: x1, + tl: { + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }) : ( + Curry._2(cmp, x1, x3) <= 0 ? ({ + hd: x1, + tl: { + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }) : ({ + hd: x3, + tl: { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }) + ) + ) : ( + Curry._2(cmp, x1, x3) <= 0 ? ({ + hd: x2, + tl: { + hd: x1, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }) : ( + Curry._2(cmp, x2, x3) <= 0 ? ({ + hd: x2, + tl: { + hd: x3, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }) : ({ + hd: x3, + tl: { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }) + ) + ); + return [ + s, + match$1.tl + ]; + } + + } + + } + + } else if (l) { + var match$2 = l.tl; + if (match$2) { + var x2$1 = match$2.hd; + var x1$1 = l.hd; + var s$1 = Curry._2(cmp, x1$1, x2$1) <= 0 ? ({ + hd: x1$1, + tl: { + hd: x2$1, + tl: /* [] */0 + } + }) : ({ + hd: x2$1, + tl: { + hd: x1$1, + tl: /* [] */0 + } + }); + return [ + s$1, + match$2.tl + ]; + } + + } + var n1 = (n >> 1); + var n2 = n - n1 | 0; + var match$3 = rev_sort(n1, l); + var match$4 = rev_sort(n2, match$3[1]); + return [ + rev_merge_rev(match$3[0], match$4[0], /* [] */0), + match$4[1] + ]; + }; + var rev_sort = function (n, l) { + if (n !== 2) { + if (n === 3 && l) { + var match = l.tl; + if (match) { + var match$1 = match.tl; + if (match$1) { + var x3 = match$1.hd; + var x2 = match.hd; + var x1 = l.hd; + var s = Curry._2(cmp, x1, x2) > 0 ? ( + Curry._2(cmp, x2, x3) > 0 ? ({ + hd: x1, + tl: { + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }) : ( + Curry._2(cmp, x1, x3) > 0 ? ({ + hd: x1, + tl: { + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }) : ({ + hd: x3, + tl: { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }) + ) + ) : ( + Curry._2(cmp, x1, x3) > 0 ? ({ + hd: x2, + tl: { + hd: x1, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }) : ( + Curry._2(cmp, x2, x3) > 0 ? ({ + hd: x2, + tl: { + hd: x3, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }) : ({ + hd: x3, + tl: { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }) + ) + ); + return [ + s, + match$1.tl + ]; + } + + } + + } + + } else if (l) { + var match$2 = l.tl; + if (match$2) { + var x2$1 = match$2.hd; + var x1$1 = l.hd; + var s$1 = Curry._2(cmp, x1$1, x2$1) > 0 ? ({ + hd: x1$1, + tl: { + hd: x2$1, + tl: /* [] */0 + } + }) : ({ + hd: x2$1, + tl: { + hd: x1$1, + tl: /* [] */0 + } + }); + return [ + s$1, + match$2.tl + ]; + } + + } + var n1 = (n >> 1); + var n2 = n - n1 | 0; + var match$3 = sort(n1, l); + var match$4 = sort(n2, match$3[1]); + return [ + rev_merge(match$3[0], match$4[0], /* [] */0), + match$4[1] + ]; + }; + var len = length(l); + if (len < 2) { + return l; + } else { + return sort(len, l)[0]; + } +} + +function sort_uniq(cmp, l) { + var rev_merge = function (_l1, _l2, _accu) { + while(true) { + var accu = _accu; + var l2 = _l2; + var l1 = _l1; + if (!l1) { + return rev_append(l2, accu); + } + if (!l2) { + return rev_append(l1, accu); + } + var t2 = l2.tl; + var h2 = l2.hd; + var t1 = l1.tl; + var h1 = l1.hd; + var c = Curry._2(cmp, h1, h2); + if (c === 0) { + _accu = { + hd: h1, + tl: accu + }; + _l2 = t2; + _l1 = t1; + continue ; + } + if (c < 0) { + _accu = { + hd: h1, + tl: accu + }; + _l1 = t1; + continue ; + } + _accu = { + hd: h2, + tl: accu + }; + _l2 = t2; + continue ; + }; + }; + var rev_merge_rev = function (_l1, _l2, _accu) { + while(true) { + var accu = _accu; + var l2 = _l2; + var l1 = _l1; + if (!l1) { + return rev_append(l2, accu); + } + if (!l2) { + return rev_append(l1, accu); + } + var t2 = l2.tl; + var h2 = l2.hd; + var t1 = l1.tl; + var h1 = l1.hd; + var c = Curry._2(cmp, h1, h2); + if (c === 0) { + _accu = { + hd: h1, + tl: accu + }; + _l2 = t2; + _l1 = t1; + continue ; + } + if (c > 0) { + _accu = { + hd: h1, + tl: accu + }; + _l1 = t1; + continue ; + } + _accu = { + hd: h2, + tl: accu + }; + _l2 = t2; + continue ; + }; + }; + var sort = function (n, l) { + if (n !== 2) { + if (n === 3 && l) { + var match = l.tl; + if (match) { + var match$1 = match.tl; + if (match$1) { + var x3 = match$1.hd; + var x2 = match.hd; + var x1 = l.hd; + var c = Curry._2(cmp, x1, x2); + var s; + if (c === 0) { + var c$1 = Curry._2(cmp, x2, x3); + s = c$1 === 0 ? ({ + hd: x2, + tl: /* [] */0 + }) : ( + c$1 < 0 ? ({ + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + }) : ({ + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + }) + ); + } else if (c < 0) { + var c$2 = Curry._2(cmp, x2, x3); + if (c$2 === 0) { + s = { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + }; + } else if (c$2 < 0) { + s = { + hd: x1, + tl: { + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } else { + var c$3 = Curry._2(cmp, x1, x3); + s = c$3 === 0 ? ({ + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + }) : ( + c$3 < 0 ? ({ + hd: x1, + tl: { + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }) : ({ + hd: x3, + tl: { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }) + ); + } + } else { + var c$4 = Curry._2(cmp, x1, x3); + if (c$4 === 0) { + s = { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + }; + } else if (c$4 < 0) { + s = { + hd: x2, + tl: { + hd: x1, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } else { + var c$5 = Curry._2(cmp, x2, x3); + s = c$5 === 0 ? ({ + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + }) : ( + c$5 < 0 ? ({ + hd: x2, + tl: { + hd: x3, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }) : ({ + hd: x3, + tl: { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }) + ); + } + } + return [ + s, + match$1.tl + ]; + } + + } + + } + + } else if (l) { + var match$2 = l.tl; + if (match$2) { + var x2$1 = match$2.hd; + var x1$1 = l.hd; + var c$6 = Curry._2(cmp, x1$1, x2$1); + var s$1 = c$6 === 0 ? ({ + hd: x1$1, + tl: /* [] */0 + }) : ( + c$6 < 0 ? ({ + hd: x1$1, + tl: { + hd: x2$1, + tl: /* [] */0 + } + }) : ({ + hd: x2$1, + tl: { + hd: x1$1, + tl: /* [] */0 + } + }) + ); + return [ + s$1, + match$2.tl + ]; + } + + } + var n1 = (n >> 1); + var n2 = n - n1 | 0; + var match$3 = rev_sort(n1, l); + var match$4 = rev_sort(n2, match$3[1]); + return [ + rev_merge_rev(match$3[0], match$4[0], /* [] */0), + match$4[1] + ]; + }; + var rev_sort = function (n, l) { + if (n !== 2) { + if (n === 3 && l) { + var match = l.tl; + if (match) { + var match$1 = match.tl; + if (match$1) { + var x3 = match$1.hd; + var x2 = match.hd; + var x1 = l.hd; + var c = Curry._2(cmp, x1, x2); + var s; + if (c === 0) { + var c$1 = Curry._2(cmp, x2, x3); + s = c$1 === 0 ? ({ + hd: x2, + tl: /* [] */0 + }) : ( + c$1 > 0 ? ({ + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + }) : ({ + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + }) + ); + } else if (c > 0) { + var c$2 = Curry._2(cmp, x2, x3); + if (c$2 === 0) { + s = { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + }; + } else if (c$2 > 0) { + s = { + hd: x1, + tl: { + hd: x2, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } else { + var c$3 = Curry._2(cmp, x1, x3); + s = c$3 === 0 ? ({ + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + }) : ( + c$3 > 0 ? ({ + hd: x1, + tl: { + hd: x3, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }) : ({ + hd: x3, + tl: { + hd: x1, + tl: { + hd: x2, + tl: /* [] */0 + } + } + }) + ); + } + } else { + var c$4 = Curry._2(cmp, x1, x3); + if (c$4 === 0) { + s = { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + }; + } else if (c$4 > 0) { + s = { + hd: x2, + tl: { + hd: x1, + tl: { + hd: x3, + tl: /* [] */0 + } + } + }; + } else { + var c$5 = Curry._2(cmp, x2, x3); + s = c$5 === 0 ? ({ + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + }) : ( + c$5 > 0 ? ({ + hd: x2, + tl: { + hd: x3, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }) : ({ + hd: x3, + tl: { + hd: x2, + tl: { + hd: x1, + tl: /* [] */0 + } + } + }) + ); + } + } + return [ + s, + match$1.tl + ]; + } + + } + + } + + } else if (l) { + var match$2 = l.tl; + if (match$2) { + var x2$1 = match$2.hd; + var x1$1 = l.hd; + var c$6 = Curry._2(cmp, x1$1, x2$1); + var s$1 = c$6 === 0 ? ({ + hd: x1$1, + tl: /* [] */0 + }) : ( + c$6 > 0 ? ({ + hd: x1$1, + tl: { + hd: x2$1, + tl: /* [] */0 + } + }) : ({ + hd: x2$1, + tl: { + hd: x1$1, + tl: /* [] */0 + } + }) + ); + return [ + s$1, + match$2.tl + ]; + } + + } + var n1 = (n >> 1); + var n2 = n - n1 | 0; + var match$3 = sort(n1, l); + var match$4 = sort(n2, match$3[1]); + return [ + rev_merge(match$3[0], match$4[0], /* [] */0), + match$4[1] + ]; + }; + var len = length(l); + if (len < 2) { + return l; + } else { + return sort(len, l)[0]; + } +} + +function compare_lengths(_l1, _l2) { + while(true) { + var l2 = _l2; + var l1 = _l1; + if (!l1) { + if (l2) { + return -1; + } else { + return 0; + } + } + if (!l2) { + return 1; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue ; + }; +} + +function compare_length_with(_l, _n) { + while(true) { + var n = _n; + var l = _l; + if (!l) { + if (n === 0) { + return 0; + } else if (n > 0) { + return -1; + } else { + return 1; + } + } + if (n <= 0) { + return 1; + } + _n = n - 1 | 0; + _l = l.tl; + continue ; + }; +} + +function is_empty(param) { + if (param) { + return false; + } else { + return true; + } +} + +function equal(eq, _l1, _l2) { + while(true) { + var l2 = _l2; + var l1 = _l1; + if (!l1) { + if (l2) { + return false; + } else { + return true; + } + } + if (!l2) { + return false; + } + if (!Curry._2(eq, l1.hd, l2.hd)) { + return false; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue ; + }; +} + +function compare(cmp, _l1, _l2) { + while(true) { + var l2 = _l2; + var l1 = _l1; + if (!l1) { + if (l2) { + return -1; + } else { + return 0; + } + } + if (!l2) { + return 1; + } + var c = Curry._2(cmp, l1.hd, l2.hd); + if (c !== 0) { + return c; + } + _l2 = l2.tl; + _l1 = l1.tl; + continue ; + }; +} + +function to_seq(l) { + var aux = function (l, param) { + if (!l) { + return /* Nil */0; + } + var tail = l.tl; + return /* Cons */{ + _0: l.hd, + _1: (function (param) { + return aux(tail, param); + }) + }; + }; + return function (param) { + return aux(l, param); + }; +} + +function of_seq_dps(_dst, _offset, _seq) { + while(true) { + var dst = _dst; + var offset = _offset; + var seq = _seq; + var match = Curry._1(seq, undefined); + if (!match) { + dst[offset] = /* [] */0; + return ; + } + var x1 = match._0; + var match$1 = Curry._1(match._1, undefined); + if (!match$1) { + dst[offset] = { + hd: x1, + tl: /* [] */0 + }; + return ; + } + var block = { + hd: match$1._0, + tl: 24029 + }; + dst[offset] = { + hd: x1, + tl: block + }; + _seq = match$1._1; + _offset = "tl"; + _dst = block; + continue ; + }; +} + +function of_seq(seq) { + var match = Curry._1(seq, undefined); + if (!match) { + return /* [] */0; + } + var x1 = match._0; + var match$1 = Curry._1(match._1, undefined); + if (!match$1) { + return { + hd: x1, + tl: /* [] */0 + }; + } + var block = { + hd: match$1._0, + tl: 24029 + }; + return { + hd: x1, + tl: (of_seq_dps(block, "tl", match$1._1), block) + }; +} + +var append = Stdlib.$at; + +var concat = flatten; + +var filter = find_all; + +var sort = stable_sort; + +var fast_sort = stable_sort; + +export { + length , + compare_lengths , + compare_length_with , + is_empty , + cons , + hd , + tl , + nth , + nth_opt , + rev , + init , + append , + rev_append , + concat , + flatten , + equal , + compare , + iter , + iteri , + map , + mapi , + rev_map , + filter_map , + concat_map , + fold_left_map , + fold_left , + fold_right , + iter2 , + map2 , + rev_map2 , + fold_left2 , + fold_right2 , + for_all , + exists , + for_all2 , + exists2 , + mem , + memq , + find , + find_opt , + find_index , + find_map , + find_mapi , + filter , + find_all , + filteri , + partition , + partition_map , + assoc , + assoc_opt , + assq , + assq_opt , + mem_assoc , + mem_assq , + remove_assoc , + remove_assq , + split , + combine , + sort , + stable_sort , + fast_sort , + sort_uniq , + merge , + to_seq , + of_seq , +} +/* No side effect */ diff --git a/melange-node-modules/melange/listLabels.js b/melange-node-modules/melange/listLabels.js new file mode 100644 index 0000000..d8afa7d --- /dev/null +++ b/melange-node-modules/melange/listLabels.js @@ -0,0 +1,202 @@ +// Generated by Melange + +import * as Stdlib__List from "./list.js"; + +var length = Stdlib__List.length; + +var compare_lengths = Stdlib__List.compare_lengths; + +var compare_length_with = Stdlib__List.compare_length_with; + +var is_empty = Stdlib__List.is_empty; + +var cons = Stdlib__List.cons; + +var hd = Stdlib__List.hd; + +var tl = Stdlib__List.tl; + +var nth = Stdlib__List.nth; + +var nth_opt = Stdlib__List.nth_opt; + +var rev = Stdlib__List.rev; + +var init = Stdlib__List.init; + +var append = Stdlib__List.append; + +var rev_append = Stdlib__List.rev_append; + +var concat = Stdlib__List.concat; + +var flatten = Stdlib__List.flatten; + +var equal = Stdlib__List.equal; + +var compare = Stdlib__List.compare; + +var iter = Stdlib__List.iter; + +var iteri = Stdlib__List.iteri; + +var map = Stdlib__List.map; + +var mapi = Stdlib__List.mapi; + +var rev_map = Stdlib__List.rev_map; + +var filter_map = Stdlib__List.filter_map; + +var concat_map = Stdlib__List.concat_map; + +var fold_left_map = Stdlib__List.fold_left_map; + +var fold_left = Stdlib__List.fold_left; + +var fold_right = Stdlib__List.fold_right; + +var iter2 = Stdlib__List.iter2; + +var map2 = Stdlib__List.map2; + +var rev_map2 = Stdlib__List.rev_map2; + +var fold_left2 = Stdlib__List.fold_left2; + +var fold_right2 = Stdlib__List.fold_right2; + +var for_all = Stdlib__List.for_all; + +var exists = Stdlib__List.exists; + +var for_all2 = Stdlib__List.for_all2; + +var exists2 = Stdlib__List.exists2; + +var mem = Stdlib__List.mem; + +var memq = Stdlib__List.memq; + +var find = Stdlib__List.find; + +var find_opt = Stdlib__List.find_opt; + +var find_index = Stdlib__List.find_index; + +var find_map = Stdlib__List.find_map; + +var find_mapi = Stdlib__List.find_mapi; + +var filter = Stdlib__List.filter; + +var find_all = Stdlib__List.find_all; + +var filteri = Stdlib__List.filteri; + +var partition = Stdlib__List.partition; + +var partition_map = Stdlib__List.partition_map; + +var assoc = Stdlib__List.assoc; + +var assoc_opt = Stdlib__List.assoc_opt; + +var assq = Stdlib__List.assq; + +var assq_opt = Stdlib__List.assq_opt; + +var mem_assoc = Stdlib__List.mem_assoc; + +var mem_assq = Stdlib__List.mem_assq; + +var remove_assoc = Stdlib__List.remove_assoc; + +var remove_assq = Stdlib__List.remove_assq; + +var split = Stdlib__List.split; + +var combine = Stdlib__List.combine; + +var sort = Stdlib__List.sort; + +var stable_sort = Stdlib__List.stable_sort; + +var fast_sort = Stdlib__List.fast_sort; + +var sort_uniq = Stdlib__List.sort_uniq; + +var merge = Stdlib__List.merge; + +var to_seq = Stdlib__List.to_seq; + +var of_seq = Stdlib__List.of_seq; + +export { + length , + compare_lengths , + compare_length_with , + is_empty , + cons , + hd , + tl , + nth , + nth_opt , + rev , + init , + append , + rev_append , + concat , + flatten , + equal , + compare , + iter , + iteri , + map , + mapi , + rev_map , + filter_map , + concat_map , + fold_left_map , + fold_left , + fold_right , + iter2 , + map2 , + rev_map2 , + fold_left2 , + fold_right2 , + for_all , + exists , + for_all2 , + exists2 , + mem , + memq , + find , + find_opt , + find_index , + find_map , + find_mapi , + filter , + find_all , + filteri , + partition , + partition_map , + assoc , + assoc_opt , + assq , + assq_opt , + mem_assoc , + mem_assq , + remove_assoc , + remove_assq , + split , + combine , + sort , + stable_sort , + fast_sort , + sort_uniq , + merge , + to_seq , + of_seq , +} +/* No side effect */ diff --git a/melange-node-modules/melange/map.js b/melange-node-modules/melange/map.js new file mode 100644 index 0000000..e23f6ee --- /dev/null +++ b/melange-node-modules/melange/map.js @@ -0,0 +1,1087 @@ +// Generated by Melange + +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__List from "./list.js"; +import * as Stdlib__Seq from "./seq.js"; + +function Make(funarg) { + var height = function (param) { + if (param) { + return param.h; + } else { + return 0; + } + }; + var create = function (l, x, d, r) { + var hl = height(l); + var hr = height(r); + return /* Node */{ + l: l, + v: x, + d: d, + r: r, + h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + }; + var singleton = function (x, d) { + return /* Node */{ + l: /* Empty */0, + v: x, + d: d, + r: /* Empty */0, + h: 1 + }; + }; + var bal = function (l, x, d, r) { + var hl = l ? l.h : 0; + var hr = r ? r.h : 0; + if (hl > (hr + 2 | 0)) { + if (l) { + var lr = l.r; + var ld = l.d; + var lv = l.v; + var ll = l.l; + if (height(ll) >= height(lr)) { + return create(ll, lv, ld, create(lr, x, d, r)); + } + if (lr) { + return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; + } + if (hr <= (hl + 2 | 0)) { + return /* Node */{ + l: l, + v: x, + d: d, + r: r, + h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + } + if (r) { + var rr = r.r; + var rd = r.d; + var rv = r.v; + var rl = r.l; + if (height(rr) >= height(rl)) { + return create(create(l, x, d, rl), rv, rd, rr); + } + if (rl) { + return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; + }; + var is_empty = function (param) { + if (param) { + return false; + } else { + return true; + } + }; + var add = function (x, data, m) { + if (!m) { + return /* Node */{ + l: /* Empty */0, + v: x, + d: data, + r: /* Empty */0, + h: 1 + }; + } + var r = m.r; + var d = m.d; + var v = m.v; + var l = m.l; + var c = Curry._2(funarg.compare, x, v); + if (c === 0) { + if (d === data) { + return m; + } else { + return /* Node */{ + l: l, + v: x, + d: data, + r: r, + h: m.h + }; + } + } + if (c < 0) { + var ll = add(x, data, l); + if (l === ll) { + return m; + } else { + return bal(ll, v, d, r); + } + } + var rr = add(x, data, r); + if (r === rr) { + return m; + } else { + return bal(l, v, d, rr); + } + }; + var find = function (x, _param) { + while(true) { + var param = _param; + if (param) { + var c = Curry._2(funarg.compare, x, param.v); + if (c === 0) { + return param.d; + } + _param = c < 0 ? param.l : param.r; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + }; + var find_first = function (f, _param) { + while(true) { + var param = _param; + if (param) { + var v = param.v; + if (Curry._1(f, v)) { + var _v0 = v; + var _d0 = param.d; + var _param$1 = param.l; + while(true) { + var param$1 = _param$1; + var d0 = _d0; + var v0 = _v0; + if (!param$1) { + return [ + v0, + d0 + ]; + } + var v$1 = param$1.v; + if (Curry._1(f, v$1)) { + _param$1 = param$1.l; + _d0 = param$1.d; + _v0 = v$1; + continue ; + } + _param$1 = param$1.r; + continue ; + }; + } + _param = param.r; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + }; + var find_first_opt = function (f, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + var v = param.v; + if (Curry._1(f, v)) { + var _v0 = v; + var _d0 = param.d; + var _param$1 = param.l; + while(true) { + var param$1 = _param$1; + var d0 = _d0; + var v0 = _v0; + if (!param$1) { + return [ + v0, + d0 + ]; + } + var v$1 = param$1.v; + if (Curry._1(f, v$1)) { + _param$1 = param$1.l; + _d0 = param$1.d; + _v0 = v$1; + continue ; + } + _param$1 = param$1.r; + continue ; + }; + } + _param = param.r; + continue ; + }; + }; + var find_last = function (f, _param) { + while(true) { + var param = _param; + if (param) { + var v = param.v; + if (Curry._1(f, v)) { + var _v0 = v; + var _d0 = param.d; + var _param$1 = param.r; + while(true) { + var param$1 = _param$1; + var d0 = _d0; + var v0 = _v0; + if (!param$1) { + return [ + v0, + d0 + ]; + } + var v$1 = param$1.v; + if (Curry._1(f, v$1)) { + _param$1 = param$1.r; + _d0 = param$1.d; + _v0 = v$1; + continue ; + } + _param$1 = param$1.l; + continue ; + }; + } + _param = param.l; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + }; + var find_last_opt = function (f, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + var v = param.v; + if (Curry._1(f, v)) { + var _v0 = v; + var _d0 = param.d; + var _param$1 = param.r; + while(true) { + var param$1 = _param$1; + var d0 = _d0; + var v0 = _v0; + if (!param$1) { + return [ + v0, + d0 + ]; + } + var v$1 = param$1.v; + if (Curry._1(f, v$1)) { + _param$1 = param$1.r; + _d0 = param$1.d; + _v0 = v$1; + continue ; + } + _param$1 = param$1.l; + continue ; + }; + } + _param = param.l; + continue ; + }; + }; + var find_opt = function (x, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + var c = Curry._2(funarg.compare, x, param.v); + if (c === 0) { + return Caml_option.some(param.d); + } + _param = c < 0 ? param.l : param.r; + continue ; + }; + }; + var mem = function (x, _param) { + while(true) { + var param = _param; + if (!param) { + return false; + } + var c = Curry._2(funarg.compare, x, param.v); + if (c === 0) { + return true; + } + _param = c < 0 ? param.l : param.r; + continue ; + }; + }; + var min_binding = function (_param) { + while(true) { + var param = _param; + if (param) { + var l = param.l; + if (!l) { + return [ + param.v, + param.d + ]; + } + _param = l; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + }; + var min_binding_opt = function (_param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + var l = param.l; + if (!l) { + return [ + param.v, + param.d + ]; + } + _param = l; + continue ; + }; + }; + var max_binding = function (_param) { + while(true) { + var param = _param; + if (param) { + if (!param.r) { + return [ + param.v, + param.d + ]; + } + _param = param.r; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + }; + var max_binding_opt = function (_param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + if (!param.r) { + return [ + param.v, + param.d + ]; + } + _param = param.r; + continue ; + }; + }; + var remove_min_binding = function (param) { + if (param) { + var l = param.l; + if (l) { + return bal(remove_min_binding(l), param.v, param.d, param.r); + } else { + return param.r; + } + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.remove_min_elt", + Error: new Error() + }; + }; + var merge = function (t1, t2) { + if (!t1) { + return t2; + } + if (!t2) { + return t1; + } + var match = min_binding(t2); + return bal(t1, match[0], match[1], remove_min_binding(t2)); + }; + var remove = function (x, m) { + if (!m) { + return /* Empty */0; + } + var r = m.r; + var d = m.d; + var v = m.v; + var l = m.l; + var c = Curry._2(funarg.compare, x, v); + if (c === 0) { + return merge(l, r); + } + if (c < 0) { + var ll = remove(x, l); + if (l === ll) { + return m; + } else { + return bal(ll, v, d, r); + } + } + var rr = remove(x, r); + if (r === rr) { + return m; + } else { + return bal(l, v, d, rr); + } + }; + var update = function (x, f, m) { + if (m) { + var r = m.r; + var d = m.d; + var v = m.v; + var l = m.l; + var c = Curry._2(funarg.compare, x, v); + if (c === 0) { + var data = Curry._1(f, Caml_option.some(d)); + if (data === undefined) { + return merge(l, r); + } + var data$1 = Caml_option.valFromOption(data); + if (d === data$1) { + return m; + } else { + return /* Node */{ + l: l, + v: x, + d: data$1, + r: r, + h: m.h + }; + } + } + if (c < 0) { + var ll = update(x, f, l); + if (l === ll) { + return m; + } else { + return bal(ll, v, d, r); + } + } + var rr = update(x, f, r); + if (r === rr) { + return m; + } else { + return bal(l, v, d, rr); + } + } + var data$2 = Curry._1(f, undefined); + if (data$2 !== undefined) { + return /* Node */{ + l: /* Empty */0, + v: x, + d: Caml_option.valFromOption(data$2), + r: /* Empty */0, + h: 1 + }; + } else { + return /* Empty */0; + } + }; + var add_to_list = function (x, data, m) { + var add = function (param) { + if (param !== undefined) { + return { + hd: data, + tl: param + }; + } else { + return { + hd: data, + tl: /* [] */0 + }; + } + }; + return update(x, add, m); + }; + var iter = function (f, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + iter(f, param.l); + Curry._2(f, param.v, param.d); + _param = param.r; + continue ; + }; + }; + var map = function (f, param) { + if (!param) { + return /* Empty */0; + } + var l$p = map(f, param.l); + var d$p = Curry._1(f, param.d); + var r$p = map(f, param.r); + return /* Node */{ + l: l$p, + v: param.v, + d: d$p, + r: r$p, + h: param.h + }; + }; + var mapi = function (f, param) { + if (!param) { + return /* Empty */0; + } + var v = param.v; + var l$p = mapi(f, param.l); + var d$p = Curry._2(f, v, param.d); + var r$p = mapi(f, param.r); + return /* Node */{ + l: l$p, + v: v, + d: d$p, + r: r$p, + h: param.h + }; + }; + var fold = function (f, _m, _accu) { + while(true) { + var accu = _accu; + var m = _m; + if (!m) { + return accu; + } + _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); + _m = m.r; + continue ; + }; + }; + var for_all = function (p, _param) { + while(true) { + var param = _param; + if (!param) { + return true; + } + if (!Curry._2(p, param.v, param.d)) { + return false; + } + if (!for_all(p, param.l)) { + return false; + } + _param = param.r; + continue ; + }; + }; + var exists = function (p, _param) { + while(true) { + var param = _param; + if (!param) { + return false; + } + if (Curry._2(p, param.v, param.d)) { + return true; + } + if (exists(p, param.l)) { + return true; + } + _param = param.r; + continue ; + }; + }; + var add_min_binding = function (k, x, param) { + if (param) { + return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); + } else { + return singleton(k, x); + } + }; + var add_max_binding = function (k, x, param) { + if (param) { + return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); + } else { + return singleton(k, x); + } + }; + var join = function (l, v, d, r) { + if (!l) { + return add_min_binding(v, d, r); + } + if (!r) { + return add_max_binding(v, d, l); + } + var rh = r.h; + var lh = l.h; + if (lh > (rh + 2 | 0)) { + return bal(l.l, l.v, l.d, join(l.r, v, d, r)); + } else if (rh > (lh + 2 | 0)) { + return bal(join(l, v, d, r.l), r.v, r.d, r.r); + } else { + return create(l, v, d, r); + } + }; + var concat = function (t1, t2) { + if (!t1) { + return t2; + } + if (!t2) { + return t1; + } + var match = min_binding(t2); + return join(t1, match[0], match[1], remove_min_binding(t2)); + }; + var concat_or_join = function (t1, v, d, t2) { + if (d !== undefined) { + return join(t1, v, Caml_option.valFromOption(d), t2); + } else { + return concat(t1, t2); + } + }; + var split = function (x, param) { + if (!param) { + return [ + /* Empty */0, + undefined, + /* Empty */0 + ]; + } + var r = param.r; + var d = param.d; + var v = param.v; + var l = param.l; + var c = Curry._2(funarg.compare, x, v); + if (c === 0) { + return [ + l, + Caml_option.some(d), + r + ]; + } + if (c < 0) { + var match = split(x, l); + return [ + match[0], + match[1], + join(match[2], v, d, r) + ]; + } + var match$1 = split(x, r); + return [ + join(l, v, d, match$1[0]), + match$1[1], + match$1[2] + ]; + }; + var merge$1 = function (f, s1, s2) { + if (s1) { + var v1 = s1.v; + if (s1.h >= height(s2)) { + var match = split(v1, s2); + return concat_or_join(merge$1(f, s1.l, match[0]), v1, Curry._3(f, v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); + } + + } else if (!s2) { + return /* Empty */0; + } + if (s2) { + var v2 = s2.v; + var match$1 = split(v2, s1); + return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/map.ml", + 408, + 10 + ], + Error: new Error() + }; + }; + var union = function (f, s1, s2) { + if (!s1) { + return s2; + } + if (!s2) { + return s1; + } + var d2 = s2.d; + var v2 = s2.v; + var d1 = s1.d; + var v1 = s1.v; + if (s1.h >= s2.h) { + var match = split(v1, s2); + var d2$1 = match[1]; + var l = union(f, s1.l, match[0]); + var r = union(f, s1.r, match[2]); + if (d2$1 !== undefined) { + return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); + } else { + return join(l, v1, d1, r); + } + } + var match$1 = split(v2, s1); + var d1$1 = match$1[1]; + var l$1 = union(f, match$1[0], s2.l); + var r$1 = union(f, match$1[2], s2.r); + if (d1$1 !== undefined) { + return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); + } else { + return join(l$1, v2, d2, r$1); + } + }; + var filter = function (p, m) { + if (!m) { + return /* Empty */0; + } + var r = m.r; + var d = m.d; + var v = m.v; + var l = m.l; + var l$p = filter(p, l); + var pvd = Curry._2(p, v, d); + var r$p = filter(p, r); + if (pvd) { + if (l === l$p && r === r$p) { + return m; + } else { + return join(l$p, v, d, r$p); + } + } else { + return concat(l$p, r$p); + } + }; + var filter_map = function (f, param) { + if (!param) { + return /* Empty */0; + } + var v = param.v; + var l$p = filter_map(f, param.l); + var fvd = Curry._2(f, v, param.d); + var r$p = filter_map(f, param.r); + if (fvd !== undefined) { + return join(l$p, v, Caml_option.valFromOption(fvd), r$p); + } else { + return concat(l$p, r$p); + } + }; + var partition = function (p, param) { + if (!param) { + return [ + /* Empty */0, + /* Empty */0 + ]; + } + var d = param.d; + var v = param.v; + var match = partition(p, param.l); + var lf = match[1]; + var lt = match[0]; + var pvd = Curry._2(p, v, d); + var match$1 = partition(p, param.r); + var rf = match$1[1]; + var rt = match$1[0]; + if (pvd) { + return [ + join(lt, v, d, rt), + concat(lf, rf) + ]; + } else { + return [ + concat(lt, rt), + join(lf, v, d, rf) + ]; + } + }; + var cons_enum = function (_m, _e) { + while(true) { + var e = _e; + var m = _m; + if (!m) { + return e; + } + _e = /* More */{ + _0: m.v, + _1: m.d, + _2: m.r, + _3: e + }; + _m = m.l; + continue ; + }; + }; + var compare = function (cmp, m1, m2) { + var _e1 = cons_enum(m1, /* End */0); + var _e2 = cons_enum(m2, /* End */0); + while(true) { + var e2 = _e2; + var e1 = _e1; + if (!e1) { + if (e2) { + return -1; + } else { + return 0; + } + } + if (!e2) { + return 1; + } + var c = Curry._2(funarg.compare, e1._0, e2._0); + if (c !== 0) { + return c; + } + var c$1 = Curry._2(cmp, e1._1, e2._1); + if (c$1 !== 0) { + return c$1; + } + _e2 = cons_enum(e2._2, e2._3); + _e1 = cons_enum(e1._2, e1._3); + continue ; + }; + }; + var equal = function (cmp, m1, m2) { + var _e1 = cons_enum(m1, /* End */0); + var _e2 = cons_enum(m2, /* End */0); + while(true) { + var e2 = _e2; + var e1 = _e1; + if (!e1) { + if (e2) { + return false; + } else { + return true; + } + } + if (!e2) { + return false; + } + if (Curry._2(funarg.compare, e1._0, e2._0) !== 0) { + return false; + } + if (!Curry._2(cmp, e1._1, e2._1)) { + return false; + } + _e2 = cons_enum(e2._2, e2._3); + _e1 = cons_enum(e1._2, e1._3); + continue ; + }; + }; + var cardinal = function (param) { + if (param) { + return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; + } else { + return 0; + } + }; + var bindings_aux = function (_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + _param = param.l; + _accu = { + hd: [ + param.v, + param.d + ], + tl: bindings_aux(accu, param.r) + }; + continue ; + }; + }; + var bindings = function (s) { + return bindings_aux(/* [] */0, s); + }; + var of_list = function (bs) { + return Stdlib__List.fold_left((function (m, param) { + return add(param[0], param[1], m); + }), /* Empty */0, bs); + }; + var add_seq = function (i, m) { + return Stdlib__Seq.fold_left((function (m, param) { + return add(param[0], param[1], m); + }), m, i); + }; + var of_seq = function (i) { + return add_seq(i, /* Empty */0); + }; + var seq_of_enum_ = function (c, param) { + if (!c) { + return /* Nil */0; + } + var partial_arg = cons_enum(c._2, c._3); + return /* Cons */{ + _0: [ + c._0, + c._1 + ], + _1: (function (param) { + return seq_of_enum_(partial_arg, param); + }) + }; + }; + var to_seq = function (m) { + var partial_arg = cons_enum(m, /* End */0); + return function (param) { + return seq_of_enum_(partial_arg, param); + }; + }; + var snoc_enum = function (_s, _e) { + while(true) { + var e = _e; + var s = _s; + if (!s) { + return e; + } + _e = /* More */{ + _0: s.v, + _1: s.d, + _2: s.l, + _3: e + }; + _s = s.r; + continue ; + }; + }; + var rev_seq_of_enum_ = function (c, param) { + if (!c) { + return /* Nil */0; + } + var partial_arg = snoc_enum(c._2, c._3); + return /* Cons */{ + _0: [ + c._0, + c._1 + ], + _1: (function (param) { + return rev_seq_of_enum_(partial_arg, param); + }) + }; + }; + var to_rev_seq = function (c) { + var partial_arg = snoc_enum(c, /* End */0); + return function (param) { + return rev_seq_of_enum_(partial_arg, param); + }; + }; + var to_seq_from = function (low, m) { + var aux = function (low, _m, _c) { + while(true) { + var c = _c; + var m = _m; + if (!m) { + return c; + } + var r = m.r; + var d = m.d; + var v = m.v; + var n = Curry._2(funarg.compare, v, low); + if (n === 0) { + return /* More */{ + _0: v, + _1: d, + _2: r, + _3: c + }; + } + if (n < 0) { + _m = r; + continue ; + } + _c = /* More */{ + _0: v, + _1: d, + _2: r, + _3: c + }; + _m = m.l; + continue ; + }; + }; + var partial_arg = aux(low, m, /* End */0); + return function (param) { + return seq_of_enum_(partial_arg, param); + }; + }; + return { + empty: /* Empty */0, + add: add, + add_to_list: add_to_list, + update: update, + singleton: singleton, + remove: remove, + merge: merge$1, + union: union, + cardinal: cardinal, + bindings: bindings, + min_binding: min_binding, + min_binding_opt: min_binding_opt, + max_binding: max_binding, + max_binding_opt: max_binding_opt, + choose: min_binding, + choose_opt: min_binding_opt, + find: find, + find_opt: find_opt, + find_first: find_first, + find_first_opt: find_first_opt, + find_last: find_last, + find_last_opt: find_last_opt, + iter: iter, + fold: fold, + map: map, + mapi: mapi, + filter: filter, + filter_map: filter_map, + partition: partition, + split: split, + is_empty: is_empty, + mem: mem, + equal: equal, + compare: compare, + for_all: for_all, + exists: exists, + to_list: bindings, + of_list: of_list, + to_seq: to_seq, + to_rev_seq: to_rev_seq, + to_seq_from: to_seq_from, + add_seq: add_seq, + of_seq: of_seq + }; +} + +export { + Make , +} +/* No side effect */ diff --git a/melange-node-modules/melange/marshal.js b/melange-node-modules/melange/marshal.js new file mode 100644 index 0000000..677ce1d --- /dev/null +++ b/melange-node-modules/melange/marshal.js @@ -0,0 +1,100 @@ +// Generated by Melange + +import * as Caml_bytes from "melange.js/caml_bytes.js"; +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Caml_string from "melange.js/caml_string.js"; + +function to_buffer(buff, ofs, len, v, flags) { + if (ofs < 0 || len < 0 || ofs > (buff.length - len | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Marshal.to_buffer: substring out of bounds", + Error: new Error() + }; + } + return Caml_external_polyfill.resolve("caml_output_value_to_buffer")(buff, ofs, len, v, flags); +} + +function data_size(buff, ofs) { + if (ofs < 0 || ofs > (buff.length - 16 | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Marshal.data_size", + Error: new Error() + }; + } + return Caml_external_polyfill.resolve("caml_marshal_data_size")(buff, ofs); +} + +function total_size(buff, ofs) { + return 16 + data_size(buff, ofs) | 0; +} + +function from_bytes(buff, ofs) { + if (ofs < 0 || ofs > (buff.length - 16 | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Marshal.from_bytes", + Error: new Error() + }; + } + var len = Caml_external_polyfill.resolve("caml_marshal_data_size")(buff, ofs); + if (ofs > (buff.length - (16 + len | 0) | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Marshal.from_bytes", + Error: new Error() + }; + } + return Caml_external_polyfill.resolve("caml_input_value_from_bytes")(buff, ofs); +} + +function from_string(buff, ofs) { + return from_bytes(Caml_bytes.bytes_of_string(buff), ofs); +} + +function compression_supported(param) { + var s = Caml_external_polyfill.resolve("caml_output_value_to_string")(undefined, { + hd: /* Compression */3, + tl: /* [] */0 + }); + var match = Caml_string.get(s, 3); + if (match === 189) { + return true; + } + if (match === 190) { + return false; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/marshal.ml", + 75, + 9 + ], + Error: new Error() + }; +} + +function to_channel(prim0, prim1, prim2) { + return Caml_external_polyfill.resolve("caml_output_value")(prim0, prim1, prim2); +} + +function from_channel(prim) { + return Caml_external_polyfill.resolve("caml_input_value")(prim); +} + +var header_size = 16; + +export { + to_channel , + to_buffer , + from_channel , + from_bytes , + from_string , + header_size , + data_size , + total_size , + compression_supported , +} +/* No side effect */ diff --git a/melange-node-modules/melange/moreLabels.js b/melange-node-modules/melange/moreLabels.js new file mode 100644 index 0000000..2fd5353 --- /dev/null +++ b/melange-node-modules/melange/moreLabels.js @@ -0,0 +1,18 @@ +// Generated by Melange + +import * as Stdlib__Hashtbl from "./hashtbl.js"; +import * as Stdlib__Map from "./map.js"; +import * as Stdlib__Set from "./set.js"; + +var Hashtbl = Stdlib__Hashtbl; + +var $$Map = Stdlib__Map; + +var $$Set = Stdlib__Set; + +export { + Hashtbl , + $$Map , + $$Set , +} +/* Stdlib__Hashtbl Not a pure module */ diff --git a/melange-node-modules/melange/mutex.js b/melange-node-modules/melange/mutex.js new file mode 100644 index 0000000..1f7aae2 --- /dev/null +++ b/melange-node-modules/melange/mutex.js @@ -0,0 +1,49 @@ +// Generated by Melange + +import * as Curry from "melange.js/curry.js"; + +function create(param) { + return { + contents: false + }; +} + +function lock(t) { + t.contents = true; +} + +function try_lock(t) { + if (t.contents) { + return false; + } else { + t.contents = true; + return true; + } +} + +function unlock(t) { + t.contents = false; +} + +function protect(m, f) { + m.contents = true; + var x; + try { + x = Curry._1(f, undefined); + } + catch (e){ + m.contents = false; + throw e; + } + m.contents = false; + return x; +} + +export { + create , + lock , + try_lock , + unlock , + protect , +} +/* No side effect */ diff --git a/melange-node-modules/melange/obj.js b/melange-node-modules/melange/obj.js new file mode 100644 index 0000000..c4f7bb6 --- /dev/null +++ b/melange-node-modules/melange/obj.js @@ -0,0 +1,227 @@ +// Generated by Melange + +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Stdlib__Sys from "./sys.js"; + +function is_block(a) { + return typeof a !== "number"; +} + +function double_field(x, i) { + return Caml_external_polyfill.resolve("caml_floatarray_get")(x, i); +} + +function set_double_field(x, i, v) { + Caml_external_polyfill.resolve("caml_floatarray_set")(x, i, v); +} + +var Closure = {}; + +function of_val(x) { + var slot = typeof x !== "number" && (x.TAG | 0) !== 248 && (x.length | 0) >= 1 ? x[0] : x; + var name; + if (typeof slot !== "number" && slot.TAG === 248) { + name = slot[0]; + } else { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Obj.extension_constructor", + Error: new Error() + }; + } + if (name.TAG === 252) { + return slot; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Obj.extension_constructor", + Error: new Error() + }; +} + +function name(slot) { + return slot[0]; +} + +function id(slot) { + return slot[1]; +} + +var Extension_constructor = { + of_val: of_val, + name: name, + id: id +}; + +var max_ephe_length = Stdlib__Sys.max_array_length - 2 | 0; + +function create(l) { + if (!(0 <= l && l <= max_ephe_length)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Obj.Ephemeron.create", + Error: new Error() + }; + } + return Caml_external_polyfill.resolve("caml_ephe_create")(l); +} + +function length(x) { + return (x.length | 0) - 2 | 0; +} + +function raise_if_invalid_offset(e, o, msg) { + if (0 <= o && o < ((e.length | 0) - 2 | 0)) { + return ; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: msg, + Error: new Error() + }; +} + +function get_key(e, o) { + raise_if_invalid_offset(e, o, "Obj.Ephemeron.get_key"); + return Caml_external_polyfill.resolve("caml_ephe_get_key")(e, o); +} + +function get_key_copy(e, o) { + raise_if_invalid_offset(e, o, "Obj.Ephemeron.get_key_copy"); + return Caml_external_polyfill.resolve("caml_ephe_get_key_copy")(e, o); +} + +function set_key(e, o, x) { + raise_if_invalid_offset(e, o, "Obj.Ephemeron.set_key"); + Caml_external_polyfill.resolve("caml_ephe_set_key")(e, o, x); +} + +function unset_key(e, o) { + raise_if_invalid_offset(e, o, "Obj.Ephemeron.unset_key"); + Caml_external_polyfill.resolve("caml_ephe_unset_key")(e, o); +} + +function check_key(e, o) { + raise_if_invalid_offset(e, o, "Obj.Ephemeron.check_key"); + return Caml_external_polyfill.resolve("caml_ephe_check_key")(e, o); +} + +function blit_key(e1, o1, e2, o2, l) { + if (l < 0 || o1 < 0 || o1 > (((e1.length | 0) - 2 | 0) - l | 0) || o2 < 0 || o2 > (((e2.length | 0) - 2 | 0) - l | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Obj.Ephemeron.blit_key", + Error: new Error() + }; + } + if (l !== 0) { + return Caml_external_polyfill.resolve("caml_ephe_blit_key")(e1, o1, e2, o2, l); + } + +} + +var first_non_constant_constructor_tag = 0; + +var last_non_constant_constructor_tag = 243; + +var forcing_tag = 244; + +var cont_tag = 245; + +var lazy_tag = 246; + +var closure_tag = 247; + +var object_tag = 248; + +var infix_tag = 249; + +var forward_tag = 250; + +var no_scan_tag = 251; + +var abstract_tag = 251; + +var string_tag = 252; + +var double_tag = 253; + +var double_array_tag = 254; + +var custom_tag = 255; + +var int_tag = 1000; + +var out_of_heap_tag = 1001; + +var unaligned_tag = 1002; + +function Ephemeron_get_data(prim) { + return Caml_external_polyfill.resolve("caml_ephe_get_data")(prim); +} + +function Ephemeron_get_data_copy(prim) { + return Caml_external_polyfill.resolve("caml_ephe_get_data_copy")(prim); +} + +function Ephemeron_set_data(prim0, prim1) { + return Caml_external_polyfill.resolve("caml_ephe_set_data")(prim0, prim1); +} + +function Ephemeron_unset_data(prim) { + return Caml_external_polyfill.resolve("caml_ephe_unset_data")(prim); +} + +function Ephemeron_check_data(prim) { + return Caml_external_polyfill.resolve("caml_ephe_check_data")(prim); +} + +function Ephemeron_blit_data(prim0, prim1) { + return Caml_external_polyfill.resolve("caml_ephe_blit_data")(prim0, prim1); +} + +var Ephemeron = { + create: create, + length: length, + get_key: get_key, + get_key_copy: get_key_copy, + set_key: set_key, + unset_key: unset_key, + check_key: check_key, + blit_key: blit_key, + get_data: Ephemeron_get_data, + get_data_copy: Ephemeron_get_data_copy, + set_data: Ephemeron_set_data, + unset_data: Ephemeron_unset_data, + check_data: Ephemeron_check_data, + blit_data: Ephemeron_blit_data, + max_ephe_length: max_ephe_length +}; + +export { + is_block , + double_field , + set_double_field , + first_non_constant_constructor_tag , + last_non_constant_constructor_tag , + forcing_tag , + cont_tag , + lazy_tag , + closure_tag , + object_tag , + infix_tag , + forward_tag , + no_scan_tag , + abstract_tag , + string_tag , + double_tag , + double_array_tag , + custom_tag , + int_tag , + out_of_heap_tag , + unaligned_tag , + Closure , + Extension_constructor , + Ephemeron , +} +/* No side effect */ diff --git a/melange-node-modules/melange/oo.js b/melange-node-modules/melange/oo.js new file mode 100644 index 0000000..e8b11c1 --- /dev/null +++ b/melange-node-modules/melange/oo.js @@ -0,0 +1,16 @@ +// Generated by Melange + +import * as CamlinternalOO from "./camlinternalOO.js"; + +var copy = CamlinternalOO.copy; + +var new_method = CamlinternalOO.public_method_label; + +var public_method_label = CamlinternalOO.public_method_label; + +export { + copy , + new_method , + public_method_label , +} +/* No side effect */ diff --git a/melange-node-modules/melange/option.js b/melange-node-modules/melange/option.js new file mode 100644 index 0000000..a44da55 --- /dev/null +++ b/melange-node-modules/melange/option.js @@ -0,0 +1,155 @@ +// Generated by Melange + +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib__Seq from "./seq.js"; + +function some(v) { + return Caml_option.some(v); +} + +function value(o, $$default) { + if (o !== undefined) { + return Caml_option.valFromOption(o); + } else { + return $$default; + } +} + +function get(param) { + if (param !== undefined) { + return Caml_option.valFromOption(param); + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "option is None", + Error: new Error() + }; +} + +function bind(o, f) { + if (o !== undefined) { + return Curry._1(f, Caml_option.valFromOption(o)); + } + +} + +function join(param) { + if (param !== undefined) { + return Caml_option.valFromOption(param); + } + +} + +function map(f, o) { + if (o !== undefined) { + return Caml_option.some(Curry._1(f, Caml_option.valFromOption(o))); + } + +} + +function fold(none, some, param) { + if (param !== undefined) { + return Curry._1(some, Caml_option.valFromOption(param)); + } else { + return none; + } +} + +function iter(f, param) { + if (param !== undefined) { + return Curry._1(f, Caml_option.valFromOption(param)); + } + +} + +function is_none(param) { + return param === undefined; +} + +function is_some(param) { + return param !== undefined; +} + +function equal(eq, o0, o1) { + if (o0 !== undefined) { + if (o1 !== undefined) { + return Curry._2(eq, Caml_option.valFromOption(o0), Caml_option.valFromOption(o1)); + } else { + return false; + } + } else { + return o1 === undefined; + } +} + +function compare(cmp, o0, o1) { + if (o0 !== undefined) { + if (o1 !== undefined) { + return Curry._2(cmp, Caml_option.valFromOption(o0), Caml_option.valFromOption(o1)); + } else { + return 1; + } + } else if (o1 !== undefined) { + return -1; + } else { + return 0; + } +} + +function to_result(none, param) { + if (param !== undefined) { + return { + TAG: /* Ok */0, + _0: Caml_option.valFromOption(param) + }; + } else { + return { + TAG: /* Error */1, + _0: none + }; + } +} + +function to_list(param) { + if (param !== undefined) { + return { + hd: Caml_option.valFromOption(param), + tl: /* [] */0 + }; + } else { + return /* [] */0; + } +} + +function to_seq(param) { + if (param === undefined) { + return Stdlib__Seq.empty; + } + var partial_arg = Caml_option.valFromOption(param); + return function (param) { + return Stdlib__Seq.$$return(partial_arg, param); + }; +} + +var none; + +export { + none , + some , + value , + get , + bind , + join , + map , + fold , + iter , + is_none , + is_some , + equal , + compare , + to_result , + to_list , + to_seq , +} +/* No side effect */ diff --git a/melange-node-modules/melange/out_channel.js b/melange-node-modules/melange/out_channel.js new file mode 100644 index 0000000..84fe003 --- /dev/null +++ b/melange-node-modules/melange/out_channel.js @@ -0,0 +1,108 @@ +// Generated by Melange + +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Fun from "./fun.js"; + +function with_open(openfun, s, f) { + var oc = Curry._1(openfun, s); + return Stdlib__Fun.protect((function (param) { + Stdlib.close_out_noerr(oc); + }), (function (param) { + return Curry._1(f, oc); + })); +} + +function with_open_bin(s, f) { + return with_open(Stdlib.open_out_bin, s, f); +} + +function with_open_text(s, f) { + return with_open(Stdlib.open_out, s, f); +} + +function with_open_gen(flags, perm, s, f) { + return with_open((function (param) { + return Stdlib.open_out_gen(flags, perm, param); + }), s, f); +} + +var seek = Stdlib.LargeFile.seek_out; + +var pos = Stdlib.LargeFile.pos_out; + +var length = Stdlib.LargeFile.out_channel_length; + +var stdout = Stdlib.stdout; + +var stderr = Stdlib.stderr; + +var open_bin = Stdlib.open_out_bin; + +var open_text = Stdlib.open_out; + +var open_gen = Stdlib.open_out_gen; + +var close = Stdlib.close_out; + +var close_noerr = Stdlib.close_out_noerr; + +var output_char = Stdlib.output_char; + +var output_byte = Stdlib.output_byte; + +var output_string = Stdlib.output_string; + +var output_bytes = Stdlib.output_bytes; + +var output = Stdlib.output; + +var output_substring = Stdlib.output_substring; + +var flush = Stdlib.flush; + +var flush_all = Stdlib.flush_all; + +var set_binary_mode = Stdlib.set_binary_mode_out; + +function set_buffered(prim0, prim1) { + return Caml_external_polyfill.resolve("caml_ml_set_buffered")(prim0, prim1); +} + +function is_buffered(prim) { + return Caml_external_polyfill.resolve("caml_ml_is_buffered")(prim); +} + +function isatty(prim) { + return Caml_external_polyfill.resolve("caml_sys_isatty")(prim); +} + +export { + stdout , + stderr , + open_bin , + open_text , + open_gen , + with_open_bin , + with_open_text , + with_open_gen , + close , + close_noerr , + output_char , + output_byte , + output_string , + output_bytes , + output , + output_substring , + flush , + flush_all , + seek , + pos , + length , + set_binary_mode , + set_buffered , + is_buffered , + isatty , +} +/* Stdlib__Fun Not a pure module */ diff --git a/melange-node-modules/melange/parsing.js b/melange-node-modules/melange/parsing.js new file mode 100644 index 0000000..3832a6a --- /dev/null +++ b/melange-node-modules/melange/parsing.js @@ -0,0 +1,237 @@ +// Generated by Melange + +import * as Caml_array from "melange.js/caml_array.js"; +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Caml_obj from "melange.js/caml_obj.js"; +import * as Caml_parser from "melange.js/caml_parser.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib__Array from "./array.js"; +import * as Stdlib__Lexing from "./lexing.js"; + +var YYexit = /* @__PURE__ */Caml_exceptions.create("Stdlib.Parsing.YYexit"); + +var Parse_error = /* @__PURE__ */Caml_exceptions.create("Stdlib.Parsing.Parse_error"); + +var env = { + s_stack: Caml_array.make(100, 0), + v_stack: Caml_array.make(100, undefined), + symb_start_stack: Caml_array.make(100, Stdlib__Lexing.dummy_pos), + symb_end_stack: Caml_array.make(100, Stdlib__Lexing.dummy_pos), + stacksize: 100, + stackbase: 0, + curr_char: 0, + lval: undefined, + symb_start: Stdlib__Lexing.dummy_pos, + symb_end: Stdlib__Lexing.dummy_pos, + asp: 0, + rule_len: 0, + rule_number: 0, + sp: 0, + state: 0, + errflag: 0 +}; + +function grow_stacks(param) { + var oldsize = env.stacksize; + var newsize = (oldsize << 1); + var new_s = Caml_array.make(newsize, 0); + var new_v = Caml_array.make(newsize, undefined); + var new_start = Caml_array.make(newsize, Stdlib__Lexing.dummy_pos); + var new_end = Caml_array.make(newsize, Stdlib__Lexing.dummy_pos); + Stdlib__Array.blit(env.s_stack, 0, new_s, 0, oldsize); + env.s_stack = new_s; + Stdlib__Array.blit(env.v_stack, 0, new_v, 0, oldsize); + env.v_stack = new_v; + Stdlib__Array.blit(env.symb_start_stack, 0, new_start, 0, oldsize); + env.symb_start_stack = new_start; + Stdlib__Array.blit(env.symb_end_stack, 0, new_end, 0, oldsize); + env.symb_end_stack = new_end; + env.stacksize = newsize; +} + +function clear_parser(param) { + Stdlib__Array.fill(env.v_stack, 0, env.stacksize, undefined); + env.lval = undefined; +} + +var current_lookahead_fun = { + contents: (function (param) { + return false; + }) +}; + +function yyparse(tables, start, lexer, lexbuf) { + var init_asp = env.asp; + var init_sp = env.sp; + var init_stackbase = env.stackbase; + var init_state = env.state; + var init_curr_char = env.curr_char; + var init_lval = env.lval; + var init_errflag = env.errflag; + env.stackbase = env.sp + 1 | 0; + env.curr_char = start; + env.symb_end = lexbuf.lex_curr_p; + try { + var _cmd = /* Start */0; + var _arg; + while(true) { + var arg = _arg; + var cmd = _cmd; + var match = Caml_parser.caml_parse_engine(tables, env, cmd, arg); + switch (match) { + case /* Read_token */0 : + var t = Curry._1(lexer, lexbuf); + env.symb_start = lexbuf.lex_start_p; + env.symb_end = lexbuf.lex_curr_p; + _arg = t; + _cmd = /* Token_read */1; + continue ; + case /* Raise_parse_error */1 : + throw { + RE_EXN_ID: Parse_error, + Error: new Error() + }; + case /* Grow_stacks_1 */2 : + grow_stacks(undefined); + _arg = undefined; + _cmd = /* Stacks_grown_1 */2; + continue ; + case /* Grow_stacks_2 */3 : + grow_stacks(undefined); + _arg = undefined; + _cmd = /* Stacks_grown_2 */3; + continue ; + case /* Compute_semantic_action */4 : + var match$1; + try { + match$1 = [ + /* Semantic_action_computed */4, + Curry._1(Caml_array.get(tables.actions, env.rule_number), env) + ]; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Parse_error) { + match$1 = [ + /* Error_detected */5, + undefined + ]; + } else { + throw exn; + } + } + _arg = match$1[1]; + _cmd = match$1[0]; + continue ; + case /* Call_error_function */5 : + Curry._1(tables.error_function, "syntax error"); + _arg = undefined; + _cmd = /* Error_detected */5; + continue ; + + } + }; + } + catch (raw_exn$1){ + var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); + var curr_char = env.curr_char; + env.asp = init_asp; + env.sp = init_sp; + env.stackbase = init_stackbase; + env.state = init_state; + env.curr_char = init_curr_char; + env.lval = init_lval; + env.errflag = init_errflag; + if (exn$1.RE_EXN_ID === YYexit) { + return exn$1._1; + } + current_lookahead_fun.contents = (function (tok) { + if (typeof tok !== "number") { + return Caml_array.get(tables.transl_block, tok.TAG | 0) === curr_char; + } else { + return Caml_array.get(tables.transl_const, tok) === curr_char; + } + }); + throw exn$1; + } +} + +function peek_val(env, n) { + return Caml_array.get(env.v_stack, env.asp - n | 0); +} + +function symbol_start_pos(param) { + var _i = env.rule_len; + while(true) { + var i = _i; + if (i <= 0) { + return Caml_array.get(env.symb_end_stack, env.asp); + } + var st = Caml_array.get(env.symb_start_stack, (env.asp - i | 0) + 1 | 0); + var en = Caml_array.get(env.symb_end_stack, (env.asp - i | 0) + 1 | 0); + if (Caml_obj.caml_notequal(st, en)) { + return st; + } + _i = i - 1 | 0; + continue ; + }; +} + +function symbol_end_pos(param) { + return Caml_array.get(env.symb_end_stack, env.asp); +} + +function rhs_start_pos(n) { + return Caml_array.get(env.symb_start_stack, env.asp - (env.rule_len - n | 0) | 0); +} + +function rhs_end_pos(n) { + return Caml_array.get(env.symb_end_stack, env.asp - (env.rule_len - n | 0) | 0); +} + +function symbol_start(param) { + return symbol_start_pos(undefined).pos_cnum; +} + +function symbol_end(param) { + return symbol_end_pos(undefined).pos_cnum; +} + +function rhs_start(n) { + return rhs_start_pos(n).pos_cnum; +} + +function rhs_end(n) { + return rhs_end_pos(n).pos_cnum; +} + +function is_current_lookahead(tok) { + return Curry._1(current_lookahead_fun.contents, tok); +} + +function parse_error(param) { + +} + +var set_trace = Caml_parser.caml_set_parser_trace; + +export { + symbol_start , + symbol_end , + rhs_start , + rhs_end , + symbol_start_pos , + symbol_end_pos , + rhs_start_pos , + rhs_end_pos , + clear_parser , + Parse_error , + set_trace , + YYexit , + yyparse , + peek_val , + is_current_lookahead , + parse_error , +} +/* No side effect */ diff --git a/melange-node-modules/melange/printexc.js b/melange-node-modules/melange/printexc.js new file mode 100644 index 0000000..9438fbc --- /dev/null +++ b/melange-node-modules/melange/printexc.js @@ -0,0 +1,562 @@ +// Generated by Melange + +import * as Caml_array from "melange.js/caml_array.js"; +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Caml_io from "melange.js/caml_io.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Atomic from "./atomic.js"; +import * as Stdlib__Buffer from "./buffer.js"; +import * as Stdlib__Printf from "./printf.js"; + +var printers = Stdlib__Atomic.make(/* [] */0); + +var locfmt = /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "File \"", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: "\", line ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* String_literal */11, + _0: ", characters ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* Char_literal */12, + _0: /* '-' */45, + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* String_literal */11, + _0: ": ", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: /* End_of_format */0 + } + } + } + } + } + } + } + } + } + }, + _1: "File \"%s\", line %d, characters %d-%d: %s" +}; + +var fields = (function(x){ + var s = "" + var index = 1 + while ("_"+index in x){ + s += x ["_" + index]; + ++ index + } + if(index === 1){ + return s + } + return "(" + s + ")" +}); + +function use_printers(x) { + var _param = Stdlib__Atomic.get(printers); + while(true) { + var param = _param; + if (!param) { + return ; + } + var tl = param.tl; + var val; + try { + val = Curry._1(param.hd, x); + } + catch (exn){ + _param = tl; + continue ; + } + if (val !== undefined) { + return Caml_option.some(Caml_option.valFromOption(val)); + } + _param = tl; + continue ; + }; +} + +function to_string_default(x) { + if (x.RE_EXN_ID === Stdlib.Out_of_memory) { + return "Out of memory"; + } + if (x.RE_EXN_ID === Stdlib.Stack_overflow) { + return "Stack overflow"; + } + if (x.RE_EXN_ID === Stdlib.Match_failure) { + var match = x._1; + var $$char = match[2]; + return Curry._5(Stdlib__Printf.sprintf(locfmt), match[0], match[1], $$char, $$char + 5 | 0, "Pattern matching failed"); + } + if (x.RE_EXN_ID === Stdlib.Assert_failure) { + var match$1 = x._1; + var $$char$1 = match$1[2]; + return Curry._5(Stdlib__Printf.sprintf(locfmt), match$1[0], match$1[1], $$char$1, $$char$1 + 6 | 0, "Assertion failed"); + } + if (x.RE_EXN_ID === Stdlib.Undefined_recursive_module) { + var match$2 = x._1; + var $$char$2 = match$2[2]; + return Curry._5(Stdlib__Printf.sprintf(locfmt), match$2[0], match$2[1], $$char$2, $$char$2 + 6 | 0, "Undefined recursive module"); + } + var constructor = Caml_exceptions.caml_exn_slot_name(x); + return constructor + fields(x); +} + +function to_string(e) { + var s = use_printers(e); + if (s !== undefined) { + return s; + } else { + return to_string_default(e); + } +} + +function print(fct, arg) { + try { + return Curry._1(fct, arg); + } + catch (raw_x){ + var x = Caml_js_exceptions.internalToOCamlException(raw_x); + Curry._1(Stdlib__Printf.eprintf(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "Uncaught exception: ", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "Uncaught exception: %s\n" + }), to_string(x)); + Caml_io.caml_ml_flush(Stdlib.stderr); + throw x; + } +} + +function $$catch(fct, arg) { + try { + return Curry._1(fct, arg); + } + catch (raw_x){ + var x = Caml_js_exceptions.internalToOCamlException(raw_x); + Caml_io.caml_ml_flush(Stdlib.stdout); + Curry._1(Stdlib__Printf.eprintf(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "Uncaught exception: ", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "Uncaught exception: %s\n" + }), to_string(x)); + return Stdlib.exit(2); + } +} + +function raw_backtrace_entries(bt) { + return bt; +} + +function convert_raw_backtrace_slot(param) { + throw { + RE_EXN_ID: "Failure", + _1: "convert_raw_backtrace_slot not implemented", + Error: new Error() + }; +} + +function convert_raw_backtrace(bt) { + try { + return undefined; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Failure) { + return ; + } + throw exn; + } +} + +function format_backtrace_slot(pos, slot) { + var info = function (is_raise) { + if (is_raise) { + if (pos === 0) { + return "Raised at"; + } else { + return "Re-raised at"; + } + } else if (pos === 0) { + return "Raised by primitive operation at"; + } else { + return "Called from"; + } + }; + if (slot.TAG === /* Known_location */0) { + return Curry._7(Stdlib__Printf.sprintf(/* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* Char_literal */12, + _0: /* ' ' */32, + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: " in file \"", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* Char_literal */12, + _0: /* '"' */34, + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: ", line ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* String_literal */11, + _0: ", characters ", + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* Char_literal */12, + _0: /* '-' */45, + _1: { + TAG: /* Int */4, + _0: /* Int_d */0, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: /* End_of_format */0 + } + } + } + } + } + } + } + } + } + } + } + } + }, + _1: "%s %s in file \"%s\"%s, line %d, characters %d-%d" + }), info(slot.is_raise), slot.defname, slot.filename, slot.is_inline ? " (inlined)" : "", slot.line_number, slot.start_char, slot.end_char); + } else if (slot.is_raise) { + return ; + } else { + return Curry._1(Stdlib__Printf.sprintf(/* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: " unknown location", + _1: /* End_of_format */0 + } + }, + _1: "%s unknown location" + }), info(false)); + } +} + +function print_raw_backtrace(outchan, raw_backtrace) { + var backtrace = convert_raw_backtrace(raw_backtrace); + if (backtrace === undefined) { + return Stdlib__Printf.fprintf(outchan, /* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "(Program not linked with -g, cannot print stack backtrace)\n", + _1: /* End_of_format */0 + }, + _1: "(Program not linked with -g, cannot print stack backtrace)\n" + }); + } + for(var i = 0 ,i_finish = backtrace.length; i < i_finish; ++i){ + var str = format_backtrace_slot(i, Caml_array.get(backtrace, i)); + if (str !== undefined) { + Curry._1(Stdlib__Printf.fprintf(outchan, /* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + }, + _1: "%s\n" + }), str); + } + + } +} + +function print_backtrace(outchan) { + print_raw_backtrace(outchan, undefined); +} + +function raw_backtrace_to_string(raw_backtrace) { + var backtrace = convert_raw_backtrace(raw_backtrace); + if (backtrace === undefined) { + return "(Program not linked with -g, cannot print stack backtrace)\n"; + } + var b = Stdlib__Buffer.create(1024); + for(var i = 0 ,i_finish = backtrace.length; i < i_finish; ++i){ + var str = format_backtrace_slot(i, Caml_array.get(backtrace, i)); + if (str !== undefined) { + Curry._1(Stdlib__Printf.bprintf(b, /* Format */{ + _0: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + }, + _1: "%s\n" + }), str); + } + + } + return Stdlib__Buffer.contents(b); +} + +function backtrace_slot_is_raise(param) { + return param.is_raise; +} + +function backtrace_slot_is_inline(param) { + if (param.TAG === /* Known_location */0) { + return param.is_inline; + } else { + return false; + } +} + +function backtrace_slot_location(param) { + if (param.TAG === /* Known_location */0) { + return { + filename: param.filename, + line_number: param.line_number, + start_char: param.start_char, + end_char: param.end_char + }; + } + +} + +function backtrace_slot_defname(param) { + if (param.TAG === /* Known_location */0 && param.defname !== "") { + return param.defname; + } + +} + +function backtrace_slots(raw_backtrace) { + var backtrace = convert_raw_backtrace(raw_backtrace); + if (backtrace === undefined) { + return ; + } + var usable_slot = function (param) { + if (param.TAG === /* Known_location */0) { + return true; + } else { + return false; + } + }; + var exists_usable = function (_i) { + while(true) { + var i = _i; + if (i === -1) { + return false; + } + if (usable_slot(Caml_array.get(backtrace, i))) { + return true; + } + _i = i - 1 | 0; + continue ; + }; + }; + if (exists_usable(backtrace.length - 1 | 0)) { + return backtrace; + } + +} + +function backtrace_slots_of_raw_entry(entry) { + return backtrace_slots([entry]); +} + +function raw_backtrace_length(bt) { + return bt.length; +} + +function get_backtrace(param) { + return raw_backtrace_to_string(undefined); +} + +function register_printer(fn) { + while(true) { + var old_printers = Stdlib__Atomic.get(printers); + var new_printers = { + hd: fn, + tl: old_printers + }; + var success = Stdlib__Atomic.compare_and_set(printers, old_printers, new_printers); + if (success) { + return ; + } + continue ; + }; +} + +var errors = [ + "", + "(Cannot print locations:\n bytecode executable program file not found)", + "(Cannot print locations:\n bytecode executable program file appears to be corrupt)", + "(Cannot print locations:\n bytecode executable program file has wrong magic number)", + "(Cannot print locations:\n bytecode executable program file cannot be opened;\n -- too many open files. Try running with OCAMLRUNPARAM=b=2)" +]; + +function default_uncaught_exception_handler(exn, raw_backtrace) { + Curry._1(Stdlib__Printf.eprintf(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "Fatal error: exception ", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* Char_literal */12, + _0: /* '\n' */10, + _1: /* End_of_format */0 + } + } + }, + _1: "Fatal error: exception %s\n" + }), to_string(exn)); + print_raw_backtrace(Stdlib.stderr, raw_backtrace); + var status = Caml_external_polyfill.resolve("caml_ml_debug_info_status")(undefined); + if (status < 0) { + console.error(Caml_array.get(errors, Stdlib.abs(status))); + } + Caml_io.caml_ml_flush(Stdlib.stderr); +} + +function set_uncaught_exception_handler(param) { + +} + +function record_backtrace(prim) { + +} + +function backtrace_status(prim) { + +} + +function get_raw_backtrace(prim) { + +} + +var Slot = { + is_raise: backtrace_slot_is_raise, + is_inline: backtrace_slot_is_inline, + $$location: backtrace_slot_location, + name: backtrace_slot_defname, + format: format_backtrace_slot +}; + +function get_raw_backtrace_slot(prim0, prim1) { + return Caml_external_polyfill.resolve("caml_raw_backtrace_slot")(prim0, prim1); +} + +function get_raw_backtrace_next_slot(prim) { + return Caml_external_polyfill.resolve("caml_raw_backtrace_next_slot")(prim); +} + +var exn_slot_id = Caml_exceptions.caml_exn_slot_id; + +var exn_slot_name = Caml_exceptions.caml_exn_slot_name; + +export { + to_string , + to_string_default , + print , + $$catch , + print_backtrace , + get_backtrace , + record_backtrace , + backtrace_status , + register_printer , + use_printers , + raw_backtrace_entries , + get_raw_backtrace , + print_raw_backtrace , + raw_backtrace_to_string , + default_uncaught_exception_handler , + set_uncaught_exception_handler , + backtrace_slots , + backtrace_slots_of_raw_entry , + Slot , + raw_backtrace_length , + get_raw_backtrace_slot , + convert_raw_backtrace_slot , + get_raw_backtrace_next_slot , + exn_slot_id , + exn_slot_name , +} +/* printers Not a pure module */ diff --git a/melange-node-modules/melange/printf.js b/melange-node-modules/melange/printf.js new file mode 100644 index 0000000..aaa1dfb --- /dev/null +++ b/melange-node-modules/melange/printf.js @@ -0,0 +1,92 @@ +// Generated by Melange + +import * as CamlinternalFormat from "./camlinternalFormat.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Buffer from "./buffer.js"; + +function kfprintf(k, o, param) { + return CamlinternalFormat.make_printf((function (acc) { + CamlinternalFormat.output_acc(o, acc); + return Curry._1(k, o); + }), /* End_of_acc */0, param._0); +} + +function kbprintf(k, b, param) { + return CamlinternalFormat.make_printf((function (acc) { + CamlinternalFormat.bufput_acc(b, acc); + return Curry._1(k, b); + }), /* End_of_acc */0, param._0); +} + +function ikfprintf(k, oc, param) { + return CamlinternalFormat.make_iprintf(k, oc, param._0); +} + +function fprintf(oc, fmt) { + return kfprintf((function (prim) { + + }), oc, fmt); +} + +function bprintf(b, fmt) { + return kbprintf((function (prim) { + + }), b, fmt); +} + +function ifprintf(oc, fmt) { + return ikfprintf((function (prim) { + + }), oc, fmt); +} + +function ibprintf(b, fmt) { + return ikfprintf((function (prim) { + + }), b, fmt); +} + +function printf(fmt) { + return fprintf(Stdlib.stdout, fmt); +} + +function eprintf(fmt) { + return fprintf(Stdlib.stderr, fmt); +} + +function ksprintf(k, param) { + var k$p = function (acc) { + var buf = Stdlib__Buffer.create(64); + CamlinternalFormat.strput_acc(buf, acc); + return Curry._1(k, Stdlib__Buffer.contents(buf)); + }; + return CamlinternalFormat.make_printf(k$p, /* End_of_acc */0, param._0); +} + +function sprintf(fmt) { + return ksprintf((function (s) { + return s; + }), fmt); +} + +var ikbprintf = ikfprintf; + +var kprintf = ksprintf; + +export { + fprintf , + printf , + eprintf , + sprintf , + bprintf , + ifprintf , + ibprintf , + kfprintf , + ikfprintf , + ksprintf , + kbprintf , + ikbprintf , + kprintf , +} +/* No side effect */ diff --git a/melange-node-modules/melange/queue.js b/melange-node-modules/melange/queue.js new file mode 100644 index 0000000..45177aa --- /dev/null +++ b/melange-node-modules/melange/queue.js @@ -0,0 +1,248 @@ +// Generated by Melange + +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib__Seq from "./seq.js"; + +var Empty = /* @__PURE__ */Caml_exceptions.create("Stdlib.Queue.Empty"); + +function create(param) { + return { + length: 0, + first: /* Nil */0, + last: /* Nil */0 + }; +} + +function clear(q) { + q.length = 0; + q.first = /* Nil */0; + q.last = /* Nil */0; +} + +function add(x, q) { + var cell = /* Cons */{ + content: x, + next: /* Nil */0 + }; + var last = q.last; + if (last) { + q.length = q.length + 1 | 0; + last.next = cell; + q.last = cell; + } else { + q.length = 1; + q.first = cell; + q.last = cell; + } +} + +function peek(q) { + var match = q.first; + if (match) { + return match.content; + } + throw { + RE_EXN_ID: Empty, + Error: new Error() + }; +} + +function peek_opt(q) { + var match = q.first; + if (match) { + return Caml_option.some(match.content); + } + +} + +function take(q) { + var match = q.first; + if (match) { + var content = match.content; + var match$1 = match.next; + if (match$1) { + var next = match.next; + q.length = q.length - 1 | 0; + q.first = next; + return content; + } + clear(q); + return content; + } + throw { + RE_EXN_ID: Empty, + Error: new Error() + }; +} + +function take_opt(q) { + var match = q.first; + if (!match) { + return ; + } + var content = match.content; + var match$1 = match.next; + if (match$1) { + var next = match.next; + q.length = q.length - 1 | 0; + q.first = next; + return Caml_option.some(content); + } + clear(q); + return Caml_option.some(content); +} + +function copy(q) { + var q_res = { + length: q.length, + first: /* Nil */0, + last: /* Nil */0 + }; + var _prev = /* Nil */0; + var _cell = q.first; + while(true) { + var cell = _cell; + var prev = _prev; + if (cell) { + var next = cell.next; + var res = /* Cons */{ + content: cell.content, + next: /* Nil */0 + }; + if (prev) { + prev.next = res; + } else { + q_res.first = res; + } + _cell = next; + _prev = res; + continue ; + } + q_res.last = prev; + return q_res; + }; +} + +function is_empty(q) { + return q.length === 0; +} + +function length(q) { + return q.length; +} + +function iter(f, q) { + var _cell = q.first; + while(true) { + var cell = _cell; + if (!cell) { + return ; + } + var next = cell.next; + Curry._1(f, cell.content); + _cell = next; + continue ; + }; +} + +function fold(f, accu, q) { + var _accu = accu; + var _cell = q.first; + while(true) { + var cell = _cell; + var accu$1 = _accu; + if (!cell) { + return accu$1; + } + var next = cell.next; + var accu$2 = Curry._2(f, accu$1, cell.content); + _cell = next; + _accu = accu$2; + continue ; + }; +} + +function transfer(q1, q2) { + if (q1.length <= 0) { + return ; + } + var last = q2.last; + if (last) { + q2.length = q2.length + q1.length | 0; + last.next = q1.first; + q2.last = q1.last; + return clear(q1); + } else { + q2.length = q1.length; + q2.first = q1.first; + q2.last = q1.last; + return clear(q1); + } +} + +function to_seq(q) { + var aux = function (c, param) { + if (!c) { + return /* Nil */0; + } + var next = c.next; + return /* Cons */{ + _0: c.content, + _1: (function (param) { + return aux(next, param); + }) + }; + }; + var partial_arg = q.first; + return function (param) { + return aux(partial_arg, param); + }; +} + +function add_seq(q, i) { + Stdlib__Seq.iter((function (x) { + add(x, q); + }), i); +} + +function of_seq(g) { + var q = { + length: 0, + first: /* Nil */0, + last: /* Nil */0 + }; + add_seq(q, g); + return q; +} + +var push = add; + +var pop = take; + +var top = peek; + +export { + Empty , + create , + add , + push , + take , + take_opt , + pop , + peek , + peek_opt , + top , + clear , + copy , + is_empty , + length , + iter , + fold , + transfer , + to_seq , + add_seq , + of_seq , +} +/* No side effect */ diff --git a/melange-node-modules/melange/random.js b/melange-node-modules/melange/random.js new file mode 100644 index 0000000..edebfdd --- /dev/null +++ b/melange-node-modules/melange/random.js @@ -0,0 +1,355 @@ +// Generated by Melange + +import * as Caml from "melange.js/caml.js"; +import * as Caml_array from "melange.js/caml_array.js"; +import * as Caml_format from "melange.js/caml_format.js"; +import * as Caml_int64 from "melange.js/caml_int64.js"; +import * as Caml_string from "melange.js/caml_string.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Array from "./array.js"; +import * as Stdlib__Digest from "./digest.js"; +import * as Stdlib__Int from "./int.js"; +import * as Stdlib__Int32 from "./int32.js"; +import * as Stdlib__Int64 from "./int64.js"; + +function random_seed(param) { + return [(Math.floor(Math.random()*0x7fffffff))]; +} + +function assign(st1, st2) { + Stdlib__Array.blit(st2.st, 0, st1.st, 0, 55); + st1.idx = st2.idx; +} + +function full_init(s, seed) { + var combine = function (accu, x) { + return Stdlib__Digest.string(accu + Caml_format.caml_format_int("%d", x)); + }; + var extract = function (d) { + return ((Caml_string.get(d, 0) + (Caml_string.get(d, 1) << 8) | 0) + (Caml_string.get(d, 2) << 16) | 0) + (Caml_string.get(d, 3) << 24) | 0; + }; + var seed$1 = seed.length === 0 ? [0] : seed; + var l = seed$1.length; + for(var i = 0; i <= 54; ++i){ + Caml_array.set(s.st, i, i); + } + var accu = "x"; + for(var i$1 = 0 ,i_finish = 54 + Stdlib__Int.max(55, l) | 0; i$1 <= i_finish; ++i$1){ + var j = i$1 % 55; + var k = i$1 % l; + accu = combine(accu, Caml_array.get(seed$1, k)); + Caml_array.set(s.st, j, (Caml_array.get(s.st, j) ^ extract(accu)) & 1073741823); + } + s.idx = 0; +} + +function make(seed) { + var result = { + st: Caml_array.make(55, 0), + idx: 0 + }; + full_init(result, seed); + return result; +} + +function make_self_init(param) { + return make(random_seed(undefined)); +} + +function copy(s) { + var result = { + st: Caml_array.make(55, 0), + idx: 0 + }; + assign(result, s); + return result; +} + +function bits(s) { + s.idx = (s.idx + 1 | 0) % 55; + var curval = Caml_array.get(s.st, s.idx); + var newval = Caml_array.get(s.st, (s.idx + 24 | 0) % 55) + (curval ^ (curval >>> 25) & 31) | 0; + var newval30 = newval & 1073741823; + Caml_array.set(s.st, s.idx, newval30); + return newval30; +} + +function intaux(s, n) { + while(true) { + var r = bits(s); + var v = r % n; + if ((r - v | 0) <= ((1073741823 - n | 0) + 1 | 0)) { + return v; + } + continue ; + }; +} + +function $$int(s, bound) { + if (bound > 1073741823 || bound <= 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Random.int", + Error: new Error() + }; + } + return intaux(s, bound); +} + +function full_int(s, bound) { + if (bound <= 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Random.full_int", + Error: new Error() + }; + } + if (bound > 1073741823) { + while(true) { + var b1 = bits(s); + var b2 = bits(s); + var match; + if (bound <= 2147483647) { + var bpos = ((b2 & 1073725440) << 1) | (b1 >>> 15); + match = [ + bpos, + 2147483647 + ]; + } else { + var b3 = bits(s); + var bpos$1 = ((((b3 & 1073741312) << 12) | (b2 >>> 9)) << 20) | (b1 >>> 10); + match = [ + bpos$1, + Stdlib.max_int + ]; + } + var r = match[0]; + var v = r % bound; + if ((r - v | 0) <= ((match[1] - bound | 0) + 1 | 0)) { + return v; + } + continue ; + }; + } else { + return intaux(s, bound); + } +} + +function int32(s, bound) { + if (bound <= 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Random.int32", + Error: new Error() + }; + } + while(true) { + var b1 = bits(s); + var b2 = ((bits(s) & 1) << 30); + var r = b1 | b2; + var v = r % bound; + if ((r - v | 0) <= ((Stdlib__Int32.max_int - bound | 0) + 1 | 0)) { + return v; + } + continue ; + }; +} + +function int64(s, bound) { + if (Caml.i64_le(bound, Caml_int64.zero)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Random.int64", + Error: new Error() + }; + } + while(true) { + var b1 = Caml_int64.of_int32(bits(s)); + var b2 = Caml_int64.lsl_(Caml_int64.of_int32(bits(s)), 30); + var b3 = Caml_int64.lsl_(Caml_int64.of_int32(bits(s) & 7), 60); + var r = Caml_int64.or_(b1, Caml_int64.or_(b2, b3)); + var v = Caml_int64.mod_(r, bound); + if (!Caml.i64_gt(Caml_int64.sub(r, v), Caml_int64.add(Caml_int64.sub(Stdlib__Int64.max_int, bound), Caml_int64.one))) { + return v; + } + continue ; + }; +} + +function rawfloat(s) { + var r1 = bits(s); + var r2 = bits(s); + return (r1 / 1073741824.0 + r2) / 1073741824.0; +} + +function $$float(s, bound) { + return rawfloat(s) * bound; +} + +function bool(s) { + return (bits(s) & 1) === 0; +} + +function bits32(s) { + var b1 = (bits(s) >>> 14); + var b2 = (bits(s) >>> 14); + return b1 | (b2 << 16); +} + +function bits64(s) { + var b1 = Caml_int64.lsr_(Caml_int64.of_int32(bits(s)), 9); + var b2 = Caml_int64.lsr_(Caml_int64.of_int32(bits(s)), 9); + var b3 = Caml_int64.lsr_(Caml_int64.of_int32(bits(s)), 8); + return Caml_int64.or_(b1, Caml_int64.or_(Caml_int64.lsl_(b2, 21), Caml_int64.lsl_(b3, 42))); +} + +var $$default = { + st: [ + 987910699, + 495797812, + 364182224, + 414272206, + 318284740, + 990407751, + 383018966, + 270373319, + 840823159, + 24560019, + 536292337, + 512266505, + 189156120, + 730249596, + 143776328, + 51606627, + 140166561, + 366354223, + 1003410265, + 700563762, + 981890670, + 913149062, + 526082594, + 1021425055, + 784300257, + 667753350, + 630144451, + 949649812, + 48546892, + 415514493, + 258888527, + 511570777, + 89983870, + 283659902, + 308386020, + 242688715, + 482270760, + 865188196, + 1027664170, + 207196989, + 193777847, + 619708188, + 671350186, + 149669678, + 257044018, + 87658204, + 558145612, + 183450813, + 28133145, + 901332182, + 710253903, + 510646120, + 652377910, + 409934019, + 801085050 + ], + idx: 0 +}; + +function bits$1(param) { + return bits($$default); +} + +function $$int$1(bound) { + return $$int($$default, bound); +} + +function full_int$1(bound) { + return full_int($$default, bound); +} + +function int32$1(bound) { + return int32($$default, bound); +} + +function int64$1(bound) { + return int64($$default, bound); +} + +function $$float$1(scale) { + return rawfloat($$default) * scale; +} + +function bool$1(param) { + return bool($$default); +} + +function bits32$1(param) { + return bits32($$default); +} + +function bits64$1(param) { + return bits64($$default); +} + +function full_init$1(seed) { + full_init($$default, seed); +} + +function init(seed) { + full_init($$default, [seed]); +} + +function self_init(param) { + full_init$1(random_seed(undefined)); +} + +function get_state(param) { + return copy($$default); +} + +function set_state(s) { + assign($$default, s); +} + +var State = { + make: make, + make_self_init: make_self_init, + copy: copy, + bits: bits, + $$int: $$int, + full_int: full_int, + int32: int32, + int64: int64, + $$float: $$float, + bool: bool, + bits32: bits32, + bits64: bits64 +}; + +export { + init , + full_init$1 as full_init, + self_init , + bits$1 as bits, + $$int$1 as $$int, + full_int$1 as full_int, + int32$1 as int32, + int64$1 as int64, + $$float$1 as $$float, + bool$1 as bool, + bits32$1 as bits32, + bits64$1 as bits64, + State , + get_state , + set_state , +} +/* Stdlib__Int32 Not a pure module */ diff --git a/melange-node-modules/melange/result.js b/melange-node-modules/melange/result.js new file mode 100644 index 0000000..ccea540 --- /dev/null +++ b/melange-node-modules/melange/result.js @@ -0,0 +1,205 @@ +// Generated by Melange + +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib__Seq from "./seq.js"; + +function ok(v) { + return { + TAG: /* Ok */0, + _0: v + }; +} + +function error(e) { + return { + TAG: /* Error */1, + _0: e + }; +} + +function value(r, $$default) { + if (r.TAG === /* Ok */0) { + return r._0; + } else { + return $$default; + } +} + +function get_ok(param) { + if (param.TAG === /* Ok */0) { + return param._0; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "result is Error _", + Error: new Error() + }; +} + +function get_error(param) { + if (param.TAG !== /* Ok */0) { + return param._0; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "result is Ok _", + Error: new Error() + }; +} + +function bind(r, f) { + if (r.TAG === /* Ok */0) { + return Curry._1(f, r._0); + } else { + return r; + } +} + +function join(e) { + if (e.TAG === /* Ok */0) { + return e._0; + } else { + return e; + } +} + +function map(f, e) { + if (e.TAG === /* Ok */0) { + return { + TAG: /* Ok */0, + _0: Curry._1(f, e._0) + }; + } else { + return e; + } +} + +function map_error(f, v) { + if (v.TAG === /* Ok */0) { + return v; + } else { + return { + TAG: /* Error */1, + _0: Curry._1(f, v._0) + }; + } +} + +function fold(ok, error, param) { + if (param.TAG === /* Ok */0) { + return Curry._1(ok, param._0); + } else { + return Curry._1(error, param._0); + } +} + +function iter(f, param) { + if (param.TAG === /* Ok */0) { + return Curry._1(f, param._0); + } + +} + +function iter_error(f, param) { + if (param.TAG === /* Ok */0) { + return ; + } else { + return Curry._1(f, param._0); + } +} + +function is_ok(param) { + if (param.TAG === /* Ok */0) { + return true; + } else { + return false; + } +} + +function is_error(param) { + if (param.TAG === /* Ok */0) { + return false; + } else { + return true; + } +} + +function equal(ok, error, r0, r1) { + if (r0.TAG === /* Ok */0) { + if (r1.TAG === /* Ok */0) { + return Curry._2(ok, r0._0, r1._0); + } else { + return false; + } + } else if (r1.TAG === /* Ok */0) { + return false; + } else { + return Curry._2(error, r0._0, r1._0); + } +} + +function compare(ok, error, r0, r1) { + if (r0.TAG === /* Ok */0) { + if (r1.TAG === /* Ok */0) { + return Curry._2(ok, r0._0, r1._0); + } else { + return -1; + } + } else if (r1.TAG === /* Ok */0) { + return 1; + } else { + return Curry._2(error, r0._0, r1._0); + } +} + +function to_option(param) { + if (param.TAG === /* Ok */0) { + return Caml_option.some(param._0); + } + +} + +function to_list(param) { + if (param.TAG === /* Ok */0) { + return { + hd: param._0, + tl: /* [] */0 + }; + } else { + return /* [] */0; + } +} + +function to_seq(param) { + if (param.TAG !== /* Ok */0) { + return Stdlib__Seq.empty; + } + var partial_arg = param._0; + return function (param) { + return Stdlib__Seq.$$return(partial_arg, param); + }; +} + +export { + ok , + error , + value , + get_ok , + get_error , + bind , + join , + map , + map_error , + fold , + iter , + iter_error , + is_ok , + is_error , + equal , + compare , + to_option , + to_list , + to_seq , +} +/* No side effect */ diff --git a/melange-node-modules/melange/scanf.js b/melange-node-modules/melange/scanf.js new file mode 100644 index 0000000..7c66780 --- /dev/null +++ b/melange-node-modules/melange/scanf.js @@ -0,0 +1,2236 @@ +// Generated by Melange + +import * as Caml_bytes from "melange.js/caml_bytes.js"; +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Caml_format from "melange.js/caml_format.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Caml_obj from "melange.js/caml_obj.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Caml_string from "melange.js/caml_string.js"; +import * as CamlinternalFormat from "./camlinternalFormat.js"; +import * as CamlinternalFormatBasics from "./camlinternalFormatBasics.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Buffer from "./buffer.js"; +import * as Stdlib__Int from "./int.js"; +import * as Stdlib__Printf from "./printf.js"; +import * as Stdlib__String from "./string.js"; + +function next_char(ib) { + try { + var c = Curry._1(ib.ic_get_next_char, undefined); + ib.ic_current_char = c; + ib.ic_current_char_is_valid = true; + ib.ic_char_count = ib.ic_char_count + 1 | 0; + if (c === /* '\n' */10) { + ib.ic_line_count = ib.ic_line_count + 1 | 0; + } + return c; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.End_of_file) { + ib.ic_current_char = /* '\000' */0; + ib.ic_current_char_is_valid = false; + ib.ic_eof = true; + return /* '\000' */0; + } + throw exn; + } +} + +function peek_char(ib) { + if (ib.ic_current_char_is_valid) { + return ib.ic_current_char; + } else { + return next_char(ib); + } +} + +function checked_peek_char(ib) { + var c = peek_char(ib); + if (ib.ic_eof) { + throw { + RE_EXN_ID: Stdlib.End_of_file, + Error: new Error() + }; + } + return c; +} + +function end_of_input(ib) { + peek_char(ib); + return ib.ic_eof; +} + +function beginning_of_input(ib) { + return ib.ic_char_count === 0; +} + +function name_of_input(ib) { + var _ic = ib.ic_input_name; + if (typeof _ic === "number") { + if (_ic === /* From_function */0) { + return "unnamed function"; + } else { + return "unnamed character string"; + } + } else if (_ic.TAG === /* From_channel */0) { + return "unnamed Stdlib input channel"; + } else { + return _ic._0; + } +} + +function char_count(ib) { + if (ib.ic_current_char_is_valid) { + return ib.ic_char_count - 1 | 0; + } else { + return ib.ic_char_count; + } +} + +function token(ib) { + var token_buffer = ib.ic_token_buffer; + var tok = Stdlib__Buffer.contents(token_buffer); + token_buffer.position = 0; + ib.ic_token_count = ib.ic_token_count + 1 | 0; + return tok; +} + +function ignore_char(width, ib) { + var width$1 = width - 1 | 0; + ib.ic_current_char_is_valid = false; + return width$1; +} + +function store_char(width, ib, c) { + Stdlib__Buffer.add_char(ib.ic_token_buffer, c); + return ignore_char(width, ib); +} + +function create(iname, next) { + return { + ic_eof: false, + ic_current_char: /* '\000' */0, + ic_current_char_is_valid: false, + ic_char_count: 0, + ic_line_count: 0, + ic_token_count: 0, + ic_get_next_char: next, + ic_token_buffer: Stdlib__Buffer.create(1024), + ic_input_name: iname + }; +} + +function from_string(s) { + var i = { + contents: 0 + }; + var len = s.length; + var next = function (param) { + if (i.contents >= len) { + throw { + RE_EXN_ID: Stdlib.End_of_file, + Error: new Error() + }; + } + var c = Caml_string.get(s, i.contents); + i.contents = i.contents + 1 | 0; + return c; + }; + return create(/* From_string */1, next); +} + +function from_function(param) { + return create(/* From_function */0, param); +} + +var file_buffer_size = { + contents: 1024 +}; + +function scan_close_at_end(ic) { + Caml_external_polyfill.resolve("caml_ml_close_channel")(ic); + throw { + RE_EXN_ID: Stdlib.End_of_file, + Error: new Error() + }; +} + +function scan_raise_at_end(_ic) { + throw { + RE_EXN_ID: Stdlib.End_of_file, + Error: new Error() + }; +} + +function from_ic(scan_close_ic, iname, ic) { + var len = file_buffer_size.contents; + var buf = Caml_bytes.caml_create_bytes(len); + var i = { + contents: 0 + }; + var lim = { + contents: 0 + }; + var eof = { + contents: false + }; + var next = function (param) { + if (i.contents < lim.contents) { + var c = Caml_bytes.get(buf, i.contents); + i.contents = i.contents + 1 | 0; + return c; + } + if (eof.contents) { + throw { + RE_EXN_ID: Stdlib.End_of_file, + Error: new Error() + }; + } + lim.contents = Stdlib.input(ic, buf, 0, len); + if (lim.contents === 0) { + eof.contents = true; + return Curry._1(scan_close_ic, ic); + } else { + i.contents = 1; + return Caml_bytes.get(buf, 0); + } + }; + return create(iname, next); +} + +var stdin = from_ic(scan_raise_at_end, { + TAG: /* From_file */1, + _0: "-", + _1: Stdlib.stdin + }, Stdlib.stdin); + +function open_in_file(open_in, fname) { + if (fname === "-") { + return stdin; + } + var ic = Curry._1(open_in, fname); + return from_ic(scan_close_at_end, { + TAG: /* From_file */1, + _0: fname, + _1: ic + }, ic); +} + +function open_in(param) { + return open_in_file(Stdlib.open_in, param); +} + +function open_in_bin(param) { + return open_in_file(Stdlib.open_in_bin, param); +} + +function from_channel(ic) { + return from_ic(scan_raise_at_end, { + TAG: /* From_channel */0, + _0: ic + }, ic); +} + +function close_in(ib) { + var ic = ib.ic_input_name; + if (typeof ic === "number") { + return ; + } else if (ic.TAG === /* From_channel */0) { + return Caml_external_polyfill.resolve("caml_ml_close_channel")(ic._0); + } else { + return Caml_external_polyfill.resolve("caml_ml_close_channel")(ic._1); + } +} + +var Scan_failure = /* @__PURE__ */Caml_exceptions.create("Stdlib.Scanf.Scan_failure"); + +function bad_input_escape(c) { + var s = Curry._1(Stdlib__Printf.sprintf(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "illegal escape character ", + _1: { + TAG: /* Caml_char */1, + _0: /* End_of_format */0 + } + }, + _1: "illegal escape character %C" + }), c); + throw { + RE_EXN_ID: Scan_failure, + _1: s, + Error: new Error() + }; +} + +function bad_token_length(message) { + var s = Curry._1(Stdlib__Printf.sprintf(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "scanning of ", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: " failed: the specified length was too short for token", + _1: /* End_of_format */0 + } + } + }, + _1: "scanning of %s failed: the specified length was too short for token" + }), message); + throw { + RE_EXN_ID: Scan_failure, + _1: s, + Error: new Error() + }; +} + +function bad_hex_float(param) { + throw { + RE_EXN_ID: Scan_failure, + _1: "not a valid float in hexadecimal notation", + Error: new Error() + }; +} + +function character_mismatch_err(c, ci) { + return Curry._2(Stdlib__Printf.sprintf(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "looking for ", + _1: { + TAG: /* Caml_char */1, + _0: { + TAG: /* String_literal */11, + _0: ", found ", + _1: { + TAG: /* Caml_char */1, + _0: /* End_of_format */0 + } + } + } + }, + _1: "looking for %C, found %C" + }), c, ci); +} + +function check_this_char(ib, c) { + var ci = checked_peek_char(ib); + if (ci === c) { + ib.ic_current_char_is_valid = false; + return ; + } + var s = character_mismatch_err(c, ci); + throw { + RE_EXN_ID: Scan_failure, + _1: s, + Error: new Error() + }; +} + +function check_char(ib, c) { + if (c !== 10) { + if (c !== 32) { + return check_this_char(ib, c); + } else { + while(true) { + var c$1 = peek_char(ib); + if (ib.ic_eof) { + return ; + } + if (c$1 > 13 || c$1 < 9) { + if (c$1 !== 32) { + return ; + } + ib.ic_current_char_is_valid = false; + continue ; + } + if (c$1 === 12 || c$1 === 11) { + return ; + } + ib.ic_current_char_is_valid = false; + continue ; + }; + } + } else { + var ci = checked_peek_char(ib); + if (ci === 10) { + ib.ic_current_char_is_valid = false; + return ; + } + if (ci !== 13) { + var s = character_mismatch_err(/* '\n' */10, ci); + throw { + RE_EXN_ID: Scan_failure, + _1: s, + Error: new Error() + }; + } + ib.ic_current_char_is_valid = false; + return check_this_char(ib, /* '\n' */10); + } +} + +function token_bool(ib) { + var s = token(ib); + switch (s) { + case "false" : + return false; + case "true" : + return true; + default: + var s$1 = Curry._1(Stdlib__Printf.sprintf(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "invalid boolean '", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* Char_literal */12, + _0: /* '\'' */39, + _1: /* End_of_format */0 + } + } + }, + _1: "invalid boolean '%s'" + }), s); + throw { + RE_EXN_ID: Scan_failure, + _1: s$1, + Error: new Error() + }; + } +} + +function integer_conversion_of_char(param) { + switch (param) { + case 98 : + return /* B_conversion */0; + case 100 : + return /* D_conversion */1; + case 105 : + return /* I_conversion */2; + case 111 : + return /* O_conversion */3; + case 117 : + return /* U_conversion */4; + case 89 : + case 90 : + case 91 : + case 92 : + case 93 : + case 94 : + case 95 : + case 96 : + case 97 : + case 99 : + case 101 : + case 102 : + case 103 : + case 104 : + case 106 : + case 107 : + case 108 : + case 109 : + case 110 : + case 112 : + case 113 : + case 114 : + case 115 : + case 116 : + case 118 : + case 119 : + break; + case 88 : + case 120 : + return /* X_conversion */5; + default: + + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/scanf.ml", + 516, + 9 + ], + Error: new Error() + }; +} + +function token_int_literal(conv, ib) { + var tok; + switch (conv) { + case /* B_conversion */0 : + tok = "0b" + token(ib); + break; + case /* D_conversion */1 : + case /* I_conversion */2 : + tok = token(ib); + break; + case /* O_conversion */3 : + tok = "0o" + token(ib); + break; + case /* U_conversion */4 : + tok = "0u" + token(ib); + break; + case /* X_conversion */5 : + tok = "0x" + token(ib); + break; + + } + var l = tok.length; + if (l === 0 || Caml_string.get(tok, 0) !== /* '+' */43) { + return tok; + } else { + return Stdlib__String.sub(tok, 1, l - 1 | 0); + } +} + +function token_float(ib) { + return Caml_format.caml_float_of_string(token(ib)); +} + +function scan_decimal_digit_star(_width, ib) { + while(true) { + var width = _width; + if (width === 0) { + return width; + } + var c = peek_char(ib); + if (ib.ic_eof) { + return width; + } + if (c >= 58) { + if (c !== 95) { + return width; + } + var width$1 = ignore_char(width, ib); + _width = width$1; + continue ; + } + if (c < 48) { + return width; + } + var width$2 = store_char(width, ib, c); + _width = width$2; + continue ; + }; +} + +function scan_decimal_digit_plus(width, ib) { + if (width === 0) { + return bad_token_length("decimal digits"); + } + var c = checked_peek_char(ib); + if (c > 57 || c < 48) { + var s = Curry._1(Stdlib__Printf.sprintf(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "character ", + _1: { + TAG: /* Caml_char */1, + _0: { + TAG: /* String_literal */11, + _0: " is not a decimal digit", + _1: /* End_of_format */0 + } + } + }, + _1: "character %C is not a decimal digit" + }), c); + throw { + RE_EXN_ID: Scan_failure, + _1: s, + Error: new Error() + }; + } + var width$1 = store_char(width, ib, c); + return scan_decimal_digit_star(width$1, ib); +} + +function scan_digit_plus(basis, digitp, width, ib) { + if (width === 0) { + return bad_token_length("digits"); + } + var c = checked_peek_char(ib); + if (Curry._1(digitp, c)) { + var width$1 = store_char(width, ib, c); + var _width = width$1; + while(true) { + var width$2 = _width; + if (width$2 === 0) { + return width$2; + } + var c$1 = peek_char(ib); + if (ib.ic_eof) { + return width$2; + } + if (Curry._1(digitp, c$1)) { + var width$3 = store_char(width$2, ib, c$1); + _width = width$3; + continue ; + } + if (c$1 !== 95) { + return width$2; + } + var width$4 = ignore_char(width$2, ib); + _width = width$4; + continue ; + }; + } + var s = Curry._2(Stdlib__Printf.sprintf(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "character ", + _1: { + TAG: /* Caml_char */1, + _0: { + TAG: /* String_literal */11, + _0: " is not a valid ", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: " digit", + _1: /* End_of_format */0 + } + } + } + } + }, + _1: "character %C is not a valid %s digit" + }), c, basis); + throw { + RE_EXN_ID: Scan_failure, + _1: s, + Error: new Error() + }; +} + +function is_binary_digit(param) { + return param === 49 || param === 48; +} + +function scan_binary_int(param, param$1) { + return scan_digit_plus("binary", is_binary_digit, param, param$1); +} + +function is_octal_digit(param) { + return !(param > 55 || param < 48); +} + +function scan_octal_int(param, param$1) { + return scan_digit_plus("octal", is_octal_digit, param, param$1); +} + +function is_hexa_digit(param) { + if (param > 70 || param < 48) { + return !(param > 102 || param < 97); + } else { + return param > 64 || param < 58; + } +} + +function scan_hexadecimal_int(param, param$1) { + return scan_digit_plus("hexadecimal", is_hexa_digit, param, param$1); +} + +function scan_sign(width, ib) { + var c = checked_peek_char(ib); + if (c !== 43 && c !== 45) { + return width; + } else { + return store_char(width, ib, c); + } +} + +function scan_optionally_signed_decimal_int(width, ib) { + var width$1 = scan_sign(width, ib); + return scan_decimal_digit_plus(width$1, ib); +} + +function scan_int_conversion(conv, width, ib) { + switch (conv) { + case /* B_conversion */0 : + return scan_binary_int(width, ib); + case /* D_conversion */1 : + return scan_optionally_signed_decimal_int(width, ib); + case /* I_conversion */2 : + var width$1 = scan_sign(width, ib); + var c = checked_peek_char(ib); + if (c !== 48) { + return scan_decimal_digit_plus(width$1, ib); + } + var width$2 = store_char(width$1, ib, c); + if (width$2 === 0) { + return width$2; + } + var c$1 = peek_char(ib); + if (ib.ic_eof) { + return width$2; + } else if (c$1 >= 99) { + if (c$1 !== 111) { + if (c$1 !== 120) { + return scan_decimal_digit_star(width$2, ib); + } else { + return scan_hexadecimal_int(store_char(width$2, ib, c$1), ib); + } + } else { + return scan_octal_int(store_char(width$2, ib, c$1), ib); + } + } else if (c$1 !== 88) { + if (c$1 >= 98) { + return scan_binary_int(store_char(width$2, ib, c$1), ib); + } else { + return scan_decimal_digit_star(width$2, ib); + } + } else { + return scan_hexadecimal_int(store_char(width$2, ib, c$1), ib); + } + case /* O_conversion */3 : + return scan_octal_int(width, ib); + case /* U_conversion */4 : + return scan_decimal_digit_plus(width, ib); + case /* X_conversion */5 : + return scan_hexadecimal_int(width, ib); + + } +} + +function scan_fractional_part(width, ib) { + if (width === 0) { + return width; + } + var c = peek_char(ib); + if (ib.ic_eof || c > 57 || c < 48) { + return width; + } else { + return scan_decimal_digit_star(store_char(width, ib, c), ib); + } +} + +function scan_exponent_part(width, ib) { + if (width === 0) { + return width; + } + var c = peek_char(ib); + if (ib.ic_eof || c !== 69 && c !== 101) { + return width; + } else { + return scan_optionally_signed_decimal_int(store_char(width, ib, c), ib); + } +} + +function scan_integer_part(width, ib) { + var width$1 = scan_sign(width, ib); + return scan_decimal_digit_star(width$1, ib); +} + +function scan_float(width, precision, ib) { + var width$1 = scan_integer_part(width, ib); + if (width$1 === 0) { + return [ + width$1, + precision + ]; + } + var c = peek_char(ib); + if (ib.ic_eof) { + return [ + width$1, + precision + ]; + } + if (c !== 46) { + return [ + scan_exponent_part(width$1, ib), + precision + ]; + } + var width$2 = store_char(width$1, ib, c); + var precision$1 = Stdlib__Int.min(width$2, precision); + var width$3 = width$2 - (precision$1 - scan_fractional_part(precision$1, ib) | 0) | 0; + return [ + scan_exponent_part(width$3, ib), + precision$1 + ]; +} + +function check_case_insensitive_string(width, ib, error, str) { + var lowercase = function (c) { + if (c > 90 || c < 65) { + return c; + } else { + return Stdlib.char_of_int((c - /* 'A' */65 | 0) + /* 'a' */97 | 0); + } + }; + var len = str.length; + var width$1 = width; + for(var i = 0; i < len; ++i){ + var c = peek_char(ib); + if (lowercase(c) !== lowercase(Caml_string.get(str, i))) { + Curry._1(error, undefined); + } + if (width$1 === 0) { + Curry._1(error, undefined); + } + width$1 = store_char(width$1, ib, c); + } + return width$1; +} + +function scan_hex_float(width, precision, ib) { + if (width === 0 || end_of_input(ib)) { + throw { + RE_EXN_ID: Scan_failure, + _1: "not a valid float in hexadecimal notation", + Error: new Error() + }; + } + var width$1 = scan_sign(width, ib); + if (width$1 === 0 || end_of_input(ib)) { + throw { + RE_EXN_ID: Scan_failure, + _1: "not a valid float in hexadecimal notation", + Error: new Error() + }; + } + var c = peek_char(ib); + if (c >= 78) { + if (c > 109 || c < 79) { + if (c >= 111) { + throw { + RE_EXN_ID: Scan_failure, + _1: "not a valid float in hexadecimal notation", + Error: new Error() + }; + } + var width$2 = store_char(width$1, ib, c); + if (width$2 === 0 || end_of_input(ib)) { + throw { + RE_EXN_ID: Scan_failure, + _1: "not a valid float in hexadecimal notation", + Error: new Error() + }; + } + return check_case_insensitive_string(width$2, ib, bad_hex_float, "an"); + } + if (c !== 105) { + throw { + RE_EXN_ID: Scan_failure, + _1: "not a valid float in hexadecimal notation", + Error: new Error() + }; + } + + } else if (c !== 48) { + if (c !== 73) { + throw { + RE_EXN_ID: Scan_failure, + _1: "not a valid float in hexadecimal notation", + Error: new Error() + }; + } + + } else { + var width$3 = store_char(width$1, ib, c); + if (width$3 === 0 || end_of_input(ib)) { + throw { + RE_EXN_ID: Scan_failure, + _1: "not a valid float in hexadecimal notation", + Error: new Error() + }; + } + var width$4 = check_case_insensitive_string(width$3, ib, bad_hex_float, "x"); + if (width$4 === 0 || end_of_input(ib)) { + return width$4; + } + var match = peek_char(ib); + var width$5 = match > 80 || match < 46 ? ( + match !== 112 ? scan_hexadecimal_int(width$4, ib) : width$4 + ) : ( + match > 79 || match < 47 ? width$4 : scan_hexadecimal_int(width$4, ib) + ); + if (width$5 === 0 || end_of_input(ib)) { + return width$5; + } + var c$1 = peek_char(ib); + var width$6; + if (c$1 !== 46) { + width$6 = width$5; + } else { + var width$7 = store_char(width$5, ib, c$1); + if (width$7 === 0 || end_of_input(ib)) { + width$6 = width$7; + } else { + var match$1 = peek_char(ib); + if (match$1 !== 80 && match$1 !== 112) { + var precision$1 = Stdlib__Int.min(width$7, precision); + width$6 = width$7 - (precision$1 - scan_hexadecimal_int(precision$1, ib) | 0) | 0; + } else { + width$6 = width$7; + } + } + } + if (width$6 === 0 || end_of_input(ib)) { + return width$6; + } + var c$2 = peek_char(ib); + var exit = 0; + if (c$2 !== 80) { + if (c$2 !== 112) { + return width$6; + } + exit = 2; + } else { + exit = 2; + } + if (exit === 2) { + var width$8 = store_char(width$6, ib, c$2); + if (width$8 === 0 || end_of_input(ib)) { + throw { + RE_EXN_ID: Scan_failure, + _1: "not a valid float in hexadecimal notation", + Error: new Error() + }; + } + return scan_optionally_signed_decimal_int(width$8, ib); + } + + } + var width$9 = store_char(width$1, ib, c); + if (width$9 === 0 || end_of_input(ib)) { + throw { + RE_EXN_ID: Scan_failure, + _1: "not a valid float in hexadecimal notation", + Error: new Error() + }; + } + return check_case_insensitive_string(width$9, ib, bad_hex_float, "nfinity"); +} + +function scan_caml_float_rest(width, precision, ib) { + if (width === 0 || end_of_input(ib)) { + throw { + RE_EXN_ID: Scan_failure, + _1: "no dot or exponent part found in float token", + Error: new Error() + }; + } + var width$1 = scan_decimal_digit_star(width, ib); + if (width$1 === 0 || end_of_input(ib)) { + throw { + RE_EXN_ID: Scan_failure, + _1: "no dot or exponent part found in float token", + Error: new Error() + }; + } + var c = peek_char(ib); + if (c > 101 || c < 69) { + if (c !== 46) { + throw { + RE_EXN_ID: Scan_failure, + _1: "no dot or exponent part found in float token", + Error: new Error() + }; + } + var width$2 = store_char(width$1, ib, c); + var precision$1 = Stdlib__Int.min(width$2, precision); + var width_precision = scan_fractional_part(precision$1, ib); + var frac_width = precision$1 - width_precision | 0; + var width$3 = width$2 - frac_width | 0; + return scan_exponent_part(width$3, ib); + } + if (c > 100 || c < 70) { + return scan_exponent_part(width$1, ib); + } + throw { + RE_EXN_ID: Scan_failure, + _1: "no dot or exponent part found in float token", + Error: new Error() + }; +} + +function scan_caml_float(width, precision, ib) { + if (width === 0 || end_of_input(ib)) { + throw { + RE_EXN_ID: Scan_failure, + _1: "no dot or exponent part found in float token", + Error: new Error() + }; + } + var width$1 = scan_sign(width, ib); + if (width$1 === 0 || end_of_input(ib)) { + throw { + RE_EXN_ID: Scan_failure, + _1: "no dot or exponent part found in float token", + Error: new Error() + }; + } + var c = peek_char(ib); + if (c >= 49) { + if (c >= 58) { + throw { + RE_EXN_ID: Scan_failure, + _1: "no dot or exponent part found in float token", + Error: new Error() + }; + } + var width$2 = store_char(width$1, ib, c); + if (width$2 === 0 || end_of_input(ib)) { + throw { + RE_EXN_ID: Scan_failure, + _1: "no dot or exponent part found in float token", + Error: new Error() + }; + } + return scan_caml_float_rest(width$2, precision, ib); + } + if (c >= 48) { + var width$3 = store_char(width$1, ib, c); + if (width$3 === 0 || end_of_input(ib)) { + throw { + RE_EXN_ID: Scan_failure, + _1: "no dot or exponent part found in float token", + Error: new Error() + }; + } + var c$1 = peek_char(ib); + var exit = 0; + if (c$1 !== 88) { + if (c$1 !== 120) { + return scan_caml_float_rest(width$3, precision, ib); + } + exit = 1; + } else { + exit = 1; + } + if (exit === 1) { + var width$4 = store_char(width$3, ib, c$1); + if (width$4 === 0 || end_of_input(ib)) { + throw { + RE_EXN_ID: Scan_failure, + _1: "no dot or exponent part found in float token", + Error: new Error() + }; + } + var width$5 = scan_hexadecimal_int(width$4, ib); + if (width$5 === 0 || end_of_input(ib)) { + throw { + RE_EXN_ID: Scan_failure, + _1: "no dot or exponent part found in float token", + Error: new Error() + }; + } + var c$2 = peek_char(ib); + var width$6; + if (c$2 > 112 || c$2 < 80) { + if (c$2 !== 46) { + throw { + RE_EXN_ID: Scan_failure, + _1: "no dot or exponent part found in float token", + Error: new Error() + }; + } + var width$7 = store_char(width$5, ib, c$2); + if (width$7 === 0 || end_of_input(ib)) { + width$6 = width$7; + } else { + var match = peek_char(ib); + if (match !== 80 && match !== 112) { + var precision$1 = Stdlib__Int.min(width$7, precision); + width$6 = width$7 - (precision$1 - scan_hexadecimal_int(precision$1, ib) | 0) | 0; + } else { + width$6 = width$7; + } + } + } else if (c$2 > 111 || c$2 < 81) { + width$6 = width$5; + } else { + throw { + RE_EXN_ID: Scan_failure, + _1: "no dot or exponent part found in float token", + Error: new Error() + }; + } + if (width$6 === 0 || end_of_input(ib)) { + return width$6; + } + var c$3 = peek_char(ib); + var exit$1 = 0; + if (c$3 !== 80) { + if (c$3 !== 112) { + return width$6; + } + exit$1 = 2; + } else { + exit$1 = 2; + } + if (exit$1 === 2) { + var width$8 = store_char(width$6, ib, c$3); + if (width$8 === 0 || end_of_input(ib)) { + throw { + RE_EXN_ID: Scan_failure, + _1: "not a valid float in hexadecimal notation", + Error: new Error() + }; + } + return scan_optionally_signed_decimal_int(width$8, ib); + } + + } + + } else { + throw { + RE_EXN_ID: Scan_failure, + _1: "no dot or exponent part found in float token", + Error: new Error() + }; + } +} + +function scan_string(stp, width, ib) { + var _width = width; + while(true) { + var width$1 = _width; + if (width$1 === 0) { + return width$1; + } + var c = peek_char(ib); + if (ib.ic_eof) { + return width$1; + } + if (stp !== undefined) { + if (c === stp) { + ib.ic_current_char_is_valid = false; + return width$1; + } + _width = store_char(width$1, ib, c); + continue ; + } + if (c > 13 || c < 9) { + if (c === 32) { + return width$1; + } + _width = store_char(width$1, ib, c); + continue ; + } + if (!(c === 12 || c === 11)) { + return width$1; + } + _width = store_char(width$1, ib, c); + continue ; + }; +} + +function scan_char(width, ib) { + return store_char(width, ib, checked_peek_char(ib)); +} + +function char_for_backslash(c) { + if (c < 110) { + if (c !== 98) { + return c; + } else { + return /* '\b' */8; + } + } + if (c >= 117) { + return c; + } + switch (c) { + case 110 : + return /* '\n' */10; + case 114 : + return /* '\r' */13; + case 111 : + case 112 : + case 113 : + case 115 : + return c; + case 116 : + return /* '\t' */9; + + } +} + +function char_for_decimal_code(c0, c1, c2) { + var c = (Math.imul(100, c0 - /* '0' */48 | 0) + Math.imul(10, c1 - /* '0' */48 | 0) | 0) + (c2 - /* '0' */48 | 0) | 0; + if (!(c < 0 || c > 255)) { + return Stdlib.char_of_int(c); + } + var s = Curry._3(Stdlib__Printf.sprintf(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "bad character decimal encoding \\", + _1: { + TAG: /* Char */0, + _0: { + TAG: /* Char */0, + _0: { + TAG: /* Char */0, + _0: /* End_of_format */0 + } + } + } + }, + _1: "bad character decimal encoding \\%c%c%c" + }), c0, c1, c2); + throw { + RE_EXN_ID: Scan_failure, + _1: s, + Error: new Error() + }; +} + +function hexadecimal_value_of_char(c) { + if (c >= /* 'a' */97) { + return c - 87 | 0; + } else if (c >= /* 'A' */65) { + return c - 55 | 0; + } else { + return c - /* '0' */48 | 0; + } +} + +function char_for_hexadecimal_code(c1, c2) { + var c = (hexadecimal_value_of_char(c1) << 4) + hexadecimal_value_of_char(c2) | 0; + if (!(c < 0 || c > 255)) { + return Stdlib.char_of_int(c); + } + var s = Curry._2(Stdlib__Printf.sprintf(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "bad character hexadecimal encoding \\", + _1: { + TAG: /* Char */0, + _0: { + TAG: /* Char */0, + _0: /* End_of_format */0 + } + } + }, + _1: "bad character hexadecimal encoding \\%c%c" + }), c1, c2); + throw { + RE_EXN_ID: Scan_failure, + _1: s, + Error: new Error() + }; +} + +function check_next_char(message, width, ib) { + if (width === 0) { + return bad_token_length(message); + } + var c = peek_char(ib); + if (ib.ic_eof) { + var s = Curry._1(Stdlib__Printf.sprintf(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "scanning of ", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: { + TAG: /* String_literal */11, + _0: " failed: premature end of file occurred before end of token", + _1: /* End_of_format */0 + } + } + }, + _1: "scanning of %s failed: premature end of file occurred before end of token" + }), message); + throw { + RE_EXN_ID: Scan_failure, + _1: s, + Error: new Error() + }; + } else { + return c; + } +} + +function scan_backslash_char(width, ib) { + var c = check_next_char("a Char", width, ib); + if (c >= 40) { + if (c >= 58) { + switch (c) { + case 92 : + case 98 : + case 110 : + case 114 : + case 116 : + break; + case 93 : + case 94 : + case 95 : + case 96 : + case 97 : + case 99 : + case 100 : + case 101 : + case 102 : + case 103 : + case 104 : + case 105 : + case 106 : + case 107 : + case 108 : + case 109 : + case 111 : + case 112 : + case 113 : + case 115 : + case 117 : + case 118 : + case 119 : + return bad_input_escape(c); + case 120 : + var get_digit = function (param) { + var c = next_char(ib); + if (c > 70 || c < 48) { + if (c > 102 || c < 97) { + return bad_input_escape(c); + } else { + return c; + } + } else if (c > 64 || c < 58) { + return c; + } else { + return bad_input_escape(c); + } + }; + var c1 = get_digit(undefined); + var c2 = get_digit(undefined); + return store_char(width - 2 | 0, ib, char_for_hexadecimal_code(c1, c2)); + default: + return bad_input_escape(c); + } + } else { + if (c < 48) { + return bad_input_escape(c); + } + var get_digit$1 = function (param) { + var c = next_char(ib); + if (c > 57 || c < 48) { + return bad_input_escape(c); + } else { + return c; + } + }; + var c1$1 = get_digit$1(undefined); + var c2$1 = get_digit$1(undefined); + return store_char(width - 2 | 0, ib, char_for_decimal_code(c, c1$1, c2$1)); + } + } else if (c !== 34 && c < 39) { + return bad_input_escape(c); + } + return store_char(width, ib, char_for_backslash(c)); +} + +function scan_caml_char(width, ib) { + var find_stop = function (width) { + var c = check_next_char("a Char", width, ib); + if (c === 39) { + return ignore_char(width, ib); + } + var s = character_mismatch_err(/* '\'' */39, c); + throw { + RE_EXN_ID: Scan_failure, + _1: s, + Error: new Error() + }; + }; + var c = checked_peek_char(ib); + if (c === 39) { + var width$1 = ignore_char(width, ib); + var c$1 = check_next_char("a Char", width$1, ib); + if (c$1 !== 92) { + return find_stop(store_char(width$1, ib, c$1)); + } else { + return find_stop(scan_backslash_char(ignore_char(width$1, ib), ib)); + } + } + var s = character_mismatch_err(/* '\'' */39, c); + throw { + RE_EXN_ID: Scan_failure, + _1: s, + Error: new Error() + }; +} + +function scan_caml_string(width, ib) { + var find_stop = function (_width) { + while(true) { + var width = _width; + var c = check_next_char("a String", width, ib); + if (c === 34) { + return ignore_char(width, ib); + } + if (c === 92) { + var width$1 = ignore_char(width, ib); + var match = check_next_char("a String", width$1, ib); + if (match !== 10) { + if (match !== 13) { + return find_stop(scan_backslash_char(width$1, ib)); + } else { + var width$2 = ignore_char(width$1, ib); + var match$1 = check_next_char("a String", width$2, ib); + if (match$1 !== 10) { + return find_stop(store_char(width$2, ib, /* '\r' */13)); + } else { + return skip_spaces(ignore_char(width$2, ib)); + } + } + } else { + return skip_spaces(ignore_char(width$1, ib)); + } + } + _width = store_char(width, ib, c); + continue ; + }; + }; + var skip_spaces = function (_width) { + while(true) { + var width = _width; + var match = check_next_char("a String", width, ib); + if (match !== 32) { + return find_stop(width); + } + _width = ignore_char(width, ib); + continue ; + }; + }; + var c = checked_peek_char(ib); + if (c === 34) { + return find_stop(ignore_char(width, ib)); + } + var s = character_mismatch_err(/* '"' */34, c); + throw { + RE_EXN_ID: Scan_failure, + _1: s, + Error: new Error() + }; +} + +function scan_chars_in_char_set(char_set, scan_indic, width, ib) { + var scan_chars = function (_i, stp) { + while(true) { + var i = _i; + var c = peek_char(ib); + if (!(i > 0 && !ib.ic_eof && CamlinternalFormat.is_in_char_set(char_set, c) && c !== stp)) { + return ; + } + store_char(Stdlib.max_int, ib, c); + _i = i - 1 | 0; + continue ; + }; + }; + if (scan_indic === undefined) { + return scan_chars(width, -1); + } + scan_chars(width, scan_indic); + if (ib.ic_eof) { + return ; + } + var ci = peek_char(ib); + if (scan_indic === ci) { + ib.ic_current_char_is_valid = false; + return ; + } + var s = character_mismatch_err(scan_indic, ci); + throw { + RE_EXN_ID: Scan_failure, + _1: s, + Error: new Error() + }; +} + +function scanf_bad_input(ib, x) { + var s; + if (x.RE_EXN_ID === Scan_failure || x.RE_EXN_ID === Stdlib.Failure) { + s = x._1; + } else { + throw x; + } + var i = char_count(ib); + var s$1 = Curry._2(Stdlib__Printf.sprintf(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "scanf: bad input at char number ", + _1: { + TAG: /* Int */4, + _0: /* Int_i */3, + _1: /* No_padding */0, + _2: /* No_precision */0, + _3: { + TAG: /* String_literal */11, + _0: ": ", + _1: { + TAG: /* String */2, + _0: /* No_padding */0, + _1: /* End_of_format */0 + } + } + } + }, + _1: "scanf: bad input at char number %i: %s" + }), i, s); + throw { + RE_EXN_ID: Scan_failure, + _1: s$1, + Error: new Error() + }; +} + +function get_counter(ib, counter) { + switch (counter) { + case /* Line_counter */0 : + return ib.ic_line_count; + case /* Char_counter */1 : + return char_count(ib); + case /* Token_counter */2 : + return ib.ic_token_count; + + } +} + +function stopper_of_formatting_lit(fmting) { + if (Caml_obj.caml_equal(fmting, /* Escaped_percent */6)) { + return [ + /* '%' */37, + "" + ]; + } + var str = CamlinternalFormat.string_of_formatting_lit(fmting); + var stp = Caml_string.get(str, 1); + var sub_str = Stdlib__String.sub(str, 2, str.length - 2 | 0); + return [ + stp, + sub_str + ]; +} + +function take_format_readers(k, _fmt) { + while(true) { + var fmt = _fmt; + if (typeof fmt === "number") { + return Curry._1(k, /* Nil */0); + } + switch (fmt.TAG | 0) { + case /* Int */4 : + case /* Int32 */5 : + case /* Nativeint */6 : + case /* Int64 */7 : + case /* Float */8 : + _fmt = fmt._3; + continue ; + case /* Format_subst */14 : + return take_fmtty_format_readers(k, CamlinternalFormatBasics.erase_rel(CamlinternalFormat.symm(fmt._1)), fmt._2); + case /* Formatting_gen */18 : + _fmt = CamlinternalFormatBasics.concat_fmt(fmt._0._0._0, fmt._1); + continue ; + case /* Reader */19 : + var fmt_rest = fmt._0; + return (function(fmt_rest){ + return function (reader) { + var new_k = function (readers_rest) { + return Curry._1(k, /* Cons */{ + _0: reader, + _1: readers_rest + }); + }; + return take_format_readers(new_k, fmt_rest); + } + }(fmt_rest)); + case /* Char */0 : + case /* Caml_char */1 : + case /* Flush */10 : + case /* Alpha */15 : + case /* Theta */16 : + case /* Scan_next_char */22 : + _fmt = fmt._0; + continue ; + case /* Ignored_param */23 : + var ign = fmt._0; + var fmt$1 = fmt._1; + if (typeof ign === "number") { + if (ign === /* Ignored_reader */2) { + return (function(fmt$1){ + return function (reader) { + var new_k = function (readers_rest) { + return Curry._1(k, /* Cons */{ + _0: reader, + _1: readers_rest + }); + }; + return take_format_readers(new_k, fmt$1); + } + }(fmt$1)); + } else { + return take_format_readers(k, fmt$1); + } + } else if (ign.TAG === /* Ignored_format_subst */9) { + return take_fmtty_format_readers(k, ign._1, fmt$1); + } else { + return take_format_readers(k, fmt$1); + } + case /* Format_arg */13 : + case /* Scan_char_set */20 : + case /* Custom */24 : + _fmt = fmt._2; + continue ; + default: + _fmt = fmt._1; + continue ; + } + }; +} + +function take_fmtty_format_readers(k, _fmtty, fmt) { + while(true) { + var fmtty = _fmtty; + if (typeof fmtty === "number") { + return take_format_readers(k, fmt); + } + switch (fmtty.TAG | 0) { + case /* Format_arg_ty */8 : + _fmtty = fmtty._1; + continue ; + case /* Format_subst_ty */9 : + var ty = CamlinternalFormat.trans(CamlinternalFormat.symm(fmtty._0), fmtty._1); + _fmtty = CamlinternalFormatBasics.concat_fmtty(ty, fmtty._2); + continue ; + case /* Reader_ty */13 : + var fmt_rest = fmtty._0; + return (function(fmt_rest){ + return function (reader) { + var new_k = function (readers_rest) { + return Curry._1(k, /* Cons */{ + _0: reader, + _1: readers_rest + }); + }; + return take_fmtty_format_readers(new_k, fmt_rest, fmt); + } + }(fmt_rest)); + case /* Ignored_reader_ty */14 : + var fmt_rest$1 = fmtty._0; + return (function(fmt_rest$1){ + return function (reader) { + var new_k = function (readers_rest) { + return Curry._1(k, /* Cons */{ + _0: reader, + _1: readers_rest + }); + }; + return take_fmtty_format_readers(new_k, fmt_rest$1, fmt); + } + }(fmt_rest$1)); + default: + _fmtty = fmtty._0; + continue ; + } + }; +} + +function make_scanf(ib, _fmt, readers) { + while(true) { + var fmt = _fmt; + if (typeof fmt === "number") { + return /* Nil */0; + } + switch (fmt.TAG | 0) { + case /* Char */0 : + scan_char(0, ib); + var c = Caml_string.get(token(ib), 0); + return /* Cons */{ + _0: c, + _1: make_scanf(ib, fmt._0, readers) + }; + case /* Caml_char */1 : + scan_caml_char(0, ib); + var c$1 = Caml_string.get(token(ib), 0); + return /* Cons */{ + _0: c$1, + _1: make_scanf(ib, fmt._0, readers) + }; + case /* String */2 : + var pad = fmt._0; + var match = fmt._1; + if (typeof match !== "number") { + switch (match.TAG | 0) { + case /* Formatting_lit */17 : + var match$1 = stopper_of_formatting_lit(match._0); + var stp = match$1[0]; + var scan = (function(stp){ + return function scan(width, param, ib) { + return scan_string(stp, width, ib); + } + }(stp)); + var str_rest_0 = match$1[1]; + var str_rest_1 = match._1; + var str_rest = { + TAG: /* String_literal */11, + _0: str_rest_0, + _1: str_rest_1 + }; + return pad_prec_scanf(ib, str_rest, readers, pad, /* No_precision */0, scan, token); + case /* Formatting_gen */18 : + var match$2 = match._0; + if (match$2.TAG === /* Open_tag */0) { + var scan$1 = function (width, param, ib) { + return scan_string(/* '{' */123, width, ib); + }; + return pad_prec_scanf(ib, CamlinternalFormatBasics.concat_fmt(match$2._0._0, match._1), readers, pad, /* No_precision */0, scan$1, token); + } + var scan$2 = function (width, param, ib) { + return scan_string(/* '[' */91, width, ib); + }; + return pad_prec_scanf(ib, CamlinternalFormatBasics.concat_fmt(match$2._0._0, match._1), readers, pad, /* No_precision */0, scan$2, token); + default: + + } + } + var scan$3 = function (width, param, ib) { + return scan_string(undefined, width, ib); + }; + return pad_prec_scanf(ib, fmt._1, readers, pad, /* No_precision */0, scan$3, token); + case /* Caml_string */3 : + var scan$4 = function (width, param, ib) { + return scan_caml_string(width, ib); + }; + return pad_prec_scanf(ib, fmt._1, readers, fmt._0, /* No_precision */0, scan$4, token); + case /* Int */4 : + var c$2 = integer_conversion_of_char(CamlinternalFormat.char_of_iconv(fmt._0)); + var scan$5 = (function(c$2){ + return function scan$5(width, param, ib) { + return scan_int_conversion(c$2, width, ib); + } + }(c$2)); + return pad_prec_scanf(ib, fmt._3, readers, fmt._1, fmt._2, scan$5, (function(c$2){ + return function (param) { + return Caml_format.caml_int_of_string(token_int_literal(c$2, param)); + } + }(c$2))); + case /* Int32 */5 : + var c$3 = integer_conversion_of_char(CamlinternalFormat.char_of_iconv(fmt._0)); + var scan$6 = (function(c$3){ + return function scan$6(width, param, ib) { + return scan_int_conversion(c$3, width, ib); + } + }(c$3)); + return pad_prec_scanf(ib, fmt._3, readers, fmt._1, fmt._2, scan$6, (function(c$3){ + return function (param) { + return Caml_format.caml_int32_of_string(token_int_literal(c$3, param)); + } + }(c$3))); + case /* Nativeint */6 : + var c$4 = integer_conversion_of_char(CamlinternalFormat.char_of_iconv(fmt._0)); + var scan$7 = (function(c$4){ + return function scan$7(width, param, ib) { + return scan_int_conversion(c$4, width, ib); + } + }(c$4)); + return pad_prec_scanf(ib, fmt._3, readers, fmt._1, fmt._2, scan$7, (function(c$4){ + return function (param) { + return Caml_format.caml_nativeint_of_string(token_int_literal(c$4, param)); + } + }(c$4))); + case /* Int64 */7 : + var c$5 = integer_conversion_of_char(CamlinternalFormat.char_of_iconv(fmt._0)); + var scan$8 = (function(c$5){ + return function scan$8(width, param, ib) { + return scan_int_conversion(c$5, width, ib); + } + }(c$5)); + return pad_prec_scanf(ib, fmt._3, readers, fmt._1, fmt._2, scan$8, (function(c$5){ + return function (param) { + return Caml_format.caml_int64_of_string(token_int_literal(c$5, param)); + } + }(c$5))); + case /* Float */8 : + var exit = 0; + switch (fmt._0[1]) { + case /* Float_f */0 : + case /* Float_e */1 : + case /* Float_E */2 : + case /* Float_g */3 : + case /* Float_G */4 : + exit = 2; + break; + case /* Float_h */6 : + case /* Float_H */7 : + exit = 3; + break; + case /* Float_F */5 : + case /* Float_CF */8 : + exit = 1; + break; + + } + switch (exit) { + case 1 : + return pad_prec_scanf(ib, fmt._3, readers, fmt._1, fmt._2, scan_caml_float, token_float); + case 2 : + return pad_prec_scanf(ib, fmt._3, readers, fmt._1, fmt._2, scan_float, token_float); + case 3 : + return pad_prec_scanf(ib, fmt._3, readers, fmt._1, fmt._2, scan_hex_float, token_float); + + } + break; + case /* Bool */9 : + var scan$9 = function (param, param$1, ib) { + var c = checked_peek_char(ib); + var m; + if (c !== 102) { + if (c !== 116) { + var s = Curry._1(Stdlib__Printf.sprintf(/* Format */{ + _0: { + TAG: /* String_literal */11, + _0: "the character ", + _1: { + TAG: /* Caml_char */1, + _0: { + TAG: /* String_literal */11, + _0: " cannot start a boolean", + _1: /* End_of_format */0 + } + } + }, + _1: "the character %C cannot start a boolean" + }), c); + throw { + RE_EXN_ID: Scan_failure, + _1: s, + Error: new Error() + }; + } + m = 4; + } else { + m = 5; + } + return scan_string(undefined, m, ib); + }; + return pad_prec_scanf(ib, fmt._1, readers, fmt._0, /* No_precision */0, scan$9, token_bool); + case /* Flush */10 : + if (end_of_input(ib)) { + _fmt = fmt._0; + continue ; + } + throw { + RE_EXN_ID: Scan_failure, + _1: "end of input not found", + Error: new Error() + }; + case /* String_literal */11 : + Stdlib__String.iter((function (param) { + return check_char(ib, param); + }), fmt._0); + _fmt = fmt._1; + continue ; + case /* Char_literal */12 : + check_char(ib, fmt._0); + _fmt = fmt._1; + continue ; + case /* Format_arg */13 : + var pad_opt = fmt._0; + scan_caml_string(pad_opt !== undefined ? pad_opt : Stdlib.max_int, ib); + var s = token(ib); + var fmt$1; + try { + fmt$1 = CamlinternalFormat.format_of_string_fmtty(s, fmt._1); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Failure) { + throw { + RE_EXN_ID: Scan_failure, + _1: exn._1, + Error: new Error() + }; + } + throw exn; + } + return /* Cons */{ + _0: fmt$1, + _1: make_scanf(ib, fmt._2, readers) + }; + case /* Format_subst */14 : + var fmtty = fmt._1; + var pad_opt$1 = fmt._0; + scan_caml_string(pad_opt$1 !== undefined ? pad_opt$1 : Stdlib.max_int, ib); + var s$1 = token(ib); + var match$3; + try { + var fmt$2 = CamlinternalFormat.fmt_ebb_of_string(undefined, s$1); + var fmt$p = CamlinternalFormat.fmt_ebb_of_string(undefined, s$1); + match$3 = [ + CamlinternalFormat.type_format(fmt$2._0, CamlinternalFormatBasics.erase_rel(fmtty)), + CamlinternalFormat.type_format(fmt$p._0, CamlinternalFormatBasics.erase_rel(CamlinternalFormat.symm(fmtty))) + ]; + } + catch (raw_exn$1){ + var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); + if (exn$1.RE_EXN_ID === Stdlib.Failure) { + throw { + RE_EXN_ID: Scan_failure, + _1: exn$1._1, + Error: new Error() + }; + } + throw exn$1; + } + return /* Cons */{ + _0: /* Format */{ + _0: match$3[0], + _1: s$1 + }, + _1: make_scanf(ib, CamlinternalFormatBasics.concat_fmt(match$3[1], fmt._2), readers) + }; + case /* Alpha */15 : + throw { + RE_EXN_ID: "Invalid_argument", + _1: "scanf: bad conversion \"%a\"", + Error: new Error() + }; + case /* Theta */16 : + throw { + RE_EXN_ID: "Invalid_argument", + _1: "scanf: bad conversion \"%t\"", + Error: new Error() + }; + case /* Formatting_lit */17 : + Stdlib__String.iter((function (param) { + return check_char(ib, param); + }), CamlinternalFormat.string_of_formatting_lit(fmt._0)); + _fmt = fmt._1; + continue ; + case /* Formatting_gen */18 : + var match$4 = fmt._0; + if (match$4.TAG === /* Open_tag */0) { + check_char(ib, /* '@' */64); + check_char(ib, /* '{' */123); + _fmt = CamlinternalFormatBasics.concat_fmt(match$4._0._0, fmt._1); + continue ; + } + check_char(ib, /* '@' */64); + check_char(ib, /* '[' */91); + _fmt = CamlinternalFormatBasics.concat_fmt(match$4._0._0, fmt._1); + continue ; + case /* Reader */19 : + if (readers) { + var x = Curry._1(readers._0, ib); + return /* Cons */{ + _0: x, + _1: make_scanf(ib, fmt._0, readers._1) + }; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "scanf: missing reader", + Error: new Error() + }; + case /* Scan_char_set */20 : + var width_opt = fmt._0; + var match$5 = fmt._2; + if (typeof match$5 !== "number" && match$5.TAG === /* Formatting_lit */17) { + var match$6 = stopper_of_formatting_lit(match$5._0); + var width = width_opt !== undefined ? width_opt : Stdlib.max_int; + scan_chars_in_char_set(fmt._1, match$6[0], width, ib); + var s$2 = token(ib); + var str_rest_0$1 = match$6[1]; + var str_rest_1$1 = match$5._1; + var str_rest$1 = { + TAG: /* String_literal */11, + _0: str_rest_0$1, + _1: str_rest_1$1 + }; + return /* Cons */{ + _0: s$2, + _1: make_scanf(ib, str_rest$1, readers) + }; + } + var width$1 = width_opt !== undefined ? width_opt : Stdlib.max_int; + scan_chars_in_char_set(fmt._1, undefined, width$1, ib); + var s$3 = token(ib); + return /* Cons */{ + _0: s$3, + _1: make_scanf(ib, fmt._2, readers) + }; + case /* Scan_get_counter */21 : + var count = get_counter(ib, fmt._0); + return /* Cons */{ + _0: count, + _1: make_scanf(ib, fmt._1, readers) + }; + case /* Scan_next_char */22 : + var c$6 = checked_peek_char(ib); + return /* Cons */{ + _0: c$6, + _1: make_scanf(ib, fmt._0, readers) + }; + case /* Ignored_param */23 : + var fmt$p$1 = CamlinternalFormat.param_format_of_ignored_format(fmt._0, fmt._1); + var match$7 = make_scanf(ib, fmt$p$1._0, readers); + if (match$7) { + return match$7._1; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/scanf.ml", + 1414, + 13 + ], + Error: new Error() + }; + case /* Custom */24 : + throw { + RE_EXN_ID: "Invalid_argument", + _1: "scanf: bad conversion \"%?\" (custom converter)", + Error: new Error() + }; + + } + }; +} + +function pad_prec_scanf(ib, fmt, readers, pad, prec, scan, token) { + if (typeof pad === "number") { + if (typeof prec === "number") { + if (prec) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "scanf: bad conversion \"%*\"", + Error: new Error() + }; + } + Curry._3(scan, Stdlib.max_int, Stdlib.max_int, ib); + var x = Curry._1(token, ib); + return /* Cons */{ + _0: x, + _1: make_scanf(ib, fmt, readers) + }; + } + Curry._3(scan, Stdlib.max_int, prec._0, ib); + var x$1 = Curry._1(token, ib); + return /* Cons */{ + _0: x$1, + _1: make_scanf(ib, fmt, readers) + }; + } + if (pad.TAG === /* Lit_padding */0) { + if (pad._0) { + var w = pad._1; + if (typeof prec === "number") { + if (prec) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "scanf: bad conversion \"%*\"", + Error: new Error() + }; + } + Curry._3(scan, w, Stdlib.max_int, ib); + var x$2 = Curry._1(token, ib); + return /* Cons */{ + _0: x$2, + _1: make_scanf(ib, fmt, readers) + }; + } + Curry._3(scan, w, prec._0, ib); + var x$3 = Curry._1(token, ib); + return /* Cons */{ + _0: x$3, + _1: make_scanf(ib, fmt, readers) + }; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "scanf: bad conversion \"%-\"", + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "scanf: bad conversion \"%*\"", + Error: new Error() + }; +} + +function kscanf_gen(ib, ef, af, param) { + var str = param._1; + var fmt = param._0; + var apply = function (_f, _args) { + while(true) { + var args = _args; + var f = _f; + if (!args) { + return f; + } + _args = args._1; + _f = Curry._1(f, args._0); + continue ; + }; + }; + var k = function (readers, f) { + Stdlib__Buffer.reset(ib.ic_token_buffer); + var args; + try { + args = make_scanf(ib, fmt, readers); + } + catch (raw_exc){ + var exc = Caml_js_exceptions.internalToOCamlException(raw_exc); + if (exc.RE_EXN_ID === Scan_failure) { + return Curry._2(ef, ib, exc); + } + if (exc.RE_EXN_ID === Stdlib.Failure) { + return Curry._2(ef, ib, exc); + } + if (exc.RE_EXN_ID === Stdlib.End_of_file) { + return Curry._2(ef, ib, exc); + } + if (exc.RE_EXN_ID === Stdlib.Invalid_argument) { + var s = exc._1 + (" in format \"" + (Stdlib__String.escaped(str) + "\"")); + throw { + RE_EXN_ID: "Invalid_argument", + _1: s, + Error: new Error() + }; + } + throw exc; + } + return Curry._1(af, apply(f, args)); + }; + return take_format_readers(k, fmt); +} + +function kscanf(ib, ef, fmt) { + return kscanf_gen(ib, ef, (function (x) { + return x; + }), fmt); +} + +function kscanf_opt(ib, fmt) { + return kscanf_gen(ib, (function (param, param$1) { + + }), (function (x) { + return Caml_option.some(x); + }), fmt); +} + +function bscanf(ib, fmt) { + return kscanf(ib, scanf_bad_input, fmt); +} + +var bscanf_opt = kscanf_opt; + +function ksscanf(s, ef, fmt) { + return kscanf(from_string(s), ef, fmt); +} + +function sscanf(s, fmt) { + return kscanf(from_string(s), scanf_bad_input, fmt); +} + +function sscanf_opt(s, fmt) { + return kscanf_opt(from_string(s), fmt); +} + +function scanf(fmt) { + return kscanf(stdin, scanf_bad_input, fmt); +} + +function scanf_opt(fmt) { + return kscanf_opt(stdin, fmt); +} + +function bscanf_format(ib, format, f) { + scan_caml_string(Stdlib.max_int, ib); + var str = token(ib); + var tmp; + try { + tmp = CamlinternalFormat.format_of_string_format(str, format); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Failure) { + throw { + RE_EXN_ID: Scan_failure, + _1: exn._1, + Error: new Error() + }; + } + throw exn; + } + return Curry._1(f, tmp); +} + +function sscanf_format(s, format, f) { + return bscanf_format(from_string(s), format, f); +} + +function format_from_string(s, fmt) { + return sscanf_format("\"" + (Stdlib__String.escaped(s) + "\""), fmt, (function (x) { + return x; + })); +} + +function unescaped(s) { + return Curry._1(sscanf("\"" + (s + "\""), /* Format */{ + _0: { + TAG: /* Caml_string */3, + _0: /* No_padding */0, + _1: { + TAG: /* Flush */10, + _0: /* End_of_format */0 + } + }, + _1: "%S%!" + }), (function (x) { + return x; + })); +} + +var Scanning = { + stdin: stdin, + open_in: open_in, + open_in_bin: open_in_bin, + close_in: close_in, + from_file: open_in, + from_file_bin: open_in_bin, + from_string: from_string, + from_function: from_function, + from_channel: from_channel, + end_of_input: end_of_input, + beginning_of_input: beginning_of_input, + name_of_input: name_of_input +}; + +export { + Scanning , + Scan_failure , + bscanf , + bscanf_opt , + sscanf , + sscanf_opt , + scanf , + scanf_opt , + kscanf , + ksscanf , + bscanf_format , + sscanf_format , + format_from_string , + unescaped , +} +/* stdin Not a pure module */ diff --git a/melange-node-modules/melange/seq.js b/melange-node-modules/melange/seq.js new file mode 100644 index 0000000..4e275a6 --- /dev/null +++ b/melange-node-modules/melange/seq.js @@ -0,0 +1,1203 @@ +// Generated by Melange + +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as CamlinternalLazy from "./camlinternalLazy.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib__Atomic from "./atomic.js"; + +function empty(param) { + return /* Nil */0; +} + +function $$return(x, param) { + return /* Cons */{ + _0: x, + _1: empty + }; +} + +function cons(x, next, param) { + return /* Cons */{ + _0: x, + _1: next + }; +} + +function append(seq1, seq2, param) { + var match = Curry._1(seq1, undefined); + if (!match) { + return Curry._1(seq2, undefined); + } + var next = match._1; + return /* Cons */{ + _0: match._0, + _1: (function (param) { + return append(next, seq2, param); + }) + }; +} + +function map(f, seq, param) { + var match = Curry._1(seq, undefined); + if (!match) { + return /* Nil */0; + } + var next = match._1; + return /* Cons */{ + _0: Curry._1(f, match._0), + _1: (function (param) { + return map(f, next, param); + }) + }; +} + +function filter_map(f, _seq, _param) { + while(true) { + var seq = _seq; + var match = Curry._1(seq, undefined); + if (!match) { + return /* Nil */0; + } + var next = match._1; + var y = Curry._1(f, match._0); + if (y !== undefined) { + return /* Cons */{ + _0: Caml_option.valFromOption(y), + _1: (function(next){ + return function (param) { + return filter_map(f, next, param); + } + }(next)) + }; + } + _param = undefined; + _seq = next; + continue ; + }; +} + +function filter(f, _seq, _param) { + while(true) { + var seq = _seq; + var match = Curry._1(seq, undefined); + if (!match) { + return /* Nil */0; + } + var next = match._1; + var x = match._0; + if (Curry._1(f, x)) { + return /* Cons */{ + _0: x, + _1: (function(next){ + return function (param) { + return filter(f, next, param); + } + }(next)) + }; + } + _param = undefined; + _seq = next; + continue ; + }; +} + +function concat(seq, param) { + var match = Curry._1(seq, undefined); + if (!match) { + return /* Nil */0; + } + var next = match._1; + return append(match._0, (function (param) { + return concat(next, param); + }), undefined); +} + +function flat_map(f, seq, param) { + var match = Curry._1(seq, undefined); + if (!match) { + return /* Nil */0; + } + var next = match._1; + return append(Curry._1(f, match._0), (function (param) { + return flat_map(f, next, param); + }), undefined); +} + +function fold_left(f, _acc, _seq) { + while(true) { + var seq = _seq; + var acc = _acc; + var match = Curry._1(seq, undefined); + if (!match) { + return acc; + } + var acc$1 = Curry._2(f, acc, match._0); + _seq = match._1; + _acc = acc$1; + continue ; + }; +} + +function iter(f, _seq) { + while(true) { + var seq = _seq; + var match = Curry._1(seq, undefined); + if (!match) { + return ; + } + Curry._1(f, match._0); + _seq = match._1; + continue ; + }; +} + +function unfold(f, u, param) { + var match = Curry._1(f, u); + if (match === undefined) { + return /* Nil */0; + } + var u$p = match[1]; + return /* Cons */{ + _0: match[0], + _1: (function (param) { + return unfold(f, u$p, param); + }) + }; +} + +function is_empty(xs) { + var match = Curry._1(xs, undefined); + if (match) { + return false; + } else { + return true; + } +} + +function uncons(xs) { + var match = Curry._1(xs, undefined); + if (match) { + return [ + match._0, + match._1 + ]; + } + +} + +function length(xs) { + var _accu = 0; + var _xs = xs; + while(true) { + var xs$1 = _xs; + var accu = _accu; + var match = Curry._1(xs$1, undefined); + if (!match) { + return accu; + } + _xs = match._1; + _accu = accu + 1 | 0; + continue ; + }; +} + +function iteri(f, xs) { + var _i = 0; + var _xs = xs; + while(true) { + var xs$1 = _xs; + var i = _i; + var match = Curry._1(xs$1, undefined); + if (!match) { + return ; + } + Curry._2(f, i, match._0); + _xs = match._1; + _i = i + 1 | 0; + continue ; + }; +} + +function fold_lefti(f, accu, xs) { + var _accu = accu; + var _i = 0; + var _xs = xs; + while(true) { + var xs$1 = _xs; + var i = _i; + var accu$1 = _accu; + var match = Curry._1(xs$1, undefined); + if (!match) { + return accu$1; + } + var accu$2 = Curry._3(f, accu$1, i, match._0); + _xs = match._1; + _i = i + 1 | 0; + _accu = accu$2; + continue ; + }; +} + +function for_all(p, _xs) { + while(true) { + var xs = _xs; + var match = Curry._1(xs, undefined); + if (!match) { + return true; + } + if (!Curry._1(p, match._0)) { + return false; + } + _xs = match._1; + continue ; + }; +} + +function exists(p, _xs) { + while(true) { + var xs = _xs; + var match = Curry._1(xs, undefined); + if (!match) { + return false; + } + if (Curry._1(p, match._0)) { + return true; + } + _xs = match._1; + continue ; + }; +} + +function find(p, _xs) { + while(true) { + var xs = _xs; + var match = Curry._1(xs, undefined); + if (!match) { + return ; + } + var x = match._0; + if (Curry._1(p, x)) { + return Caml_option.some(x); + } + _xs = match._1; + continue ; + }; +} + +function find_index(p, xs) { + var _i = 0; + var _xs = xs; + while(true) { + var xs$1 = _xs; + var i = _i; + var match = Curry._1(xs$1, undefined); + if (!match) { + return ; + } + if (Curry._1(p, match._0)) { + return i; + } + _xs = match._1; + _i = i + 1 | 0; + continue ; + }; +} + +function find_map(f, _xs) { + while(true) { + var xs = _xs; + var match = Curry._1(xs, undefined); + if (!match) { + return ; + } + var result = Curry._1(f, match._0); + if (result !== undefined) { + return result; + } + _xs = match._1; + continue ; + }; +} + +function find_mapi(f, xs) { + var _i = 0; + var _xs = xs; + while(true) { + var xs$1 = _xs; + var i = _i; + var match = Curry._1(xs$1, undefined); + if (!match) { + return ; + } + var result = Curry._2(f, i, match._0); + if (result !== undefined) { + return result; + } + _xs = match._1; + _i = i + 1 | 0; + continue ; + }; +} + +function iter2(f, _xs, _ys) { + while(true) { + var ys = _ys; + var xs = _xs; + var match = Curry._1(xs, undefined); + if (!match) { + return ; + } + var match$1 = Curry._1(ys, undefined); + if (!match$1) { + return ; + } + Curry._2(f, match._0, match$1._0); + _ys = match$1._1; + _xs = match._1; + continue ; + }; +} + +function fold_left2(f, _accu, _xs, _ys) { + while(true) { + var ys = _ys; + var xs = _xs; + var accu = _accu; + var match = Curry._1(xs, undefined); + if (!match) { + return accu; + } + var match$1 = Curry._1(ys, undefined); + if (!match$1) { + return accu; + } + var accu$1 = Curry._3(f, accu, match._0, match$1._0); + _ys = match$1._1; + _xs = match._1; + _accu = accu$1; + continue ; + }; +} + +function for_all2(f, _xs, _ys) { + while(true) { + var ys = _ys; + var xs = _xs; + var match = Curry._1(xs, undefined); + if (!match) { + return true; + } + var match$1 = Curry._1(ys, undefined); + if (!match$1) { + return true; + } + if (!Curry._2(f, match._0, match$1._0)) { + return false; + } + _ys = match$1._1; + _xs = match._1; + continue ; + }; +} + +function exists2(f, _xs, _ys) { + while(true) { + var ys = _ys; + var xs = _xs; + var match = Curry._1(xs, undefined); + if (!match) { + return false; + } + var match$1 = Curry._1(ys, undefined); + if (!match$1) { + return false; + } + if (Curry._2(f, match._0, match$1._0)) { + return true; + } + _ys = match$1._1; + _xs = match._1; + continue ; + }; +} + +function equal(eq, _xs, _ys) { + while(true) { + var ys = _ys; + var xs = _xs; + var match = Curry._1(xs, undefined); + var match$1 = Curry._1(ys, undefined); + if (!match) { + if (match$1) { + return false; + } else { + return true; + } + } + if (!match$1) { + return false; + } + if (!Curry._2(eq, match._0, match$1._0)) { + return false; + } + _ys = match$1._1; + _xs = match._1; + continue ; + }; +} + +function compare(cmp, _xs, _ys) { + while(true) { + var ys = _ys; + var xs = _xs; + var match = Curry._1(xs, undefined); + var match$1 = Curry._1(ys, undefined); + if (!match) { + if (match$1) { + return -1; + } else { + return 0; + } + } + if (!match$1) { + return 1; + } + var c = Curry._2(cmp, match._0, match$1._0); + if (c !== 0) { + return c; + } + _ys = match$1._1; + _xs = match._1; + continue ; + }; +} + +function init_aux(f, i, j, param) { + if (i >= j) { + return /* Nil */0; + } + var partial_arg = i + 1 | 0; + return /* Cons */{ + _0: Curry._1(f, i), + _1: (function (param) { + return init_aux(f, partial_arg, j, param); + }) + }; +} + +function init(n, f) { + if (n < 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Seq.init", + Error: new Error() + }; + } + return function (param) { + return init_aux(f, 0, n, param); + }; +} + +function repeat(x, param) { + return /* Cons */{ + _0: x, + _1: (function (param) { + return repeat(x, param); + }) + }; +} + +function forever(f, param) { + return /* Cons */{ + _0: Curry._1(f, undefined), + _1: (function (param) { + return forever(f, param); + }) + }; +} + +function cycle_nonempty(xs, param) { + return append(xs, (function (param) { + return cycle_nonempty(xs, param); + }), undefined); +} + +function cycle(xs, param) { + var match = Curry._1(xs, undefined); + if (!match) { + return /* Nil */0; + } + var xs$p = match._1; + return /* Cons */{ + _0: match._0, + _1: (function (param) { + return append(xs$p, (function (param) { + return cycle_nonempty(xs, param); + }), param); + }) + }; +} + +function iterate1(f, x, param) { + var y = Curry._1(f, x); + return /* Cons */{ + _0: y, + _1: (function (param) { + return iterate1(f, y, param); + }) + }; +} + +function iterate(f, x) { + return function (param) { + return /* Cons */{ + _0: x, + _1: (function (param) { + return iterate1(f, x, param); + }) + }; + }; +} + +function mapi_aux(f, i, xs, param) { + var match = Curry._1(xs, undefined); + if (!match) { + return /* Nil */0; + } + var xs$1 = match._1; + var partial_arg = i + 1 | 0; + return /* Cons */{ + _0: Curry._2(f, i, match._0), + _1: (function (param) { + return mapi_aux(f, partial_arg, xs$1, param); + }) + }; +} + +function mapi(f, xs) { + return function (param) { + return mapi_aux(f, 0, xs, param); + }; +} + +function tail_scan(f, s, xs, param) { + var match = Curry._1(xs, undefined); + if (!match) { + return /* Nil */0; + } + var xs$1 = match._1; + var s$1 = Curry._2(f, s, match._0); + return /* Cons */{ + _0: s$1, + _1: (function (param) { + return tail_scan(f, s$1, xs$1, param); + }) + }; +} + +function scan(f, s, xs) { + return function (param) { + return /* Cons */{ + _0: s, + _1: (function (param) { + return tail_scan(f, s, xs, param); + }) + }; + }; +} + +function take_aux(n, xs) { + if (n === 0) { + return empty; + } else { + return function (param) { + var match = Curry._1(xs, undefined); + if (match) { + return /* Cons */{ + _0: match._0, + _1: take_aux(n - 1 | 0, match._1) + }; + } else { + return /* Nil */0; + } + }; + } +} + +function take(n, xs) { + if (n < 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Seq.take", + Error: new Error() + }; + } + return take_aux(n, xs); +} + +function drop(n, xs) { + if (n < 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Seq.drop", + Error: new Error() + }; + } + if (n === 0) { + return xs; + } else { + return function (param) { + var _n = n; + var _xs = xs; + while(true) { + var xs$1 = _xs; + var n$1 = _n; + var match = Curry._1(xs$1, undefined); + if (!match) { + return /* Nil */0; + } + var xs$2 = match._1; + var n$2 = n$1 - 1 | 0; + if (n$2 === 0) { + return Curry._1(xs$2, undefined); + } + _xs = xs$2; + _n = n$2; + continue ; + }; + }; + } +} + +function take_while(p, xs, param) { + var match = Curry._1(xs, undefined); + if (!match) { + return /* Nil */0; + } + var xs$1 = match._1; + var x = match._0; + if (Curry._1(p, x)) { + return /* Cons */{ + _0: x, + _1: (function (param) { + return take_while(p, xs$1, param); + }) + }; + } else { + return /* Nil */0; + } +} + +function drop_while(p, _xs, _param) { + while(true) { + var xs = _xs; + var node = Curry._1(xs, undefined); + if (!node) { + return /* Nil */0; + } + if (!Curry._1(p, node._0)) { + return node; + } + _param = undefined; + _xs = node._1; + continue ; + }; +} + +function group(eq, xs, param) { + var match = Curry._1(xs, undefined); + if (!match) { + return /* Nil */0; + } + var xs$1 = match._1; + var x = match._0; + var partial_arg = Curry._1(eq, x); + var partial_arg$1 = function (param) { + return take_while(partial_arg, xs$1, param); + }; + var partial_arg$2 = Curry._1(eq, x); + var partial_arg$3 = function (param) { + return drop_while(partial_arg$2, xs$1, param); + }; + return /* Cons */{ + _0: (function (param) { + return /* Cons */{ + _0: x, + _1: partial_arg$1 + }; + }), + _1: (function (param) { + return group(eq, partial_arg$3, param); + }) + }; +} + +var Forced_twice = /* @__PURE__ */Caml_exceptions.create("Stdlib.Seq.Forced_twice"); + +function failure(param) { + throw { + RE_EXN_ID: Forced_twice, + Error: new Error() + }; +} + +function memoize(xs) { + var partial_arg = { + LAZY_DONE: false, + VAL: (function () { + var match = Curry._1(xs, undefined); + if (match) { + return /* Cons */{ + _0: match._0, + _1: memoize(match._1) + }; + } else { + return /* Nil */0; + } + }) + }; + return function (param) { + return CamlinternalLazy.force(partial_arg); + }; +} + +function once(xs) { + var f = function (param) { + var match = Curry._1(xs, undefined); + if (match) { + return /* Cons */{ + _0: match._0, + _1: once(match._1) + }; + } else { + return /* Nil */0; + } + }; + var action = Stdlib__Atomic.make(f); + return function (param) { + var f = Stdlib__Atomic.exchange(action, failure); + return Curry._1(f, undefined); + }; +} + +function zip(xs, ys, param) { + var match = Curry._1(xs, undefined); + if (!match) { + return /* Nil */0; + } + var xs$1 = match._1; + var match$1 = Curry._1(ys, undefined); + if (!match$1) { + return /* Nil */0; + } + var ys$1 = match$1._1; + return /* Cons */{ + _0: [ + match._0, + match$1._0 + ], + _1: (function (param) { + return zip(xs$1, ys$1, param); + }) + }; +} + +function map2(f, xs, ys, param) { + var match = Curry._1(xs, undefined); + if (!match) { + return /* Nil */0; + } + var xs$1 = match._1; + var match$1 = Curry._1(ys, undefined); + if (!match$1) { + return /* Nil */0; + } + var ys$1 = match$1._1; + return /* Cons */{ + _0: Curry._2(f, match._0, match$1._0), + _1: (function (param) { + return map2(f, xs$1, ys$1, param); + }) + }; +} + +function interleave(xs, ys, param) { + var match = Curry._1(xs, undefined); + if (!match) { + return Curry._1(ys, undefined); + } + var xs$1 = match._1; + return /* Cons */{ + _0: match._0, + _1: (function (param) { + return interleave(ys, xs$1, param); + }) + }; +} + +function sorted_merge1(cmp, x, xs, y, ys) { + if (Curry._2(cmp, x, y) <= 0) { + return /* Cons */{ + _0: x, + _1: (function (param) { + var match = Curry._1(xs, undefined); + if (match) { + return sorted_merge1(cmp, match._0, match._1, y, ys); + } else { + return /* Cons */{ + _0: y, + _1: ys + }; + } + }) + }; + } else { + return /* Cons */{ + _0: y, + _1: (function (param) { + var match = Curry._1(ys, undefined); + if (match) { + return sorted_merge1(cmp, x, xs, match._0, match._1); + } else { + return /* Cons */{ + _0: x, + _1: xs + }; + } + }) + }; + } +} + +function sorted_merge(cmp, xs, ys, param) { + var match = Curry._1(xs, undefined); + var match$1 = Curry._1(ys, undefined); + if (match) { + if (match$1) { + return sorted_merge1(cmp, match._0, match._1, match$1._0, match$1._1); + } else { + return match; + } + } else if (match$1) { + return match$1; + } else { + return /* Nil */0; + } +} + +function map_fst(xys, param) { + var match = Curry._1(xys, undefined); + if (!match) { + return /* Nil */0; + } + var xys$1 = match._1; + return /* Cons */{ + _0: match._0[0], + _1: (function (param) { + return map_fst(xys$1, param); + }) + }; +} + +function map_snd(xys, param) { + var match = Curry._1(xys, undefined); + if (!match) { + return /* Nil */0; + } + var xys$1 = match._1; + return /* Cons */{ + _0: match._0[1], + _1: (function (param) { + return map_snd(xys$1, param); + }) + }; +} + +function unzip(xys) { + return [ + (function (param) { + return map_fst(xys, param); + }), + (function (param) { + return map_snd(xys, param); + }) + ]; +} + +function filter_map_find_left_map(f, _xs, _param) { + while(true) { + var xs = _xs; + var match = Curry._1(xs, undefined); + if (!match) { + return /* Nil */0; + } + var xs$1 = match._1; + var y = Curry._1(f, match._0); + if (y.TAG === /* Left */0) { + return /* Cons */{ + _0: y._0, + _1: (function(xs$1){ + return function (param) { + return filter_map_find_left_map(f, xs$1, param); + } + }(xs$1)) + }; + } + _param = undefined; + _xs = xs$1; + continue ; + }; +} + +function filter_map_find_right_map(f, _xs, _param) { + while(true) { + var xs = _xs; + var match = Curry._1(xs, undefined); + if (!match) { + return /* Nil */0; + } + var xs$1 = match._1; + var z = Curry._1(f, match._0); + if (z.TAG !== /* Left */0) { + return /* Cons */{ + _0: z._0, + _1: (function(xs$1){ + return function (param) { + return filter_map_find_right_map(f, xs$1, param); + } + }(xs$1)) + }; + } + _param = undefined; + _xs = xs$1; + continue ; + }; +} + +function partition_map(f, xs) { + return [ + (function (param) { + return filter_map_find_left_map(f, xs, param); + }), + (function (param) { + return filter_map_find_right_map(f, xs, param); + }) + ]; +} + +function partition(p, xs) { + return [ + (function (param) { + return filter(p, xs, param); + }), + (function (param) { + return filter((function (x) { + return !Curry._1(p, x); + }), xs, param); + }) + ]; +} + +function transpose(xss, param) { + var match = unzip(function (param) { + return filter_map(uncons, xss, param); + }); + var tails = match[1]; + var heads = match[0]; + if (!is_empty(heads)) { + return /* Cons */{ + _0: heads, + _1: (function (param) { + return transpose(tails, param); + }) + }; + } + if (!is_empty(tails)) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/seq.ml", + 616, + 4 + ], + Error: new Error() + }; + } + return /* Nil */0; +} + +function diagonals(remainders, xss, param) { + var match = Curry._1(xss, undefined); + if (!match) { + return transpose(remainders, undefined); + } + var xss$1 = match._1; + var match$1 = Curry._1(match._0, undefined); + if (match$1) { + var xs = match$1._1; + var x = match$1._0; + var match$2 = unzip(function (param) { + return filter_map(uncons, remainders, param); + }); + var tails = match$2[1]; + var heads = match$2[0]; + return /* Cons */{ + _0: (function (param) { + return /* Cons */{ + _0: x, + _1: heads + }; + }), + _1: (function (param) { + return diagonals((function (param) { + return /* Cons */{ + _0: xs, + _1: tails + }; + }), xss$1, param); + }) + }; + } + var match$3 = unzip(function (param) { + return filter_map(uncons, remainders, param); + }); + var tails$1 = match$3[1]; + return /* Cons */{ + _0: match$3[0], + _1: (function (param) { + return diagonals(tails$1, xss$1, param); + }) + }; +} + +function map_product(f, xs, ys) { + return function (param) { + return concat((function (param) { + return diagonals(empty, (function (param) { + return map((function (x) { + return function (param) { + return map((function (y) { + return Curry._2(f, x, y); + }), ys, param); + }; + }), xs, param); + }), param); + }), param); + }; +} + +function product(xs, ys) { + return map_product((function (x, y) { + return [ + x, + y + ]; + }), xs, ys); +} + +function of_dispenser(it) { + var c = function (param) { + var x = Curry._1(it, undefined); + if (x !== undefined) { + return /* Cons */{ + _0: Caml_option.valFromOption(x), + _1: c + }; + } else { + return /* Nil */0; + } + }; + return c; +} + +function to_dispenser(xs) { + var s = { + contents: xs + }; + return function (param) { + var match = Curry._1(s.contents, undefined); + if (match) { + s.contents = match._1; + return Caml_option.some(match._0); + } + + }; +} + +function ints(i, param) { + var partial_arg = i + 1 | 0; + return /* Cons */{ + _0: i, + _1: (function (param) { + return ints(partial_arg, param); + }) + }; +} + +var concat_map = flat_map; + +var split = unzip; + +export { + is_empty , + uncons , + length , + iter , + fold_left , + iteri , + fold_lefti , + for_all , + exists , + find , + find_index , + find_map , + find_mapi , + iter2 , + fold_left2 , + for_all2 , + exists2 , + equal , + compare , + empty , + $$return , + cons , + init , + unfold , + repeat , + forever , + cycle , + iterate , + map , + mapi , + filter , + filter_map , + scan , + take , + drop , + take_while , + drop_while , + group , + memoize , + Forced_twice , + once , + transpose , + append , + concat , + flat_map , + concat_map , + zip , + map2 , + interleave , + sorted_merge , + product , + map_product , + unzip , + split , + partition_map , + partition , + of_dispenser , + to_dispenser , + ints , +} +/* No side effect */ diff --git a/melange-node-modules/melange/set.js b/melange-node-modules/melange/set.js new file mode 100644 index 0000000..4f79e55 --- /dev/null +++ b/melange-node-modules/melange/set.js @@ -0,0 +1,1157 @@ +// Generated by Melange + +import * as Caml_obj from "melange.js/caml_obj.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__List from "./list.js"; +import * as Stdlib__Seq from "./seq.js"; + +function Make(funarg) { + var height = function (param) { + if (param) { + return param.h; + } else { + return 0; + } + }; + var create = function (l, v, r) { + var hl = l ? l.h : 0; + var hr = r ? r.h : 0; + return /* Node */{ + l: l, + v: v, + r: r, + h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + }; + var bal = function (l, v, r) { + var hl = l ? l.h : 0; + var hr = r ? r.h : 0; + if (hl > (hr + 2 | 0)) { + if (l) { + var lr = l.r; + var lv = l.v; + var ll = l.l; + if (height(ll) >= height(lr)) { + return create(ll, lv, create(lr, v, r)); + } + if (lr) { + return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Set.bal", + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Set.bal", + Error: new Error() + }; + } + if (hr <= (hl + 2 | 0)) { + return /* Node */{ + l: l, + v: v, + r: r, + h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + } + if (r) { + var rr = r.r; + var rv = r.v; + var rl = r.l; + if (height(rr) >= height(rl)) { + return create(create(l, v, rl), rv, rr); + } + if (rl) { + return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Set.bal", + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Set.bal", + Error: new Error() + }; + }; + var add = function (x, t) { + if (!t) { + return /* Node */{ + l: /* Empty */0, + v: x, + r: /* Empty */0, + h: 1 + }; + } + var r = t.r; + var v = t.v; + var l = t.l; + var c = Curry._2(funarg.compare, x, v); + if (c === 0) { + return t; + } + if (c < 0) { + var ll = add(x, l); + if (l === ll) { + return t; + } else { + return bal(ll, v, r); + } + } + var rr = add(x, r); + if (r === rr) { + return t; + } else { + return bal(l, v, rr); + } + }; + var singleton = function (x) { + return /* Node */{ + l: /* Empty */0, + v: x, + r: /* Empty */0, + h: 1 + }; + }; + var add_min_element = function (x, param) { + if (param) { + return bal(add_min_element(x, param.l), param.v, param.r); + } else { + return singleton(x); + } + }; + var add_max_element = function (x, param) { + if (param) { + return bal(param.l, param.v, add_max_element(x, param.r)); + } else { + return singleton(x); + } + }; + var join = function (l, v, r) { + if (!l) { + return add_min_element(v, r); + } + if (!r) { + return add_max_element(v, l); + } + var rh = r.h; + var lh = l.h; + if (lh > (rh + 2 | 0)) { + return bal(l.l, l.v, join(l.r, v, r)); + } else if (rh > (lh + 2 | 0)) { + return bal(join(l, v, r.l), r.v, r.r); + } else { + return create(l, v, r); + } + }; + var min_elt = function (_param) { + while(true) { + var param = _param; + if (param) { + var l = param.l; + if (!l) { + return param.v; + } + _param = l; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + }; + var min_elt_opt = function (_param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + var l = param.l; + if (!l) { + return Caml_option.some(param.v); + } + _param = l; + continue ; + }; + }; + var max_elt = function (_param) { + while(true) { + var param = _param; + if (param) { + if (!param.r) { + return param.v; + } + _param = param.r; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + }; + var max_elt_opt = function (_param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + if (!param.r) { + return Caml_option.some(param.v); + } + _param = param.r; + continue ; + }; + }; + var remove_min_elt = function (param) { + if (param) { + var l = param.l; + if (l) { + return bal(remove_min_elt(l), param.v, param.r); + } else { + return param.r; + } + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Set.remove_min_elt", + Error: new Error() + }; + }; + var concat = function (t1, t2) { + if (t1) { + if (t2) { + return join(t1, min_elt(t2), remove_min_elt(t2)); + } else { + return t1; + } + } else { + return t2; + } + }; + var split = function (x, param) { + if (!param) { + return [ + /* Empty */0, + false, + /* Empty */0 + ]; + } + var r = param.r; + var v = param.v; + var l = param.l; + var c = Curry._2(funarg.compare, x, v); + if (c === 0) { + return [ + l, + true, + r + ]; + } + if (c < 0) { + var match = split(x, l); + return [ + match[0], + match[1], + join(match[2], v, r) + ]; + } + var match$1 = split(x, r); + return [ + join(l, v, match$1[0]), + match$1[1], + match$1[2] + ]; + }; + var is_empty = function (param) { + if (param) { + return false; + } else { + return true; + } + }; + var mem = function (x, _param) { + while(true) { + var param = _param; + if (!param) { + return false; + } + var c = Curry._2(funarg.compare, x, param.v); + if (c === 0) { + return true; + } + _param = c < 0 ? param.l : param.r; + continue ; + }; + }; + var remove = function (x, t) { + if (!t) { + return /* Empty */0; + } + var r = t.r; + var v = t.v; + var l = t.l; + var c = Curry._2(funarg.compare, x, v); + if (c === 0) { + if (l) { + if (r) { + return bal(l, min_elt(r), remove_min_elt(r)); + } else { + return l; + } + } else { + return r; + } + } + if (c < 0) { + var ll = remove(x, l); + if (l === ll) { + return t; + } else { + return bal(ll, v, r); + } + } + var rr = remove(x, r); + if (r === rr) { + return t; + } else { + return bal(l, v, rr); + } + }; + var union = function (s1, s2) { + if (!s1) { + return s2; + } + if (!s2) { + return s1; + } + var h2 = s2.h; + var v2 = s2.v; + var h1 = s1.h; + var v1 = s1.v; + if (h1 >= h2) { + if (h2 === 1) { + return add(v2, s1); + } + var match = split(v1, s2); + return join(union(s1.l, match[0]), v1, union(s1.r, match[2])); + } + if (h1 === 1) { + return add(v1, s2); + } + var match$1 = split(v2, s1); + return join(union(match$1[0], s2.l), v2, union(match$1[2], s2.r)); + }; + var inter = function (s1, s2) { + if (!s1) { + return /* Empty */0; + } + if (!s2) { + return /* Empty */0; + } + var r1 = s1.r; + var v1 = s1.v; + var l1 = s1.l; + var match = split(v1, s2); + var l2 = match[0]; + if (match[1]) { + return join(inter(l1, l2), v1, inter(r1, match[2])); + } else { + return concat(inter(l1, l2), inter(r1, match[2])); + } + }; + var split_bis = function (x, param) { + if (!param) { + return /* NotFound */{ + _0: /* Empty */0, + _1: (function (param) { + return /* Empty */0; + }) + }; + } + var r = param.r; + var v = param.v; + var l = param.l; + var c = Curry._2(funarg.compare, x, v); + if (c === 0) { + return /* Found */0; + } + if (c < 0) { + var match = split_bis(x, l); + if (!match) { + return /* Found */0; + } + var rl = match._1; + return /* NotFound */{ + _0: match._0, + _1: (function (param) { + return join(Curry._1(rl, undefined), v, r); + }) + }; + } + var match$1 = split_bis(x, r); + if (match$1) { + return /* NotFound */{ + _0: join(l, v, match$1._0), + _1: match$1._1 + }; + } else { + return /* Found */0; + } + }; + var disjoint = function (_s1, _s2) { + while(true) { + var s2 = _s2; + var s1 = _s1; + if (!s1) { + return true; + } + if (!s2) { + return true; + } + if (s1 === s2) { + return false; + } + var match = split_bis(s1.v, s2); + if (!match) { + return false; + } + if (!disjoint(s1.l, match._0)) { + return false; + } + _s2 = Curry._1(match._1, undefined); + _s1 = s1.r; + continue ; + }; + }; + var diff = function (s1, s2) { + if (!s1) { + return /* Empty */0; + } + if (!s2) { + return s1; + } + var r1 = s1.r; + var v1 = s1.v; + var l1 = s1.l; + var match = split(v1, s2); + var l2 = match[0]; + if (match[1]) { + return concat(diff(l1, l2), diff(r1, match[2])); + } else { + return join(diff(l1, l2), v1, diff(r1, match[2])); + } + }; + var cons_enum = function (_s, _e) { + while(true) { + var e = _e; + var s = _s; + if (!s) { + return e; + } + _e = /* More */{ + _0: s.v, + _1: s.r, + _2: e + }; + _s = s.l; + continue ; + }; + }; + var compare = function (s1, s2) { + var _e1 = cons_enum(s1, /* End */0); + var _e2 = cons_enum(s2, /* End */0); + while(true) { + var e2 = _e2; + var e1 = _e1; + if (!e1) { + if (e2) { + return -1; + } else { + return 0; + } + } + if (!e2) { + return 1; + } + var c = Curry._2(funarg.compare, e1._0, e2._0); + if (c !== 0) { + return c; + } + _e2 = cons_enum(e2._1, e2._2); + _e1 = cons_enum(e1._1, e1._2); + continue ; + }; + }; + var equal = function (s1, s2) { + return compare(s1, s2) === 0; + }; + var subset = function (_s1, _s2) { + while(true) { + var s2 = _s2; + var s1 = _s1; + if (!s1) { + return true; + } + if (!s2) { + return false; + } + var r2 = s2.r; + var l2 = s2.l; + var r1 = s1.r; + var v1 = s1.v; + var l1 = s1.l; + var c = Curry._2(funarg.compare, v1, s2.v); + if (c === 0) { + if (!subset(l1, l2)) { + return false; + } + _s2 = r2; + _s1 = r1; + continue ; + } + if (c < 0) { + if (!subset(/* Node */{ + l: l1, + v: v1, + r: /* Empty */0, + h: 0 + }, l2)) { + return false; + } + _s1 = r1; + continue ; + } + if (!subset(/* Node */{ + l: /* Empty */0, + v: v1, + r: r1, + h: 0 + }, r2)) { + return false; + } + _s1 = l1; + continue ; + }; + }; + var iter = function (f, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + iter(f, param.l); + Curry._1(f, param.v); + _param = param.r; + continue ; + }; + }; + var fold = function (f, _s, _accu) { + while(true) { + var accu = _accu; + var s = _s; + if (!s) { + return accu; + } + _accu = Curry._2(f, s.v, fold(f, s.l, accu)); + _s = s.r; + continue ; + }; + }; + var for_all = function (p, _param) { + while(true) { + var param = _param; + if (!param) { + return true; + } + if (!Curry._1(p, param.v)) { + return false; + } + if (!for_all(p, param.l)) { + return false; + } + _param = param.r; + continue ; + }; + }; + var exists = function (p, _param) { + while(true) { + var param = _param; + if (!param) { + return false; + } + if (Curry._1(p, param.v)) { + return true; + } + if (exists(p, param.l)) { + return true; + } + _param = param.r; + continue ; + }; + }; + var filter = function (p, t) { + if (!t) { + return /* Empty */0; + } + var r = t.r; + var v = t.v; + var l = t.l; + var l$p = filter(p, l); + var pv = Curry._1(p, v); + var r$p = filter(p, r); + if (pv) { + if (l === l$p && r === r$p) { + return t; + } else { + return join(l$p, v, r$p); + } + } else { + return concat(l$p, r$p); + } + }; + var partition = function (p, param) { + if (!param) { + return [ + /* Empty */0, + /* Empty */0 + ]; + } + var v = param.v; + var match = partition(p, param.l); + var lf = match[1]; + var lt = match[0]; + var pv = Curry._1(p, v); + var match$1 = partition(p, param.r); + var rf = match$1[1]; + var rt = match$1[0]; + if (pv) { + return [ + join(lt, v, rt), + concat(lf, rf) + ]; + } else { + return [ + concat(lt, rt), + join(lf, v, rf) + ]; + } + }; + var cardinal = function (param) { + if (param) { + return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; + } else { + return 0; + } + }; + var elements_aux = function (_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + _param = param.l; + _accu = { + hd: param.v, + tl: elements_aux(accu, param.r) + }; + continue ; + }; + }; + var elements = function (s) { + return elements_aux(/* [] */0, s); + }; + var find = function (x, _param) { + while(true) { + var param = _param; + if (param) { + var v = param.v; + var c = Curry._2(funarg.compare, x, v); + if (c === 0) { + return v; + } + _param = c < 0 ? param.l : param.r; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + }; + var find_first = function (f, _param) { + while(true) { + var param = _param; + if (param) { + var v = param.v; + if (Curry._1(f, v)) { + var _v0 = v; + var _param$1 = param.l; + while(true) { + var param$1 = _param$1; + var v0 = _v0; + if (!param$1) { + return v0; + } + var v$1 = param$1.v; + if (Curry._1(f, v$1)) { + _param$1 = param$1.l; + _v0 = v$1; + continue ; + } + _param$1 = param$1.r; + continue ; + }; + } + _param = param.r; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + }; + var find_first_opt = function (f, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + var v = param.v; + if (Curry._1(f, v)) { + var _v0 = v; + var _param$1 = param.l; + while(true) { + var param$1 = _param$1; + var v0 = _v0; + if (!param$1) { + return Caml_option.some(v0); + } + var v$1 = param$1.v; + if (Curry._1(f, v$1)) { + _param$1 = param$1.l; + _v0 = v$1; + continue ; + } + _param$1 = param$1.r; + continue ; + }; + } + _param = param.r; + continue ; + }; + }; + var find_last = function (f, _param) { + while(true) { + var param = _param; + if (param) { + var v = param.v; + if (Curry._1(f, v)) { + var _v0 = v; + var _param$1 = param.r; + while(true) { + var param$1 = _param$1; + var v0 = _v0; + if (!param$1) { + return v0; + } + var v$1 = param$1.v; + if (Curry._1(f, v$1)) { + _param$1 = param$1.r; + _v0 = v$1; + continue ; + } + _param$1 = param$1.l; + continue ; + }; + } + _param = param.l; + continue ; + } + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + }; + }; + var find_last_opt = function (f, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + var v = param.v; + if (Curry._1(f, v)) { + var _v0 = v; + var _param$1 = param.r; + while(true) { + var param$1 = _param$1; + var v0 = _v0; + if (!param$1) { + return Caml_option.some(v0); + } + var v$1 = param$1.v; + if (Curry._1(f, v$1)) { + _param$1 = param$1.r; + _v0 = v$1; + continue ; + } + _param$1 = param$1.l; + continue ; + }; + } + _param = param.l; + continue ; + }; + }; + var find_opt = function (x, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + var v = param.v; + var c = Curry._2(funarg.compare, x, v); + if (c === 0) { + return Caml_option.some(v); + } + _param = c < 0 ? param.l : param.r; + continue ; + }; + }; + var try_join = function (l, v, r) { + if ((Caml_obj.caml_equal(l, /* Empty */0) || Curry._2(funarg.compare, max_elt(l), v) < 0) && (Caml_obj.caml_equal(r, /* Empty */0) || Curry._2(funarg.compare, v, min_elt(r)) < 0)) { + return join(l, v, r); + } else { + return union(l, add(v, r)); + } + }; + var map = function (f, t) { + if (!t) { + return /* Empty */0; + } + var r = t.r; + var v = t.v; + var l = t.l; + var l$p = map(f, l); + var v$p = Curry._1(f, v); + var r$p = map(f, r); + if (l === l$p && v === v$p && r === r$p) { + return t; + } else { + return try_join(l$p, v$p, r$p); + } + }; + var filter_map = function (f, t) { + if (!t) { + return /* Empty */0; + } + var r = t.r; + var v = t.v; + var l = t.l; + var l$p = filter_map(f, l); + var v$p = Curry._1(f, v); + var r$p = filter_map(f, r); + if (v$p === undefined) { + if (l$p) { + if (r$p) { + return try_join(l$p, min_elt(r$p), remove_min_elt(r$p)); + } else { + return l$p; + } + } else { + return r$p; + } + } + var v$p$1 = Caml_option.valFromOption(v$p); + if (l === l$p && v === v$p$1 && r === r$p) { + return t; + } else { + return try_join(l$p, v$p$1, r$p); + } + }; + var of_list = function (l) { + if (!l) { + return /* Empty */0; + } + var match = l.tl; + var x0 = l.hd; + if (!match) { + return singleton(x0); + } + var match$1 = match.tl; + var x1 = match.hd; + if (!match$1) { + return add(x1, singleton(x0)); + } + var match$2 = match$1.tl; + var x2 = match$1.hd; + if (!match$2) { + return add(x2, add(x1, singleton(x0))); + } + var match$3 = match$2.tl; + var x3 = match$2.hd; + if (match$3) { + if (match$3.tl) { + var l$1 = Stdlib__List.sort_uniq(funarg.compare, l); + var sub = function (n, l) { + switch (n) { + case 0 : + return [ + /* Empty */0, + l + ]; + case 1 : + if (l) { + return [ + /* Node */{ + l: /* Empty */0, + v: l.hd, + r: /* Empty */0, + h: 1 + }, + l.tl + ]; + } + break; + case 2 : + if (l) { + var match = l.tl; + if (match) { + return [ + /* Node */{ + l: /* Node */{ + l: /* Empty */0, + v: l.hd, + r: /* Empty */0, + h: 1 + }, + v: match.hd, + r: /* Empty */0, + h: 2 + }, + match.tl + ]; + } + + } + break; + case 3 : + if (l) { + var match$1 = l.tl; + if (match$1) { + var match$2 = match$1.tl; + if (match$2) { + return [ + /* Node */{ + l: /* Node */{ + l: /* Empty */0, + v: l.hd, + r: /* Empty */0, + h: 1 + }, + v: match$1.hd, + r: /* Node */{ + l: /* Empty */0, + v: match$2.hd, + r: /* Empty */0, + h: 1 + }, + h: 2 + }, + match$2.tl + ]; + } + + } + + } + break; + default: + + } + var nl = n / 2 | 0; + var match$3 = sub(nl, l); + var l$1 = match$3[1]; + if (l$1) { + var match$4 = sub((n - nl | 0) - 1 | 0, l$1.tl); + return [ + create(match$3[0], l$1.hd, match$4[0]), + match$4[1] + ]; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/set.ml", + 571, + 18 + ], + Error: new Error() + }; + }; + return sub(Stdlib__List.length(l$1), l$1)[0]; + } else { + return add(match$3.hd, add(x3, add(x2, add(x1, singleton(x0))))); + } + } else { + return add(x3, add(x2, add(x1, singleton(x0)))); + } + }; + var add_seq = function (i, m) { + return Stdlib__Seq.fold_left((function (s, x) { + return add(x, s); + }), m, i); + }; + var of_seq = function (i) { + return add_seq(i, /* Empty */0); + }; + var seq_of_enum_ = function (c, param) { + if (!c) { + return /* Nil */0; + } + var partial_arg = cons_enum(c._1, c._2); + return /* Cons */{ + _0: c._0, + _1: (function (param) { + return seq_of_enum_(partial_arg, param); + }) + }; + }; + var to_seq = function (c) { + var partial_arg = cons_enum(c, /* End */0); + return function (param) { + return seq_of_enum_(partial_arg, param); + }; + }; + var snoc_enum = function (_s, _e) { + while(true) { + var e = _e; + var s = _s; + if (!s) { + return e; + } + _e = /* More */{ + _0: s.v, + _1: s.l, + _2: e + }; + _s = s.r; + continue ; + }; + }; + var rev_seq_of_enum_ = function (c, param) { + if (!c) { + return /* Nil */0; + } + var partial_arg = snoc_enum(c._1, c._2); + return /* Cons */{ + _0: c._0, + _1: (function (param) { + return rev_seq_of_enum_(partial_arg, param); + }) + }; + }; + var to_rev_seq = function (c) { + var partial_arg = snoc_enum(c, /* End */0); + return function (param) { + return rev_seq_of_enum_(partial_arg, param); + }; + }; + var to_seq_from = function (low, s) { + var aux = function (low, _s, _c) { + while(true) { + var c = _c; + var s = _s; + if (!s) { + return c; + } + var r = s.r; + var v = s.v; + var n = Curry._2(funarg.compare, v, low); + if (n === 0) { + return /* More */{ + _0: v, + _1: r, + _2: c + }; + } + if (n < 0) { + _s = r; + continue ; + } + _c = /* More */{ + _0: v, + _1: r, + _2: c + }; + _s = s.l; + continue ; + }; + }; + var partial_arg = aux(low, s, /* End */0); + return function (param) { + return seq_of_enum_(partial_arg, param); + }; + }; + return { + empty: /* Empty */0, + add: add, + singleton: singleton, + remove: remove, + union: union, + inter: inter, + disjoint: disjoint, + diff: diff, + cardinal: cardinal, + elements: elements, + min_elt: min_elt, + min_elt_opt: min_elt_opt, + max_elt: max_elt, + max_elt_opt: max_elt_opt, + choose: min_elt, + choose_opt: min_elt_opt, + find: find, + find_opt: find_opt, + find_first: find_first, + find_first_opt: find_first_opt, + find_last: find_last, + find_last_opt: find_last_opt, + iter: iter, + fold: fold, + map: map, + filter: filter, + filter_map: filter_map, + partition: partition, + split: split, + is_empty: is_empty, + mem: mem, + equal: equal, + compare: compare, + subset: subset, + for_all: for_all, + exists: exists, + to_list: elements, + of_list: of_list, + to_seq_from: to_seq_from, + to_seq: to_seq, + to_rev_seq: to_rev_seq, + add_seq: add_seq, + of_seq: of_seq + }; +} + +export { + Make , +} +/* No side effect */ diff --git a/melange-node-modules/melange/stack.js b/melange-node-modules/melange/stack.js new file mode 100644 index 0000000..ad00b41 --- /dev/null +++ b/melange-node-modules/melange/stack.js @@ -0,0 +1,147 @@ +// Generated by Melange + +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; +import * as Caml_obj from "melange.js/caml_obj.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Stdlib__List from "./list.js"; +import * as Stdlib__Seq from "./seq.js"; + +var Empty = /* @__PURE__ */Caml_exceptions.create("Stdlib.Stack.Empty"); + +function create(param) { + return { + c: /* [] */0, + len: 0 + }; +} + +function clear(s) { + s.c = /* [] */0; + s.len = 0; +} + +function copy(s) { + return { + c: s.c, + len: s.len + }; +} + +function push(x, s) { + s.c = { + hd: x, + tl: s.c + }; + s.len = s.len + 1 | 0; +} + +function pop(s) { + var match = s.c; + if (match) { + s.c = match.tl; + s.len = s.len - 1 | 0; + return match.hd; + } + throw { + RE_EXN_ID: Empty, + Error: new Error() + }; +} + +function pop_opt(s) { + var match = s.c; + if (match) { + s.c = match.tl; + s.len = s.len - 1 | 0; + return Caml_option.some(match.hd); + } + +} + +function drop(s) { + var match = s.c; + if (match) { + s.c = match.tl; + s.len = s.len - 1 | 0; + return ; + } + throw { + RE_EXN_ID: Empty, + Error: new Error() + }; +} + +function top(s) { + var match = s.c; + if (match) { + return match.hd; + } + throw { + RE_EXN_ID: Empty, + Error: new Error() + }; +} + +function top_opt(s) { + var match = s.c; + if (match) { + return Caml_option.some(match.hd); + } + +} + +function is_empty(s) { + return Caml_obj.caml_equal(s.c, /* [] */0); +} + +function length(s) { + return s.len; +} + +function iter(f, s) { + Stdlib__List.iter(f, s.c); +} + +function fold(f, acc, s) { + return Stdlib__List.fold_left(f, acc, s.c); +} + +function to_seq(s) { + return Stdlib__List.to_seq(s.c); +} + +function add_seq(q, i) { + Stdlib__Seq.iter((function (x) { + push(x, q); + }), i); +} + +function of_seq(g) { + var s = { + c: /* [] */0, + len: 0 + }; + add_seq(s, g); + return s; +} + +export { + Empty , + create , + push , + pop , + pop_opt , + drop , + top , + top_opt , + clear , + copy , + is_empty , + length , + iter , + fold , + to_seq , + add_seq , + of_seq , +} +/* No side effect */ diff --git a/melange-node-modules/melange/stdLabels.js b/melange-node-modules/melange/stdLabels.js new file mode 100644 index 0000000..9bb81da --- /dev/null +++ b/melange-node-modules/melange/stdLabels.js @@ -0,0 +1,2 @@ +// Generated by Melange +/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/melange-node-modules/melange/std_exit.js b/melange-node-modules/melange/std_exit.js new file mode 100644 index 0000000..8616b0a --- /dev/null +++ b/melange-node-modules/melange/std_exit.js @@ -0,0 +1,10 @@ +// Generated by Melange + +import * as Stdlib from "./stdlib.js"; + +Stdlib.do_at_exit(undefined); + +export { + +} +/* Not a pure module */ diff --git a/melange-node-modules/melange/stdlib.js b/melange-node-modules/melange/stdlib.js new file mode 100644 index 0000000..0d57763 --- /dev/null +++ b/melange-node-modules/melange/stdlib.js @@ -0,0 +1,852 @@ +// Generated by Melange + +import * as Caml_bytes from "melange.js/caml_bytes.js"; +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Caml_format from "melange.js/caml_format.js"; +import * as Caml_io from "melange.js/caml_io.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Caml_string from "melange.js/caml_string.js"; +import * as Caml_sys from "melange.js/caml_sys.js"; +import * as CamlinternalFormatBasics from "./camlinternalFormatBasics.js"; +import * as Curry from "melange.js/curry.js"; + +function failwith(s) { + throw { + RE_EXN_ID: "Failure", + _1: s, + Error: new Error() + }; +} + +function invalid_arg(s) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: s, + Error: new Error() + }; +} + +var Exit = /* @__PURE__ */Caml_exceptions.create("Stdlib.Exit"); + +var Failure = "Failure"; + +var Sys_error = "Sys_error"; + +var End_of_file = "End_of_file"; + +function abs(x) { + if (x >= 0) { + return x; + } else { + return -x | 0; + } +} + +function lnot(x) { + return x ^ -1; +} + +var min_int = -2147483648; + +function classify_float(x) { + if (isFinite(x)) { + if (Math.abs(x) >= 2.22507385850720138e-308) { + return /* FP_normal */0; + } else if (x !== 0) { + return /* FP_subnormal */1; + } else { + return /* FP_zero */2; + } + } else if (isNaN(x)) { + return /* FP_nan */4; + } else { + return /* FP_infinite */3; + } +} + +function char_of_int(n) { + if (n < 0 || n > 255) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "char_of_int", + Error: new Error() + }; + } + return n; +} + +function string_of_bool(b) { + if (b) { + return "true"; + } else { + return "false"; + } +} + +function bool_of_string(param) { + switch (param) { + case "false" : + return false; + case "true" : + return true; + default: + throw { + RE_EXN_ID: "Invalid_argument", + _1: "bool_of_string", + Error: new Error() + }; + } +} + +function bool_of_string_opt(param) { + switch (param) { + case "false" : + return false; + case "true" : + return true; + default: + return ; + } +} + +function int_of_string_opt(s) { + try { + return Caml_format.caml_int_of_string(s); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Failure) { + return ; + } + throw exn; + } +} + +function valid_float_lexem(s) { + var l = s.length; + var _i = 0; + while(true) { + var i = _i; + if (i >= l) { + return s + "."; + } + var match = Caml_string.get(s, i); + if (match >= 48) { + if (match >= 58) { + return s; + } + _i = i + 1 | 0; + continue ; + } + if (match !== 45) { + return s; + } + _i = i + 1 | 0; + continue ; + }; +} + +function string_of_float(f) { + return valid_float_lexem(Caml_format.caml_format_float("%.12g", f)); +} + +function float_of_string_opt(s) { + try { + return Caml_format.caml_float_of_string(s); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Failure) { + return ; + } + throw exn; + } +} + +function $at_dps(_dst, _offset, _l1, l2) { + while(true) { + var dst = _dst; + var offset = _offset; + var l1 = _l1; + if (!l1) { + dst[offset] = l2; + return ; + } + var match = l1.tl; + var h1 = l1.hd; + if (!match) { + dst[offset] = { + hd: h1, + tl: l2 + }; + return ; + } + var match$1 = match.tl; + var h2 = match.hd; + if (!match$1) { + dst[offset] = { + hd: h1, + tl: { + hd: h2, + tl: l2 + } + }; + return ; + } + var block = { + hd: match$1.hd, + tl: 24029 + }; + dst[offset] = { + hd: h1, + tl: { + hd: h2, + tl: block + } + }; + _l1 = match$1.tl; + _offset = "tl"; + _dst = block; + continue ; + }; +} + +function $at(l1, l2) { + if (!l1) { + return l2; + } + var match = l1.tl; + var h1 = l1.hd; + if (!match) { + return { + hd: h1, + tl: l2 + }; + } + var match$1 = match.tl; + var h2 = match.hd; + if (!match$1) { + return { + hd: h1, + tl: { + hd: h2, + tl: l2 + } + }; + } + var block = { + hd: match$1.hd, + tl: 24029 + }; + return { + hd: h1, + tl: { + hd: h2, + tl: ($at_dps(block, "tl", match$1.tl, l2), block) + } + }; +} + +var stdin = Caml_io.stdin; + +var stdout = Caml_io.stdout; + +var stderr = Caml_io.stderr; + +function open_out_gen(mode, perm, name) { + var c = Caml_external_polyfill.resolve("caml_ml_open_descriptor_out")(Caml_external_polyfill.resolve("caml_sys_open")(name, mode, perm)); + Caml_external_polyfill.resolve("caml_ml_set_channel_name")(c, name); + return c; +} + +function open_out(name) { + return open_out_gen({ + hd: /* Open_wronly */1, + tl: { + hd: /* Open_creat */3, + tl: { + hd: /* Open_trunc */4, + tl: { + hd: /* Open_text */7, + tl: /* [] */0 + } + } + } + }, 438, name); +} + +function open_out_bin(name) { + return open_out_gen({ + hd: /* Open_wronly */1, + tl: { + hd: /* Open_creat */3, + tl: { + hd: /* Open_trunc */4, + tl: { + hd: /* Open_binary */6, + tl: /* [] */0 + } + } + } + }, 438, name); +} + +function flush_all(param) { + var _param = Caml_io.caml_ml_out_channels_list(undefined); + while(true) { + var param$1 = _param; + if (!param$1) { + return ; + } + try { + Caml_io.caml_ml_flush(param$1.hd); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID !== Sys_error) { + throw exn; + } + + } + _param = param$1.tl; + continue ; + }; +} + +function output_bytes(oc, s) { + Caml_external_polyfill.resolve("caml_ml_output_bytes")(oc, s, 0, s.length); +} + +function output_string(oc, s) { + Caml_io.caml_ml_output(oc, s, 0, s.length); +} + +function output(oc, s, ofs, len) { + if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "output", + Error: new Error() + }; + } + Caml_external_polyfill.resolve("caml_ml_output_bytes")(oc, s, ofs, len); +} + +function output_substring(oc, s, ofs, len) { + if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "output_substring", + Error: new Error() + }; + } + Caml_io.caml_ml_output(oc, s, ofs, len); +} + +function output_value(chan, v) { + Caml_external_polyfill.resolve("caml_output_value")(chan, v, /* [] */0); +} + +function close_out(oc) { + Caml_io.caml_ml_flush(oc); + Caml_external_polyfill.resolve("caml_ml_close_channel")(oc); +} + +function close_out_noerr(oc) { + try { + Caml_io.caml_ml_flush(oc); + } + catch (exn){ + + } + try { + return Caml_external_polyfill.resolve("caml_ml_close_channel")(oc); + } + catch (exn$1){ + return ; + } +} + +function open_in_gen(mode, perm, name) { + var c = Caml_external_polyfill.resolve("caml_ml_open_descriptor_in")(Caml_external_polyfill.resolve("caml_sys_open")(name, mode, perm)); + Caml_external_polyfill.resolve("caml_ml_set_channel_name")(c, name); + return c; +} + +function open_in(name) { + return open_in_gen({ + hd: /* Open_rdonly */0, + tl: { + hd: /* Open_text */7, + tl: /* [] */0 + } + }, 0, name); +} + +function open_in_bin(name) { + return open_in_gen({ + hd: /* Open_rdonly */0, + tl: { + hd: /* Open_binary */6, + tl: /* [] */0 + } + }, 0, name); +} + +function input(ic, s, ofs, len) { + if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "input", + Error: new Error() + }; + } + return Caml_external_polyfill.resolve("caml_ml_input")(ic, s, ofs, len); +} + +function unsafe_really_input(ic, s, _ofs, _len) { + while(true) { + var len = _len; + var ofs = _ofs; + if (len <= 0) { + return ; + } + var r = Caml_external_polyfill.resolve("caml_ml_input")(ic, s, ofs, len); + if (r === 0) { + throw { + RE_EXN_ID: End_of_file, + Error: new Error() + }; + } + _len = len - r | 0; + _ofs = ofs + r | 0; + continue ; + }; +} + +function really_input(ic, s, ofs, len) { + if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "really_input", + Error: new Error() + }; + } + unsafe_really_input(ic, s, ofs, len); +} + +function really_input_string(ic, len) { + var s = Caml_bytes.caml_create_bytes(len); + really_input(ic, s, 0, len); + return Caml_bytes.bytes_to_string(s); +} + +function input_line(chan) { + var build_result = function (buf, _pos, _param) { + while(true) { + var param = _param; + var pos = _pos; + if (!param) { + return buf; + } + var hd = param.hd; + var len = hd.length; + Caml_bytes.caml_blit_bytes(hd, 0, buf, pos - len | 0, len); + _param = param.tl; + _pos = pos - len | 0; + continue ; + }; + }; + var scan = function (_accu, _len) { + while(true) { + var len = _len; + var accu = _accu; + var n = Caml_external_polyfill.resolve("caml_ml_input_scan_line")(chan); + if (n === 0) { + if (accu) { + return build_result(Caml_bytes.caml_create_bytes(len), len, accu); + } + throw { + RE_EXN_ID: End_of_file, + Error: new Error() + }; + } + if (n > 0) { + var res = Caml_bytes.caml_create_bytes(n - 1 | 0); + Caml_external_polyfill.resolve("caml_ml_input")(chan, res, 0, n - 1 | 0); + Caml_external_polyfill.resolve("caml_ml_input_char")(chan); + if (!accu) { + return res; + } + var len$1 = (len + n | 0) - 1 | 0; + return build_result(Caml_bytes.caml_create_bytes(len$1), len$1, { + hd: res, + tl: accu + }); + } + var beg = Caml_bytes.caml_create_bytes(-n | 0); + Caml_external_polyfill.resolve("caml_ml_input")(chan, beg, 0, -n | 0); + _len = len - n | 0; + _accu = { + hd: beg, + tl: accu + }; + continue ; + }; + }; + return Caml_bytes.bytes_to_string(scan(/* [] */0, 0)); +} + +function close_in_noerr(ic) { + try { + return Caml_external_polyfill.resolve("caml_ml_close_channel")(ic); + } + catch (exn){ + return ; + } +} + +function print_char(c) { + Caml_io.caml_ml_output_char(stdout, c); +} + +function print_string(s) { + output_string(stdout, s); +} + +function print_bytes(s) { + output_bytes(stdout, s); +} + +function print_int(i) { + output_string(stdout, String(i)); +} + +function print_float(f) { + output_string(stdout, valid_float_lexem(Caml_format.caml_format_float("%.12g", f))); +} + +function print_newline(param) { + Caml_io.caml_ml_output_char(stdout, /* '\n' */10); + Caml_io.caml_ml_flush(stdout); +} + +function prerr_char(c) { + Caml_io.caml_ml_output_char(stderr, c); +} + +function prerr_string(s) { + output_string(stderr, s); +} + +function prerr_bytes(s) { + output_bytes(stderr, s); +} + +function prerr_int(i) { + output_string(stderr, String(i)); +} + +function prerr_float(f) { + output_string(stderr, valid_float_lexem(Caml_format.caml_format_float("%.12g", f))); +} + +function prerr_newline(param) { + Caml_io.caml_ml_output_char(stderr, /* '\n' */10); + Caml_io.caml_ml_flush(stderr); +} + +function read_line(param) { + Caml_io.caml_ml_flush(stdout); + return input_line(stdin); +} + +function read_int(param) { + return Caml_format.caml_int_of_string((Caml_io.caml_ml_flush(stdout), input_line(stdin))); +} + +function read_int_opt(param) { + return int_of_string_opt((Caml_io.caml_ml_flush(stdout), input_line(stdin))); +} + +function read_float(param) { + return Caml_format.caml_float_of_string((Caml_io.caml_ml_flush(stdout), input_line(stdin))); +} + +function read_float_opt(param) { + return float_of_string_opt((Caml_io.caml_ml_flush(stdout), input_line(stdin))); +} + +function string_of_format(param) { + return param._1; +} + +function $caret$caret(param, param$1) { + return /* Format */{ + _0: CamlinternalFormatBasics.concat_fmt(param._0, param$1._0), + _1: param._1 + ("%," + param$1._1) + }; +} + +var exit_function = { + contents: flush_all +}; + +function at_exit(f) { + var f_yet_to_run = { + contents: true + }; + var old_exit = exit_function.contents; + var new_exit = function (param) { + if (!f_yet_to_run.contents) { + f_yet_to_run.contents = false; + Curry._1(f, undefined); + } + Curry._1(old_exit, undefined); + }; + exit_function.contents = new_exit; +} + +var do_domain_local_at_exit = { + contents: (function (param) { + + }) +}; + +function do_at_exit(param) { + Curry._1(do_domain_local_at_exit.contents, undefined); + Curry._1(exit_function.contents, undefined); +} + +function exit(retcode) { + do_at_exit(undefined); + return Caml_sys.caml_sys_exit(retcode); +} + +var Match_failure = "Match_failure"; + +var Assert_failure = "Assert_failure"; + +var Invalid_argument = "Invalid_argument"; + +var Not_found = "Not_found"; + +var Out_of_memory = "Out_of_memory"; + +var Stack_overflow = "Stack_overflow"; + +var Division_by_zero = "Division_by_zero"; + +var Sys_blocked_io = "Sys_blocked_io"; + +var Undefined_recursive_module = "Undefined_recursive_module"; + +var max_int = 2147483647; + +var infinity = Infinity; + +var neg_infinity = -Infinity; + +var max_float = 1.79769313486231571e+308; + +var min_float = 2.22507385850720138e-308; + +var epsilon_float = 2.22044604925031308e-16; + +var flush = Caml_io.caml_ml_flush; + +var output_char = Caml_io.caml_ml_output_char; + +var output_byte = Caml_io.caml_ml_output_char; + +function output_binary_int(prim0, prim1) { + return Caml_external_polyfill.resolve("caml_ml_output_int")(prim0, prim1); +} + +function seek_out(prim0, prim1) { + return Caml_external_polyfill.resolve("caml_ml_seek_out")(prim0, prim1); +} + +function pos_out(prim) { + return Caml_external_polyfill.resolve("caml_ml_pos_out")(prim); +} + +function out_channel_length(prim) { + return Caml_external_polyfill.resolve("caml_ml_channel_size")(prim); +} + +function set_binary_mode_out(prim0, prim1) { + return Caml_external_polyfill.resolve("caml_ml_set_binary_mode")(prim0, prim1); +} + +function input_char(prim) { + return Caml_external_polyfill.resolve("caml_ml_input_char")(prim); +} + +function input_byte(prim) { + return Caml_external_polyfill.resolve("caml_ml_input_char")(prim); +} + +function input_binary_int(prim) { + return Caml_external_polyfill.resolve("caml_ml_input_int")(prim); +} + +function input_value(prim) { + return Caml_external_polyfill.resolve("caml_input_value")(prim); +} + +function seek_in(prim0, prim1) { + return Caml_external_polyfill.resolve("caml_ml_seek_in")(prim0, prim1); +} + +function pos_in(prim) { + return Caml_external_polyfill.resolve("caml_ml_pos_in")(prim); +} + +function in_channel_length(prim) { + return Caml_external_polyfill.resolve("caml_ml_channel_size")(prim); +} + +function close_in(prim) { + return Caml_external_polyfill.resolve("caml_ml_close_channel")(prim); +} + +function set_binary_mode_in(prim0, prim1) { + return Caml_external_polyfill.resolve("caml_ml_set_binary_mode")(prim0, prim1); +} + +function LargeFile_seek_out(prim0, prim1) { + return Caml_external_polyfill.resolve("caml_ml_seek_out_64")(prim0, prim1); +} + +function LargeFile_pos_out(prim) { + return Caml_external_polyfill.resolve("caml_ml_pos_out_64")(prim); +} + +function LargeFile_out_channel_length(prim) { + return Caml_external_polyfill.resolve("caml_ml_channel_size_64")(prim); +} + +function LargeFile_seek_in(prim0, prim1) { + return Caml_external_polyfill.resolve("caml_ml_seek_in_64")(prim0, prim1); +} + +function LargeFile_pos_in(prim) { + return Caml_external_polyfill.resolve("caml_ml_pos_in_64")(prim); +} + +function LargeFile_in_channel_length(prim) { + return Caml_external_polyfill.resolve("caml_ml_channel_size_64")(prim); +} + +var LargeFile = { + seek_out: LargeFile_seek_out, + pos_out: LargeFile_pos_out, + out_channel_length: LargeFile_out_channel_length, + seek_in: LargeFile_seek_in, + pos_in: LargeFile_pos_in, + in_channel_length: LargeFile_in_channel_length +}; + +export { + invalid_arg , + failwith , + Exit , + Match_failure , + Assert_failure , + Invalid_argument , + Failure , + Not_found , + Out_of_memory , + Stack_overflow , + Sys_error , + End_of_file , + Division_by_zero , + Sys_blocked_io , + Undefined_recursive_module , + abs , + max_int , + min_int , + lnot , + infinity , + neg_infinity , + max_float , + min_float , + epsilon_float , + classify_float , + char_of_int , + string_of_bool , + bool_of_string_opt , + bool_of_string , + int_of_string_opt , + string_of_float , + float_of_string_opt , + $at , + stdin , + stdout , + stderr , + print_char , + print_string , + print_bytes , + print_int , + print_float , + print_newline , + prerr_char , + prerr_string , + prerr_bytes , + prerr_int , + prerr_float , + prerr_newline , + read_line , + read_int_opt , + read_int , + read_float_opt , + read_float , + open_out , + open_out_bin , + open_out_gen , + flush , + flush_all , + output_char , + output_string , + output_bytes , + output , + output_substring , + output_byte , + output_binary_int , + output_value , + seek_out , + pos_out , + out_channel_length , + close_out , + close_out_noerr , + set_binary_mode_out , + open_in , + open_in_bin , + open_in_gen , + input_char , + input_line , + input , + really_input , + really_input_string , + input_byte , + input_binary_int , + input_value , + seek_in , + pos_in , + in_channel_length , + close_in , + close_in_noerr , + set_binary_mode_in , + LargeFile , + string_of_format , + $caret$caret , + exit , + at_exit , + valid_float_lexem , + unsafe_really_input , + do_at_exit , + do_domain_local_at_exit , +} +/* No side effect */ diff --git a/melange-node-modules/melange/string.js b/melange-node-modules/melange/string.js new file mode 100644 index 0000000..ae2f81f --- /dev/null +++ b/melange-node-modules/melange/string.js @@ -0,0 +1,469 @@ +// Generated by Melange + +import * as Caml from "melange.js/caml.js"; +import * as Caml_bytes from "melange.js/caml_bytes.js"; +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Caml_js_exceptions from "melange.js/caml_js_exceptions.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Bytes from "./bytes.js"; + +function make(n, c) { + return Caml_bytes.bytes_to_string(Stdlib__Bytes.make(n, c)); +} + +function init(n, f) { + return Caml_bytes.bytes_to_string(Stdlib__Bytes.init(n, f)); +} + +function sub(s, ofs, len) { + return Caml_bytes.bytes_to_string(Stdlib__Bytes.sub(Caml_bytes.bytes_of_string(s), ofs, len)); +} + +function ensure_ge(x, y) { + if (x >= y) { + return x; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.concat", + Error: new Error() + }; +} + +function sum_lengths(_acc, seplen, _param) { + while(true) { + var param = _param; + var acc = _acc; + if (!param) { + return acc; + } + var hd = param.hd; + if (!param.tl) { + return hd.length + acc | 0; + } + _param = param.tl; + _acc = ensure_ge((hd.length + seplen | 0) + acc | 0, acc); + continue ; + }; +} + +function unsafe_blits(dst, _pos, sep, seplen, _param) { + while(true) { + var param = _param; + var pos = _pos; + if (!param) { + return dst; + } + var hd = param.hd; + if (param.tl) { + Caml_bytes.caml_blit_string(hd, 0, dst, pos, hd.length); + Caml_bytes.caml_blit_string(sep, 0, dst, pos + hd.length | 0, seplen); + _param = param.tl; + _pos = (pos + hd.length | 0) + seplen | 0; + continue ; + } + Caml_bytes.caml_blit_string(hd, 0, dst, pos, hd.length); + return dst; + }; +} + +function concat(sep, l) { + if (!l) { + return ""; + } + var seplen = sep.length; + return Caml_bytes.bytes_to_string(unsafe_blits(Caml_bytes.caml_create_bytes(sum_lengths(0, seplen, l)), 0, sep, seplen, l)); +} + +function cat(prim0, prim1) { + return prim0 + prim1; +} + +function iter(f, s) { + for(var i = 0 ,i_finish = s.length; i < i_finish; ++i){ + Curry._1(f, s.charCodeAt(i)); + } +} + +function iteri(f, s) { + for(var i = 0 ,i_finish = s.length; i < i_finish; ++i){ + Curry._2(f, i, s.charCodeAt(i)); + } +} + +function map(f, s) { + return Caml_bytes.bytes_to_string(Stdlib__Bytes.map(f, Caml_bytes.bytes_of_string(s))); +} + +function mapi(f, s) { + return Caml_bytes.bytes_to_string(Stdlib__Bytes.mapi(f, Caml_bytes.bytes_of_string(s))); +} + +function fold_right(f, x, a) { + return Stdlib__Bytes.fold_right(f, Caml_bytes.bytes_of_string(x), a); +} + +function fold_left(f, a, x) { + return Stdlib__Bytes.fold_left(f, a, Caml_bytes.bytes_of_string(x)); +} + +function exists(f, s) { + return Stdlib__Bytes.exists(f, Caml_bytes.bytes_of_string(s)); +} + +function for_all(f, s) { + return Stdlib__Bytes.for_all(f, Caml_bytes.bytes_of_string(s)); +} + +function is_space(param) { + if (param > 13 || param < 9) { + return param === 32; + } else { + return param !== 11; + } +} + +function trim(s) { + if (s === "" || !(is_space(s.charCodeAt(0)) || is_space(s.charCodeAt(s.length - 1 | 0)))) { + return s; + } else { + return Caml_bytes.bytes_to_string(Stdlib__Bytes.trim(Caml_bytes.bytes_of_string(s))); + } +} + +function escaped(s) { + var b = Caml_bytes.bytes_of_string(s); + return Caml_bytes.bytes_to_string(Stdlib__Bytes.unsafe_escape(b)); +} + +function index_rec(s, lim, _i, c) { + while(true) { + var i = _i; + if (i >= lim) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + if (s.charCodeAt(i) === c) { + return i; + } + _i = i + 1 | 0; + continue ; + }; +} + +function index(s, c) { + return index_rec(s, s.length, 0, c); +} + +function index_rec_opt(s, lim, _i, c) { + while(true) { + var i = _i; + if (i >= lim) { + return ; + } + if (s.charCodeAt(i) === c) { + return i; + } + _i = i + 1 | 0; + continue ; + }; +} + +function index_opt(s, c) { + return index_rec_opt(s, s.length, 0, c); +} + +function index_from(s, i, c) { + var l = s.length; + if (i < 0 || i > l) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from / Bytes.index_from", + Error: new Error() + }; + } + return index_rec(s, l, i, c); +} + +function index_from_opt(s, i, c) { + var l = s.length; + if (i < 0 || i > l) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.index_from_opt / Bytes.index_from_opt", + Error: new Error() + }; + } + return index_rec_opt(s, l, i, c); +} + +function rindex_rec(s, _i, c) { + while(true) { + var i = _i; + if (i < 0) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + } + if (s.charCodeAt(i) === c) { + return i; + } + _i = i - 1 | 0; + continue ; + }; +} + +function rindex(s, c) { + return rindex_rec(s, s.length - 1 | 0, c); +} + +function rindex_from(s, i, c) { + if (i < -1 || i >= s.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from / Bytes.rindex_from", + Error: new Error() + }; + } + return rindex_rec(s, i, c); +} + +function rindex_rec_opt(s, _i, c) { + while(true) { + var i = _i; + if (i < 0) { + return ; + } + if (s.charCodeAt(i) === c) { + return i; + } + _i = i - 1 | 0; + continue ; + }; +} + +function rindex_opt(s, c) { + return rindex_rec_opt(s, s.length - 1 | 0, c); +} + +function rindex_from_opt(s, i, c) { + if (i < -1 || i >= s.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.rindex_from_opt / Bytes.rindex_from_opt", + Error: new Error() + }; + } + return rindex_rec_opt(s, i, c); +} + +function contains_from(s, i, c) { + var l = s.length; + if (i < 0 || i > l) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.contains_from / Bytes.contains_from", + Error: new Error() + }; + } + try { + index_rec(s, l, i, c); + return true; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + return false; + } + throw exn; + } +} + +function contains(s, c) { + return contains_from(s, 0, c); +} + +function rcontains_from(s, i, c) { + if (i < 0 || i >= s.length) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "String.rcontains_from / Bytes.rcontains_from", + Error: new Error() + }; + } + try { + rindex_rec(s, i, c); + return true; + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === Stdlib.Not_found) { + return false; + } + throw exn; + } +} + +function uppercase_ascii(s) { + return Caml_bytes.bytes_to_string(Stdlib__Bytes.uppercase_ascii(Caml_bytes.bytes_of_string(s))); +} + +function lowercase_ascii(s) { + return Caml_bytes.bytes_to_string(Stdlib__Bytes.lowercase_ascii(Caml_bytes.bytes_of_string(s))); +} + +function capitalize_ascii(s) { + return Caml_bytes.bytes_to_string(Stdlib__Bytes.capitalize_ascii(Caml_bytes.bytes_of_string(s))); +} + +function uncapitalize_ascii(s) { + return Caml_bytes.bytes_to_string(Stdlib__Bytes.uncapitalize_ascii(Caml_bytes.bytes_of_string(s))); +} + +function starts_with(prefix, s) { + var len_s = s.length; + var len_pre = prefix.length; + if (len_s >= len_pre) { + var _i = 0; + while(true) { + var i = _i; + if (i === len_pre) { + return true; + } + if (s.charCodeAt(i) !== prefix.charCodeAt(i)) { + return false; + } + _i = i + 1 | 0; + continue ; + }; + } else { + return false; + } +} + +function ends_with(suffix, s) { + var len_s = s.length; + var len_suf = suffix.length; + var diff = len_s - len_suf | 0; + if (diff >= 0) { + var _i = 0; + while(true) { + var i = _i; + if (i === len_suf) { + return true; + } + if (s.charCodeAt(diff + i | 0) !== suffix.charCodeAt(i)) { + return false; + } + _i = i + 1 | 0; + continue ; + }; + } else { + return false; + } +} + +function hash(x) { + return Caml_external_polyfill.resolve("caml_string_hash")(0, x); +} + +function split_on_char(sep, s) { + var r = /* [] */0; + var j = s.length; + for(var i = s.length - 1 | 0; i >= 0; --i){ + if (s.charCodeAt(i) === sep) { + r = { + hd: sub(s, i + 1 | 0, (j - i | 0) - 1 | 0), + tl: r + }; + j = i; + } + + } + return { + hd: sub(s, 0, j), + tl: r + }; +} + +var compare = Caml.caml_string_compare; + +function to_seq(s) { + return Stdlib__Bytes.to_seq(Caml_bytes.bytes_of_string(s)); +} + +function to_seqi(s) { + return Stdlib__Bytes.to_seqi(Caml_bytes.bytes_of_string(s)); +} + +function of_seq(g) { + return Caml_bytes.bytes_to_string(Stdlib__Bytes.of_seq(g)); +} + +var empty = ""; + +var of_bytes = Stdlib__Bytes.to_string; + +var to_bytes = Stdlib__Bytes.of_string; + +function equal(prim0, prim1) { + return prim0 === prim1; +} + +var blit = Stdlib__Bytes.blit_string; + +function seeded_hash(prim0, prim1) { + return Caml_external_polyfill.resolve("caml_string_hash")(prim0, prim1); +} + +export { + make , + init , + empty , + of_bytes , + to_bytes , + concat , + cat , + equal , + compare , + starts_with , + ends_with , + contains_from , + rcontains_from , + contains , + sub , + split_on_char , + map , + mapi , + fold_left , + fold_right , + for_all , + exists , + trim , + escaped , + uppercase_ascii , + lowercase_ascii , + capitalize_ascii , + uncapitalize_ascii , + iter , + iteri , + index_from , + index_from_opt , + rindex_from , + rindex_from_opt , + index , + index_opt , + rindex , + rindex_opt , + to_seq , + to_seqi , + of_seq , + blit , + hash , + seeded_hash , +} +/* No side effect */ diff --git a/melange-node-modules/melange/stringLabels.js b/melange-node-modules/melange/stringLabels.js new file mode 100644 index 0000000..fa33968 --- /dev/null +++ b/melange-node-modules/melange/stringLabels.js @@ -0,0 +1,133 @@ +// Generated by Melange + +import * as Stdlib__String from "./string.js"; + +var make = Stdlib__String.make; + +var init = Stdlib__String.init; + +var empty = Stdlib__String.empty; + +var of_bytes = Stdlib__String.of_bytes; + +var to_bytes = Stdlib__String.to_bytes; + +var concat = Stdlib__String.concat; + +var cat = Stdlib__String.cat; + +var equal = Stdlib__String.equal; + +var compare = Stdlib__String.compare; + +var starts_with = Stdlib__String.starts_with; + +var ends_with = Stdlib__String.ends_with; + +var contains_from = Stdlib__String.contains_from; + +var rcontains_from = Stdlib__String.rcontains_from; + +var contains = Stdlib__String.contains; + +var sub = Stdlib__String.sub; + +var split_on_char = Stdlib__String.split_on_char; + +var map = Stdlib__String.map; + +var mapi = Stdlib__String.mapi; + +var fold_left = Stdlib__String.fold_left; + +var fold_right = Stdlib__String.fold_right; + +var for_all = Stdlib__String.for_all; + +var exists = Stdlib__String.exists; + +var trim = Stdlib__String.trim; + +var escaped = Stdlib__String.escaped; + +var uppercase_ascii = Stdlib__String.uppercase_ascii; + +var lowercase_ascii = Stdlib__String.lowercase_ascii; + +var capitalize_ascii = Stdlib__String.capitalize_ascii; + +var uncapitalize_ascii = Stdlib__String.uncapitalize_ascii; + +var iter = Stdlib__String.iter; + +var iteri = Stdlib__String.iteri; + +var index_from = Stdlib__String.index_from; + +var index_from_opt = Stdlib__String.index_from_opt; + +var rindex_from = Stdlib__String.rindex_from; + +var rindex_from_opt = Stdlib__String.rindex_from_opt; + +var index = Stdlib__String.index; + +var index_opt = Stdlib__String.index_opt; + +var rindex = Stdlib__String.rindex; + +var rindex_opt = Stdlib__String.rindex_opt; + +var to_seq = Stdlib__String.to_seq; + +var to_seqi = Stdlib__String.to_seqi; + +var of_seq = Stdlib__String.of_seq; + +var blit = Stdlib__String.blit; + +export { + make , + init , + empty , + of_bytes , + to_bytes , + concat , + cat , + equal , + compare , + starts_with , + ends_with , + contains_from , + rcontains_from , + contains , + sub , + split_on_char , + map , + mapi , + fold_left , + fold_right , + for_all , + exists , + trim , + escaped , + uppercase_ascii , + lowercase_ascii , + capitalize_ascii , + uncapitalize_ascii , + iter , + iteri , + index_from , + index_from_opt , + rindex_from , + rindex_from_opt , + index , + index_opt , + rindex , + rindex_opt , + to_seq , + to_seqi , + of_seq , + blit , +} +/* No side effect */ diff --git a/melange-node-modules/melange/sys.js b/melange-node-modules/melange/sys.js new file mode 100644 index 0000000..9749cd9 --- /dev/null +++ b/melange-node-modules/melange/sys.js @@ -0,0 +1,197 @@ +// Generated by Melange + +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Caml_sys from "melange.js/caml_sys.js"; + +var executable_name = Caml_sys.caml_sys_executable_name(undefined); + +var os_type = Caml_sys.os_type(undefined); + +var backend_type = /* Other */{ + _0: "BS" +}; + +var big_endian = false; + +var unix = Caml_sys.os_type(undefined) === "Unix"; + +var win32 = Caml_sys.os_type(undefined) === "Win32"; + +function getenv_opt(s) { + var x = typeof process === "undefined" ? undefined : process; + if (x !== undefined) { + return x.env[s]; + } + +} + +var interactive = { + contents: false +}; + +function set_signal(sig_num, sig_beh) { + +} + +var Break = /* @__PURE__ */Caml_exceptions.create("Stdlib.Sys.Break"); + +function catch_break(on) { + +} + +function Make(Immediate, Non_immediate) { + var repr = /* Non_immediate */1; + return { + repr: repr + }; +} + +var Immediate64 = { + Make: Make +}; + +var cygwin = false; + +var word_size = 32; + +var int_size = 32; + +var max_string_length = 2147483647; + +var max_array_length = 2147483647; + +var max_floatarray_length = 2147483647; + +var sigabrt = -1; + +var sigalrm = -2; + +var sigfpe = -3; + +var sighup = -4; + +var sigill = -5; + +var sigint = -6; + +var sigkill = -7; + +var sigpipe = -8; + +var sigquit = -9; + +var sigsegv = -10; + +var sigterm = -11; + +var sigusr1 = -12; + +var sigusr2 = -13; + +var sigchld = -14; + +var sigcont = -15; + +var sigstop = -16; + +var sigtstp = -17; + +var sigttin = -18; + +var sigttou = -19; + +var sigvtalrm = -20; + +var sigprof = -21; + +var sigbus = -22; + +var sigpoll = -23; + +var sigsys = -24; + +var sigtrap = -25; + +var sigurg = -26; + +var sigxcpu = -27; + +var sigxfsz = -28; + +var ocaml_version = "4.14.0+mel"; + +var development_version = false; + +var ocaml_release = { + major: 4, + minor: 14, + patchlevel: 0, + extra: [ + /* Plus */0, + "mel" + ] +}; + +function enable_runtime_warnings(prim) { + return Caml_external_polyfill.resolve("caml_ml_enable_runtime_warnings")(prim); +} + +function runtime_warnings_enabled(prim) { + return Caml_external_polyfill.resolve("caml_ml_runtime_warnings_enabled")(prim); +} + +export { + executable_name , + getenv_opt , + interactive , + os_type , + backend_type , + unix , + win32 , + cygwin , + word_size , + int_size , + big_endian , + max_string_length , + max_array_length , + max_floatarray_length , + set_signal , + sigabrt , + sigalrm , + sigfpe , + sighup , + sigill , + sigint , + sigkill , + sigpipe , + sigquit , + sigsegv , + sigterm , + sigusr1 , + sigusr2 , + sigchld , + sigcont , + sigstop , + sigtstp , + sigttin , + sigttou , + sigvtalrm , + sigprof , + sigbus , + sigpoll , + sigsys , + sigtrap , + sigurg , + sigxcpu , + sigxfsz , + Break , + catch_break , + ocaml_version , + development_version , + ocaml_release , + enable_runtime_warnings , + runtime_warnings_enabled , + Immediate64 , +} +/* No side effect */ diff --git a/melange-node-modules/melange/type.js b/melange-node-modules/melange/type.js new file mode 100644 index 0000000..1e32749 --- /dev/null +++ b/melange-node-modules/melange/type.js @@ -0,0 +1,35 @@ +// Generated by Melange + +import * as Caml_exceptions from "melange.js/caml_exceptions.js"; +import * as Stdlib__Obj from "./obj.js"; + +function make(param) { + var Id = /* @__PURE__ */Caml_exceptions.create("Id"); + return { + Id: Id + }; +} + +function uid(A) { + return Stdlib__Obj.Extension_constructor.id(Stdlib__Obj.Extension_constructor.of_val({ + RE_EXN_ID: A.Id + })); +} + +function provably_equal(A, B) { + if (A.Id === B.Id) { + return /* Equal */0; + } + +} + +var Id = { + make: make, + uid: uid, + provably_equal: provably_equal +}; + +export { + Id , +} +/* No side effect */ diff --git a/melange-node-modules/melange/uchar.js b/melange-node-modules/melange/uchar.js new file mode 100644 index 0000000..4555daf --- /dev/null +++ b/melange-node-modules/melange/uchar.js @@ -0,0 +1,224 @@ +// Generated by Melange + +import * as Caml from "melange.js/caml.js"; +import * as Caml_format from "melange.js/caml_format.js"; + +function err_not_sv(i) { + return Caml_format.caml_format_int("%X", i) + " is not an Unicode scalar value"; +} + +function err_not_latin1(u) { + return "U+" + (Caml_format.caml_format_int("%04X", u) + " is not a latin1 character"); +} + +function succ(u) { + if (u === 55295) { + return 57344; + } + if (u === 1114111) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "U+10FFFF has no successor", + Error: new Error() + }; + } + return u + 1 | 0; +} + +function pred(u) { + if (u === 57344) { + return 55295; + } + if (u === 0) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "U+0000 has no predecessor", + Error: new Error() + }; + } + return u - 1 | 0; +} + +function is_valid(i) { + if (0 <= i && i <= 55295) { + return true; + } else if (57344 <= i) { + return i <= 1114111; + } else { + return false; + } +} + +function of_int(i) { + if (is_valid(i)) { + return i; + } + var s = err_not_sv(i); + throw { + RE_EXN_ID: "Invalid_argument", + _1: s, + Error: new Error() + }; +} + +function is_char(u) { + return u < 256; +} + +function of_char(c) { + return c; +} + +function to_char(u) { + if (u <= 255) { + return u; + } + var s = err_not_latin1(u); + throw { + RE_EXN_ID: "Invalid_argument", + _1: s, + Error: new Error() + }; +} + +function unsafe_to_char(prim) { + return prim; +} + +function equal(prim0, prim1) { + return prim0 === prim1; +} + +var compare = Caml.caml_int_compare; + +function hash(prim) { + return prim; +} + +function utf_decode_is_valid(d) { + return (d >>> 27) === 1; +} + +function utf_decode_length(d) { + return (d >>> 24) & 7; +} + +function utf_decode_uchar(d) { + return d & 16777215; +} + +function utf_decode(n, u) { + return ((8 | n) << 24) | u; +} + +function utf_decode_invalid(n) { + return (n << 24) | 65533; +} + +function utf_8_byte_length(u) { + if (u < 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/uchar.ml", + 80, + 18 + ], + Error: new Error() + }; + } + if (u <= 127) { + return 1; + } + if (u <= 2047) { + return 2; + } + if (u <= 65535) { + return 3; + } + if (u <= 1114111) { + return 4; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/uchar.ml", + 85, + 7 + ], + Error: new Error() + }; +} + +function utf_16_byte_length(u) { + if (u < 0) { + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/uchar.ml", + 88, + 18 + ], + Error: new Error() + }; + } + if (u <= 65535) { + return 2; + } + if (u <= 1114111) { + return 4; + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/uchar.ml", + 91, + 7 + ], + Error: new Error() + }; +} + +var min = 0; + +var max = 1114111; + +var bom = 65279; + +var rep = 65533; + +function unsafe_of_int(prim) { + return prim; +} + +function to_int(prim) { + return prim; +} + +export { + min , + max , + bom , + rep , + succ , + pred , + is_valid , + of_int , + unsafe_of_int , + to_int , + is_char , + of_char , + to_char , + unsafe_to_char , + equal , + compare , + hash , + utf_decode_is_valid , + utf_decode_uchar , + utf_decode_length , + utf_decode , + utf_decode_invalid , + utf_8_byte_length , + utf_16_byte_length , +} +/* No side effect */ diff --git a/melange-node-modules/melange/unit.js b/melange-node-modules/melange/unit.js new file mode 100644 index 0000000..034b1c6 --- /dev/null +++ b/melange-node-modules/melange/unit.js @@ -0,0 +1,21 @@ +// Generated by Melange + + +function equal(param, param$1) { + return true; +} + +function compare(param, param$1) { + return 0; +} + +function to_string(param) { + return "()"; +} + +export { + equal , + compare , + to_string , +} +/* No side effect */ diff --git a/melange-node-modules/melange/weak.js b/melange-node-modules/melange/weak.js new file mode 100644 index 0000000..9b27e26 --- /dev/null +++ b/melange-node-modules/melange/weak.js @@ -0,0 +1,463 @@ +// Generated by Melange + +import * as Caml from "melange.js/caml.js"; +import * as Caml_array from "melange.js/caml_array.js"; +import * as Caml_external_polyfill from "melange.js/caml_external_polyfill.js"; +import * as Caml_option from "melange.js/caml_option.js"; +import * as Curry from "melange.js/curry.js"; +import * as Stdlib from "./stdlib.js"; +import * as Stdlib__Array from "./array.js"; +import * as Stdlib__Int from "./int.js"; +import * as Stdlib__Obj from "./obj.js"; +import * as Stdlib__Sys from "./sys.js"; + +function create(l) { + if (!(0 <= l && l <= Stdlib__Obj.Ephemeron.max_ephe_length)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Weak.create", + Error: new Error() + }; + } + return Caml_external_polyfill.resolve("caml_weak_create")(l); +} + +function length(x) { + return (x.length | 0) - 2 | 0; +} + +function raise_if_invalid_offset(e, o, msg) { + if (0 <= o && o < length(e)) { + return ; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: msg, + Error: new Error() + }; +} + +function set(e, o, x) { + raise_if_invalid_offset(e, o, "Weak.set"); + if (x !== undefined) { + return Caml_external_polyfill.resolve("caml_ephe_set_key")(e, o, Caml_option.valFromOption(x)); + } else { + return Caml_external_polyfill.resolve("caml_ephe_unset_key")(e, o); + } +} + +function get(e, o) { + raise_if_invalid_offset(e, o, "Weak.get"); + return Caml_external_polyfill.resolve("caml_weak_get")(e, o); +} + +function get_copy(e, o) { + raise_if_invalid_offset(e, o, "Weak.get_copy"); + return Caml_external_polyfill.resolve("caml_weak_get_copy")(e, o); +} + +function check(e, o) { + raise_if_invalid_offset(e, o, "Weak.check"); + return Caml_external_polyfill.resolve("caml_weak_check")(e, o); +} + +function blit(e1, o1, e2, o2, l) { + if (l < 0 || o1 < 0 || o1 > (length(e1) - l | 0) || o2 < 0 || o2 > (length(e2) - l | 0)) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Weak.blit", + Error: new Error() + }; + } + if (l !== 0) { + return Caml_external_polyfill.resolve("caml_weak_blit")(e1, o1, e2, o2, l); + } + +} + +function fill(ar, ofs, len, x) { + if (ofs < 0 || len < 0 || ofs > (length(ar) - len | 0)) { + throw { + RE_EXN_ID: Stdlib.Invalid_argument, + _1: "Weak.fill", + Error: new Error() + }; + } + for(var i = ofs ,i_finish = ofs + len | 0; i < i_finish; ++i){ + set(ar, i, x); + } +} + +function Make(H) { + var emptybucket = create(0); + var get_index = function (t, h) { + return (h & Stdlib.max_int) % t.table.length; + }; + var create$1 = function (sz) { + var sz$1 = sz < 7 ? 7 : sz; + var sz$2 = sz$1 > Stdlib__Sys.max_array_length ? Stdlib__Sys.max_array_length : sz$1; + return { + table: Caml_array.make(sz$2, emptybucket), + hashes: Caml_array.make(sz$2, []), + limit: 7, + oversize: 0, + rover: 0 + }; + }; + var clear = function (t) { + for(var i = 0 ,i_finish = t.table.length; i < i_finish; ++i){ + Caml_array.set(t.table, i, emptybucket); + Caml_array.set(t.hashes, i, []); + } + t.limit = 7; + t.oversize = 0; + }; + var fold = function (f, t, init) { + return Stdlib__Array.fold_right((function (param, param$1) { + var _i = 0; + var _accu = param$1; + while(true) { + var accu = _accu; + var i = _i; + if (i >= length(param)) { + return accu; + } + var v = get(param, i); + if (v !== undefined) { + _accu = Curry._2(f, Caml_option.valFromOption(v), accu); + _i = i + 1 | 0; + continue ; + } + _i = i + 1 | 0; + continue ; + }; + }), t.table, init); + }; + var iter = function (f, t) { + Stdlib__Array.iter((function (param) { + var _i = 0; + while(true) { + var i = _i; + if (i >= length(param)) { + return ; + } + var v = get(param, i); + if (v !== undefined) { + Curry._1(f, Caml_option.valFromOption(v)); + _i = i + 1 | 0; + continue ; + } + _i = i + 1 | 0; + continue ; + }; + }), t.table); + }; + var iter_weak = function (f, t) { + Stdlib__Array.iteri((function (param, param$1) { + var _i = 0; + while(true) { + var i = _i; + if (i >= length(param$1)) { + return ; + } + if (check(param$1, i)) { + Curry._3(f, param$1, Caml_array.get(t.hashes, param), i); + _i = i + 1 | 0; + continue ; + } + _i = i + 1 | 0; + continue ; + }; + }), t.table); + }; + var count_bucket = function (_i, b, _accu) { + while(true) { + var accu = _accu; + var i = _i; + if (i >= length(b)) { + return accu; + } + _accu = accu + ( + check(b, i) ? 1 : 0 + ) | 0; + _i = i + 1 | 0; + continue ; + }; + }; + var count = function (t) { + return Stdlib__Array.fold_right((function (param, param$1) { + return count_bucket(0, param, param$1); + }), t.table, 0); + }; + var next_sz = function (n) { + return Stdlib__Int.min((Math.imul(3, n) / 2 | 0) + 3 | 0, Stdlib__Sys.max_array_length); + }; + var prev_sz = function (n) { + return (((n - 3 | 0) << 1) + 2 | 0) / 3 | 0; + }; + var test_shrink_bucket = function (t) { + var bucket = Caml_array.get(t.table, t.rover); + var hbucket = Caml_array.get(t.hashes, t.rover); + var len = length(bucket); + var prev_len = prev_sz(len); + var live = count_bucket(0, bucket, 0); + if (live <= prev_len) { + var loop = function (_i, _j) { + while(true) { + var j = _j; + var i = _i; + if (j < prev_len) { + return ; + } + if (check(bucket, i)) { + _i = i + 1 | 0; + continue ; + } + if (check(bucket, j)) { + blit(bucket, j, bucket, i, 1); + Caml_array.set(hbucket, i, Caml_array.get(hbucket, j)); + _j = j - 1 | 0; + _i = i + 1 | 0; + continue ; + } + _j = j - 1 | 0; + continue ; + }; + }; + loop(0, length(bucket) - 1 | 0); + if (prev_len === 0) { + Caml_array.set(t.table, t.rover, emptybucket); + Caml_array.set(t.hashes, t.rover, []); + } else { + var newbucket = create(prev_len); + blit(bucket, 0, newbucket, 0, prev_len); + Caml_array.set(t.table, t.rover, newbucket); + Caml_array.set(t.hashes, t.rover, Stdlib__Array.sub(hbucket, 0, prev_len)); + } + if (len > t.limit && prev_len <= t.limit) { + t.oversize = t.oversize - 1 | 0; + } + + } + t.rover = (t.rover + 1 | 0) % t.table.length; + }; + var add_aux = function (t, setter, d, h, index) { + var bucket = Caml_array.get(t.table, index); + var hashes = Caml_array.get(t.hashes, index); + var sz = length(bucket); + var _i = 0; + while(true) { + var i = _i; + if (i >= sz) { + var newsz = Stdlib__Int.min((Math.imul(3, sz) / 2 | 0) + 3 | 0, Stdlib__Sys.max_array_length - 2 | 0); + if (newsz <= sz) { + throw { + RE_EXN_ID: "Failure", + _1: "Weak.Make: hash bucket cannot grow more", + Error: new Error() + }; + } + var newbucket = create(newsz); + var newhashes = Caml_array.make(newsz, 0); + blit(bucket, 0, newbucket, 0, sz); + Stdlib__Array.blit(hashes, 0, newhashes, 0, sz); + Curry._3(setter, newbucket, sz, d); + Caml_array.set(newhashes, sz, h); + Caml_array.set(t.table, index, newbucket); + Caml_array.set(t.hashes, index, newhashes); + if (sz <= t.limit && newsz > t.limit) { + t.oversize = t.oversize + 1 | 0; + for(var _i$1 = 0; _i$1 <= 2; ++_i$1){ + test_shrink_bucket(t); + } + } + if (t.oversize > (t.table.length >> 1)) { + var oldlen = t.table.length; + var newlen = next_sz(oldlen); + if (newlen > oldlen) { + var newt = create$1(newlen); + var add_weak = (function(newt){ + return function add_weak(ob, oh, oi) { + var setter = function (nb, ni, param) { + blit(ob, oi, nb, ni, 1); + }; + var h = Caml_array.get(oh, oi); + add_aux(newt, setter, undefined, h, get_index(newt, h)); + } + }(newt)); + iter_weak(add_weak, t); + t.table = newt.table; + t.hashes = newt.hashes; + t.limit = newt.limit; + t.oversize = newt.oversize; + t.rover = t.rover % newt.table.length; + return ; + } + t.limit = Stdlib.max_int; + t.oversize = 0; + return ; + } else { + return ; + } + } + if (check(bucket, i)) { + _i = i + 1 | 0; + continue ; + } + Curry._3(setter, bucket, i, d); + return Caml_array.set(hashes, i, h); + }; + }; + var add = function (t, d) { + var h = Curry._1(H.hash, d); + add_aux(t, set, Caml_option.some(d), h, get_index(t, h)); + }; + var find_aux = function (t, d, found, notfound) { + var h = Curry._1(H.hash, d); + var index = get_index(t, h); + var bucket = Caml_array.get(t.table, index); + var hashes = Caml_array.get(t.hashes, index); + var sz = length(bucket); + var _i = 0; + while(true) { + var i = _i; + if (i >= sz) { + return Curry._2(notfound, h, index); + } + if (h === Caml_array.get(hashes, i)) { + var opt = get(bucket, i); + if (opt !== undefined) { + var v = Caml_option.valFromOption(opt); + if (Curry._2(H.equal, v, d)) { + return Curry._4(found, bucket, i, opt, v); + } + _i = i + 1 | 0; + continue ; + } + _i = i + 1 | 0; + continue ; + } + _i = i + 1 | 0; + continue ; + }; + }; + var find_opt = function (t, d) { + return find_aux(t, d, (function (_b, _i, o, _v) { + return o; + }), (function (_h, _i) { + + })); + }; + var merge = function (t, d) { + return find_aux(t, d, (function (_b, _i, _o, v) { + return v; + }), (function (h, i) { + add_aux(t, set, Caml_option.some(d), h, i); + return d; + })); + }; + var find = function (t, d) { + return find_aux(t, d, (function (_b, _i, _o, v) { + return v; + }), (function (_h, _i) { + throw { + RE_EXN_ID: Stdlib.Not_found, + Error: new Error() + }; + })); + }; + var remove = function (t, d) { + find_aux(t, d, (function (b, i, _o, _v) { + set(b, i, undefined); + }), (function (_h, _i) { + + })); + }; + var mem = function (t, d) { + return find_aux(t, d, (function (_b, _i, _o, _v) { + return true; + }), (function (_h, _i) { + return false; + })); + }; + var find_all = function (t, d) { + var h = Curry._1(H.hash, d); + var index = get_index(t, h); + var bucket = Caml_array.get(t.table, index); + var hashes = Caml_array.get(t.hashes, index); + var sz = length(bucket); + var _i = 0; + var _accu = /* [] */0; + while(true) { + var accu = _accu; + var i = _i; + if (i >= sz) { + return accu; + } + if (h === Caml_array.get(hashes, i)) { + var v = get(bucket, i); + if (v !== undefined) { + var v$1 = Caml_option.valFromOption(v); + if (Curry._2(H.equal, v$1, d)) { + _accu = { + hd: v$1, + tl: accu + }; + _i = i + 1 | 0; + continue ; + } + _i = i + 1 | 0; + continue ; + } + _i = i + 1 | 0; + continue ; + } + _i = i + 1 | 0; + continue ; + }; + }; + var stats = function (t) { + var len = t.table.length; + var lens = Stdlib__Array.map(length, t.table); + Stdlib__Array.sort(Caml.caml_int_compare, lens); + var totlen = Stdlib__Array.fold_left((function (prim0, prim1) { + return prim0 + prim1 | 0; + }), 0, lens); + return [ + len, + count(t), + totlen, + Caml_array.get(lens, 0), + Caml_array.get(lens, len / 2 | 0), + Caml_array.get(lens, len - 1 | 0) + ]; + }; + return { + create: create$1, + clear: clear, + merge: merge, + add: add, + remove: remove, + find: find, + find_opt: find_opt, + find_all: find_all, + mem: mem, + iter: iter, + fold: fold, + count: count, + stats: stats + }; +} + +export { + create , + length , + set , + get , + get_copy , + check , + fill , + blit , + Make , +} +/* No side effect */ diff --git a/package-lock.json b/package-lock.json index e8ed1c3..89dca0e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,8 @@ }, "devDependencies": { "@docusaurus/module-type-aliases": "3.3.2", - "@docusaurus/types": "3.3.2" + "@docusaurus/types": "3.3.2", + "reason-loader": "^0.1.0-dev.5" }, "engines": { "node": ">=18.0" @@ -11971,6 +11972,12 @@ "resolved": "https://registry.npmjs.org/reading-time/-/reading-time-1.5.0.tgz", "integrity": "sha512-onYyVhBNr4CmAxFsKS7bz+uTLRakypIe4R+5A824vBSkQy/hB3fZepoVEf8OVAxzLvK+H/jm9TzpI3ETSm64Kg==" }, + "node_modules/reason-loader": { + "version": "0.1.0-dev.5", + "resolved": "https://registry.npmjs.org/reason-loader/-/reason-loader-0.1.0-dev.5.tgz", + "integrity": "sha512-+orhlm52p6XOEM6iO72wlXxlQ6mEWlMVSIn5aLX0UepFKK1vMkkhlcMHuTYWV61E6JGG5HAM9OuqSs602gF3rQ==", + "dev": true + }, "node_modules/rechoir": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", diff --git a/package.json b/package.json index d3006f6..6390962 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ }, "devDependencies": { "@docusaurus/module-type-aliases": "3.3.2", - "@docusaurus/types": "3.3.2" + "@docusaurus/types": "3.3.2", + "reason-loader": "^0.1.0-dev.5" }, "browserslist": { "production": [ diff --git a/plugins/docusaurus-webpack-plugin/index.js b/plugins/docusaurus-webpack-plugin/index.js new file mode 100644 index 0000000..49a3977 --- /dev/null +++ b/plugins/docusaurus-webpack-plugin/index.js @@ -0,0 +1,24 @@ +import * as path from "path"; +const loaderPath = require.resolve("reason-loader"); +export default function (context, options) { + return { + name: "docusaurus-plugin", + configureWebpack(config, isServer, utils, content) { + return { + module: { + rules: [ + { + test: /\.rei?$/, + use: [ + { + loader: loaderPath, + options: {}, + }, + ], + }, + ], + }, + }; + }, + }; +} diff --git a/plugins/docusaurus-webpack-plugin/package-lock.json b/plugins/docusaurus-webpack-plugin/package-lock.json new file mode 100644 index 0000000..a2fcda4 --- /dev/null +++ b/plugins/docusaurus-webpack-plugin/package-lock.json @@ -0,0 +1,18 @@ +{ + "name": "ri-docusaurus-webpack-plugin", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "ri-docusaurus-webpack-plugin", + "dependencies": { + "reason-loader": "*" + } + }, + "node_modules/reason-loader": { + "version": "0.1.0-dev.1", + "resolved": "https://registry.npmjs.org/reason-loader/-/reason-loader-0.1.0-dev.1.tgz", + "integrity": "sha512-N1PNcy1+PgbjdZYY0amLwRQ1VsnonvDHex7iZ5P09fe+3Upzp3vWFp0TXtQ3Ii1Ia2NQKo9bp73sE6RwqVfXTQ==" + } + } +} diff --git a/plugins/docusaurus-webpack-plugin/package.json b/plugins/docusaurus-webpack-plugin/package.json new file mode 100644 index 0000000..cb75d01 --- /dev/null +++ b/plugins/docusaurus-webpack-plugin/package.json @@ -0,0 +1,7 @@ +{ + "name": "ri-docusaurus-webpack-plugin", + "lib": "./index.js", + "dependencies": { + "reason-loader": "*" + } +} diff --git a/plugins/docusaurus-webpack-plugin/reason-loader.js b/plugins/docusaurus-webpack-plugin/reason-loader.js new file mode 100644 index 0000000..ca1b8c3 --- /dev/null +++ b/plugins/docusaurus-webpack-plugin/reason-loader.js @@ -0,0 +1,14 @@ +const cp = require("child_process"); +module.exports = function (source) { + let file = this.resourcePath; + console.log(Object.keys(this)); + // return cp + // .execSync( + // `melc -pp 'refmt --print binary' -impl ${file} -o ${file.replace( + // ".re", + // ".js", + // )}`, + // ) + // .toString(); + return "module.exports = 'todo'"; +}; diff --git a/src/pages/mdn-game-tutorial/Animation.re b/src/pages/mdn-game-tutorial/Animation.re new file mode 100644 index 0000000..efa6323 --- /dev/null +++ b/src/pages/mdn-game-tutorial/Animation.re @@ -0,0 +1,60 @@ +open Bindings; + +/* Bindings to external JavaScript APIs */ +let ballRadius = 10; +/* The main render function */ +let rec render = (canvasRef: reactRef, x, dx, y, dy) => { + let canvas = getCurrent(canvasRef); + let ctx = getContext(canvas, "2d"); + let square = x => x * x; + let sum_sq = [1, 2, 3]->(Belt.List.map(square)); + Js.log(sum_sq); + + print_endline("hey"); + let width = float_of_int(getWidth(canvas)); + let height = float_of_int(getHeight(canvas)); + + /* Clear the canvas */ + ctx->clearRect(0., 0., width, height); + + /* Draw the ball */ + beginPath(ctx); + ctx->arc( + x +. dx, + y +. dy, + float_of_int(ballRadius), + 0., + 2. *. Float.pi, + false, + ); + setFillStyle(ctx, "green"); + fill(ctx); + closePath(ctx); + + /* Boundary detection and update positions */ + let newDx = + if (x + +. dx > width + -. float_of_int(ballRadius) + || x + +. dx < float_of_int(ballRadius)) { + -. dx; + } else { + dx; + }; + let newDy = + if (y + +. dy > height + -. float_of_int(ballRadius) + || y + +. dy < float_of_int(ballRadius)) { + -. dy; + } else { + dy; + }; + + /* Request next animation frame */ + requestAnimationFrame(() => + render(canvasRef, x +. newDx, newDx, y +. newDy, newDy) + ); +}; diff --git a/src/pages/mdn-game-tutorial/bindings.re b/src/pages/mdn-game-tutorial/bindings.re new file mode 100644 index 0000000..b868b2f --- /dev/null +++ b/src/pages/mdn-game-tutorial/bindings.re @@ -0,0 +1,24 @@ +type canvas; +type context2d; +type document; +type reactRef; + +external document: document = "document"; +[@mel.send] +external getElementById: (document, string) => canvas = "getElementById"; +[@mel.send] external getContext: (canvas, string) => context2d = "getContext"; +[@mel.get] external getWidth: canvas => int = "width"; +[@mel.get] external getHeight: canvas => int = "height"; +[@mel.get] external getCurrent: reactRef => canvas = "current"; +[@mel.send] +external clearRect: (context2d, float, float, float, float) => unit = + "clearRect"; +[@mel.send] external beginPath: context2d => unit = "beginPath"; +[@mel.send] +external arc: (context2d, float, float, float, float, float, bool) => unit = + "arc"; +[@mel.set] external setFillStyle: (context2d, string) => unit = "fillStyle"; +[@mel.send] external fill: context2d => unit = "fill"; +[@mel.send] external closePath: context2d => unit = "closePath"; +external requestAnimationFrame: (unit => unit) => unit = + "requestAnimationFrame"; diff --git a/src/pages/mdn-game-tutorial/index.js b/src/pages/mdn-game-tutorial/index.js new file mode 100644 index 0000000..1f8d724 --- /dev/null +++ b/src/pages/mdn-game-tutorial/index.js @@ -0,0 +1,27 @@ +import { useRef, useEffect } from "react"; +import Link from "@docusaurus/Link"; +import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; +import Layout from "@theme/Layout"; +import { render } from "./Animation.re"; + +export default function Home() { + const { siteConfig } = useDocusaurusContext(); + const canvasRef = useRef(); + + useEffect(() => { + let x = canvasRef.current.width / 2; + let y = canvasRef.current.height - 30; + render(canvasRef, x, 2, y, -2); + }); + + return ( + +
+ +
+
+ ); +}