From 74d00ed842178a33f0b06ab19c8d64a5bfabdb0d Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sun, 6 Aug 2023 20:24:17 -0700 Subject: [PATCH] melange-ppx: deprecate [@@mel.val] and suggest its removal (#678) * melange-ppx: deprecate `[@@mel.val]` and suggest its removal * chore: remove `mel.val` attribute from runtime/stdlib * chore: add changelog entry * chore: promote tests --- Changes.md | 4 + flake.lock | 14 +-- jscomp/others/belt_Float.ml | 6 +- jscomp/others/belt_Float.mli | 2 +- jscomp/others/belt_Int.ml | 6 +- jscomp/others/belt_Int.mli | 2 +- jscomp/others/dom_storage.ml | 8 +- jscomp/others/dom_storage2.ml | 8 +- jscomp/others/node_buffer.ml | 10 +- jscomp/others/node_fs.ml | 31 +++--- jscomp/others/node_module.ml | 1 - jscomp/runtime/caml_float.ml | 16 +-- jscomp/runtime/caml_float.mli | 2 +- jscomp/runtime/caml_float_extern.ml | 12 +-- jscomp/runtime/caml_int64.ml | 12 +-- jscomp/runtime/caml_nativeint_extern.ml | 2 +- jscomp/runtime/caml_obj.ml | 6 +- jscomp/runtime/caml_string_extern.ml | 5 +- jscomp/runtime/js_array.ml | 94 +++++++++--------- jscomp/runtime/js_array2.ml | 66 ++++++------- jscomp/runtime/js_console.ml | 64 +++++------- jscomp/runtime/js_date.ml | 111 ++++++++++----------- jscomp/runtime/js_dict.ml | 12 +-- jscomp/runtime/js_dict.mli | 12 +-- jscomp/runtime/js_float.ml | 24 ++--- jscomp/runtime/js_global.ml | 20 ++-- jscomp/runtime/js_internal.ml | 16 ++- jscomp/runtime/js_json.ml | 14 ++- jscomp/runtime/js_json.mli | 10 +- jscomp/runtime/js_math.ml | 125 ++++++++++++------------ jscomp/runtime/js_obj.ml | 6 +- jscomp/runtime/js_promise.ml | 28 +++--- jscomp/runtime/js_string.ml | 110 ++++++++++----------- jscomp/runtime/js_string2.ml | 106 ++++++++++---------- jscomp/runtime/js_typed_array.cppo.ml | 8 +- jscomp/runtime/js_typed_array2.cppo.ml | 8 +- jscomp/runtime/melange_mini_stdlib.ml | 5 +- jscomp/stdlib/float.cppo.ml | 42 ++++---- jscomp/stdlib/float.cppo.mli | 42 ++++---- jscomp/stdlib/stdlib.cppo.ml | 52 +++++----- jscomp/stdlib/stdlib.cppo.mli | 52 +++++----- ppx/ast_external_process.ml | 1 + ppx/bs_ast_invariant.ml | 9 +- ppx/bs_ast_invariant.mli | 1 + test/blackbox-tests/ffi-error-debug.t | 10 ++ test/blackbox-tests/legacy-ounit-cmd.t | 31 ++++++ test/blackbox-tests/mel-attributes.t | 6 ++ test/blackbox-tests/no-mel-val.t | 63 ++++++++++++ 48 files changed, 690 insertions(+), 605 deletions(-) create mode 100644 test/blackbox-tests/no-mel-val.t diff --git a/Changes.md b/Changes.md index ce094fbd09..9167299004 100644 --- a/Changes.md +++ b/Changes.md @@ -45,6 +45,10 @@ Unreleased [#664](https://github.com/melange-re/melange/pull/664)) - [melange]: Upgrade the OCaml typechecker version to 5.1 ([#668](https://github.com/melange-re/melange/pull/668)) +- [melange.ppx]: Deprecate `[@@mel.val]` and suggest its removal. This + attribute is redundant and unnecessary + ([#675](https://github.com/melange-re/melange/issues/675), + [#678](https://github.com/melange-re/melange/pull/678)) 1.0.0 2023-05-31 --------------- diff --git a/flake.lock b/flake.lock index edff3abdae..e51960368c 100644 --- a/flake.lock +++ b/flake.lock @@ -64,11 +64,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1691101025, - "narHash": "sha256-6jZ4syp5JU6shwFptJKOsJ+a5XpmQNgNpF3CfGREcBQ=", + "lastModified": 1691343906, + "narHash": "sha256-1mExFr3hhEAFt/5eRgVLDs2U/3QsOlmo8QHlKaH6KLk=", "owner": "nix-ocaml", "repo": "nix-overlays", - "rev": "1353ee3af1fec78ec4c6e0bbe5493f8dcbb2ad41", + "rev": "e80fa1f581f9d15bb5247de79897a34df2918313", "type": "github" }, "original": { @@ -79,17 +79,17 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1691071044, - "narHash": "sha256-bYBWtupK/NO/diSpye8TP1E0IC7wj29y2q6blD0FtPk=", + "lastModified": 1691330556, + "narHash": "sha256-15+34IU0cEe/8Q7p1I5K9wH7m7NzsVdAMj6LzHFIJLk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2a1f1797be6e4125ade0be6ac32bb70106ff7245", + "rev": "40ded9e2b8e725a5931927e4e5604ecdcbb6c3c4", "type": "github" }, "original": { "owner": "NixOS", "repo": "nixpkgs", - "rev": "2a1f1797be6e4125ade0be6ac32bb70106ff7245", + "rev": "40ded9e2b8e725a5931927e4e5604ecdcbb6c3c4", "type": "github" } }, diff --git a/jscomp/others/belt_Float.ml b/jscomp/others/belt_Float.ml index b31fccf21b..ad231a04d0 100644 --- a/jscomp/others/belt_Float.ml +++ b/jscomp/others/belt_Float.ml @@ -26,15 +26,15 @@ Utililites for Float *) -external isNaN : float -> bool = "isNaN" [@@mel.val] +external isNaN : float -> bool = "isNaN" external toInt : float -> int = "%intoffloat" external fromInt : int -> float = "%identity" -external fromString : string -> float = "parseFloat" [@@mel.val] +external fromString : string -> float = "parseFloat" let fromString i = match fromString i with i when isNaN i -> None | i -> Some i -external toString : float -> string = "String" [@@mel.val] +external toString : float -> string = "String" external ( + ) : float -> float -> float = "%addfloat" external ( - ) : float -> float -> float = "%subfloat" external ( * ) : float -> float -> float = "%mulfloat" diff --git a/jscomp/others/belt_Float.mli b/jscomp/others/belt_Float.mli index 55d40d986c..793ac74aea 100644 --- a/jscomp/others/belt_Float.mli +++ b/jscomp/others/belt_Float.mli @@ -29,7 +29,7 @@ external toInt : float -> int = "%intoffloat" external fromInt : int -> float = "%identity" val fromString : string -> float option -external toString : float -> string = "String" [@@mel.val] +external toString : float -> string = "String" external ( + ) : float -> float -> float = "%addfloat" external ( - ) : float -> float -> float = "%subfloat" external ( * ) : float -> float -> float = "%mulfloat" diff --git a/jscomp/others/belt_Int.ml b/jscomp/others/belt_Int.ml index 547c1e5dff..75077c8db4 100644 --- a/jscomp/others/belt_Int.ml +++ b/jscomp/others/belt_Int.ml @@ -26,15 +26,15 @@ Utililites for Int *) -external isNaN : int -> bool = "isNaN" [@@mel.val] +external isNaN : int -> bool = "isNaN" external toFloat : int -> float = "%identity" external fromFloat : float -> int = "%intoffloat" -external fromString : string -> (_[@mel.as 10]) -> int = "parseInt" [@@mel.val] +external fromString : string -> (_[@mel.as 10]) -> int = "parseInt" let fromString i = match fromString i with i when isNaN i -> None | i -> Some i -external toString : int -> string = "String" [@@mel.val] +external toString : int -> string = "String" external ( + ) : int -> int -> int = "%addint" external ( - ) : int -> int -> int = "%subint" external ( * ) : int -> int -> int = "%mulint" diff --git a/jscomp/others/belt_Int.mli b/jscomp/others/belt_Int.mli index 9a35486383..0da224711d 100644 --- a/jscomp/others/belt_Int.mli +++ b/jscomp/others/belt_Int.mli @@ -29,7 +29,7 @@ external toFloat : int -> float = "%identity" external fromFloat : float -> int = "%intoffloat" val fromString : string -> int option -external toString : int -> string = "String" [@@mel.val] +external toString : int -> string = "String" external ( + ) : int -> int -> int = "%addint" external ( - ) : int -> int -> int = "%subint" external ( * ) : int -> int -> int = "%mulint" diff --git a/jscomp/others/dom_storage.ml b/jscomp/others/dom_storage.ml index d8c055273a..6c7fffd65d 100644 --- a/jscomp/others/dom_storage.ml +++ b/jscomp/others/dom_storage.ml @@ -1,15 +1,15 @@ type t = Dom_storage2.t external getItem : string -> string option = "getItem" - [@@mel.send.pipe: t] [@@mel.return null_to_opt] +[@@mel.send.pipe: t] [@@mel.return null_to_opt] external setItem : string -> string -> unit = "setItem" [@@mel.send.pipe: t] external removeItem : string -> unit = "removeItem" [@@mel.send.pipe: t] external clear : unit = "clear" [@@mel.send.pipe: t] external key : int -> string option = "key" - [@@mel.send.pipe: t] [@@mel.return null_to_opt] +[@@mel.send.pipe: t] [@@mel.return null_to_opt] external length : t -> int = "length" [@@mel.get] -external localStorage : t = "localStorage" [@@mel.val] -external sessionStorage : t = "sessionStorage" [@@mel.val] +external localStorage : t = "localStorage" +external sessionStorage : t = "sessionStorage" diff --git a/jscomp/others/dom_storage2.ml b/jscomp/others/dom_storage2.ml index c2e2c33f4f..7512a4ae4f 100644 --- a/jscomp/others/dom_storage2.ml +++ b/jscomp/others/dom_storage2.ml @@ -1,15 +1,15 @@ type t external getItem : t -> string -> string option = "getItem" - [@@mel.send] [@@mel.return null_to_opt] +[@@mel.send] [@@mel.return null_to_opt] external setItem : t -> string -> string -> unit = "setItem" [@@mel.send] external removeItem : t -> string -> unit = "removeItem" [@@mel.send] external clear : t -> unit = "clear" [@@mel.send] external key : t -> int -> string option = "key" - [@@mel.send] [@@mel.return null_to_opt] +[@@mel.send] [@@mel.return null_to_opt] external length : t -> int = "length" [@@mel.get] -external localStorage : t = "localStorage" [@@mel.val] -external sessionStorage : t = "sessionStorage" [@@mel.val] +external localStorage : t = "localStorage" +external sessionStorage : t = "sessionStorage" diff --git a/jscomp/others/node_buffer.ml b/jscomp/others/node_buffer.ml index 7feb0388ac..e641cd2e53 100644 --- a/jscomp/others/node_buffer.ml +++ b/jscomp/others/node_buffer.ml @@ -26,18 +26,18 @@ type t = Node.buffer -external isBuffer : 'a -> bool = "Buffer.isBuffer" [@@mel.val] -external fromString : string -> t = "Buffer.from" [@@mel.val] +external isBuffer : 'a -> bool = "Buffer.isBuffer" +external fromString : string -> t = "Buffer.from" type encoding = [ `ascii | `utf8 | `utf16le | `usc2 | `base64 | `latin1 | `binary | `hex ] external fromStringWithEncoding : string -> encoding -> t = "from" - [@@mel.val] [@@mel.scope "Buffer"] +[@@mel.scope "Buffer"] external toString : t -> string = "toString" [@@mel.send] external toStringWithEncoding : t -> encoding -> string = "toString" - [@@mel.send] +[@@mel.send] -external concat : t array -> t = "Buffer.concat" [@@mel.val] +external concat : t array -> t = "Buffer.concat" diff --git a/jscomp/others/node_fs.ml b/jscomp/others/node_fs.ml index 5eef1f22f6..58ed2c028e 100644 --- a/jscomp/others/node_fs.ml +++ b/jscomp/others/node_fs.ml @@ -28,14 +28,14 @@ *) external readdirSync : string -> string array = "readdirSync" - [@@mel.module "fs"] +[@@mel.module "fs"] (** Most fs functions let you omit the callback argument. If you do, a default callback is used that rethrows errors. To get a trace to the original call site, set the `NODE_DEBUG` environment variable: *) external renameSync : string -> string -> unit = "renameSync" - [@@mel.module "fs"] +[@@mel.module "fs"] type fd = private int @@ -55,10 +55,10 @@ module Watch = struct ?encoding:Js.String.t -> unit -> config = "" - [@@mel.obj] + [@@mel.obj] external watch : string -> ?config:config -> unit -> t = "watch" - [@@mel.module "fs"] + [@@mel.module "fs"] (** there is no need to accept listener, since we return a [watcher] back it can register event listener there . Currently we introduce a type [string_buffer], for the @@ -73,7 +73,7 @@ module Watch = struct | `error of (unit -> unit[@u]) ] [@mel.string]) -> t = "on" - [@@mel.send.pipe: t] [@@deprecated "Please use `Node.Fs.on_` instead "] + [@@mel.send.pipe: t] [@@deprecated "Please use `Node.Fs.on_` instead "] external on_ : t -> @@ -82,7 +82,7 @@ module Watch = struct | `error of (unit -> unit[@u]) ] [@mel.string]) -> t = "on" - [@@mel.send] + [@@mel.send] external close : t -> unit = "close" [@@mel.send] end @@ -90,13 +90,13 @@ end external ftruncateSync : fd -> int -> unit = "ftruncateSync" [@@mel.module "fs"] external truncateSync : string -> int -> unit = "truncateSync" - [@@mel.module "fs"] +[@@mel.module "fs"] external chownSync : string -> uid:int -> gid:int -> unit = "chownSync" - [@@mel.module "fs"] +[@@mel.module "fs"] external fchownSync : fd -> uid:int -> gid:int -> unit = "fchownSync" - [@@mel.module "fs"] +[@@mel.module "fs"] external readlinkSync : string -> string = "readlinkSync" [@@mel.module "fs"] external unlinkSync : string -> unit = "unlinkSync" [@@mel.module "fs"] @@ -118,7 +118,7 @@ external openSync : | `Append_read_fail_if_exists [@mel.as "ax+"] ] [@mel.string]) -> unit = "openSync" - [@@mel.module "fs"] +[@@mel.module "fs"] type encoding = [ `hex @@ -132,18 +132,17 @@ type encoding = | `utf16le ] external readFileSync : string -> encoding -> string = "readFileSync" - [@@mel.val] [@@mel.module "fs"] +[@@mel.module "fs"] external readFileAsUtf8Sync : string -> (_[@mel.as "utf8"]) -> string = "readFileSync" - [@@mel.val] [@@mel.module "fs"] +[@@mel.module "fs"] -external existsSync : string -> bool = "existsSync" - [@@mel.val] [@@mel.module "fs"] +external existsSync : string -> bool = "existsSync" [@@mel.module "fs"] external writeFileSync : string -> string -> encoding -> unit = "writeFileSync" - [@@mel.val] [@@mel.module "fs"] +[@@mel.module "fs"] external writeFileAsUtf8Sync : string -> string -> (_[@mel.as "utf8"]) -> unit = "writeFileSync" - [@@mel.val] [@@mel.module "fs"] +[@@mel.module "fs"] diff --git a/jscomp/others/node_module.ml b/jscomp/others/node_module.ml index 11bb4df54b..8a4ee9c1b9 100644 --- a/jscomp/others/node_module.ml +++ b/jscomp/others/node_module.ml @@ -25,4 +25,3 @@ (** Node Module API *) external module_ : < __cache : Node.node_module Js.Dict.t > Js.t = "module" - [@@mel.val] diff --git a/jscomp/runtime/caml_float.ml b/jscomp/runtime/caml_float.ml index 0ab0fb4ec0..ba7b1ed394 100644 --- a/jscomp/runtime/caml_float.ml +++ b/jscomp/runtime/caml_float.ml @@ -25,14 +25,14 @@ open Melange_mini_stdlib (* borrowed from others/js_math.ml *) -external _LOG2E : float = "Math.LOG2E" [@@mel.val] -external _LOG10E : float = "Math.LOG10E" [@@mel.val] -external abs_float : float -> float = "Math.abs" [@@mel.val] -external floor : float -> float = "Math.floor" [@@mel.val] -external exp : float -> float = "exp" [@@mel.val] [@@mel.scope "Math"] -external log : float -> float = "Math.log" [@@mel.val] -external sqrt : float -> float = "sqrt" [@@mel.val] [@@mel.scope "Math"] -external pow_float : base:float -> exp:float -> float = "Math.pow" [@@mel.val] +external _LOG2E : float = "Math.LOG2E" +external _LOG10E : float = "Math.LOG10E" +external abs_float : float -> float = "Math.abs" +external floor : float -> float = "Math.floor" +external exp : float -> float = "exp" [@@mel.scope "Math"] +external log : float -> float = "Math.log" +external sqrt : float -> float = "sqrt" [@@mel.scope "Math"] +external pow_float : base:float -> exp:float -> float = "Math.pow" external int_of_float : float -> int = "%intoffloat" external float_of_int : int -> float = "%floatofint" diff --git a/jscomp/runtime/caml_float.mli b/jscomp/runtime/caml_float.mli index a90639b7c0..5359bf65fc 100644 --- a/jscomp/runtime/caml_float.mli +++ b/jscomp/runtime/caml_float.mli @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -external floor : float -> float = "Math.floor" [@@mel.val] +external floor : float -> float = "Math.floor" (** *) external int_of_float : float -> int = "%intoffloat" diff --git a/jscomp/runtime/caml_float_extern.ml b/jscomp/runtime/caml_float_extern.ml index 4521a2f3fa..bac30e75ae 100644 --- a/jscomp/runtime/caml_float_extern.ml +++ b/jscomp/runtime/caml_float_extern.ml @@ -1,14 +1,14 @@ -external _NaN : float = "NaN" [@@mel.val] -external isNaN : float -> bool = "isNaN" [@@mel.val] -external isFinite : float -> bool = "isFinite" [@@mel.val] +external _NaN : float = "NaN" +external isNaN : float -> bool = "isNaN" +external isFinite : float -> bool = "isFinite" external toExponentialWithPrecision : float -> digits:int -> string = "toExponential" - [@@mel.send] +[@@mel.send] external toFixed : float -> string = "toFixed" [@@mel.send] external toFixedWithPrecision : float -> digits:int -> string = "toFixed" - [@@mel.send] +[@@mel.send] -external fromString : string -> float = "Number" [@@mel.val] +external fromString : string -> float = "Number" diff --git a/jscomp/runtime/caml_int64.ml b/jscomp/runtime/caml_int64.ml index 33d1a96b19..92d1a6822f 100644 --- a/jscomp/runtime/caml_int64.ml +++ b/jscomp/runtime/caml_int64.ml @@ -223,11 +223,11 @@ let rec of_float (x : float) : t = ~lo:(Caml_nativeint_extern.of_float (mod_float x two_ptr_32_dbl)) ~hi:(Caml_nativeint_extern.of_float (x /. two_ptr_32_dbl)) -external log2 : float = "LN2" [@@mel.val] [@@mel.scope "Math"] -external log : float -> float = "log" [@@mel.val] [@@mel.scope "Math"] -external ceil : float -> float = "ceil" [@@mel.val] [@@mel.scope "Math"] -external floor : float -> float = "floor" [@@mel.val] [@@mel.scope "Math"] -(* external maxFloat : float -> float -> float = "Math.max" [@@mel.val] *) +external log2 : float = "LN2" [@@mel.scope "Math"] +external log : float -> float = "log" [@@mel.scope "Math"] +external ceil : float -> float = "ceil" [@@mel.scope "Math"] +external floor : float -> float = "floor" [@@mel.scope "Math"] +(* external maxFloat : float -> float -> float = "Math.max" *) (* either top 11 bits are all 0 or all 1 when it is all 1, we need exclude -2^53 @@ -237,7 +237,7 @@ let isSafeInteger { hi; lo } = top11Bits = 0 || (top11Bits = -1 && Pervasives.not (lo = 0 && hi = 0xff_e0_00_00)) -external string_of_float : float -> string = "String" [@@mel.val] +external string_of_float : float -> string = "String" let rec to_string (self : int64) = let ({ hi = self_hi; _ } as self) = unsafe_of_int64 self in diff --git a/jscomp/runtime/caml_nativeint_extern.ml b/jscomp/runtime/caml_nativeint_extern.ml index 81408e4424..c3f8406aa8 100644 --- a/jscomp/runtime/caml_nativeint_extern.ml +++ b/jscomp/runtime/caml_nativeint_extern.ml @@ -5,4 +5,4 @@ external shift_right_logical : int -> int -> int = "nativeint_lsr" external mul : int -> int -> int = "nativeint_mul" external to_float : int -> float = "%identity" external of_float : float -> int = "caml_int_of_float" -external to_string : int -> string = "String" [@@mel.val] +external to_string : int -> string = "String" diff --git a/jscomp/runtime/caml_obj.ml b/jscomp/runtime/caml_obj.ml index 15eed54cfe..5133e14220 100644 --- a/jscomp/runtime/caml_obj.ml +++ b/jscomp/runtime/caml_obj.ml @@ -27,7 +27,7 @@ open Melange_mini_stdlib type t = Obj.t module O = struct - external isArray : 'a -> bool = "Array.isArray" [@@mel.val] + external isArray : 'a -> bool = "Array.isArray" type key = string @@ -38,7 +38,7 @@ module O = struct |}] external hasOwnProperty : t -> key -> bool = "call" - [@@mel.scope "Object", "prototype", "hasOwnProperty"] [@@mel.val] + [@@mel.scope "Object", "prototype", "hasOwnProperty"] (** JS objects are not guaranteed to have `Object` in their prototype chain so calling `some_obj.hasOwnProperty(key)` can sometimes throw @@ -369,7 +369,7 @@ let caml_equal_nullable (x : Obj.t) (y : Obj.t Js_internal.nullable) = let isNumberOrBigInt a = Js_internal.typeof a = "number" || Js_internal.typeof a = "bigint" - [@@inline] +[@@inline] let canNumericCompare a b = isNumberOrBigInt a && isNumberOrBigInt b [@@inline] diff --git a/jscomp/runtime/caml_string_extern.ml b/jscomp/runtime/caml_string_extern.ml index 1fc3ab6f99..f4c756b402 100644 --- a/jscomp/runtime/caml_string_extern.ml +++ b/jscomp/runtime/caml_string_extern.ml @@ -33,7 +33,7 @@ *) (*ATT: this relies on we encode `char' as int *) -external of_char : char -> string = "String.fromCharCode" [@@mel.val] +external of_char : char -> string = "String.fromCharCode" external get_string_unsafe : string -> int -> string = "" [@@mel.get_index] external toUpperCase : string -> string = "toUpperCase" [@@mel.send] external of_int : int -> base:int -> string = "toString" [@@mel.send] @@ -44,10 +44,9 @@ external index_of : string -> string -> int = "indexOf" [@@mel.send] external of_small_int_array : (_[@mel.as {json|null|json}]) -> int array -> string = "String.fromCharCode.apply" - [@@mel.val] external of_small_int32_array : int32 array -> string = "String.fromCharCode" - [@@mel.val] [@@mel.splice] +[@@mel.splice] external lastIndexOf : string -> string -> int = "lastIndexOf" [@@mel.send] (* used in {!Caml_io} *) diff --git a/jscomp/runtime/js_array.ml b/jscomp/runtime/js_array.ml index 1b4aff429b..80a1e9f8ee 100644 --- a/jscomp/runtime/js_array.ml +++ b/jscomp/runtime/js_array.ml @@ -31,15 +31,15 @@ type 'a array_like = 'a Js_array2.array_like type 'a array_iter = 'a array_like *) -external from : 'a array_like -> 'a array = "Array.from" [@@mel.val] +external from : 'a array_like -> 'a array = "Array.from" (* ES2015 *) external fromMap : 'a array_like -> (('a -> 'b)[@mel.uncurry]) -> 'b array = "Array.from" - [@@mel.val] + (* ES2015 *) -external isArray : 'a -> bool = "Array.isArray" [@@mel.val] +external isArray : 'a -> bool = "Array.isArray" (* ES2015 *) (* ES2015 *) @@ -50,116 +50,116 @@ external length : 'a array -> int = "length" [@@mel.get] (* Mutator functions *) external copyWithin : to_:int -> 'this = "copyWithin" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] (* ES2015 *) external copyWithinFrom : to_:int -> from:int -> 'this = "copyWithin" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] (* ES2015 *) external copyWithinFromRange : to_:int -> start:int -> end_:int -> 'this = "copyWithin" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] (* ES2015 *) external fillInPlace : 'a -> 'this = "fill" [@@mel.send.pipe: 'a t as 'this] (* ES2015 *) external fillFromInPlace : 'a -> from:int -> 'this = "fill" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] (* ES2015 *) external fillRangeInPlace : 'a -> start:int -> end_:int -> 'this = "fill" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] (* ES2015 *) external pop : 'a option = "pop" - [@@mel.send.pipe: 'a t as 'this] [@@mel.return undefined_to_opt] +[@@mel.send.pipe: 'a t as 'this] [@@mel.return undefined_to_opt] (** https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push *) external push : 'a -> int = "push" [@@mel.send.pipe: 'a t as 'this] external pushMany : 'a array -> int = "push" - [@@mel.send.pipe: 'a t as 'this] [@@mel.splice] +[@@mel.send.pipe: 'a t as 'this] [@@mel.splice] external reverseInPlace : 'this = "reverse" [@@mel.send.pipe: 'a t as 'this] external shift : 'a option = "shift" - [@@mel.send.pipe: 'a t as 'this] [@@mel.return { undefined_to_opt }] +[@@mel.send.pipe: 'a t as 'this] [@@mel.return { undefined_to_opt }] external sortInPlace : 'this = "sort" [@@mel.send.pipe: 'a t as 'this] external sortInPlaceWith : (('a -> 'a -> int)[@mel.uncurry]) -> 'this = "sort" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external spliceInPlace : pos:int -> remove:int -> add:'a array -> 'this = "splice" - [@@mel.send.pipe: 'a t as 'this] [@@mel.splice] +[@@mel.send.pipe: 'a t as 'this] [@@mel.splice] external removeFromInPlace : pos:int -> 'this = "splice" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external removeCountInPlace : pos:int -> count:int -> 'this = "splice" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] (* screwy naming, but screwy function *) external unshift : 'a -> int = "unshift" [@@mel.send.pipe: 'a t as 'this] external unshiftMany : 'a array -> int = "unshift" - [@@mel.send.pipe: 'a t as 'this] [@@mel.splice] +[@@mel.send.pipe: 'a t as 'this] [@@mel.splice] (* Accessor functions *) external append : 'a -> 'this = "concat" - [@@mel.send.pipe: 'a t as 'this] - [@@deprecated "append is not type-safe. Use `concat` instead, and see #1884"] +[@@mel.send.pipe: 'a t as 'this] +[@@deprecated "append is not type-safe. Use `concat` instead, and see #1884"] external concat : 'this -> 'this = "concat" [@@mel.send.pipe: 'a t as 'this] external concatMany : 'this array -> 'this = "concat" - [@@mel.send.pipe: 'a t as 'this] [@@mel.splice] +[@@mel.send.pipe: 'a t as 'this] [@@mel.splice] (* TODO: Not available in Node V4 *) external includes : 'a -> bool = "includes" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] (** ES2016 *) external indexOf : 'a -> int = "indexOf" [@@mel.send.pipe: 'a t as 'this] external indexOfFrom : 'a -> from:int -> int = "indexOf" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external join : 'a t -> string = "join" - [@@mel.send] [@@deprecated "please use joinWith instead"] +[@@mel.send] [@@deprecated "please use joinWith instead"] external joinWith : string -> string = "join" [@@mel.send.pipe: 'a t as 'this] external lastIndexOf : 'a -> int = "lastIndexOf" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external lastIndexOfFrom : 'a -> from:int -> int = "lastIndexOf" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external lastIndexOf_start : 'a -> int = "lastIndexOf" - [@@mel.send.pipe: 'a t as 'this] [@@deprecated "Please use `lastIndexOf"] +[@@mel.send.pipe: 'a t as 'this] [@@deprecated "Please use `lastIndexOf"] external slice : start:int -> end_:int -> 'this = "slice" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external copy : 'this = "slice" [@@mel.send.pipe: 'a t as 'this] external slice_copy : unit -> 'this = "slice" - [@@mel.send.pipe: 'a t as 'this] [@@deprecated "Please use `copy`"] +[@@mel.send.pipe: 'a t as 'this] [@@deprecated "Please use `copy`"] external sliceFrom : int -> 'this = "slice" [@@mel.send.pipe: 'a t as 'this] external slice_start : int -> 'this = "slice" - [@@mel.send.pipe: 'a t as 'this] [@@deprecated "Please use `sliceFrom`"] +[@@mel.send.pipe: 'a t as 'this] [@@deprecated "Please use `sliceFrom`"] external toString : string = "toString" [@@mel.send.pipe: 'a t as 'this] external toLocaleString : string = "toLocaleString" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] (* Iteration functions *) @@ -168,70 +168,70 @@ external toLocaleString : string = "toLocaleString" *) external every : (('a -> bool)[@mel.uncurry]) -> bool = "every" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external everyi : (('a -> int -> bool)[@mel.uncurry]) -> bool = "every" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external filter : (('a -> bool)[@mel.uncurry]) -> 'this = "filter" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] (** should we use [bool] or [boolean] seems they are intechangeable here *) external filteri : (('a -> int -> bool)[@mel.uncurry]) -> 'this = "filter" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external find : (('a -> bool)[@mel.uncurry]) -> 'a option = "find" - [@@mel.send.pipe: 'a t as 'this] [@@mel.return { undefined_to_opt }] +[@@mel.send.pipe: 'a t as 'this] [@@mel.return { undefined_to_opt }] (* ES2015 *) external findi : (('a -> int -> bool)[@mel.uncurry]) -> 'a option = "find" - [@@mel.send.pipe: 'a t as 'this] [@@mel.return { undefined_to_opt }] +[@@mel.send.pipe: 'a t as 'this] [@@mel.return { undefined_to_opt }] (* ES2015 *) external findIndex : (('a -> bool)[@mel.uncurry]) -> int = "findIndex" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] (* ES2015 *) external findIndexi : (('a -> int -> bool)[@mel.uncurry]) -> int = "findIndex" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] (* ES2015 *) external forEach : (('a -> unit)[@mel.uncurry]) -> unit = "forEach" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external forEachi : (('a -> int -> unit)[@mel.uncurry]) -> unit = "forEach" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] (* commented out until bs has a plan for iterators external keys : int array_iter = "" [@@mel.send.pipe: 'a t as 'this] (* ES2015 *) *) external map : (('a -> 'b)[@mel.uncurry]) -> 'b t = "map" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external mapi : (('a -> int -> 'b)[@mel.uncurry]) -> 'b t = "map" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external reduce : (('b -> 'a -> 'b)[@mel.uncurry]) -> 'b -> 'b = "reduce" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external reducei : (('b -> 'a -> int -> 'b)[@mel.uncurry]) -> 'b -> 'b = "reduce" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external reduceRight : (('b -> 'a -> 'b)[@mel.uncurry]) -> 'b -> 'b = "reduceRight" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external reduceRighti : (('b -> 'a -> int -> 'b)[@mel.uncurry]) -> 'b -> 'b = "reduceRight" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external some : (('a -> bool)[@mel.uncurry]) -> bool = "some" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] external somei : (('a -> int -> bool)[@mel.uncurry]) -> bool = "some" - [@@mel.send.pipe: 'a t as 'this] +[@@mel.send.pipe: 'a t as 'this] (* commented out until bs has a plan for iterators external values : 'a array_iter = "" [@@mel.send.pipe: 'a t as 'this] (* ES2015 *) diff --git a/jscomp/runtime/js_array2.ml b/jscomp/runtime/js_array2.ml index 57df92cd7e..76c45e51c5 100644 --- a/jscomp/runtime/js_array2.ml +++ b/jscomp/runtime/js_array2.ml @@ -31,15 +31,15 @@ type 'a array_like type 'a array_iter = 'a array_like *) -external from : 'a array_like -> 'a array = "Array.from" [@@mel.val] +external from : 'a array_like -> 'a array = "Array.from" (* ES2015 *) external fromMap : 'a array_like -> (('a -> 'b)[@mel.uncurry]) -> 'b array = "Array.from" - [@@mel.val] + (* ES2015 *) -external isArray : 'a -> bool = "Array.isArray" [@@mel.val] +external isArray : 'a -> bool = "Array.isArray" (* ES2015 *) (* ES2015 *) @@ -53,12 +53,12 @@ external copyWithin : 'a t -> to_:int -> 'a t = "copyWithin" [@@mel.send] (* ES2015 *) external copyWithinFrom : 'a t -> to_:int -> from:int -> 'a t = "copyWithin" - [@@mel.send] +[@@mel.send] (* ES2015 *) external copyWithinFromRange : 'a t -> to_:int -> start:int -> end_:int -> 'a t = "copyWithin" - [@@mel.send] +[@@mel.send] (* ES2015 *) external fillInPlace : 'a t -> 'a -> 'a t = "fill" [@@mel.send] (* ES2015 *) @@ -66,11 +66,11 @@ external fillFromInPlace : 'a t -> 'a -> from:int -> 'a t = "fill" [@@mel.send] (* ES2015 *) external fillRangeInPlace : 'a t -> 'a -> start:int -> end_:int -> 'a t = "fill" - [@@mel.send] +[@@mel.send] (* ES2015 *) external pop : 'a t -> 'a option = "pop" - [@@mel.send] [@@mel.return undefined_to_opt] +[@@mel.send] [@@mel.return undefined_to_opt] (** https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push *) external push : 'a t -> 'a -> int = "push" [@@mel.send] @@ -78,39 +78,39 @@ external pushMany : 'a t -> 'a array -> int = "push" [@@mel.send] [@@mel.splice] external reverseInPlace : 'a t -> 'a t = "reverse" [@@mel.send] external shift : 'a t -> 'a option = "shift" - [@@mel.send] [@@mel.return undefined_to_opt] +[@@mel.send] [@@mel.return undefined_to_opt] external sortInPlace : 'a t -> 'a t = "sort" [@@mel.send] external sortInPlaceWith : 'a t -> (('a -> 'a -> int)[@mel.uncurry]) -> 'a t = "sort" - [@@mel.send] +[@@mel.send] external spliceInPlace : 'a t -> pos:int -> remove:int -> add:'a array -> 'a t = "splice" - [@@mel.send] [@@mel.splice] +[@@mel.send] [@@mel.splice] external removeFromInPlace : 'a t -> pos:int -> 'a t = "splice" [@@mel.send] external removeCountInPlace : 'a t -> pos:int -> count:int -> 'a t = "splice" - [@@mel.send] +[@@mel.send] (* screwy naming, but screwy function *) external unshift : 'a t -> 'a -> int = "unshift" [@@mel.send] external unshiftMany : 'a t -> 'a array -> int = "unshift" - [@@mel.send] [@@mel.splice] +[@@mel.send] [@@mel.splice] (* Accessor functions *) external append : 'a t -> 'a -> 'a t = "concat" - [@@mel.send] - [@@deprecated "append is not type-safe. Use `concat` instead, and see #1884"] +[@@mel.send] +[@@deprecated "append is not type-safe. Use `concat` instead, and see #1884"] external concat : 'a t -> 'a t -> 'a t = "concat" [@@mel.send] external concatMany : 'a t -> 'a t array -> 'a t = "concat" - [@@mel.send] [@@mel.splice] +[@@mel.send] [@@mel.splice] (* TODO: Not available in Node V4 *) external includes : 'a t -> 'a -> bool = "includes" [@@mel.send] @@ -122,7 +122,7 @@ external joinWith : 'a t -> string -> string = "join" [@@mel.send] external lastIndexOf : 'a t -> 'a -> int = "lastIndexOf" [@@mel.send] external lastIndexOfFrom : 'a t -> 'a -> from:int -> int = "lastIndexOf" - [@@mel.send] +[@@mel.send] external slice : 'a t -> start:int -> end_:int -> 'a t = "slice" [@@mel.send] external copy : 'a t -> 'a t = "slice" [@@mel.send] @@ -137,43 +137,43 @@ external toLocaleString : 'a t -> string = "toLocaleString" [@@mel.send] *) external every : 'a t -> (('a -> bool)[@mel.uncurry]) -> bool = "every" - [@@mel.send] +[@@mel.send] external everyi : 'a t -> (('a -> int -> bool)[@mel.uncurry]) -> bool = "every" - [@@mel.send] +[@@mel.send] external filter : 'a t -> (('a -> bool)[@mel.uncurry]) -> 'a t = "filter" - [@@mel.send] +[@@mel.send] (** should we use [bool] or [boolean] seems they are intechangeable here *) external filteri : 'a t -> (('a -> int -> bool)[@mel.uncurry]) -> 'a t = "filter" - [@@mel.send] +[@@mel.send] external find : 'a t -> (('a -> bool)[@mel.uncurry]) -> 'a option = "find" - [@@mel.send] [@@mel.return { undefined_to_opt }] +[@@mel.send] [@@mel.return { undefined_to_opt }] (* ES2015 *) external findi : 'a t -> (('a -> int -> bool)[@mel.uncurry]) -> 'a option = "find" - [@@mel.send] [@@mel.return { undefined_to_opt }] +[@@mel.send] [@@mel.return { undefined_to_opt }] (* ES2015 *) external findIndex : 'a t -> (('a -> bool)[@mel.uncurry]) -> int = "findIndex" - [@@mel.send] +[@@mel.send] (* ES2015 *) external findIndexi : 'a t -> (('a -> int -> bool)[@mel.uncurry]) -> int = "findIndex" - [@@mel.send] +[@@mel.send] (* ES2015 *) external forEach : 'a t -> (('a -> unit)[@mel.uncurry]) -> unit = "forEach" - [@@mel.send] +[@@mel.send] external forEachi : 'a t -> (('a -> int -> unit)[@mel.uncurry]) -> unit = "forEach" - [@@mel.send] +[@@mel.send] (* commented out until bs has a plan for iterators external keys : 'a t -> int array_iter = "" [@@mel.send] (* ES2015 *) @@ -182,29 +182,29 @@ external forEachi : 'a t -> (('a -> int -> unit)[@mel.uncurry]) -> unit external map : 'a t -> (('a -> 'b)[@mel.uncurry]) -> 'b t = "map" [@@mel.send] external mapi : 'a t -> (('a -> int -> 'b)[@mel.uncurry]) -> 'b t = "map" - [@@mel.send] +[@@mel.send] external reduce : 'a t -> (('b -> 'a -> 'b)[@mel.uncurry]) -> 'b -> 'b = "reduce" - [@@mel.send] +[@@mel.send] external reducei : 'a t -> (('b -> 'a -> int -> 'b)[@mel.uncurry]) -> 'b -> 'b = "reduce" - [@@mel.send] +[@@mel.send] external reduceRight : 'a t -> (('b -> 'a -> 'b)[@mel.uncurry]) -> 'b -> 'b = "reduceRight" - [@@mel.send] +[@@mel.send] external reduceRighti : 'a t -> (('b -> 'a -> int -> 'b)[@mel.uncurry]) -> 'b -> 'b = "reduceRight" - [@@mel.send] +[@@mel.send] external some : 'a t -> (('a -> bool)[@mel.uncurry]) -> bool = "some" - [@@mel.send] +[@@mel.send] external somei : 'a t -> (('a -> int -> bool)[@mel.uncurry]) -> bool = "some" - [@@mel.send] +[@@mel.send] (* commented out until bs has a plan for iterators external values : 'a t -> 'a array_iter = "" [@@mel.send] (* ES2015 *) diff --git a/jscomp/runtime/js_console.ml b/jscomp/runtime/js_console.ml index 1f871593fa..5916172be6 100644 --- a/jscomp/runtime/js_console.ml +++ b/jscomp/runtime/js_console.ml @@ -1,53 +1,35 @@ -external log : 'a -> unit = "log" [@@mel.val] [@@mel.scope "console"] -external log2 : 'a -> 'b -> unit = "log" [@@mel.val] [@@mel.scope "console"] - -external log3 : 'a -> 'b -> 'c -> unit = "log" - [@@mel.val] [@@mel.scope "console"] - -external log4 : 'a -> 'b -> 'c -> 'd -> unit = "log" - [@@mel.val] [@@mel.scope "console"] +external log : 'a -> unit = "log" [@@mel.scope "console"] +external log2 : 'a -> 'b -> unit = "log" [@@mel.scope "console"] +external log3 : 'a -> 'b -> 'c -> unit = "log" [@@mel.scope "console"] +external log4 : 'a -> 'b -> 'c -> 'd -> unit = "log" [@@mel.scope "console"] external logMany : 'a array -> unit = "log" - [@@mel.val] [@@mel.scope "console"] [@@mel.splice] - -external info : 'a -> unit = "info" [@@mel.val] [@@mel.scope "console"] -external info2 : 'a -> 'b -> unit = "info" [@@mel.val] [@@mel.scope "console"] +[@@mel.scope "console"] [@@mel.splice] -external info3 : 'a -> 'b -> 'c -> unit = "info" - [@@mel.val] [@@mel.scope "console"] - -external info4 : 'a -> 'b -> 'c -> 'd -> unit = "info" - [@@mel.val] [@@mel.scope "console"] +external info : 'a -> unit = "info" [@@mel.scope "console"] +external info2 : 'a -> 'b -> unit = "info" [@@mel.scope "console"] +external info3 : 'a -> 'b -> 'c -> unit = "info" [@@mel.scope "console"] +external info4 : 'a -> 'b -> 'c -> 'd -> unit = "info" [@@mel.scope "console"] external infoMany : 'a array -> unit = "info" - [@@mel.val] [@@mel.scope "console"] [@@mel.splice] - -external warn : 'a -> unit = "warn" [@@mel.val] [@@mel.scope "console"] -external warn2 : 'a -> 'b -> unit = "warn" [@@mel.val] [@@mel.scope "console"] +[@@mel.scope "console"] [@@mel.splice] -external warn3 : 'a -> 'b -> 'c -> unit = "warn" - [@@mel.val] [@@mel.scope "console"] - -external warn4 : 'a -> 'b -> 'c -> 'd -> unit = "warn" - [@@mel.val] [@@mel.scope "console"] +external warn : 'a -> unit = "warn" [@@mel.scope "console"] +external warn2 : 'a -> 'b -> unit = "warn" [@@mel.scope "console"] +external warn3 : 'a -> 'b -> 'c -> unit = "warn" [@@mel.scope "console"] +external warn4 : 'a -> 'b -> 'c -> 'd -> unit = "warn" [@@mel.scope "console"] external warnMany : 'a array -> unit = "warn" - [@@mel.val] [@@mel.scope "console"] [@@mel.splice] - -external error : 'a -> unit = "error" [@@mel.val] [@@mel.scope "console"] -external error2 : 'a -> 'b -> unit = "error" [@@mel.val] [@@mel.scope "console"] +[@@mel.scope "console"] [@@mel.splice] -external error3 : 'a -> 'b -> 'c -> unit = "error" - [@@mel.val] [@@mel.scope "console"] - -external error4 : 'a -> 'b -> 'c -> 'd -> unit = "error" - [@@mel.val] [@@mel.scope "console"] +external error : 'a -> unit = "error" [@@mel.scope "console"] +external error2 : 'a -> 'b -> unit = "error" [@@mel.scope "console"] +external error3 : 'a -> 'b -> 'c -> unit = "error" [@@mel.scope "console"] +external error4 : 'a -> 'b -> 'c -> 'd -> unit = "error" [@@mel.scope "console"] external errorMany : 'a array -> unit = "error" - [@@mel.val] [@@mel.scope "console"] [@@mel.splice] - -external trace : unit -> unit = "trace" [@@mel.val] [@@mel.scope "console"] -external timeStart : string -> unit = "time" [@@mel.val] [@@mel.scope "console"] +[@@mel.scope "console"] [@@mel.splice] -external timeEnd : string -> unit = "timeEnd" - [@@mel.val] [@@mel.scope "console"] +external trace : unit -> unit = "trace" [@@mel.scope "console"] +external timeStart : string -> unit = "time" [@@mel.scope "console"] +external timeEnd : string -> unit = "timeEnd" [@@mel.scope "console"] diff --git a/jscomp/runtime/js_date.ml b/jscomp/runtime/js_date.ml index 4f37b0e6a8..bc84676e07 100644 --- a/jscomp/runtime/js_date.ml +++ b/jscomp/runtime/js_date.ml @@ -27,26 +27,26 @@ type t external valueOf : t -> float = "valueOf" - [@@mel.send] +[@@mel.send] (** returns the primitive value of this date, equivalent to getTime *) external make : unit -> t = "Date" - [@@mel.new] +[@@mel.new] (** returns a date representing the current time *) external fromFloat : float -> t = "Date" [@@mel.new] external fromString : string -> t = "Date" [@@mel.new] external makeWithYM : year:float -> month:float -> unit -> t = "Date" - [@@mel.new] +[@@mel.new] external makeWithYMD : year:float -> month:float -> date:float -> unit -> t = "Date" - [@@mel.new] +[@@mel.new] external makeWithYMDH : year:float -> month:float -> date:float -> hours:float -> unit -> t = "Date" - [@@mel.new] +[@@mel.new] external makeWithYMDHM : year:float -> @@ -56,7 +56,7 @@ external makeWithYMDHM : minutes:float -> unit -> t = "Date" - [@@mel.new] +[@@mel.new] external makeWithYMDHMS : year:float -> @@ -67,18 +67,19 @@ external makeWithYMDHMS : seconds:float -> unit -> t = "Date" - [@@mel.new] +[@@mel.new] -external utcWithYM : year:float -> month:float -> unit -> float = "" - [@@mel.val "Date.UTC"] +external utcWithYM : year:float -> month:float -> unit -> float = "UTC" +[@@mel.scope "Date"] external utcWithYMD : year:float -> month:float -> date:float -> unit -> float - = "" - [@@mel.val "Date.UTC"] + = "UTC" +[@@mel.scope "Date"] external utcWithYMDH : - year:float -> month:float -> date:float -> hours:float -> unit -> float = "" - [@@mel.val "Date.UTC"] + year:float -> month:float -> date:float -> hours:float -> unit -> float + = "UTC" +[@@mel.scope "Date"] external utcWithYMDHM : year:float -> @@ -87,8 +88,8 @@ external utcWithYMDHM : hours:float -> minutes:float -> unit -> - float = "" - [@@mel.val "Date.UTC"] + float = "UTC" +[@@mel.scope "Date"] external utcWithYMDHMS : year:float -> @@ -98,26 +99,26 @@ external utcWithYMDHMS : minutes:float -> seconds:float -> unit -> - float = "" - [@@mel.val "Date.UTC"] + float = "UTC" +[@@mel.scope "Date"] -external now : unit -> float = "" - [@@mel.val "Date.now"] +external now : unit -> float = "now" +[@@mel.scope "Date"] (** returns the number of milliseconds since Unix epoch *) external parse : string -> t = "Date" - [@@mel.new] [@@deprecated "Please use `fromString` instead"] +[@@mel.new] [@@deprecated "Please use `fromString` instead"] -external parseAsFloat : string -> float = "" - [@@mel.val "parse"] [@@mel.scope "Date"] +external parseAsFloat : string -> float = "parse" +[@@mel.scope "Date"] (** returns NaN if passed invalid date string *) external getDate : t -> float = "getDate" - [@@mel.send] +[@@mel.send] (** return the day of the month (1-31) *) external getDay : t -> float = "getDay" - [@@mel.send] +[@@mel.send] (** returns the day of the week (0-6) *) external getFullYear : t -> float = "getFullYear" [@@mel.send] @@ -126,23 +127,23 @@ external getMilliseconds : t -> float = "getMilliseconds" [@@mel.send] external getMinutes : t -> float = "getMinutes" [@@mel.send] external getMonth : t -> float = "getMonth" - [@@mel.send] +[@@mel.send] (** returns the month (0-11) *) external getSeconds : t -> float = "getSeconds" [@@mel.send] external getTime : t -> float = "getTime" - [@@mel.send] +[@@mel.send] (** returns the number of milliseconds since Unix epoch *) external getTimezoneOffset : t -> float = "getTimezoneOffset" [@@mel.send] external getUTCDate : t -> float = "getUTCDate" - [@@mel.send] +[@@mel.send] (** return the day of the month (1-31) *) external getUTCDay : t -> float = "getUTCDay" - [@@mel.send] +[@@mel.send] (** returns the day of the week (0-6) *) external getUTCFullYear : t -> float = "getUTCFullYear" [@@mel.send] @@ -151,35 +152,35 @@ external getUTCMilliseconds : t -> float = "getUTCMilliseconds" [@@mel.send] external getUTCMinutes : t -> float = "getUTCMinutes" [@@mel.send] external getUTCMonth : t -> float = "getUTCMonth" - [@@mel.send] +[@@mel.send] (** returns the month (0-11) *) external getUTCSeconds : t -> float = "getUTCSeconds" [@@mel.send] external getYear : t -> float = "getYear" - [@@mel.send] [@@deprecated "use `getFullYear` instead"] +[@@mel.send] [@@deprecated "use `getFullYear` instead"] external setDate : t -> float -> float = "setDate" [@@mel.send] external setFullYear : t -> float -> float = "setFullYear" [@@mel.send] external setFullYearM : t -> year:float -> month:float -> unit -> float = "setFullYear" - [@@mel.send] +[@@mel.send] external setFullYearMD : t -> year:float -> month:float -> date:float -> unit -> float = "setFullYear" - [@@mel.send] +[@@mel.send] external setHours : t -> float -> float = "setHours" [@@mel.send] external setHoursM : t -> hours:float -> minutes:float -> unit -> float = "setHours" - [@@mel.send] +[@@mel.send] external setHoursMS : t -> hours:float -> minutes:float -> seconds:float -> unit -> float = "setHours" - [@@mel.send] +[@@mel.send] external setHoursMSMs : t -> @@ -189,31 +190,31 @@ external setHoursMSMs : milliseconds:float -> unit -> float = "setHours" - [@@mel.send] +[@@mel.send] external setMilliseconds : t -> float -> float = "setMilliseconds" [@@mel.send] external setMinutes : t -> float -> float = "setMinutes" [@@mel.send] external setMinutesS : t -> minutes:float -> seconds:float -> unit -> float = "setMinutes" - [@@mel.send] +[@@mel.send] external setMinutesSMs : t -> minutes:float -> seconds:float -> milliseconds:float -> unit -> float = "setMinutes" - [@@mel.send] +[@@mel.send] external setMonth : t -> float -> float = "setMonth" [@@mel.send] external setMonthD : t -> month:float -> date:float -> unit -> float = "setMonth" - [@@mel.send] +[@@mel.send] external setSeconds : t -> float -> float = "setSeconds" [@@mel.send] external setSecondsMs : t -> seconds:float -> milliseconds:float -> unit -> float = "setSeconds" - [@@mel.send] +[@@mel.send] external setTime : t -> float -> float = "setTime" [@@mel.send] external setUTCDate : t -> float -> float = "setUTCDate" [@@mel.send] @@ -221,23 +222,23 @@ external setUTCFullYear : t -> float -> float = "setUTCFullYear" [@@mel.send] external setUTCFullYearM : t -> year:float -> month:float -> unit -> float = "setUTCFullYear" - [@@mel.send] +[@@mel.send] external setUTCFullYearMD : t -> year:float -> month:float -> date:float -> unit -> float = "setUTCFullYear" - [@@mel.send] +[@@mel.send] external setUTCHours : t -> float -> float = "setUTCHours" [@@mel.send] external setUTCHoursM : t -> hours:float -> minutes:float -> unit -> float = "setUTCHours" - [@@mel.send] +[@@mel.send] external setUTCHoursMS : t -> hours:float -> minutes:float -> seconds:float -> unit -> float = "setUTCHours" - [@@mel.send] +[@@mel.send] external setUTCHoursMSMs : t -> @@ -247,51 +248,51 @@ external setUTCHoursMSMs : milliseconds:float -> unit -> float = "setUTCHours" - [@@mel.send] +[@@mel.send] external setUTCMilliseconds : t -> float -> float = "setUTCMilliseconds" - [@@mel.send] +[@@mel.send] external setUTCMinutes : t -> float -> float = "setUTCMinutes" [@@mel.send] external setUTCMinutesS : t -> minutes:float -> seconds:float -> unit -> float = "setUTCMinutes" - [@@mel.send] +[@@mel.send] external setUTCMinutesSMs : t -> minutes:float -> seconds:float -> milliseconds:float -> unit -> float = "setUTCMinutes" - [@@mel.send] +[@@mel.send] external setUTCMonth : t -> float -> float = "setUTCMonth" [@@mel.send] external setUTCMonthD : t -> month:float -> date:float -> unit -> float = "setUTCMonth" - [@@mel.send] +[@@mel.send] external setUTCSeconds : t -> float -> float = "setUTCSeconds" [@@mel.send] external setUTCSecondsMs : t -> seconds:float -> milliseconds:float -> unit -> float = "setUTCSeconds" - [@@mel.send] +[@@mel.send] external setUTCTime : t -> float -> float = "setTime" [@@mel.send] external setYear : t -> float -> float = "setYear" - [@@mel.send] [@@deprecated "use `setFullYear` instead"] +[@@mel.send] [@@deprecated "use `setFullYear` instead"] external toDateString : t -> string = "toDateString" [@@mel.send] external toGMTString : t -> string = "toGMTString" - [@@mel.send] [@@deprecated "use `toUTCString` instead"] +[@@mel.send] [@@deprecated "use `toUTCString` instead"] external toISOString : t -> string = "toISOString" [@@mel.send] external toJSON : t -> string = "toJSON" - [@@mel.send] - [@@deprecated - "This method is unsafe. It will be changed to return option in a future \ - release. Please use toJSONUnsafe instead."] +[@@mel.send] +[@@deprecated + "This method is unsafe. It will be changed to return option in a future \ + release. Please use toJSONUnsafe instead."] external toJSONUnsafe : t -> string = "toJSON" [@@mel.send] external toLocaleDateString : t -> string = "toLocaleDateString" [@@mel.send] diff --git a/jscomp/runtime/js_dict.ml b/jscomp/runtime/js_dict.ml index c64f517df6..613b50a8a4 100644 --- a/jscomp/runtime/js_dict.ml +++ b/jscomp/runtime/js_dict.ml @@ -32,7 +32,7 @@ type key = string (** The key type, an alias of string *) external unsafeGet : 'a t -> key -> 'a = "" - [@@mel.get_index] +[@@mel.get_index] (** [unsafeGet dict key] returns the value associated with [key] in [dict] This function will return an invalid value ([undefined]) if [key] does not exist in [dict]. It @@ -50,15 +50,15 @@ let get (type u) (dict : u t) (k : key) : u option = if [%raw {|k in dict|}] then Some dict.!(k) else None external set : 'a t -> key -> 'a -> unit = "" - [@@mel.set_index] +[@@mel.set_index] (** [set dict key value] sets the value of [key] in [dict] to [value] *) external keys : 'a t -> key array = "Object.keys" - [@@mel.val] + (** [keys dict] returns an array of all the keys in [dict] *) external empty : unit -> 'a t = "" - [@@mel.obj] +[@@mel.obj] (** [empty ()] creates an empty dictionary *) let unsafeDeleteKey : (string t -> string -> unit[@u]) = @@ -69,7 +69,7 @@ let unsafeDeleteKey : (string t -> string -> unit[@u]) = external unsafeCreate : int -> 'a array = "Array" [@@mel.new] -(* external entries : 'a t -> (key * 'a) array = "Object.entries" [@@mel.val] (* ES2017 *) *) +(* external entries : 'a t -> (key * 'a) array = "Object.entries" (* ES2017 *) *) let entries dict = let keys = keys dict in let l = Js_array2.length keys in @@ -80,7 +80,7 @@ let entries dict = done; values -(* external values : 'a t -> 'a array = "Object.values" [@@mel.val] (* ES2017 *) *) +(* external values : 'a t -> 'a array = "Object.values" (* ES2017 *) *) let values dict = let keys = keys dict in let l = Js_array2.length keys in diff --git a/jscomp/runtime/js_dict.mli b/jscomp/runtime/js_dict.mli index d9426ea87a..94f09598bc 100644 --- a/jscomp/runtime/js_dict.mli +++ b/jscomp/runtime/js_dict.mli @@ -36,7 +36,7 @@ val get : 'a t -> key -> 'a option dictionary, [Some value] otherwise *) external unsafeGet : 'a t -> key -> 'a = "" - [@@mel.get_index] +[@@mel.get_index] (** [unsafeGet dict key] return the value if the [key] exists, otherwise an {b undefined} value is returned. Must be used only when the existence of a key is certain. (i.e. when having called [keys] @@ -48,15 +48,15 @@ Array.iter (fun key -> Js.log (Js_dict.unsafeGet dic key)) (Js_dict.keys dict) *) external set : 'a t -> key -> 'a -> unit = "" - [@@mel.set_index] +[@@mel.set_index] (** [set dict key value] sets the [key]/[value] in [dict] *) external keys : 'a t -> string array = "Object.keys" - [@@mel.val] + (** [keys dict] returns all the keys in the dictionary [dict]*) external empty : unit -> 'a t = "" - [@@mel.obj] +[@@mel.obj] (** [empty ()] returns an empty dictionary *) module Js := Js_internal @@ -64,11 +64,11 @@ module Js := Js_internal val unsafeDeleteKey : (string t -> string -> unit[@u]) (** Experimental internal function *) -(* external entries : 'a t -> (key * 'a) array = "Object.entries" [@@mel.val] *) +(* external entries : 'a t -> (key * 'a) array = "Object.entries" *) val entries : 'a t -> (key * 'a) array (** [entries dict] returns the key value pairs in [dict] (ES2017) *) -(* external values : 'a t -> 'a array = "Object.values" [@@mel.val] *) +(* external values : 'a t -> 'a array = "Object.values" *) val values : 'a t -> 'a array (** [values dict] returns the values in [dict] (ES2017) *) diff --git a/jscomp/runtime/js_float.ml b/jscomp/runtime/js_float.ml index 2d8f38388e..b2ade05093 100644 --- a/jscomp/runtime/js_float.ml +++ b/jscomp/runtime/js_float.ml @@ -26,14 +26,14 @@ *) external _NaN : float = "NaN" - [@@mel.val] + (** The special value "Not a Number" @see MDN *) external isNaN : float -> bool = "isNaN" - [@@mel.val] [@@mel.scope "Number"] +[@@mel.scope "Number"] (** Tests if the given value is [_NaN] Note that both [_NaN = _NaN] and [_NaN == _NaN] will return [false]. [isNaN] is @@ -45,7 +45,7 @@ therefore necessary to test for [_NaN]. *) external isFinite : float -> bool = "isFinite" - [@@mel.val] [@@mel.scope "Number"] +[@@mel.scope "Number"] (** Tests if the given value is finite {b Returns} [true] if the given value is a finite number, [false] otherwise @@ -68,7 +68,7 @@ let _ = Js.Float.isFinite 1234 *) external toExponential : float -> string = "toExponential" - [@@mel.send] +[@@mel.send] (** Formats a [float] using exponential (scientific) notation {b Returns} a [string] representing the given value in exponential notation @@ -88,7 +88,7 @@ external toExponential : float -> string = "toExponential" external toExponentialWithPrecision : float -> digits:int -> string = "toExponential" - [@@mel.send] +[@@mel.send] (** Formats a [float] using exponential (scientific) notation {b digits} specifies how many digits should appear after the decimal point. The @@ -110,7 +110,7 @@ The output will be rounded or padded with zeroes if necessary. *) external toFixed : float -> string = "toFixed" - [@@mel.send] +[@@mel.send] (** Formats a [float] using fixed point notation {b Returns} a [string] representing the given value in fixed-point notation (usually) @@ -129,7 +129,7 @@ external toFixed : float -> string = "toFixed" *) external toFixedWithPrecision : float -> digits:int -> string = "toFixed" - [@@mel.send] +[@@mel.send] (** Formats a [float] using fixed point notation {b digits} specifies how many digits should appear after the decimal point. The @@ -153,7 +153,7 @@ The output will be rounded or padded with zeroes if necessary. *) external toPrecision : float -> string = "toPrecision" - [@@mel.send] +[@@mel.send] (** Formats a [float] using some fairly arbitrary rules {b Returns} a [string] representing the given value in fixed-point (usually) @@ -178,7 +178,7 @@ decimal point. external toPrecisionWithPrecision : float -> digits:int -> string = "toPrecision" - [@@mel.send] +[@@mel.send] (** Formats a [float] using some fairly arbitrary rules {b digits} specifies how many digits should appear in total. The @@ -209,7 +209,7 @@ before the decimal point. *) external toString : float -> string = "toString" - [@@mel.send] +[@@mel.send] (** Formats a [float] as a string {b Returns} a [string] representing the given value in fixed-point (usually) @@ -223,7 +223,7 @@ external toString : float -> string = "toString" *) external toStringWithRadix : float -> radix:int -> string = "toString" - [@@mel.send] +[@@mel.send] (** Formats a [float] as a string {b radix} specifies the radix base to use for the formatted number. The @@ -251,7 +251,7 @@ value must be in the range \[2, 36\] (inclusive). *) external fromString : string -> float = "Number" - [@@mel.val] + (** Parses the given [string] into a [float] using JavaScript semantics {b Returns} the number as a [float] if successfully parsed, [_NaN] otherwise. diff --git a/jscomp/runtime/js_global.ml b/jscomp/runtime/js_global.ml index 33078f360e..8c69aec834 100644 --- a/jscomp/runtime/js_global.ml +++ b/jscomp/runtime/js_global.ml @@ -32,7 +32,7 @@ type timeoutId (** Identify timeout started by {! setTimeout} *) external clearInterval : intervalId -> unit = "clearInterval" - [@@mel.val] + (** Clear an interval started by {! setInterval} {[ @@ -55,7 +55,7 @@ let cancel () = *) external clearTimeout : timeoutId -> unit = "clearTimeout" - [@@mel.val] + (** Clear a timeout started by {! setTimeout} {[ (* A simple model of a code monkey's brain *) @@ -74,7 +74,7 @@ let procrastinate mins = *) external setInterval : (unit -> unit) -> int -> intervalId = "setInterval" - [@@mel.val] + (** {i Repeatedly} executes a callback with a specified interval (in milliseconds) between calls {b Return} an {! intervalId} that can be passed to {! clearInterval} to cancel the timeout @@ -96,7 +96,7 @@ let _ = external setIntervalFloat : (unit -> unit) -> float -> intervalId = "setInterval" - [@@mel.val] + (** {i Repeatedly} executes a callback with a specified interval (in milliseconds) between calls {b Return} an {! intervalId} that can be passed to {! clearInterval} to cancel the timeout @@ -117,7 +117,7 @@ let _ = *) external setTimeout : (unit -> unit) -> int -> timeoutId = "setTimeout" - [@@mel.val] + (** Execute a callback after a specified delay (in milliseconds) {b returns} a {! timeoutId} that can be passed to {! clearTimeout} to cancel the timeout @@ -135,7 +135,7 @@ let _ = *) external setTimeoutFloat : (unit -> unit) -> float -> timeoutId = "setTimeout" - [@@mel.val] + (** Execute a callback after a specified delay (in milliseconds) {b returns} a {! timeoutId} that can be passed to {! clearTimeout} to cancel the timeout @@ -153,28 +153,28 @@ let _ = *) external encodeURI : string -> string = "encodeURI" - [@@mel.val] + (** URL-encodes a string. @see MDN *) external decodeURI : string -> string = "decodeURI" - [@@mel.val] + (** Decodes a URL-enmcoded string produced by [encodeURI] @see MDN *) external encodeURIComponent : string -> string = "encodeURIComponent" - [@@mel.val] + (** URL-encodes a string, including characters with special meaning in a URI. @see MDN *) external decodeURIComponent : string -> string = "decodeURIComponent" - [@@mel.val] + (** Decodes a URL-enmcoded string produced by [encodeURIComponent] @see MDN diff --git a/jscomp/runtime/js_internal.ml b/jscomp/runtime/js_internal.ml index e382c7ec67..d97a39704d 100644 --- a/jscomp/runtime/js_internal.ml +++ b/jscomp/runtime/js_internal.ml @@ -85,7 +85,7 @@ module Internal = struct (* Use opaque instead of [._n] to prevent some optimizations happening *) external run : 'a arity0 -> 'a = "#run" - [@@ocaml.warning "-unboxable-type-in-prim-decl"] + [@@ocaml.warning "-unboxable-type-in-prim-decl"] external opaque : 'a -> 'a = "%opaque" end @@ -125,19 +125,15 @@ external typeof : 'a -> string = "#typeof" *) external log : 'a -> unit = "log" - [@@mel.val] [@@mel.scope "console"] +[@@mel.scope "console"] (** A convenience function to log everything *) -external log2 : 'a -> 'b -> unit = "log" [@@mel.val] [@@mel.scope "console"] - -external log3 : 'a -> 'b -> 'c -> unit = "log" - [@@mel.val] [@@mel.scope "console"] - -external log4 : 'a -> 'b -> 'c -> 'd -> unit = "log" - [@@mel.val] [@@mel.scope "console"] +external log2 : 'a -> 'b -> unit = "log" [@@mel.scope "console"] +external log3 : 'a -> 'b -> 'c -> unit = "log" [@@mel.scope "console"] +external log4 : 'a -> 'b -> 'c -> 'd -> unit = "log" [@@mel.scope "console"] external logMany : 'a array -> unit = "log" - [@@mel.val] [@@mel.scope "console"] [@@mel.splice] +[@@mel.scope "console"] [@@mel.splice] (** A convenience function to log more than 4 arguments *) external eqNull : 'a -> 'a null -> bool = "%bs_equal_null" diff --git a/jscomp/runtime/js_json.ml b/jscomp/runtime/js_json.ml index 7d90392e09..5aa2b340b1 100644 --- a/jscomp/runtime/js_json.ml +++ b/jscomp/runtime/js_json.ml @@ -95,15 +95,13 @@ let decodeNull json : _ Js_internal.null option = else None (* external parse : string -> t = "parse" - [@@mel.val][@@mel.scope "JSON"] *) + [@@mel.scope "JSON"] *) -external parseExn : string -> t = "parse" [@@mel.val] [@@mel.scope "JSON"] - -external stringifyAny : 'a -> string option = "stringify" - [@@mel.val] [@@mel.scope "JSON"] +external parseExn : string -> t = "parse" [@@mel.scope "JSON"] +external stringifyAny : 'a -> string option = "stringify" [@@mel.scope "JSON"] (* TODO: more docs when parse error happens or stringify non-stringfy value *) -external null : t = "null" [@@mel.val] +external null : t = "null" external string : string -> t = "%identity" external number : float -> t = "%identity" external boolean : bool -> t = "%identity" @@ -116,11 +114,11 @@ external stringArray : string array -> t = "%identity" external numberArray : float array -> t = "%identity" external booleanArray : bool array -> t = "%identity" external objectArray : t Js_dict.t array -> t = "%identity" -external stringify : t -> string = "stringify" [@@mel.val] [@@mel.scope "JSON"] +external stringify : t -> string = "stringify" [@@mel.scope "JSON"] external stringifyWithSpace : t -> (_[@mel.as {json|null|json}]) -> int -> string = "stringify" - [@@mel.val] [@@mel.scope "JSON"] +[@@mel.scope "JSON"] (* in memory modification does not work until your root is actually None, so we need wrap it as `[v]` and diff --git a/jscomp/runtime/js_json.mli b/jscomp/runtime/js_json.mli index 2502d92e78..222faf5c3c 100644 --- a/jscomp/runtime/js_json.mli +++ b/jscomp/runtime/js_json.mli @@ -88,7 +88,7 @@ val decodeNull : t -> 'a Js_null.t option *) external null : t = "null" - [@@mel.val] + (** [null] is the singleton null JSON value *) external string : string -> t = "%identity" @@ -125,7 +125,7 @@ external objectArray : t Js_dict.t array -> t = "%identity" (** {2 String conversion} *) external parseExn : string -> t = "parse" - [@@mel.val] [@@mel.scope "JSON"] +[@@mel.scope "JSON"] (** [parseExn s] parses the string [s] into a JSON data structure {b Returns} a JSON data structure @@ -179,7 +179,7 @@ let getIds s = *) external stringify : t -> string = "stringify" - [@@mel.val] [@@mel.scope "JSON"] +[@@mel.scope "JSON"] (** [stringify json] formats the JSON data structure as a string {b Returns} the string representation of a given JSON data structure @@ -201,7 +201,7 @@ Js.log (Js.Json.stringify (Js.Json.object_ dict)) external stringifyWithSpace : t -> (_[@mel.as {json|null|json}]) -> int -> string = "stringify" - [@@mel.val] [@@mel.scope "JSON"] +[@@mel.scope "JSON"] (** [stringify json] formats the JSON data structure as a string {b Returns} the string representation of a given JSON data structure @@ -222,7 +222,7 @@ Js.Dict.set dict "likes" *) external stringifyAny : 'a -> string option = "stringify" - [@@mel.val] [@@mel.scope "JSON"] +[@@mel.scope "JSON"] (** [stringifyAny value] formats any [value] into a JSON string {[ diff --git a/jscomp/runtime/js_math.ml b/jscomp/runtime/js_math.ml index c4c6e8d59f..8443f519e1 100644 --- a/jscomp/runtime/js_math.ml +++ b/jscomp/runtime/js_math.ml @@ -26,83 +26,80 @@ open Melange_mini_stdlib (** JavaScript Math API *) -external _E : float = "E" [@@mel.val] [@@mel.scope "Math"] +external _E : float = "E" [@@mel.scope "Math"] (** Euler's number *) -external _LN2 : float = "LN2" - [@@mel.val] [@@mel.scope "Math"] +external _LN2 : float = "LN2" [@@mel.scope "Math"] (** natural logarithm of 2 *) external _LN10 : float = "LN10" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** natural logarithm of 10 *) external _LOG2E : float = "LOG2E" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** base 2 logarithm of E *) external _LOG10E : float = "LOG10E" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** base 10 logarithm of E *) external _PI : float = "PI" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** Pi... (ratio of the circumference and diameter of a circle) *) external _SQRT1_2 : float = "SQRT1_2" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** square root of 1/2 *) -external _SQRT2 : float = "SQRT2" - [@@mel.val] [@@mel.scope "Math"] +external _SQRT2 : float = "SQRT2" [@@mel.scope "Math"] (** square root of 2 *) -external abs_int : int -> int = "abs" - [@@mel.val] [@@mel.scope "Math"] +external abs_int : int -> int = "abs" [@@mel.scope "Math"] (** absolute value *) external abs_float : float -> float = "abs" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** absolute value *) external acos : float -> float = "acos" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** arccosine in radians, can return NaN *) external acosh : float -> float = "acosh" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** hyperbolic arccosine in raidans, can return NaN, ES2015 *) external asin : float -> float = "asin" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** arcsine in radians, can return NaN *) external asinh : float -> float = "asinh" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** hyperbolic arcsine in raidans, ES2015 *) external atan : float -> float = "atan" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** arctangent in radians *) external atanh : float -> float = "atanh" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** hyperbolic arctangent in radians, can return NaN, ES2015 *) external atan2 : y:float -> x:float -> unit -> float = "atan2" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** arctangent of the quotient of x and y, mostly... this one's a bit weird *) external cbrt : float -> float = "cbrt" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** cube root, can return NaN, ES2015 *) external unsafe_ceil_int : float -> int = "ceil" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** may return values not representable by [int] *) let unsafe_ceil = unsafe_ceil_int - [@@deprecated "Please use `unsafe_ceil_int` instead"] +[@@deprecated "Please use `unsafe_ceil_int` instead"] (** smallest int greater than or equal to the argument *) let ceil_int (f : float) : int = @@ -113,36 +110,36 @@ let ceil_int (f : float) : int = let ceil = ceil_int [@@deprecated "Please use `ceil_int` instead"] external ceil_float : float -> float = "ceil" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** smallest float greater than or equal to the argument *) external clz32 : int -> int = "clz32" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** number of leading zero bits of the argument's 32 bit int representation, ES2015 *) (* can convert string, float etc. to number *) external cos : float -> float = "cos" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** cosine in radians *) external cosh : float -> float = "cosh" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** hyperbolic cosine in radians, ES2015 *) external exp : float -> float = "exp" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** natural exponentional *) external expm1 : float -> float = "expm1" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** natural exponential minus 1, ES2015 *) external unsafe_floor_int : float -> int = "floor" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** may return values not representable by [int] *) let unsafe_floor = unsafe_floor_int - [@@deprecated "Please use `unsafe_floor_int` instead"] +[@@deprecated "Please use `unsafe_floor_int` instead"] (** largest int greater than or equal to the arugment *) let floor_int f = @@ -152,129 +149,127 @@ let floor_int f = let floor = floor_int [@@deprecated "Please use `floor_int` instead"] -external floor_float : float -> float = "floor" [@@mel.val] [@@mel.scope "Math"] +external floor_float : float -> float = "floor" [@@mel.scope "Math"] external fround : float -> float = "fround" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** round to nearest single precision float, ES2015 *) external hypot : float -> float -> float = "hypot" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** pythagorean equation, ES2015 *) external hypotMany : float array -> float = "hypot" - [@@mel.val] [@@mel.splice] [@@mel.scope "Math"] +[@@mel.splice] [@@mel.scope "Math"] (** generalized pythagorean equation, ES2015 *) external imul : int -> int -> int = "imul" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** 32-bit integer multiplication, ES2015 *) external log : float -> float = "log" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** natural logarithm, can return NaN *) external log1p : float -> float = "log1p" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** natural logarithm of 1 + the argument, can return NaN, ES2015 *) external log10 : float -> float = "log10" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** base 10 logarithm, can return NaN, ES2015 *) external log2 : float -> float = "log2" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** base 2 logarithm, can return NaN, ES2015 *) external max_int : int -> int -> int = "max" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** max value *) external maxMany_int : int array -> int = "max" - [@@mel.val] [@@mel.splice] [@@mel.scope "Math"] +[@@mel.splice] [@@mel.scope "Math"] (** max value *) external max_float : float -> float -> float = "max" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** max value *) external maxMany_float : float array -> float = "max" - [@@mel.val] [@@mel.splice] [@@mel.scope "Math"] +[@@mel.splice] [@@mel.scope "Math"] (** max value *) external min_int : int -> int -> int = "min" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** min value *) external minMany_int : int array -> int = "min" - [@@mel.val] [@@mel.splice] [@@mel.scope "Math"] +[@@mel.splice] [@@mel.scope "Math"] (** min value *) external min_float : float -> float -> float = "min" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** min value *) external minMany_float : float array -> float = "min" - [@@mel.val] [@@mel.splice] [@@mel.scope "Math"] +[@@mel.splice] [@@mel.scope "Math"] (** min value *) external pow_int : base:int -> exp:int -> int = "pow" - [@@mel.val] - [@@mel.scope "Math"] - [@@deprecated "use `pow_float` instead, the return type may be not int"] +[@@mel.scope "Math"] +[@@deprecated "use `pow_float` instead, the return type may be not int"] (** base to the power of the exponent *) external pow_float : base:float -> exp:float -> float = "pow" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** base to the power of the exponent *) external random : unit -> float = "random" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** random number in \[0,1) *) (** random number in \[min,max) *) let random_int min max = floor (random () *. Js_int.toFloat (max - min)) + min external unsafe_round : float -> int = "round" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** rounds to nearest integer, returns a value not representable as [int] if NaN *) external round : float -> float = "round" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** rounds to nearest integer *) external sign_int : int -> int = "sign" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** the sign of the argument, 1, -1 or 0, ES2015 *) external sign_float : float -> float = "sign" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** the sign of the argument, 1, -1, 0, -0 or NaN, ES2015 *) -external sin : float -> float = "sin" - [@@mel.val] [@@mel.scope "Math"] +external sin : float -> float = "sin" [@@mel.scope "Math"] (** sine in radians *) external sinh : float -> float = "sinh" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** hyperbolic sine in radians, ES2015 *) external sqrt : float -> float = "sqrt" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** square root, can return NaN *) external tan : float -> float = "tan" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** tangent in radians *) external tanh : float -> float = "tanh" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** hyperbolic tangent in radians, ES2015 *) external unsafe_trunc : float -> int = "trunc" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** truncate, ie. remove fractional digits, returns a value not representable as [int] if NaN, ES2015 *) external trunc : float -> float = "trunc" - [@@mel.val] [@@mel.scope "Math"] +[@@mel.scope "Math"] (** truncate, ie. remove fractional digits, returns a value not representable as [int] if NaN, ES2015 *) diff --git a/jscomp/runtime/js_obj.ml b/jscomp/runtime/js_obj.ml index c5a6f56449..817039d1c6 100644 --- a/jscomp/runtime/js_obj.ml +++ b/jscomp/runtime/js_obj.ml @@ -26,13 +26,13 @@ *) external empty : unit -> < .. > Js_internal.t = "" - [@@mel.obj] +[@@mel.obj] (** [empty ()] returns the empty object [\{\}] *) external assign : < .. > Js_internal.t -> < .. > Js_internal.t -> < .. > Js_internal.t = "Object.assign" - [@@mel.val] + (** [assign target source] copies properties from [source] to [target] Properties in [target] will be overwritten by properties in [source] if they @@ -103,7 +103,7 @@ let _ = Js.log target *) external keys : _ Js_internal.t -> string array = "Object.keys" - [@@mel.val] + (** [keys obj] returns an array of the keys of [obj]'s own enumerable properties @see MDN diff --git a/jscomp/runtime/js_promise.ml b/jscomp/runtime/js_promise.ml index 86dda2eeed..2d59ab674f 100644 --- a/jscomp/runtime/js_promise.ml +++ b/jscomp/runtime/js_promise.ml @@ -40,42 +40,38 @@ external make : ((resolve:(('a -> unit)[@u]) -> reject:((exn -> unit)[@u]) -> unit) [@mel.uncurry]) -> 'a t = "Promise" - [@@mel.new] +[@@mel.new] (* [make (fun resolve reject -> .. )] *) -external resolve : 'a -> 'a t = "resolve" [@@mel.val] [@@mel.scope "Promise"] -external reject : exn -> 'a t = "reject" [@@mel.val] [@@mel.scope "Promise"] - -external all : 'a t array -> 'a array t = "all" - [@@mel.val] [@@mel.scope "Promise"] - -external all2 : 'a0 t * 'a1 t -> ('a0 * 'a1) t = "all" - [@@mel.val] [@@mel.scope "Promise"] +external resolve : 'a -> 'a t = "resolve" [@@mel.scope "Promise"] +external reject : exn -> 'a t = "reject" [@@mel.scope "Promise"] +external all : 'a t array -> 'a array t = "all" [@@mel.scope "Promise"] +external all2 : 'a0 t * 'a1 t -> ('a0 * 'a1) t = "all" [@@mel.scope "Promise"] external all3 : 'a0 t * 'a1 t * 'a2 t -> ('a0 * 'a1 * 'a2) t = "all" - [@@mel.val] [@@mel.scope "Promise"] +[@@mel.scope "Promise"] external all4 : 'a0 t * 'a1 t * 'a2 t * 'a3 t -> ('a0 * 'a1 * 'a2 * 'a3) t = "all" - [@@mel.val] [@@mel.scope "Promise"] +[@@mel.scope "Promise"] external all5 : 'a0 t * 'a1 t * 'a2 t * 'a3 t * 'a4 t -> ('a0 * 'a1 * 'a2 * 'a3 * 'a4) t = "all" - [@@mel.val] [@@mel.scope "Promise"] +[@@mel.scope "Promise"] external all6 : 'a0 t * 'a1 t * 'a2 t * 'a3 t * 'a4 t * 'a5 t -> ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5) t = "all" - [@@mel.val] [@@mel.scope "Promise"] +[@@mel.scope "Promise"] -external race : 'a t array -> 'a t = "race" [@@mel.val] [@@mel.scope "Promise"] +external race : 'a t array -> 'a t = "race" [@@mel.scope "Promise"] external then_ : (('a -> 'b t)[@mel.uncurry]) -> 'b t = "then" - [@@mel.send.pipe: 'a t] +[@@mel.send.pipe: 'a t] external catch : ((error -> 'a t)[@mel.uncurry]) -> 'a t = "catch" - [@@mel.send.pipe: 'a t] +[@@mel.send.pipe: 'a t] (* [ p|> catch handler] Note in JS the returned promise type is actually runtime dependent, if promise is rejected, it will pick the [handler] otherwise the original promise, diff --git a/jscomp/runtime/js_string.ml b/jscomp/runtime/js_string.ml index 2919eb7f58..4809831c7b 100644 --- a/jscomp/runtime/js_string.ml +++ b/jscomp/runtime/js_string.ml @@ -27,7 +27,7 @@ type t = string external make : 'a -> t = "String" - [@@mel.val] + (** [make value] converts the given value to a string {[ @@ -37,7 +37,7 @@ external make : 'a -> t = "String" *) external fromCharCode : int -> t = "String.fromCharCode" - [@@mel.val] + (** [fromCharCode n] creates a string containing the character corresponding to that number; {i n} ranges from 0 to 65535. If out of range, the lower 16 bits of the value are used. Thus, [fromCharCode 0x1F63A] gives the same result as [fromCharCode 0xF63A]. @@ -50,7 +50,7 @@ external fromCharCode : int -> t = "String.fromCharCode" *) external fromCharCodeMany : int array -> t = "String.fromCharCode" - [@@mel.val] [@@mel.splice] +[@@mel.splice] (** [fromCharCodeMany \[|n1;n2;n3|\]] creates a string from the characters corresponding to the given numbers, using the same rules as [fromCharCode]. {[ @@ -58,6 +58,7 @@ external fromCharCodeMany : int array -> t = "String.fromCharCode" ]} *) +external fromCodePoint : int -> t = "String.fromCodePoint" (** [fromCodePoint n] creates a string containing the character corresponding to that numeric code point. If the number is not a valid code point, {b raises} [RangeError]. Thus, [fromCodePoint 0x1F63A] will produce a correct value, unlike [fromCharCode 0x1F63A], and [fromCodePoint -5] will raise a [RangeError]. @@ -69,8 +70,7 @@ external fromCharCodeMany : int array -> t = "String.fromCharCode" ]} *) -external fromCodePoint : int -> t = "String.fromCodePoint" - [@@mel.val] + (** ES2015 *) (** [fromCharCodeMany \[|n1;n2;n3|\]] creates a string from the characters corresponding to the given code point numbers, using the same rules as [fromCodePoint]. @@ -80,13 +80,13 @@ external fromCodePoint : int -> t = "String.fromCodePoint" ]} *) external fromCodePointMany : int array -> t = "String.fromCodePoint" - [@@mel.val] [@@mel.splice] +[@@mel.splice] (** ES2015 *) (* String.raw: ES2015, meant to be used with template strings, not directly *) external length : t -> int = "length" - [@@mel.get] +[@@mel.get] (** [length s] returns the length of the given string. {[ @@ -96,7 +96,7 @@ external length : t -> int = "length" *) external get : t -> int -> t = "" - [@@mel.get_index] +[@@mel.get_index] (** [get s n] returns as a string the character at the given index number. If [n] is out of range, this function returns [undefined], so at some point this function may be modified to return [t option]. {[ @@ -107,7 +107,7 @@ external get : t -> int -> t = "" *) external charAt : int -> t = "charAt" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [charAt n s] gets the character at index [n] within string [s]. If [n] is negative or greater than the length of [s], returns the empty string. If the string contains characters outside the range [\u0000-\uffff], it will return the first 16-bit value at that position in the string. {[ @@ -118,7 +118,7 @@ external charAt : int -> t = "charAt" *) external charCodeAt : int -> float = "charCodeAt" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [charCodeAt n s] returns the character code at position [n] in string [s]; the result is in the range 0-65535, unlke [codePointAt], so it will not work correctly for characters with code points greater than or equal to [0x10000]. The return type is [float] because this function returns [NaN] if [n] is less than zero or greater than the length of the string. @@ -137,11 +137,11 @@ The return type is [float] because this function returns [NaN] if [n] is less th ]} *) external codePointAt : int -> int option = "codePointAt" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** ES2015 *) external concat : t -> t = "concat" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [concat append original] returns a new string with [append] added after [original]. {[ @@ -150,7 +150,7 @@ external concat : t -> t = "concat" *) external concatMany : t array -> t = "concat" - [@@mel.send.pipe: t] [@@mel.splice] +[@@mel.send.pipe: t] [@@mel.splice] (** [concat arr original] returns a new string consisting of each item of an array of strings added to the [original] string. {[ @@ -159,7 +159,7 @@ external concatMany : t array -> t = "concat" *) external endsWith : t -> bool = "endsWith" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** ES2015: [endsWith substr str] returns [true] if the [str] ends with [substr], [false] otherwise. @@ -180,7 +180,7 @@ external endsWith : t -> bool = "endsWith" ]} *) external endsWithFrom : t -> int -> bool = "endsWith" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** ES2015 *) (** @@ -194,7 +194,7 @@ external endsWithFrom : t -> int -> bool = "endsWith" ]} *) external includes : t -> bool = "includes" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** ES2015 *) (** @@ -207,11 +207,11 @@ external includes : t -> bool = "includes" ]} *) external includesFrom : t -> int -> bool = "includes" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** ES2015 *) external indexOf : t -> int = "indexOf" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [indexOf searchValue s] returns the position at which [searchValue] was first found within [s], or [-1] if [searchValue] is not in [s]. @@ -224,7 +224,7 @@ external indexOf : t -> int = "indexOf" *) external indexOfFrom : t -> int -> int = "indexOf" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [indexOfFrom searchValue start s] returns the position at which [searchValue] was found within [s] starting at character position [start], or [-1] if [searchValue] is not found in that portion of [s]. The return value is relative to the beginning of the string, no matter where the search started from. @@ -237,7 +237,7 @@ external indexOfFrom : t -> int -> int = "indexOf" *) external lastIndexOf : t -> int = "lastIndexOf" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [lastIndexOf searchValue s] returns the position of the {i last} occurrence of [searchValue] within [s], searching backwards from the end of the string. Returns [-1] if [searchValue] is not in [s]. The return value is always relative to the beginning of the string. @@ -249,7 +249,7 @@ external lastIndexOf : t -> int = "lastIndexOf" *) external lastIndexOfFrom : t -> int -> int = "lastIndexOf" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [lastIndexOfFrom searchValue start s] returns the position of the {i last} occurrence of [searchValue] within [s], searching backwards from the given [start] position. Returns [-1] if [searchValue] is not in [s]. The return value is always relative to the beginning of the string. @@ -264,7 +264,7 @@ external lastIndexOfFrom : t -> int -> int = "lastIndexOf" (* extended by ECMA-402 *) external localeCompare : t -> float = "localeCompare" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [localeCompare comparison reference] returns @@ -282,7 +282,7 @@ external localeCompare : t -> float = "localeCompare" *) external match_ : Js_re.t -> t option array option = "match" - [@@mel.send.pipe: t] [@@mel.return { null_to_opt }] +[@@mel.send.pipe: t] [@@mel.return { null_to_opt }] (** [match regexp str] matches a string against the given [regexp]. If there is no match, it returns [None]. For regular expressions without the [g] modifier, if there is a match, the return value is [Some array] where the array contains: @@ -311,11 +311,11 @@ Consider the character [ã], which can be represented as the single codepoint [\ @see Unicode technical report for details *) external normalize : t = "normalize" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** ES2015 *) external normalizeByForm : t -> t = "normalize" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [normalize str form] (ES2015) returns the normalized Unicode string using the specified form of normalization, which may be one of: @@ -338,11 +338,11 @@ external normalizeByForm : t -> t = "normalize" ]} *) external repeat : int -> t = "repeat" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** ES2015 *) external replace : t -> t -> t = "replace" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [replace substr newSubstr string] returns a new string which is identical to [string] except with the first matching instance of [substr] replaced by [newSubstr]. @@ -357,7 +357,7 @@ expression. *) external replaceByRe : Js_re.t -> t -> t = "replace" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [replaceByRe regex replacement string] returns a new string where occurrences matching [regex] have been replaced by [replacement]. @@ -369,7 +369,7 @@ have been replaced by [replacement]. external unsafeReplaceBy0 : Js_re.t -> ((t -> int -> t -> t)[@mel.uncurry]) -> t = "replace" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** returns a new string with some or all matches of a pattern with no capturing parentheses replaced by the value returned from the given function. The function receives as its parameters the matched string, the offset at which the @@ -391,7 +391,7 @@ let () = Js.log replaced (* prints "bEAUtifUl vOwEls" *) external unsafeReplaceBy1 : Js_re.t -> ((t -> t -> int -> t -> t)[@mel.uncurry]) -> t = "replace" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** returns a new string with some or all matches of a pattern with one set of capturing parentheses replaced by the value returned from the given function. The function receives as its parameters the matched string, the captured string, @@ -413,7 +413,7 @@ let () = Js.log replaced (* prints "increment 23 is 24" *) external unsafeReplaceBy2 : Js_re.t -> ((t -> t -> t -> int -> t -> t)[@mel.uncurry]) -> t = "replace" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** returns a new string with some or all matches of a pattern with two sets of capturing parentheses replaced by the value returned from the given function. The function receives as its parameters the matched string, the captured strings, @@ -436,7 +436,7 @@ let () = Js.log replaced (* prints "42" *) external unsafeReplaceBy3 : Js_re.t -> ((t -> t -> t -> t -> int -> t -> t)[@mel.uncurry]) -> t = "replace" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** returns a new string with some or all matches of a pattern with three sets of capturing parentheses replaced by the value returned from the given function. The function receives as its parameters the matched string, the captured strings, @@ -446,7 +446,7 @@ the offset at which the match begins, and the whole string being matched. *) external search : Js_re.t -> int = "search" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [search regexp str] returns the starting position of the first match of [regexp] in the given [str], or -1 if there is no match. {[ @@ -456,7 +456,7 @@ search [%re "/\\d+/"] "no numbers" = -1;; *) external slice : from:int -> to_:int -> t = "slice" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [slice from:n1 to_:n2 str] returns the substring of [str] starting at character [n1] up to but not including [n2] If either [n1] or [n2] is negative, then it is evaluated as [length str - n1] (or [length str - n2]. @@ -474,7 +474,7 @@ If [n1] is greater than [n2], [slice] returns the empty string. *) external sliceToEnd : from:int -> t = "slice" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [sliceToEnd from: n str] returns the substring of [str] starting at character [n] to the end of the string If [n] is negative, then it is evaluated as [length str - n]. @@ -489,7 +489,7 @@ If [n] is greater than the length of [str], then [sliceToEnd] returns the empty *) external split : t -> t array = "split" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [split delimiter str] splits the given [str] at every occurrence of [delimiter] and returns an array of the resulting substrings. @@ -503,7 +503,7 @@ external split : t -> t array = "split" *) external splitAtMost : t -> limit:int -> t array = "split" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [splitAtMost delimiter ~limit: n str] splits the given [str] at every occurrence of [delimiter] and returns an array of the first [n] resulting substrings. If [n] is negative or greater than the number of substrings, the array will contain all the substrings. @@ -515,13 +515,13 @@ external splitAtMost : t -> limit:int -> t array = "split" *) external splitLimited : t -> int -> t array = "split" - [@@mel.send.pipe: t] [@@deprecated "Please use splitAtMost"] +[@@mel.send.pipe: t] [@@deprecated "Please use splitAtMost"] (** Deprecated - Please use [splitAtMost] *) external splitByRe : Js_re.t -> t option array = "split" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [splitByRe regex str] splits the given [str] at every occurrence of [regex] and returns an array of the resulting substrings. @@ -534,7 +534,7 @@ external splitByRe : Js_re.t -> t option array = "split" *) external splitByReAtMost : Js_re.t -> limit:int -> t option array = "split" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [splitByReAtMost regex ~limit: n str] splits the given [str] at every occurrence of [regex] and returns an array of the first [n] resulting substrings. If [n] is negative or greater than the number of substrings, the array will contain all the substrings. @@ -548,13 +548,13 @@ external splitByReAtMost : Js_re.t -> limit:int -> t option array = "split" *) external splitRegexpLimited : Js_re.t -> int -> t array = "split" - [@@mel.send.pipe: t] [@@deprecated "Please use splitByReAtMost"] +[@@mel.send.pipe: t] [@@deprecated "Please use splitByReAtMost"] (** Deprecated - Please use [splitByReAtMost] *) external startsWith : t -> bool = "startsWith" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** ES2015: [startsWith substr str] returns [true] if the [str] starts with [substr], [false] otherwise. @@ -566,7 +566,7 @@ external startsWith : t -> bool = "startsWith" *) external startsWithFrom : t -> int -> bool = "startsWith" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** ES2015: [startsWithFrom substr n str] returns [true] if the [str] starts with [substr] starting at position [n], [false] otherwise. If [n] is negative, the search starts at the beginning of [str]. @@ -578,7 +578,7 @@ external startsWithFrom : t -> int -> bool = "startsWith" *) external substr : from:int -> t = "substr" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [substr ~from: n str] returns the substring of [str] from position [n] to the end of the string. @@ -594,7 +594,7 @@ external substr : from:int -> t = "substr" *) external substrAtMost : from:int -> length:int -> t = "substr" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [substrAtMost ~from: pos ~length: n str] returns the substring of [str] of length [n] starting at position [pos]. @@ -612,7 +612,7 @@ external substrAtMost : from:int -> length:int -> t = "substr" *) external substring : from:int -> to_:int -> t = "substring" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [substring ~from: start ~to_: finish str] returns characters [start] up to but not including [finish] from [str]. @@ -630,7 +630,7 @@ external substring : from:int -> to_:int -> t = "substring" *) external substringToEnd : from:int -> t = "substring" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [substringToEnd ~from: start str] returns the substring of [str] from position [start] to the end. @@ -646,7 +646,7 @@ external substringToEnd : from:int -> t = "substring" *) external toLowerCase : t = "toLowerCase" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [toLowerCase str] converts [str] to lower case using the locale-insensitive case mappings in the Unicode Character Database. Notice that the conversion can give different results depending upon context, for example with the Greek letter sigma, which has two different lower case forms when it is the last character in a string or not. @@ -658,13 +658,13 @@ external toLowerCase : t = "toLowerCase" *) external toLocaleLowerCase : t = "toLocaleLowerCase" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [toLocaleLowerCase str] converts [str] to lower case using the current locale *) external toUpperCase : t = "toUpperCase" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [toUpperCase str] converts [str] to upper case using the locale-insensitive case mappings in the Unicode Character Database. Notice that the conversion can expand the number of letters in the result; for example the German [ß] capitalizes to two [S]es in a row. @@ -676,13 +676,13 @@ external toUpperCase : t = "toUpperCase" *) external toLocaleUpperCase : t = "toLocaleUpperCase" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [toLocaleUpperCase str] converts [str] to upper case using the current locale *) external trim : t = "trim" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** [trim str] returns a string that is [str] with whitespace stripped from both ends. Internal whitespace is not removed. @@ -702,7 +702,7 @@ external trim : t = "trim" ]} *) external anchor : t -> t = "anchor" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** ES2015 *) (** @@ -713,11 +713,11 @@ external anchor : t -> t = "anchor" ]} *) external link : t -> t = "link" - [@@mel.send.pipe: t] +[@@mel.send.pipe: t] (** ES2015 *) external castToArrayLike : t -> t Js_array2.array_like = "%identity" (* FIXME: we should not encourage people to use [%identity], better - to provide something using [@@mel.val] so that we can track such + to provide something using so that we can track such casting *) diff --git a/jscomp/runtime/js_string2.ml b/jscomp/runtime/js_string2.ml index d41170a176..e3b843b5ea 100644 --- a/jscomp/runtime/js_string2.ml +++ b/jscomp/runtime/js_string2.ml @@ -27,7 +27,7 @@ type t = string external make : 'a -> t = "String" - [@@mel.val] + (** [make value] converts the given value to a string {[ @@ -37,7 +37,7 @@ external make : 'a -> t = "String" *) external fromCharCode : int -> t = "String.fromCharCode" - [@@mel.val] + (** [fromCharCode n] creates a string containing the character corresponding to that number; {i n} ranges from 0 to 65535. If out of range, the lower 16 bits of the value are used. Thus, [fromCharCode 0x1F63A] gives the same result as [fromCharCode 0xF63A]. @@ -50,7 +50,7 @@ external fromCharCode : int -> t = "String.fromCharCode" *) external fromCharCodeMany : int array -> t = "String.fromCharCode" - [@@mel.val] [@@mel.splice] +[@@mel.splice] (** [fromCharCodeMany \[|n1;n2;n3|\]] creates a string from the characters corresponding to the given numbers, using the same rules as [fromCharCode]. {[ @@ -58,6 +58,7 @@ external fromCharCodeMany : int array -> t = "String.fromCharCode" ]} *) +external fromCodePoint : int -> t = "String.fromCodePoint" (** [fromCodePoint n] creates a string containing the character corresponding to that numeric code point. If the number is not a valid code point, {b raises} [RangeError]. Thus, [fromCodePoint 0x1F63A] will produce a correct value, unlike [fromCharCode 0x1F63A], and [fromCodePoint -5] will raise a [RangeError]. @@ -69,8 +70,7 @@ external fromCharCodeMany : int array -> t = "String.fromCharCode" ]} *) -external fromCodePoint : int -> t = "String.fromCodePoint" - [@@mel.val] + (** ES2015 *) (** [fromCharCodeMany \[|n1;n2;n3|\]] creates a string from the characters corresponding to the given code point numbers, using the same rules as [fromCodePoint]. @@ -80,13 +80,13 @@ external fromCodePoint : int -> t = "String.fromCodePoint" ]} *) external fromCodePointMany : int array -> t = "String.fromCodePoint" - [@@mel.val] [@@mel.splice] +[@@mel.splice] (** ES2015 *) (* String.raw: ES2015, meant to be used with template strings, not directly *) external length : t -> int = "length" - [@@mel.get] +[@@mel.get] (** [length s] returns the length of the given string. {[ @@ -96,7 +96,7 @@ external length : t -> int = "length" *) external get : t -> int -> t = "" - [@@mel.get_index] +[@@mel.get_index] (** [get s n] returns as a string the character at the given index number. If [n] is out of range, this function returns [undefined], so at some point this function may be modified to return [t option]. {[ @@ -107,7 +107,7 @@ external get : t -> int -> t = "" *) external charAt : t -> int -> t = "charAt" - [@@mel.send] +[@@mel.send] (** [charAt n s] gets the character at index [n] within string [s]. If [n] is negative or greater than the length of [s], returns the empty string. If the string contains characters outside the range [\u0000-\uffff], it will return the first 16-bit value at that position in the string. {[ @@ -118,7 +118,7 @@ external charAt : t -> int -> t = "charAt" *) external charCodeAt : t -> int -> float = "charCodeAt" - [@@mel.send] +[@@mel.send] (** [charCodeAt n s] returns the character code at position [n] in string [s]; the result is in the range 0-65535, unlke [codePointAt], so it will not work correctly for characters with code points greater than or equal to [0x10000]. The return type is [float] because this function returns [NaN] if [n] is less than zero or greater than the length of the string. @@ -137,11 +137,11 @@ The return type is [float] because this function returns [NaN] if [n] is less th ]} *) external codePointAt : t -> int -> int option = "codePointAt" - [@@mel.send] +[@@mel.send] (** ES2015 *) external concat : t -> t -> t = "concat" - [@@mel.send] +[@@mel.send] (** [concat append original] returns a new string with [append] added after [original]. {[ @@ -150,7 +150,7 @@ external concat : t -> t -> t = "concat" *) external concatMany : t -> t array -> t = "concat" - [@@mel.send] [@@mel.splice] +[@@mel.send] [@@mel.splice] (** [concat arr original] returns a new string consisting of each item of an array of strings added to the [original] string. {[ @@ -159,7 +159,7 @@ external concatMany : t -> t array -> t = "concat" *) external endsWith : t -> t -> bool = "endsWith" - [@@mel.send] +[@@mel.send] (** ES2015: [endsWith substr str] returns [true] if the [str] ends with [substr], [false] otherwise. @@ -180,7 +180,7 @@ external endsWith : t -> t -> bool = "endsWith" ]} *) external endsWithFrom : t -> t -> int -> bool = "endsWith" - [@@mel.send] +[@@mel.send] (** ES2015 *) (** @@ -194,7 +194,7 @@ external endsWithFrom : t -> t -> int -> bool = "endsWith" ]} *) external includes : t -> t -> bool = "includes" - [@@mel.send] +[@@mel.send] (** ES2015 *) (** @@ -207,11 +207,11 @@ external includes : t -> t -> bool = "includes" ]} *) external includesFrom : t -> t -> int -> bool = "includes" - [@@mel.send] +[@@mel.send] (** ES2015 *) external indexOf : t -> t -> int = "indexOf" - [@@mel.send] +[@@mel.send] (** [indexOf searchValue s] returns the position at which [searchValue] was first found within [s], or [-1] if [searchValue] is not in [s]. @@ -224,7 +224,7 @@ external indexOf : t -> t -> int = "indexOf" *) external indexOfFrom : t -> t -> int -> int = "indexOf" - [@@mel.send] +[@@mel.send] (** [indexOfFrom searchValue start s] returns the position at which [searchValue] was found within [s] starting at character position [start], or [-1] if [searchValue] is not found in that portion of [s]. The return value is relative to the beginning of the string, no matter where the search started from. @@ -237,7 +237,7 @@ external indexOfFrom : t -> t -> int -> int = "indexOf" *) external lastIndexOf : t -> t -> int = "lastIndexOf" - [@@mel.send] +[@@mel.send] (** [lastIndexOf searchValue s] returns the position of the {i last} occurrence of [searchValue] within [s], searching backwards from the end of the string. Returns [-1] if [searchValue] is not in [s]. The return value is always relative to the beginning of the string. @@ -249,7 +249,7 @@ external lastIndexOf : t -> t -> int = "lastIndexOf" *) external lastIndexOfFrom : t -> t -> int -> int = "lastIndexOf" - [@@mel.send] +[@@mel.send] (** [lastIndexOfFrom searchValue start s] returns the position of the {i last} occurrence of [searchValue] within [s], searching backwards from the given [start] position. Returns [-1] if [searchValue] is not in [s]. The return value is always relative to the beginning of the string. @@ -264,7 +264,7 @@ external lastIndexOfFrom : t -> t -> int -> int = "lastIndexOf" (* extended by ECMA-402 *) external localeCompare : t -> t -> float = "localeCompare" - [@@mel.send] +[@@mel.send] (** [localeCompare comparison reference] returns @@ -282,7 +282,7 @@ external localeCompare : t -> t -> float = "localeCompare" *) external match_ : t -> Js_re.t -> t option array option = "match" - [@@mel.send] [@@mel.return { null_to_opt }] +[@@mel.send] [@@mel.return { null_to_opt }] (** [match regexp str] matches a string against the given [regexp]. If there is no match, it returns [None]. For regular expressions without the [g] modifier, if there is a match, the return value is [Some array] where the array contains: @@ -310,11 +310,11 @@ Consider the character [ã], which can be represented as the single codepoint [\ @see Unicode technical report for details *) external normalize : t -> t = "normalize" - [@@mel.send] +[@@mel.send] (** ES2015 *) external normalizeByForm : t -> t -> t = "normalize" - [@@mel.send] +[@@mel.send] (** [normalize str form] (ES2015) returns the normalized Unicode string using the specified form of normalization, which may be one of: @@ -337,11 +337,11 @@ external normalizeByForm : t -> t -> t = "normalize" ]} *) external repeat : t -> int -> t = "repeat" - [@@mel.send] +[@@mel.send] (** ES2015 *) external replace : t -> t -> t -> t = "replace" - [@@mel.send] +[@@mel.send] (** [replace substr newSubstr string] returns a new string which is identical to [string] except with the first matching instance of [substr] replaced by [newSubstr]. @@ -356,7 +356,7 @@ expression. *) external replaceByRe : t -> Js_re.t -> t -> t = "replace" - [@@mel.send] +[@@mel.send] (** [replaceByRe regex replacement string] returns a new string where occurrences matching [regex] have been replaced by [replacement]. @@ -368,7 +368,7 @@ have been replaced by [replacement]. external unsafeReplaceBy0 : t -> Js_re.t -> ((t -> int -> t -> t)[@mel.uncurry]) -> t = "replace" - [@@mel.send] +[@@mel.send] (** returns a new string with some or all matches of a pattern with no capturing parentheses replaced by the value returned from the given function. The function receives as its parameters the matched string, the offset at which the @@ -390,7 +390,7 @@ let () = Js.log replaced (* prints "bEAUtifUl vOwEls" *) external unsafeReplaceBy1 : t -> Js_re.t -> ((t -> t -> int -> t -> t)[@mel.uncurry]) -> t = "replace" - [@@mel.send] +[@@mel.send] (** returns a new string with some or all matches of a pattern with one set of capturing parentheses replaced by the value returned from the given function. The function receives as its parameters the matched string, the captured string, @@ -413,7 +413,7 @@ let () = Js.log replaced (* prints "increment 23 is 24" *) external unsafeReplaceBy2 : t -> Js_re.t -> ((t -> t -> t -> int -> t -> t)[@mel.uncurry]) -> t = "replace" - [@@mel.send] +[@@mel.send] (** returns a new string with some or all matches of a pattern with two sets of capturing parentheses replaced by the value returned from the given function. The function receives as its parameters the matched string, the captured strings, @@ -436,7 +436,7 @@ let () = Js.log replaced (* prints "42" *) external unsafeReplaceBy3 : t -> Js_re.t -> ((t -> t -> t -> t -> int -> t -> t)[@mel.uncurry]) -> t = "replace" - [@@mel.send] +[@@mel.send] (** returns a new string with some or all matches of a pattern with three sets of capturing parentheses replaced by the value returned from the given function. The function receives as its parameters the matched string, the captured strings, @@ -446,7 +446,7 @@ the offset at which the match begins, and the whole string being matched. *) external search : t -> Js_re.t -> int = "search" - [@@mel.send] +[@@mel.send] (** [search regexp str] returns the starting position of the first match of [regexp] in the given [str], or -1 if there is no match. {[ @@ -456,7 +456,7 @@ search "no numbers" [%re "/\\d+/"] = -1;; *) external slice : t -> from:int -> to_:int -> t = "slice" - [@@mel.send] +[@@mel.send] (** [slice from:n1 to_:n2 str] returns the substring of [str] starting at character [n1] up to but not including [n2] If either [n1] or [n2] is negative, then it is evaluated as [length str - n1] (or [length str - n2]. @@ -474,7 +474,7 @@ If [n1] is greater than [n2], [slice] returns the empty string. *) external sliceToEnd : t -> from:int -> t = "slice" - [@@mel.send] +[@@mel.send] (** [sliceToEnd from: n str] returns the substring of [str] starting at character [n] to the end of the string If [n] is negative, then it is evaluated as [length str - n]. @@ -489,7 +489,7 @@ If [n] is greater than the length of [str], then [sliceToEnd] returns the empty *) external split : t -> t -> t array = "split" - [@@mel.send] +[@@mel.send] (** [split delimiter str] splits the given [str] at every occurrence of [delimiter] and returns an array of the resulting substrings. @@ -503,7 +503,7 @@ external split : t -> t -> t array = "split" *) external splitAtMost : t -> t -> limit:int -> t array = "split" - [@@mel.send] +[@@mel.send] (** [splitAtMost delimiter ~limit: n str] splits the given [str] at every occurrence of [delimiter] and returns an array of the first [n] resulting substrings. If [n] is negative or greater than the number of substrings, the array will contain all the substrings. @@ -515,7 +515,7 @@ external splitAtMost : t -> t -> limit:int -> t array = "split" *) external splitByRe : t -> Js_re.t -> t option array = "split" - [@@mel.send] +[@@mel.send] (** [splitByRe regex str] splits the given [str] at every occurrence of [regex] and returns an array of the resulting substrings. @@ -527,7 +527,7 @@ external splitByRe : t -> Js_re.t -> t option array = "split" *) external splitByReAtMost : t -> Js_re.t -> limit:int -> t option array = "split" - [@@mel.send] +[@@mel.send] (** [splitByReAtMost regex ~limit: n str] splits the given [str] at every occurrence of [regex] and returns an array of the first [n] resulting substrings. If [n] is negative or greater than the number of substrings, the array will contain all the substrings. @@ -540,7 +540,7 @@ external splitByReAtMost : t -> Js_re.t -> limit:int -> t option array = "split" *) external startsWith : t -> t -> bool = "startsWith" - [@@mel.send] +[@@mel.send] (** ES2015: [startsWith substr str] returns [true] if the [str] starts with [substr], [false] otherwise. @@ -552,7 +552,7 @@ external startsWith : t -> t -> bool = "startsWith" *) external startsWithFrom : t -> t -> int -> bool = "startsWith" - [@@mel.send] +[@@mel.send] (** ES2015: [startsWithFrom substr n str] returns [true] if the [str] starts with [substr] starting at position [n], [false] otherwise. If [n] is negative, the search starts at the beginning of [str]. @@ -564,7 +564,7 @@ external startsWithFrom : t -> t -> int -> bool = "startsWith" *) external substr : t -> from:int -> t = "substr" - [@@mel.send] +[@@mel.send] (** [substr ~from: n str] returns the substring of [str] from position [n] to the end of the string. @@ -580,7 +580,7 @@ external substr : t -> from:int -> t = "substr" *) external substrAtMost : t -> from:int -> length:int -> t = "substr" - [@@mel.send] +[@@mel.send] (** [substrAtMost ~from: pos ~length: n str] returns the substring of [str] of length [n] starting at position [pos]. @@ -598,7 +598,7 @@ external substrAtMost : t -> from:int -> length:int -> t = "substr" *) external substring : t -> from:int -> to_:int -> t = "substring" - [@@mel.send] +[@@mel.send] (** [substring ~from: start ~to_: finish str] returns characters [start] up to but not including [finish] from [str]. @@ -616,7 +616,7 @@ external substring : t -> from:int -> to_:int -> t = "substring" *) external substringToEnd : t -> from:int -> t = "substring" - [@@mel.send] +[@@mel.send] (** [substringToEnd ~from: start str] returns the substring of [str] from position [start] to the end. @@ -632,7 +632,7 @@ external substringToEnd : t -> from:int -> t = "substring" *) external toLowerCase : t -> t = "toLowerCase" - [@@mel.send] +[@@mel.send] (** [toLowerCase str] converts [str] to lower case using the locale-insensitive case mappings in the Unicode Character Database. Notice that the conversion can give different results depending upon context, for example with the Greek letter sigma, which has two different lower case forms when it is the last character in a string or not. @@ -644,13 +644,13 @@ external toLowerCase : t -> t = "toLowerCase" *) external toLocaleLowerCase : t -> t = "toLocaleLowerCase" - [@@mel.send] +[@@mel.send] (** [toLocaleLowerCase str] converts [str] to lower case using the current locale *) external toUpperCase : t -> t = "toUpperCase" - [@@mel.send] +[@@mel.send] (** [toUpperCase str] converts [str] to upper case using the locale-insensitive case mappings in the Unicode Character Database. Notice that the conversion can expand the number of letters in the result; for example the German [ß] capitalizes to two [S]es in a row. @@ -662,13 +662,13 @@ external toUpperCase : t -> t = "toUpperCase" *) external toLocaleUpperCase : t -> t = "toLocaleUpperCase" - [@@mel.send] +[@@mel.send] (** [toLocaleUpperCase str] converts [str] to upper case using the current locale *) external trim : t -> t = "trim" - [@@mel.send] +[@@mel.send] (** [trim str] returns a string that is [str] with whitespace stripped from both ends. Internal whitespace is not removed. @@ -688,7 +688,7 @@ external trim : t -> t = "trim" ]} *) external anchor : t -> t -> t = "anchor" - [@@mel.send] +[@@mel.send] (** ES2015 *) (** @@ -699,11 +699,11 @@ external anchor : t -> t -> t = "anchor" ]} *) external link : t -> t -> t = "link" - [@@mel.send] +[@@mel.send] (** ES2015 *) external castToArrayLike : t -> t Js_array2.array_like = "%identity" (* FIXME: we should not encourage people to use [%identity], better - to provide something using [@@mel.val] so that we can track such + to provide something using so that we can track such casting *) diff --git a/jscomp/runtime/js_typed_array.cppo.ml b/jscomp/runtime/js_typed_array.cppo.ml index f662a81b00..1734fd6bcc 100644 --- a/jscomp/runtime/js_typed_array.cppo.ml +++ b/jscomp/runtime/js_typed_array.cppo.ml @@ -48,8 +48,8 @@ module ArrayBuffer = struct (* ArrayBuffer.isView: seems pointless with a type system *) (* experimental - external transfer : array_buffer -> t = "ArrayBuffer.transfer" [@@mel.val] - external transferWithLength : array_buffer -> int -> t = "ArrayBuffer.transfer" [@@mel.val] + external transfer : array_buffer -> t = "ArrayBuffer.transfer" + external transferWithLength : array_buffer -> int -> t = "ArrayBuffer.transfer" *) external byteLength : t -> int = "byteLength" [@@mel.get] @@ -263,7 +263,7 @@ end external some : (elt -> bool [@u]) -> bool = "some" [@@mel.send.pipe: t]\ external somei : (elt -> int -> bool [@u]) -> bool = "some" [@@mel.send.pipe: t]\ \ - external _BYTES_PER_ELEMENT: int = STRINGIFY(moduleName.BYTES_PER_ELEMENT) [@@mel.val]\ + external _BYTES_PER_ELEMENT: int = STRINGIFY(moduleName.BYTES_PER_ELEMENT) \ \ external make : elt array -> t = STRINGIFY(moduleName) [@@mel.new]\ external fromBuffer : array_buffer -> t = STRINGIFY(moduleName) [@@mel.new]\ @@ -278,7 +278,7 @@ end @param offset is in bytes, length in elements *)\ \ external fromLength : int -> t = STRINGIFY(moduleName) [@@mel.new]\ - external from : elt array_like -> t = STRINGIFY(moduleName.from) [@@mel.val]\ + external from : elt array_like -> t = STRINGIFY(moduleName.from) \ (* *Array.of is redundant, use make *) (* commented out until bs has a plan for iterators diff --git a/jscomp/runtime/js_typed_array2.cppo.ml b/jscomp/runtime/js_typed_array2.cppo.ml index cc84a4705b..476ee6431c 100644 --- a/jscomp/runtime/js_typed_array2.cppo.ml +++ b/jscomp/runtime/js_typed_array2.cppo.ml @@ -43,8 +43,8 @@ module ArrayBuffer = struct (* ArrayBuffer.isView: seems pointless with a type system *) (* experimental - external transfer : array_buffer -> t = "ArrayBuffer.transfer" [@@mel.val] - external transferWithLength : array_buffer -> int -> t = "ArrayBuffer.transfer" [@@mel.val] + external transfer : array_buffer -> t = "ArrayBuffer.transfer" + external transferWithLength : array_buffer -> int -> t = "ArrayBuffer.transfer" *) external byteLength : t -> int = "byteLength" [@@mel.get] @@ -153,7 +153,7 @@ end external some : t -> (elt -> bool [@u]) -> bool = "some" [@@mel.send]\ external somei : t -> (elt -> int -> bool [@u]) -> bool = "some" [@@mel.send]\ \ - external _BYTES_PER_ELEMENT: int = STRINGIFY(moduleName.BYTES_PER_ELEMENT) [@@mel.val]\ + external _BYTES_PER_ELEMENT: int = STRINGIFY(moduleName.BYTES_PER_ELEMENT) \ \ external make : elt array -> t = STRINGIFY(moduleName) [@@mel.new]\ external fromBuffer : array_buffer -> t = STRINGIFY(moduleName) [@@mel.new]\ @@ -168,7 +168,7 @@ end @param offset is in bytes, length in elements *)\ \ external fromLength : int -> t = STRINGIFY(moduleName) [@@mel.new]\ - external from : elt array_like -> t = STRINGIFY(moduleName.from) [@@mel.val]\ + external from : elt array_like -> t = STRINGIFY(moduleName.from) \ (* *Array.of is redundant, use make *) (* commented out until bs has a plan for iterators diff --git a/jscomp/runtime/melange_mini_stdlib.ml b/jscomp/runtime/melange_mini_stdlib.ml index 7d35843266..2213cca7f1 100644 --- a/jscomp/runtime/melange_mini_stdlib.ml +++ b/jscomp/runtime/melange_mini_stdlib.ml @@ -43,10 +43,7 @@ external raise : exn -> 'a = "%raise" external ignore : 'a -> unit = "%ignore" external ( |> ) : 'a -> ('a -> 'b) -> 'b = "%revapply" external ( @@ ) : ('a -> 'b) -> 'a -> 'b = "%apply" - -external ( ** ) : float -> float -> float = "pow" - [@@mel.val] [@@mel.scope "Math"] - +external ( ** ) : float -> float -> float = "pow" [@@mel.scope "Math"] external ( ~-. ) : float -> float = "%negfloat" external ( +. ) : float -> float -> float = "%addfloat" external ( -. ) : float -> float -> float = "%subfloat" diff --git a/jscomp/stdlib/float.cppo.ml b/jscomp/stdlib/float.cppo.ml index ffd87836ed..ae8f9101e2 100644 --- a/jscomp/stdlib/float.cppo.ml +++ b/jscomp/stdlib/float.cppo.ml @@ -24,7 +24,7 @@ external rem : float -> float -> float = "caml_fmod_float" "fmod" external fma : float -> float -> float -> float = "caml_fma_float" "caml_fma" [@@unboxed] [@@noalloc] #ifdef BS -external abs : float -> float = "abs"[@@mel.val] [@@mel.scope "Math"] +external abs : float -> float = "abs" [@@mel.scope "Math"] #else external abs : float -> float = "%absfloat" #endif @@ -63,34 +63,34 @@ external classify_float : (float [@unboxed]) -> fpclass = "caml_classify_float" "caml_classify_float_unboxed" [@@noalloc] #ifdef BS -external pow : float -> float -> float = "pow" [@@mel.val] [@@mel.scope "Math"] -external sqrt : float -> float = "sqrt" [@@mel.val] [@@mel.scope "Math"] -external cbrt : float -> float = "cbrt" [@@mel.val] [@@mel.scope "Math"] -external exp : float -> float = "exp" [@@mel.val][@@mel.scope "Math"] +external pow : float -> float -> float = "pow" [@@mel.scope "Math"] +external sqrt : float -> float = "sqrt" [@@mel.scope "Math"] +external cbrt : float -> float = "cbrt" [@@mel.scope "Math"] +external exp : float -> float = "exp" [@@mel.scope "Math"] external exp2 : float -> float = "caml_exp2_float" "caml_exp2" [@@unboxed] [@@noalloc] -external log : float -> float = "log" [@@mel.val] [@@mel.scope "Math"] -external log10 : float -> float = "log10"[@@mel.val] [@@mel.scope "Math"] +external log : float -> float = "log" [@@mel.scope "Math"] +external log10 : float -> float = "log10" [@@mel.scope "Math"] external log2 : float -> float = "caml_log2_float" "caml_log2" [@@unboxed] [@@noalloc] external expm1 : float -> float = "caml_expm1_float" "caml_expm1" [@@unboxed] [@@noalloc] -external log1p : float -> float = "log1p" [@@mel.val] [@@mel.scope "Math"] -external cos : float -> float = "cos" [@@mel.val] [@@mel.scope "Math"] -external sin : float -> float = "sin" [@@mel.val] [@@mel.scope "Math"] -external tan : float -> float = "tan" [@@mel.val] [@@mel.scope "Math"] -external acos : float -> float = "acos" [@@mel.val] [@@mel.scope "Math"] -external asin : float -> float = "asin" [@@mel.val] [@@mel.scope "Math"] -external atan : float -> float = "atan" [@@mel.val] [@@mel.scope "Math"] -external atan2 : float -> float -> float = "atan2" [@@mel.val] [@@mel.scope "Math"] +external log1p : float -> float = "log1p" [@@mel.scope "Math"] +external cos : float -> float = "cos" [@@mel.scope "Math"] +external sin : float -> float = "sin" [@@mel.scope "Math"] +external tan : float -> float = "tan" [@@mel.scope "Math"] +external acos : float -> float = "acos" [@@mel.scope "Math"] +external asin : float -> float = "asin" [@@mel.scope "Math"] +external atan : float -> float = "atan" [@@mel.scope "Math"] +external atan2 : float -> float -> float = "atan2" [@@mel.scope "Math"] external hypot : float -> float -> float = "caml_hypot_float" "caml_hypot" [@@unboxed] [@@noalloc] -external cosh : float -> float = "cosh" [@@mel.val] [@@mel.scope "Math"] -external sinh : float -> float = "sinh" [@@mel.val] [@@mel.scope "Math"] -external tanh : float -> float = "tanh" [@@mel.val] [@@mel.scope "Math"] -external acosh : float -> float = "acosh" [@@mel.val] [@@mel.scope "Math"] -external asinh : float -> float = "asinh" [@@mel.val] [@@mel.scope "Math"] -external atanh : float -> float = "atanh" [@@mel.val] [@@mel.scope "Math"] +external cosh : float -> float = "cosh" [@@mel.scope "Math"] +external sinh : float -> float = "sinh" [@@mel.scope "Math"] +external tanh : float -> float = "tanh" [@@mel.scope "Math"] +external acosh : float -> float = "acosh" [@@mel.scope "Math"] +external asinh : float -> float = "asinh" [@@mel.scope "Math"] +external atanh : float -> float = "atanh" [@@mel.scope "Math"] external erf : float -> float = "caml_erf_float" "caml_erf" [@@unboxed] [@@noalloc] external erfc : float -> float = "caml_erfc_float" "caml_erfc" diff --git a/jscomp/stdlib/float.cppo.mli b/jscomp/stdlib/float.cppo.mli index 5ea8b8658a..6f395cbee5 100644 --- a/jscomp/stdlib/float.cppo.mli +++ b/jscomp/stdlib/float.cppo.mli @@ -98,7 +98,7 @@ val pred : float -> float @since 4.08 *) #ifdef BS -external abs : float -> float = "abs"[@@mel.val] [@@mel.scope "Math"] +external abs : float -> float = "abs" [@@mel.scope "Math"] #else external abs : float -> float = "%absfloat" #endif @@ -218,7 +218,7 @@ external classify_float : (float [@unboxed]) -> fpclass = normal, subnormal, zero, infinite, or not a number. *) #ifdef BS -external pow : float -> float -> float = "pow" [@@mel.val] [@@mel.scope "Math"] +external pow : float -> float -> float = "pow" [@@mel.scope "Math"] #else external pow : float -> float -> float = "caml_power_float" "pow" [@@unboxed] [@@noalloc] @@ -226,7 +226,7 @@ external pow : float -> float -> float = "caml_power_float" "pow" (** Exponentiation. *) #ifdef BS -external sqrt : float -> float = "sqrt" [@@mel.val] [@@mel.scope "Math"] +external sqrt : float -> float = "sqrt" [@@mel.scope "Math"] #else external sqrt : float -> float = "caml_sqrt_float" "sqrt" [@@unboxed] [@@noalloc] @@ -234,7 +234,7 @@ external sqrt : float -> float = "caml_sqrt_float" "sqrt" (** Square root. *) #ifdef BS -external cbrt : float -> float = "cbrt" [@@mel.val] [@@mel.scope "Math"] +external cbrt : float -> float = "cbrt" [@@mel.scope "Math"] #else external cbrt : float -> float = "caml_cbrt_float" "caml_cbrt" [@@unboxed] [@@noalloc] @@ -245,7 +245,7 @@ external cbrt : float -> float = "caml_cbrt_float" "caml_cbrt" *) #ifdef BS -external exp : float -> float = "exp" [@@mel.val][@@mel.scope "Math"] +external exp : float -> float = "exp" [@@mel.scope "Math"] #else external exp : float -> float = "caml_exp_float" "exp" [@@unboxed] [@@noalloc] #endif @@ -259,14 +259,14 @@ external exp2 : float -> float = "caml_exp2_float" "caml_exp2" *) #ifdef BS -external log : float -> float = "log" [@@mel.val] [@@mel.scope "Math"] +external log : float -> float = "log" [@@mel.scope "Math"] #else external log : float -> float = "caml_log_float" "log" [@@unboxed] [@@noalloc] #endif (** Natural logarithm. *) #ifdef BS -external log10 : float -> float = "log10"[@@mel.val] [@@mel.scope "Math"] +external log10 : float -> float = "log10" [@@mel.scope "Math"] #else external log10 : float -> float = "caml_log10_float" "log10" [@@unboxed] [@@noalloc] @@ -286,7 +286,7 @@ external expm1 : float -> float = "caml_expm1_float" "caml_expm1" even if [x] is close to [0.0]. *) #ifdef BS -external log1p : float -> float = "log1p" [@@mel.val] [@@mel.scope "Math"] +external log1p : float -> float = "log1p" [@@mel.scope "Math"] #else external log1p : float -> float = "caml_log1p_float" "caml_log1p" [@@unboxed] [@@noalloc] @@ -295,28 +295,28 @@ external log1p : float -> float = "caml_log1p_float" "caml_log1p" giving numerically-accurate results even if [x] is close to [0.0]. *) #ifdef BS -external cos : float -> float = "cos" [@@mel.val] [@@mel.scope "Math"] +external cos : float -> float = "cos" [@@mel.scope "Math"] #else external cos : float -> float = "caml_cos_float" "cos" [@@unboxed] [@@noalloc] #endif (** Cosine. Argument is in radians. *) #ifdef BS -external sin : float -> float = "sin" [@@mel.val] [@@mel.scope "Math"] +external sin : float -> float = "sin" [@@mel.scope "Math"] #else external sin : float -> float = "caml_sin_float" "sin" [@@unboxed] [@@noalloc] #endif (** Sine. Argument is in radians. *) #ifdef BS -external tan : float -> float = "tan" [@@mel.val] [@@mel.scope "Math"] +external tan : float -> float = "tan" [@@mel.scope "Math"] #else external tan : float -> float = "caml_tan_float" "tan" [@@unboxed] [@@noalloc] #endif (** Tangent. Argument is in radians. *) #ifdef BS -external acos : float -> float = "acos" [@@mel.val] [@@mel.scope "Math"] +external acos : float -> float = "acos" [@@mel.scope "Math"] #else external acos : float -> float = "caml_acos_float" "acos" [@@unboxed] [@@noalloc] @@ -325,7 +325,7 @@ external acos : float -> float = "caml_acos_float" "acos" Result is in radians and is between [0.0] and [pi]. *) #ifdef BS -external asin : float -> float = "asin" [@@mel.val] [@@mel.scope "Math"] +external asin : float -> float = "asin" [@@mel.scope "Math"] #else external asin : float -> float = "caml_asin_float" "asin" [@@unboxed] [@@noalloc] @@ -334,7 +334,7 @@ external asin : float -> float = "caml_asin_float" "asin" Result is in radians and is between [-pi/2] and [pi/2]. *) #ifdef BS -external atan : float -> float = "atan" [@@mel.val] [@@mel.scope "Math"] +external atan : float -> float = "atan" [@@mel.scope "Math"] #else external atan : float -> float = "caml_atan_float" "atan" [@@unboxed] [@@noalloc] @@ -343,7 +343,7 @@ external atan : float -> float = "caml_atan_float" "atan" Result is in radians and is between [-pi/2] and [pi/2]. *) #ifdef BS -external atan2 : float -> float -> float = "atan2" [@@mel.val] [@@mel.scope "Math"] +external atan2 : float -> float -> float = "atan2" [@@mel.scope "Math"] #else external atan2 : float -> float -> float = "caml_atan2_float" "atan2" [@@unboxed] [@@noalloc] @@ -361,7 +361,7 @@ external hypot : float -> float -> float = "caml_hypot_float" "caml_hypot" even if the other is [nan]. *) #ifdef BS -external cosh : float -> float = "cosh" [@@mel.val] [@@mel.scope "Math"] +external cosh : float -> float = "cosh" [@@mel.scope "Math"] #else external cosh : float -> float = "caml_cosh_float" "cosh" [@@unboxed] [@@noalloc] @@ -369,7 +369,7 @@ external cosh : float -> float = "caml_cosh_float" "cosh" (** Hyperbolic cosine. Argument is in radians. *) #ifdef BS -external sinh : float -> float = "sinh" [@@mel.val] [@@mel.scope "Math"] +external sinh : float -> float = "sinh" [@@mel.scope "Math"] #else external sinh : float -> float = "caml_sinh_float" "sinh" [@@unboxed] [@@noalloc] @@ -377,7 +377,7 @@ external sinh : float -> float = "caml_sinh_float" "sinh" (** Hyperbolic sine. Argument is in radians. *) #ifdef BS -external tanh : float -> float = "tanh" [@@mel.val] [@@mel.scope "Math"] +external tanh : float -> float = "tanh" [@@mel.scope "Math"] #else external tanh : float -> float = "caml_tanh_float" "tanh" [@@unboxed] [@@noalloc] @@ -385,7 +385,7 @@ external tanh : float -> float = "caml_tanh_float" "tanh" (** Hyperbolic tangent. Argument is in radians. *) #ifdef BS -external acosh : float -> float = "acosh" [@@mel.val] [@@mel.scope "Math"] +external acosh : float -> float = "acosh" [@@mel.scope "Math"] #else external acosh : float -> float = "caml_acosh_float" "caml_acosh" [@@unboxed] [@@noalloc] @@ -398,7 +398,7 @@ external acosh : float -> float = "caml_acosh_float" "caml_acosh" *) #ifdef BS -external asinh : float -> float = "asinh" [@@mel.val] [@@mel.scope "Math"] +external asinh : float -> float = "asinh" [@@mel.scope "Math"] #else external asinh : float -> float = "caml_asinh_float" "caml_asinh" [@@unboxed] [@@noalloc] @@ -411,7 +411,7 @@ external asinh : float -> float = "caml_asinh_float" "caml_asinh" *) #ifdef BS -external atanh : float -> float = "atanh" [@@mel.val] [@@mel.scope "Math"] +external atanh : float -> float = "atanh" [@@mel.scope "Math"] #else external atanh : float -> float = "caml_atanh_float" "caml_atanh" [@@unboxed] [@@noalloc] diff --git a/jscomp/stdlib/stdlib.cppo.ml b/jscomp/stdlib/stdlib.cppo.ml index 11b7592d45..3a5dd89c65 100644 --- a/jscomp/stdlib/stdlib.cppo.ml +++ b/jscomp/stdlib/stdlib.cppo.ml @@ -128,8 +128,8 @@ external ( *. ) : float -> float -> float = "%mulfloat" external ( /. ) : float -> float -> float = "%divfloat" #ifdef BS -external ( ** ) : float -> float -> float = "pow" [@@mel.val] [@@mel.scope "Math"] -external exp : float -> float = "exp" [@@mel.val][@@mel.scope "Math"] +external ( ** ) : float -> float -> float = "pow" [@@mel.scope "Math"] +external exp : float -> float = "exp" [@@mel.scope "Math"] #else external ( ** ) : float -> float -> float = "caml_power_float" "pow" [@@unboxed] [@@noalloc] @@ -139,10 +139,10 @@ external expm1 : float -> float = "caml_expm1_float" "caml_expm1" [@@unboxed] [@@noalloc] #ifdef BS -external acos : float -> float = "acos" [@@mel.val] [@@mel.scope "Math"] -external asin : float -> float = "asin" [@@mel.val] [@@mel.scope "Math"] -external atan : float -> float = "atan" [@@mel.val] [@@mel.scope "Math"] -external atan2 : float -> float -> float = "atan2" [@@mel.val] [@@mel.scope "Math"] +external acos : float -> float = "acos" [@@mel.scope "Math"] +external asin : float -> float = "asin" [@@mel.scope "Math"] +external atan : float -> float = "atan" [@@mel.scope "Math"] +external atan2 : float -> float -> float = "atan2" [@@mel.scope "Math"] #else external acos : float -> float = "caml_acos_float" "acos" [@@unboxed] [@@noalloc] @@ -157,22 +157,22 @@ external hypot : float -> float -> float = "caml_hypot_float" "caml_hypot" [@@unboxed] [@@noalloc] #ifdef BS -external cos : float -> float = "cos" [@@mel.val] [@@mel.scope "Math"] -external cosh : float -> float = "cosh" [@@mel.val] [@@mel.scope "Math"] -external acosh : float -> float = "acosh" [@@mel.val] [@@mel.scope "Math"] -external log : float -> float = "log" [@@mel.val] [@@mel.scope "Math"] -external log10 : float -> float = "log10"[@@mel.val] [@@mel.scope "Math"] -external log1p : float -> float = "log1p" [@@mel.val] [@@mel.scope "Math"] -external sin : float -> float = "sin" [@@mel.val] [@@mel.scope "Math"] -external sinh : float -> float = "sinh" [@@mel.val] [@@mel.scope "Math"] -external asinh : float -> float = "asinh" [@@mel.val] [@@mel.scope "Math"] -external sqrt : float -> float = "sqrt" [@@mel.val] [@@mel.scope "Math"] -external tan : float -> float = "tan" [@@mel.val] [@@mel.scope "Math"] -external tanh : float -> float = "tanh" [@@mel.val] [@@mel.scope "Math"] -external atanh : float -> float = "atanh" [@@mel.val] [@@mel.scope "Math"] -external ceil : float -> float = "ceil" [@@mel.val] [@@mel.scope "Math"] -external floor : float -> float = "floor" [@@mel.val] [@@mel.scope "Math"] -external abs_float : float -> float = "abs"[@@mel.val] [@@mel.scope "Math"] +external cos : float -> float = "cos" [@@mel.scope "Math"] +external cosh : float -> float = "cosh" [@@mel.scope "Math"] +external acosh : float -> float = "acosh" [@@mel.scope "Math"] +external log : float -> float = "log" [@@mel.scope "Math"] +external log10 : float -> float = "log10" [@@mel.scope "Math"] +external log1p : float -> float = "log1p" [@@mel.scope "Math"] +external sin : float -> float = "sin" [@@mel.scope "Math"] +external sinh : float -> float = "sinh" [@@mel.scope "Math"] +external asinh : float -> float = "asinh" [@@mel.scope "Math"] +external sqrt : float -> float = "sqrt" [@@mel.scope "Math"] +external tan : float -> float = "tan" [@@mel.scope "Math"] +external tanh : float -> float = "tanh" [@@mel.scope "Math"] +external atanh : float -> float = "atanh" [@@mel.scope "Math"] +external ceil : float -> float = "ceil" [@@mel.scope "Math"] +external floor : float -> float = "floor" [@@mel.scope "Math"] +external abs_float : float -> float = "abs" [@@mel.scope "Math"] #else external cos : float -> float = "caml_cos_float" "cos" [@@unboxed] [@@noalloc] external cosh : float -> float = "caml_cosh_float" "cosh" @@ -230,7 +230,7 @@ external float_of_bits : int64 -> float let infinity = 0x1p2047 let neg_infinity = -0x1p2047 external nan : float = "NaN" -[@@mel.val] [@@mel.scope "Number"] + [@@mel.scope "Number"] let max_float = 1.79769313486231571e+308 (*0x1.ffff_ffff_ffff_fp+1023*) let min_float = 2.22507385850720138e-308 (* 0x1p-1022 *) let epsilon_float = 2.22044604925031308e-16 (* 0x1p-52 *) @@ -348,7 +348,7 @@ let bool_of_string_opt = function | _ -> None #ifdef BS -external string_of_int : int -> string = "String" [@@mel.val] +external string_of_int : int -> string = "String" #else let string_of_int n = format_int "%d" n @@ -580,7 +580,7 @@ let print_float f = output_string stdout (string_of_float f) #ifdef BS external print_endline : string -> unit = "log" -[@@mel.val] [@@mel.scope "console"] + [@@mel.scope "console"] #else let print_endline s = output_string stdout s; output_char stdout '\n'; flush stdout @@ -596,7 +596,7 @@ let prerr_int i = output_string stderr (string_of_int i) let prerr_float f = output_string stderr (string_of_float f) #ifdef BS external prerr_endline : string -> unit = "error" -[@@mel.val] [@@mel.scope "console"] + [@@mel.scope "console"] #else let prerr_endline s = output_string stderr s; output_char stderr '\n'; flush stderr diff --git a/jscomp/stdlib/stdlib.cppo.mli b/jscomp/stdlib/stdlib.cppo.mli index 1ff223398f..f64765f939 100644 --- a/jscomp/stdlib/stdlib.cppo.mli +++ b/jscomp/stdlib/stdlib.cppo.mli @@ -473,19 +473,19 @@ external ( /. ) : float -> float -> float = "%divfloat" *) #ifdef BS -external ( ** ) : float -> float -> float = "pow" [@@mel.val] [@@mel.scope "Math"] +external ( ** ) : float -> float -> float = "pow" [@@mel.scope "Math"] (** Exponentiation. *) -external sqrt : float -> float = "sqrt" [@@mel.val] [@@mel.scope "Math"] +external sqrt : float -> float = "sqrt" [@@mel.scope "Math"] (** Square root. *) -external exp : float -> float = "exp" [@@mel.val] [@@mel.scope "Math"] +external exp : float -> float = "exp" [@@mel.scope "Math"] (** Exponential. *) -external log : float -> float = "log" [@@mel.val] [@@mel.scope "Math"] +external log : float -> float = "log" [@@mel.scope "Math"] (** Natural logarithm. *) -external log10 : float -> float = "log10" [@@mel.val] [@@mel.scope "Math"] +external log10 : float -> float = "log10" [@@mel.scope "Math"] (** Base 10 logarithm. *) external expm1 : float -> float = "caml_expm1_float" "caml_expm1" [@@unboxed] [@@noalloc] @@ -494,34 +494,34 @@ external expm1 : float -> float = "caml_expm1_float" "caml_expm1" [@@unboxed] [@ @since 3.12.0 *) -external log1p : float -> float = "log1p" [@@mel.val] [@@mel.scope "Math"] +external log1p : float -> float = "log1p" [@@mel.scope "Math"] (** [log1p x] computes [log(1.0 +. x)] (natural logarithm), giving numerically-accurate results even if [x] is close to [0.0]. @since 3.12.0 *) -external cos : float -> float = "cos" [@@mel.val] [@@mel.scope "Math"] +external cos : float -> float = "cos" [@@mel.scope "Math"] (** Cosine. Argument is in radians. *) -external sin : float -> float = "sin" [@@mel.val] [@@mel.scope "Math"] +external sin : float -> float = "sin" [@@mel.scope "Math"] (** Sine. Argument is in radians. *) -external tan : float -> float = "tan" [@@mel.val] [@@mel.scope "Math"] +external tan : float -> float = "tan" [@@mel.scope "Math"] (** Tangent. Argument is in radians. *) -external acos : float -> float = "acos" [@@mel.val] [@@mel.scope "Math"] +external acos : float -> float = "acos" [@@mel.scope "Math"] (** Arc cosine. The argument must fall within the range [[-1.0, 1.0]]. Result is in radians and is between [0.0] and [pi]. *) -external asin : float -> float = "asin" [@@mel.val] [@@mel.scope "Math"] +external asin : float -> float = "asin" [@@mel.scope "Math"] (** Arc sine. The argument must fall within the range [[-1.0, 1.0]]. Result is in radians and is between [-pi/2] and [pi/2]. *) -external atan : float -> float = "atan" [@@mel.val] [@@mel.scope "Math"] +external atan : float -> float = "atan" [@@mel.scope "Math"] (** Arc tangent. Result is in radians and is between [-pi/2] and [pi/2]. *) -external atan2 : float -> float -> float = "atan2" [@@mel.val] [@@mel.scope "Math"] +external atan2 : float -> float -> float = "atan2" [@@mel.scope "Math"] (** [atan2 y x] returns the arc tangent of [y /. x]. The signs of [x] and [y] are used to determine the quadrant of the result. Result is in radians and is between [-pi] and [pi]. *) @@ -534,48 +534,48 @@ external hypot : float -> float -> float to origin. @since 4.00.0 *) -external cosh : float -> float = "cosh" [@@mel.val] [@@mel.scope "Math"] +external cosh : float -> float = "cosh" [@@mel.scope "Math"] (** Hyperbolic cosine. Argument is in radians. *) -external sinh : float -> float = "sinh" [@@mel.val] [@@mel.scope "Math"] +external sinh : float -> float = "sinh" [@@mel.scope "Math"] (** Hyperbolic sine. Argument is in radians. *) -external tanh : float -> float = "tanh" [@@mel.val] [@@mel.scope "Math"] +external tanh : float -> float = "tanh" [@@mel.scope "Math"] (** Hyperbolic tangent. Argument is in radians. *) -external acosh : float -> float = "acosh" [@@mel.val] [@@mel.scope "Math"] +external acosh : float -> float = "acosh" [@@mel.scope "Math"] (** Hyperbolic arc cosine. The argument must fall within the range [[1.0, inf]]. Result is in radians and is between [0.0] and [inf]. @since 4.13.0 *) -external asinh : float -> float = "asinh" [@@mel.val] [@@mel.scope "Math"] +external asinh : float -> float = "asinh" [@@mel.scope "Math"] (** Hyperbolic arc sine. The argument and result range over the entire real line. Result is in radians. @since 4.13.0 *) -external atanh : float -> float = "atanh" [@@mel.val] [@@mel.scope "Math"] +external atanh : float -> float = "atanh" [@@mel.scope "Math"] (** Hyperbolic arc tangent. The argument must fall within the range [[-1.0, 1.0]]. Result is in radians and ranges over the entire real line. @since 4.13.0 *) -external ceil : float -> float = "ceil" [@@mel.val] [@@mel.scope "Math"] +external ceil : float -> float = "ceil" [@@mel.scope "Math"] (** Round above to an integer value. [ceil f] returns the least integer value greater than or equal to [f]. The result is returned as a float. *) -external floor : float -> float = "floor" [@@mel.val] [@@mel.scope "Math"] +external floor : float -> float = "floor" [@@mel.scope "Math"] (** Round below to an integer value. [floor f] returns the greatest integer value less than or equal to [f]. The result is returned as a float. *) -external abs_float : float -> float = "abs" [@@mel.val] [@@mel.scope "Math"] +external abs_float : float -> float = "abs" [@@mel.scope "Math"] (** [abs_float f] returns the absolute value of [f]. *) #else @@ -760,7 +760,7 @@ val neg_infinity : float (** Negative infinity. *) #ifdef BS -external nan : float = "NaN" [@@mel.val] [@@mel.scope "Number"] +external nan : float = "NaN" [@@mel.scope "Number"] (* we could also use [0. /. 0.] *) #else val nan : float @@ -865,7 +865,7 @@ val bool_of_string : string -> bool [Invalid_argument "bool_of_string"] instead of returning [None]. *) #ifdef BS -external string_of_int : int -> string = "String" [@@mel.val] +external string_of_int : int -> string = "String" #else val string_of_int : int -> string #endif @@ -993,7 +993,7 @@ val print_float : float -> unit #ifdef BS external print_endline : string -> unit = "log" -[@@mel.val] [@@mel.scope "console"] + [@@mel.scope "console"] #else val print_endline : string -> unit #endif @@ -1029,7 +1029,7 @@ val prerr_float : float -> unit #ifdef BS external prerr_endline : string -> unit = "error" -[@@mel.val] [@@mel.scope "console"] + [@@mel.scope "console"] #else val prerr_endline : string -> unit #endif diff --git a/ppx/ast_external_process.ml b/ppx/ast_external_process.ml index 81865d14e6..299ff7aa77 100644 --- a/ppx/ast_external_process.ml +++ b/ppx/ast_external_process.ml @@ -258,6 +258,7 @@ let parse_external_attributes (no_arguments : bool) (prim_name_check : string) Ast_attributes.warn_if_bs ~loc txt; match txt with | "mel.val" | "bs.val" | "val" -> + Bs_ast_invariant.warn ~loc Deprecated_val; if no_arguments then { st with val_name = name_from_payload_or_prim ~loc payload } else diff --git a/ppx/bs_ast_invariant.ml b/ppx/bs_ast_invariant.ml index 69072b7414..6ec4c01a32 100644 --- a/ppx/bs_ast_invariant.ml +++ b/ppx/bs_ast_invariant.ml @@ -31,12 +31,14 @@ module Warnings = struct | Redundant_bs_string | Deprecated_uncurry_attribute | Deprecated_attribute_namespace + | Deprecated_val let kind = function | Unused_attribute _ -> "unused" | Fragile_external _ -> "fragile" | Redundant_bs_string -> "redundant" - | Deprecated_uncurry_attribute | Deprecated_attribute_namespace -> + | Deprecated_uncurry_attribute | Deprecated_attribute_namespace + | Deprecated_val -> "deprecated" let pp fmt t = @@ -65,6 +67,11 @@ module Warnings = struct "The `[@bs.*]' attributes are deprecated and will be removed in the\n\ next release.@\n\ Use `[@mel.*]' instead." + | Deprecated_val -> + Format.fprintf fmt + "`[@mel.val]' attributes are redundant and will be removed in the \ + next release.@\n\ + Consider removing them from any external declarations." end let warn ~loc msg = diff --git a/ppx/bs_ast_invariant.mli b/ppx/bs_ast_invariant.mli index 2a8e595f02..e7135bfddc 100644 --- a/ppx/bs_ast_invariant.mli +++ b/ppx/bs_ast_invariant.mli @@ -31,6 +31,7 @@ module Warnings : sig | Redundant_bs_string | Deprecated_uncurry_attribute | Deprecated_attribute_namespace + | Deprecated_val end val warn : loc:Location.t -> Warnings.t -> unit diff --git a/test/blackbox-tests/ffi-error-debug.t b/test/blackbox-tests/ffi-error-debug.t index 00986ab398..534e974bdb 100644 --- a/test/blackbox-tests/ffi-error-debug.t +++ b/test/blackbox-tests/ffi-error-debug.t @@ -31,6 +31,11 @@ > unit -> unit = "err" [@@mel.val] > EOF $ melc -ppx melppx x.ml + File "x.ml", line 3, characters 26-33: + 3 | unit -> unit = "err" [@@mel.val] + ^^^^^^^ + Alert deprecated: `[@mel.val]' attributes are redundant and will be removed in the next release. + Consider removing them from any external declarations. File "x.ml", lines 1-3, characters 0-34: 1 | external err : 2 | ?hi_should_error:([`a of int | `b of string ] [@mel.string]) -> @@ -47,6 +52,11 @@ Each [@mel.unwrap] variant constructor requires an argument > unit -> unit = "err" [@@mel.val] > EOF $ melc -ppx melppx x.ml + File "x.ml", line 3, characters 26-33: + 3 | unit -> unit = "err" [@@mel.val] + ^^^^^^^ + Alert deprecated: `[@mel.val]' attributes are redundant and will be removed in the next release. + Consider removing them from any external declarations. File "x.ml", line 2, characters 20-36: 2 | ?hi_should_error:([`a of int | `b] [@mel.unwrap]) -> ^^^^^^^^^^^^^^^^ diff --git a/test/blackbox-tests/legacy-ounit-cmd.t b/test/blackbox-tests/legacy-ounit-cmd.t index e53f3a80a9..2d7aa69145 100644 --- a/test/blackbox-tests/legacy-ounit-cmd.t +++ b/test/blackbox-tests/legacy-ounit-cmd.t @@ -61,6 +61,11 @@ Skip over the temporary file name printed in the error trace $ melc -ppx melppx -bs-eval 'external mk : int -> ([`a|`b [@mel.string]]) = "mk" [@@mel.val]' 2>&1 | grep -v File + 1 | external mk : int -> ([`a|`b [@mel.string]]) = "mk" [@@mel.val] + ^^^^^^^ + Alert deprecated: `[@mel.val]' attributes are redundant and will be removed in the next release. + Consider removing them from any external declarations. + 1 | external mk : int -> ([`a|`b [@mel.string]]) = "mk" [@@mel.val] ^^^^^^^^^^ Alert unused: Unused attribute [@mel.string] @@ -89,6 +94,12 @@ Skip over the temporary file name printed in the error trace > int -> int -> (int -> int -> int [@mel.uncurry]) = "v3"[@@mel.val] > EOF $ melc -ppx melppx x.ml + File "x.ml", line 2, characters 60-67: + 2 | int -> int -> (int -> int -> int [@mel.uncurry]) = "v3"[@@mel.val] + ^^^^^^^ + Alert deprecated: `[@mel.val]' attributes are redundant and will be removed in the next release. + Consider removing them from any external declarations. + File "x.ml", line 2, characters 37-48: 2 | int -> int -> (int -> int -> int [@mel.uncurry]) = "v3"[@@mel.val] ^^^^^^^^^^^ @@ -129,6 +140,10 @@ Skip over the temporary file name printed in the error trace $ melc -ppx melppx -bs-eval 'external mk : int -> ([`a|`b] ) = "mk" [@@mel.val]' 2>&1 | grep -v File + 1 | external mk : int -> ([`a|`b] ) = "mk" [@@mel.val] + ^^^^^^^ + Alert deprecated: `[@mel.val]' attributes are redundant and will be removed in the next release. + Consider removing them from any external declarations. // Generated by Melange /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ @@ -137,6 +152,11 @@ Skip over the temporary file name printed in the error trace > external mk : int -> (_ [@mel.as {json| { x : 3 } |json}]) -> t = "mk" [@@mel.val] > EOF $ melc -ppx melppx x.ml + File "x.ml", line 2, characters 75-82: + 2 | external mk : int -> (_ [@mel.as {json| { x : 3 } |json}]) -> t = "mk" [@@mel.val] + ^^^^^^^ + Alert deprecated: `[@mel.val]' attributes are redundant and will be removed in the next release. + Consider removing them from any external declarations. // Generated by Melange /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ @@ -145,6 +165,11 @@ Skip over the temporary file name printed in the error trace > external mk : int -> (_ [@mel.as {json| { "x" : 3 } |json}]) -> t = "mk" [@@mel.val] > EOF $ melc -ppx melppx x.ml + File "x.ml", line 2, characters 77-84: + 2 | external mk : int -> (_ [@mel.as {json| { "x" : 3 } |json}]) -> t = "mk" [@@mel.val] + ^^^^^^^ + Alert deprecated: `[@mel.val]' attributes are redundant and will be removed in the next release. + Consider removing them from any external declarations. // Generated by Melange /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ @@ -259,6 +284,12 @@ Skip over the temporary file name printed in the error trace > ) = "mk" [@@mel.val] > EOF $ melc -ppx melppx x.ml + File "x.ml", line 5, characters 12-19: + 5 | ) = "mk" [@@mel.val] + ^^^^^^^ + Alert deprecated: `[@mel.val]' attributes are redundant and will be removed in the next release. + Consider removing them from any external declarations. + File "x.ml", line 4, characters 5-15: 4 | [@mel.string] ^^^^^^^^^^ diff --git a/test/blackbox-tests/mel-attributes.t b/test/blackbox-tests/mel-attributes.t index 20c663051a..da2fad1064 100644 --- a/test/blackbox-tests/mel-attributes.t +++ b/test/blackbox-tests/mel-attributes.t @@ -54,6 +54,12 @@ next release. Use `[@mel.*]' instead. + File "x.ml", line 6, characters 26-32: + 6 | unit -> unit = "err" [@@bs.val] + ^^^^^^ + Alert deprecated: `[@mel.val]' attributes are redundant and will be removed in the next release. + Consider removing them from any external declarations. + File "x.ml", line 5, characters 35-44: 5 | x:([`a of int | `b of string ] [@bs.string]) -> ^^^^^^^^^ diff --git a/test/blackbox-tests/no-mel-val.t b/test/blackbox-tests/no-mel-val.t new file mode 100644 index 0000000000..475f6dfd22 --- /dev/null +++ b/test/blackbox-tests/no-mel-val.t @@ -0,0 +1,63 @@ +Demonstrate `@@mel.val` is redundant and unnecessary + + $ . ./setup.sh + + $ cat > x.ml < type document + > external doc : unit -> document = "" [@@mel.val "document"] + > external log : 'a -> unit = "log" [@@mel.val] [@@mel.scope "console"] + > let x = doc() + > let () = log "hello" + > EOF + + $ melc -ppx melppx x.ml + File "x.ml", line 2, characters 40-47: + 2 | external doc : unit -> document = "" [@@mel.val "document"] + ^^^^^^^ + Alert deprecated: `[@mel.val]' attributes are redundant and will be removed in the next release. + Consider removing them from any external declarations. + + File "x.ml", line 3, characters 37-44: + 3 | external log : 'a -> unit = "log" [@@mel.val] [@@mel.scope "console"] + ^^^^^^^ + Alert deprecated: `[@mel.val]' attributes are redundant and will be removed in the next release. + Consider removing them from any external declarations. + // Generated by Melange + 'use strict'; + + + var x = document(); + + console.log("hello"); + + exports.x = x; + /* x Not a pure module */ + +Demonstrate the same payload can be achieved with `@@mel.scope` + + $ cat > x.ml < external utcWithYM : year:float -> month:float -> unit -> float = "" + > [@@mel.val "Date.UTC"] + > let x = utcWithYM ~year:2023. ~month:8. () + > external utcWithYM : year:float -> month:float -> unit -> float = "UTC" + > [@@mel.scope "Date"] + > let y = utcWithYM ~year:2023. ~month:8. () + > EOF + + $ melc -ppx melppx x.ml + File "x.ml", line 2, characters 5-12: + 2 | [@@mel.val "Date.UTC"] + ^^^^^^^ + Alert deprecated: `[@mel.val]' attributes are redundant and will be removed in the next release. + Consider removing them from any external declarations. + // Generated by Melange + 'use strict'; + + + var x = Date.UTC(2023, 8); + + var y = Date.UTC(2023, 8); + + exports.x = x; + exports.y = y; + /* x Not a pure module */