diff --git a/CHANGELOG.md b/CHANGELOG.md index 79c368e4f8..6bde1c14e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ - Improve error message for pipe (`->`) syntax. https://github.com/rescript-lang/rescript/pull/7520 - Improve a few error messages around various subtyping issues. https://github.com/rescript-lang/rescript/pull/7404 - In module declarations, accept the invalid syntax `M = {...}` and format it to `M : {...}`. https://github.com/rescript-lang/rescript/pull/7527 +- Improve doc comment formatting to match the style of multiline comments. https://github.com/rescript-lang/rescript/pull/7529 #### :house: Internal diff --git a/compiler/syntax/src/res_parsetree_viewer.ml b/compiler/syntax/src/res_parsetree_viewer.ml index 56e3c0895b..df617461cf 100644 --- a/compiler/syntax/src/res_parsetree_viewer.ml +++ b/compiler/syntax/src/res_parsetree_viewer.ml @@ -567,6 +567,23 @@ let filter_printable_attributes attrs = List.filter is_printable_attribute attrs let partition_printable_attributes attrs = List.partition is_printable_attribute attrs +let partition_doc_comment_attributes attrs = + List.partition + (fun ((id, payload) : Parsetree.attribute) -> + match (id, payload) with + | ( {txt = "res.doc"}, + PStr + [ + { + pstr_desc = + Pstr_eval + ({pexp_desc = Pexp_constant (Pconst_string (_, _))}, _); + }; + ] ) -> + true + | _ -> false) + attrs + let is_fun_newtype expr = match expr.pexp_desc with | Pexp_fun _ | Pexp_newtype _ -> true diff --git a/compiler/syntax/src/res_parsetree_viewer.mli b/compiler/syntax/src/res_parsetree_viewer.mli index 242fc722a4..d697d9fa3c 100644 --- a/compiler/syntax/src/res_parsetree_viewer.mli +++ b/compiler/syntax/src/res_parsetree_viewer.mli @@ -98,6 +98,8 @@ val has_printable_attributes : Parsetree.attributes -> bool val filter_printable_attributes : Parsetree.attributes -> Parsetree.attributes val partition_printable_attributes : Parsetree.attributes -> Parsetree.attributes * Parsetree.attributes +val partition_doc_comment_attributes : + Parsetree.attributes -> Parsetree.attributes * Parsetree.attributes val requires_special_callback_printing_last_arg : (Asttypes.arg_label * Parsetree.expression) list -> bool diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index a1c1e0fbca..4d00515e30 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -1549,7 +1549,15 @@ and print_constructor_declarations ~state ~private_flag and print_constructor_declaration2 ~state i (cd : Parsetree.constructor_declaration) cmt_tbl = - let attrs = print_attributes ~state cd.pcd_attributes cmt_tbl in + let comment_attrs, attrs = + ParsetreeViewer.partition_doc_comment_attributes cd.pcd_attributes + in + let comment_doc = + match comment_attrs with + | [] -> Doc.nil + | comment_attrs -> print_doc_comments ~state cmt_tbl comment_attrs + in + let attrs = print_attributes ~state attrs cmt_tbl in let is_dot_dot_dot = cd.pcd_name.txt = "..." in let bar = if i > 0 || cd.pcd_attributes <> [] || is_dot_dot_dot then Doc.text "| " @@ -1572,6 +1580,7 @@ and print_constructor_declaration2 ~state i Doc.concat [ bar; + comment_doc; Doc.group (Doc.concat [ @@ -1934,8 +1943,20 @@ and print_typ_expr ?inline_record_definitions ~(state : State.t) let doc = match typ_expr.ptyp_attributes with | _ :: _ as attrs when not should_print_its_own_attributes -> - Doc.group - (Doc.concat [print_attributes ~state attrs cmt_tbl; rendered_type]) + let doc_comment_attr, attrs = + ParsetreeViewer.partition_doc_comment_attributes attrs + in + let comment_doc = + match doc_comment_attr with + | [] -> Doc.nil + | _ -> print_doc_comments ~state ~sep:Doc.space cmt_tbl doc_comment_attr + in + let attrs_doc = + match attrs with + | [] -> Doc.nil + | _ -> print_attributes ~state attrs cmt_tbl + in + Doc.group (Doc.concat [comment_doc; attrs_doc; rendered_type]) | _ -> rendered_type in print_comments doc cmt_tbl typ_expr.ptyp_loc @@ -5568,6 +5589,15 @@ and print_bs_object_row ~state (lbl, expr) cmt_tbl = in print_comments doc cmt_tbl cmt_loc +and print_doc_comments ~state ?(sep = Doc.hard_line) cmt_tbl attrs = + Doc.concat + [ + Doc.group + (Doc.join_with_sep + (List.map (fun attr -> print_attribute ~state attr cmt_tbl) attrs)); + sep; + ] + (* The optional loc indicates whether we need to print the attributes in * relation to some location. In practise this means the following: * `@attr type t = string` -> on the same line, print on the same line @@ -5579,6 +5609,9 @@ and print_attributes ?loc ?(inline = false) ~state match ParsetreeViewer.filter_parsing_attrs attrs with | [] -> Doc.nil | attrs -> + let comment_attrs, attrs = + ParsetreeViewer.partition_doc_comment_attributes attrs + in let line_break = match loc with | None -> Doc.line @@ -5587,15 +5620,30 @@ and print_attributes ?loc ?(inline = false) ~state | ({loc = first_loc}, _) :: _ when loc.loc_start.pos_lnum > first_loc.loc_end.pos_lnum -> Doc.hard_line - | _ -> Doc.line) + | _ -> + let has_comment_attrs = not (comment_attrs = []) in + if has_comment_attrs then Doc.space else Doc.line) in - Doc.concat - [ - Doc.group - (Doc.join_with_sep - (List.map (fun attr -> print_attribute ~state attr cmt_tbl) attrs)); - (if inline then Doc.space else line_break); - ] + let comment_doc = + match comment_attrs with + | [] -> Doc.nil + | comment_attrs -> print_doc_comments ~state cmt_tbl comment_attrs + in + let attrs_doc = + match attrs with + | [] -> Doc.nil + | _ -> + Doc.concat + [ + Doc.group + (Doc.join_with_sep + (List.map + (fun attr -> print_attribute ~state attr cmt_tbl) + attrs)); + (if inline then Doc.space else line_break); + ] + in + Doc.concat [comment_doc; attrs_doc] and print_payload ~state (payload : Parsetree.payload) cmt_tbl = match payload with diff --git a/runtime/Belt_Array.resi b/runtime/Belt_Array.resi index eaf8d2df46..ad1cdeaf4b 100644 --- a/runtime/Belt_Array.resi +++ b/runtime/Belt_Array.resi @@ -126,7 +126,6 @@ assertEqual(Belt.Array.reverse([10, 11, 12, 13, 14]), [14, 13, 12, 11, 10]) */ let reverse: t<'a> => t<'a> -@new /** `makeUninitialized(n)` creates an array of length `n` filled with the undefined value. You must specify the type of data that will eventually fill the array. @@ -139,9 +138,9 @@ let arr: array> = Belt.Array.makeUninitialized(5) assertEqual(Belt.Array.getExn(arr, 0), Js.undefined) ``` */ +@new external makeUninitialized: int => array> = "Array" -@new /** **Unsafe** @@ -157,6 +156,7 @@ Belt.Array.setExn(arr, 0, "example") assertEqual(Belt.Array.getExn(arr, 0), "example") ``` */ +@new external makeUninitializedUnsafe: int => t<'a> = "Array" /** @@ -335,11 +335,11 @@ assertEqual(Belt.Array.sliceToEnd([10, 11, 12, 13, 14, 15, 16], -4), [13, 14, 15 */ let sliceToEnd: (t<'a>, int) => t<'a> -@send /** `copy(a)` returns a copy of `a`; that is; a fresh array containing the same elements as `a`. */ +@send external copy: (t<'a>, @as(0) _) => t<'a> = "slice" /** @@ -770,7 +770,6 @@ assertEqual(Belt.Array.eq([1, 2, 3], [(-1), (-2), (-3)], (a, b) => abs(a) == abs */ let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool -@set /** Unsafe `truncateToLengthUnsafe(xs, n)` sets length of array `xs` to `n`. If `n` is greater than the length of `xs`; the extra elements are set to `Js.Null_undefined.null`. @@ -786,6 +785,7 @@ Belt.Array.truncateToLengthUnsafe(arr, 3) assertEqual(arr, ["ant", "bee", "cat"]) ``` */ +@set external truncateToLengthUnsafe: (t<'a>, int) => unit = "length" @deprecated("Use `init` instead") diff --git a/runtime/Belt_Float.resi b/runtime/Belt_Float.resi index ad0839a3ce..6f58321f3c 100644 --- a/runtime/Belt_Float.resi +++ b/runtime/Belt_Float.resi @@ -57,7 +57,6 @@ assertEqual(Belt.Float.fromString("1.0"), Some(1.0)) */ let fromString: string => option -@val /** Converts a given `float` to a `string`. Uses the JavaScript `String` constructor under the hood. @@ -67,6 +66,7 @@ Converts a given `float` to a `string`. Uses the JavaScript `String` constructor assertEqual(Belt.Float.toString(1.0), "1") ``` */ +@val external toString: float => string = "String" /** diff --git a/runtime/Belt_List.resi b/runtime/Belt_List.resi index 8d63da8716..a615ce1b05 100644 --- a/runtime/Belt_List.resi +++ b/runtime/Belt_List.resi @@ -790,7 +790,6 @@ assertEqual(Belt.List.keep(list{None, Some(2), Some(3), None}, Belt.Option.isSom */ let keep: (t<'a>, 'a => bool) => t<'a> -@deprecated("This function will soon be deprecated. Please, use `List.keep` instead.") /** Returns a list of all elements in `someList` which satisfy the predicate function `pred`. @@ -804,6 +803,7 @@ assertEqual(Belt.List.filter(list{1, 2, 3, 4}, isEven), list{2, 4}) assertEqual(Belt.List.filter(list{None, Some(2), Some(3), None}, Belt.Option.isSome), list{Some(2), Some(3)}) ``` */ +@deprecated("This function will soon be deprecated. Please, use `List.keep` instead.") let filter: (t<'a>, 'a => bool) => t<'a> /** Uncurried version of [keepWithIndex](#keepWithIndex). */ @@ -823,10 +823,6 @@ assertEqual(Belt.List.keepWithIndex(list{1, 2, 3, 4}, (_x, index) => isEven(inde */ let keepWithIndex: (t<'a>, ('a, int) => bool) => t<'a> -@deprecated( - "This function will soon be deprecated. Please, use `List.keepWithIndex` \ - instead." -) /** Returns a list of all elements in `someList` which satisfy the predicate function `pred`. @@ -838,6 +834,10 @@ let isEven = x => mod(x, 2) == 0 assertEqual(Belt.List.filterWithIndex(list{1, 2, 3, 4}, (_x, index) => isEven(index)), list{1, 3}) ``` */ +@deprecated( + "This function will soon be deprecated. Please, use `List.keepWithIndex` \ + instead." +) let filterWithIndex: (t<'a>, ('a, int) => bool) => t<'a> /** Uncurried version of [keepMap](#keepMap). */ diff --git a/runtime/Js.res b/runtime/Js.res index e1bfdcd334..2dc2cdca22 100644 --- a/runtime/Js.res +++ b/runtime/Js.res @@ -219,7 +219,8 @@ external undefined: undefined<'a> = "%undefined" */ external typeof: 'a => string = "%typeof" -@val @scope("console") /** Equivalent to console.log any value. */ +/** Equivalent to console.log any value. */ +@val @scope("console") external log: 'a => unit = "log" @val @scope("console") external log2: ('a, 'b) => unit = "log" @@ -227,7 +228,8 @@ external log: 'a => unit = "log" @val @scope("console") external log4: ('a, 'b, 'c, 'd) => unit = "log" -@val @scope("console") @variadic /** A convenience function to console.log more than 4 arguments */ +/** A convenience function to console.log more than 4 arguments */ +@val @scope("console") @variadic external logMany: array<'a> => unit = "log" external eqNull: ('a, null<'a>) => bool = "%equal_null" diff --git a/runtime/Js_array.res b/runtime/Js_array.res index 2d6bc43f1d..22f25af861 100644 --- a/runtime/Js_array.res +++ b/runtime/Js_array.res @@ -69,7 +69,6 @@ type array_like<'a> = Js_array2.array_like<'a> type 'a array_iter = 'a array_like */ -@val /** Creates a shallow copy of an array from an array-like object. See [`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) on MDN. @@ -80,11 +79,11 @@ let strArr = Js.String.castToArrayLike("abcd") Js.Array.from(strArr) == ["a", "b", "c", "d"] ``` */ +@val external from: array_like<'a> => array<'a> = "Array.from" /* ES2015 */ -@val /** Creates a new array by applying a function (the second argument) to each item in the `array_like` first argument. See @@ -99,6 +98,7 @@ let code = s => Js.String.charCodeAt(0, s) Js.Array.fromMap(strArr, code) == [97.0, 98.0, 99.0, 100.0] ``` */ +@val external fromMap: (array_like<'a>, 'a => 'b) => array<'b> = "Array.from" /* ES2015 */ @@ -119,10 +119,10 @@ Js.Array.isArray("abcd") == false ``` */ -@get /** Returns the number of elements in the array. See [`Array.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length) on MDN. */ +@get external length: array<'a> => int = "length" /* Mutator functions */ @@ -244,8 +244,7 @@ let empty: array = [] Js.Array.pop(empty) == None ``` */ -@send -@return(undefined_to_opt) +@send @return(undefined_to_opt) external pop: t<'a> => option<'a> = "pop" /** @@ -274,8 +273,7 @@ Js.Array.pushMany(["dog", "elk"], arr) == 5 arr == ["ant", "bee", "cat", "dog", "elk"] ``` */ -@send -@variadic +@send @variadic external pushMany: (t<'a>, array<'a>) => int = "push" let pushMany = (arg1, obj) => pushMany(obj, arg1) @@ -307,8 +305,7 @@ let empty: array = [] Js.Array.shift(empty) == None ``` */ -@send -@return(undefined_to_opt) +@send @return(undefined_to_opt) external shift: t<'a> => option<'a> = "shift" /** @@ -382,8 +379,7 @@ Js.Array.spliceInPlace(~pos=9, ~remove=2, ~add=["x", "y", "z"], arr3) == [] arr3 == ["a", "b", "c", "d", "e", "f", "x", "y", "z"] ``` */ -@send -@variadic +@send @variadic external spliceInPlace: (t<'a>, ~pos: int, ~remove: int, ~add: array<'a>) => 'this = "splice" let spliceInPlace = (~pos, ~remove, ~add, obj) => spliceInPlace(obj, ~pos, ~remove, ~add) @@ -458,8 +454,7 @@ Js.Array.unshiftMany(["a", "b", "c"], arr) == 5 arr == ["a", "b", "c", "d", "e"] ``` */ -@send -@variadic +@send @variadic external unshiftMany: (t<'a>, array<'a>) => int = "unshift" let unshiftMany = (arg1, obj) => unshiftMany(obj, arg1) @@ -502,8 +497,7 @@ Js.Array.concatMany([["d", "e"], ["f", "g", "h"]], ["a", "b", "c"]) == [ ] ``` */ -@send -@variadic +@send @variadic external concatMany: (t<'a>, array<'this>) => 'this = "concat" let concatMany = (arg1, obj) => concatMany(obj, arg1) @@ -780,8 +774,7 @@ Js.Array.find(x => x < 0, [33, 22, -55, 77, -44]) == Some(-55) Js.Array.find(x => x < 0, [33, 22, 55, 77, 44]) == None ``` */ -@send -@return(undefined_to_opt) +@send @return(undefined_to_opt) external find: (t<'a>, 'a => bool) => option<'a> = "find" let find = (arg1, obj) => find(obj, arg1) @@ -798,8 +791,7 @@ Js.Array.findi(positiveOddElement, [66, -33, 55, 88, 22]) == Some(88) Js.Array.findi(positiveOddElement, [66, -33, 55, -88, 22]) == None ``` */ -@send -@return(undefined_to_opt) +@send @return(undefined_to_opt) external findi: (t<'a>, ('a, int) => bool) => option<'a> = "find" let findi = (arg1, obj) => findi(obj, arg1) diff --git a/runtime/Js_array2.res b/runtime/Js_array2.res index c4239dc7a2..19d80b51f2 100644 --- a/runtime/Js_array2.res +++ b/runtime/Js_array2.res @@ -65,7 +65,6 @@ type array_like<'a> = Stdlib_Array.arrayLike<'a> type 'a array_iter = 'a array_like */ -@val /** Creates a shallow copy of an array from an array-like object. See [`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) @@ -78,11 +77,11 @@ let strArr = Js.String.castToArrayLike("abcd") Js.Array2.from(strArr) == ["a", "b", "c", "d"] ``` */ +@val external from: array_like<'a> => array<'a> = "Array.from" /* ES2015 */ -@val /** Creates a new array by applying a function (the second argument) to each item in the `array_like` first argument. See @@ -97,11 +96,11 @@ let code = s => Js.String.charCodeAt(0, s) Js.Array2.fromMap(strArr, code) == [97.0, 98.0, 99.0, 100.0] ``` */ +@val external fromMap: (array_like<'a>, 'a => 'b) => array<'b> = "Array.from" /* ES2015 */ -@val /** Returns `true` if its argument is an array; `false` otherwise. This is a runtime check, which is why the second example returns `true`---a list is internally represented as a nested JavaScript array. @@ -113,19 +112,19 @@ Js.Array2.isArray(list{5, 2, 3, 1, 4}) == true Js.Array2.isArray("abcd") == false ``` */ +@val external isArray: 'a => bool = "Array.isArray" -@get /** Returns the number of elements in the array. See [`Array.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length) on MDN. */ +@get external length: array<'a> => int = "length" /* Mutator functions */ -@send /** Copies from the first element in the given array to the designated `~to_` position, returning the resulting array. *This function modifies the original @@ -141,11 +140,11 @@ Js.Array2.copyWithin(arr, ~to_=2) == [100, 101, 100, 101, 102] arr == [100, 101, 100, 101, 102] ``` */ +@send external copyWithin: (t<'a>, ~to_: int) => t<'a> = "copyWithin" /* ES2015 */ -@send /** Copies starting at element `~from` in the given array to the designated `~to_` position, returning the resulting array. *This function modifies the original @@ -161,11 +160,11 @@ Js.Array2.copyWithinFrom(arr, ~from=2, ~to_=0) == [102, 103, 104, 103, 104] arr == [102, 103, 104, 103, 104] ``` */ +@send external copyWithinFrom: (t<'a>, ~to_: int, ~from: int) => t<'a> = "copyWithin" /* ES2015 */ -@send /** Copies starting at element `~start` in the given array up to but not including `~end_` to the designated `~to_` position, returning the resulting array. *This @@ -181,11 +180,11 @@ Js.Array2.copyWithinFromRange(arr, ~start=2, ~end_=5, ~to_=1) == [100, 102, 103, arr == [100, 102, 103, 104, 104, 105] ``` */ +@send external copyWithinFromRange: (t<'a>, ~to_: int, ~start: int, ~end_: int) => t<'a> = "copyWithin" /* ES2015 */ -@send /** Sets all elements of the given array (the first arumgent) to the designated value (the secon argument), returning the resulting array. *This function @@ -203,11 +202,11 @@ Js.Array2.fillInPlace(arr, 99) == [99, 99, 99, 99, 99] arr == [99, 99, 99, 99, 99] ``` */ +@send external fillInPlace: (t<'a>, 'a) => t<'a> = "fill" /* ES2015 */ -@send /** Sets all elements of the given array (the first arumgent) from position `~from` to the end to the designated value (the second argument), returning the @@ -223,11 +222,11 @@ Js.Array2.fillFromInPlace(arr, 99, ~from=2) == [100, 101, 99, 99, 99] arr == [100, 101, 99, 99, 99] ``` */ +@send external fillFromInPlace: (t<'a>, 'a, ~from: int) => t<'a> = "fill" /* ES2015 */ -@send /** Sets the elements of the given array (the first arumgent) from position `~start` up to but not including position `~end_` to the designated value (the @@ -244,12 +243,11 @@ Js.Array2.fillRangeInPlace(arr, 99, ~start=1, ~end_=4) == [100, 99, 99, 99, 104] arr == [100, 99, 99, 99, 104] ``` */ +@send external fillRangeInPlace: (t<'a>, 'a, ~start: int, ~end_: int) => t<'a> = "fill" /* ES2015 */ -@send -@return(undefined_to_opt) /** If the array is not empty, removes the last element and returns it as `Some(value)`; returns `None` if the array is empty. *This function modifies @@ -268,9 +266,9 @@ let empty: array = [] Js.Array2.pop(empty) == None ``` */ +@send @return(undefined_to_opt) external pop: t<'a> => option<'a> = "pop" -@send /** Appends the given value to the array, returning the number of elements in the updated array. *This function modifies the original array.* See @@ -285,10 +283,9 @@ Js.Array2.push(arr, "dog") == 4 arr == ["ant", "bee", "cat", "dog"] ``` */ +@send external push: (t<'a>, 'a) => int = "push" -@send -@variadic /** Appends the values from one array (the second argument) to another (the first argument), returning the number of elements in the updated array. *This @@ -304,9 +301,9 @@ Js.Array2.pushMany(arr, ["dog", "elk"]) == 5 arr == ["ant", "bee", "cat", "dog", "elk"] ``` */ +@send @variadic external pushMany: (t<'a>, array<'a>) => int = "push" -@send /** Returns an array with the elements of the input array in reverse order. *This function modifies the original array.* See @@ -321,10 +318,9 @@ Js.Array2.reverseInPlace(arr) == ["cat", "bee", "ant"] arr == ["cat", "bee", "ant"] ``` */ +@send external reverseInPlace: t<'a> => t<'a> = "reverse" -@send -@return(undefined_to_opt) /** If the array is not empty, removes the first element and returns it as `Some(value)`; returns `None` if the array is empty. *This function modifies @@ -343,9 +339,9 @@ let empty: array = [] Js.Array2.shift(empty) == None ``` */ +@send @return(undefined_to_opt) external shift: t<'a> => option<'a> = "shift" -@send /** Sorts the given array in place and returns the sorted array. JavaScript sorts the array by converting the arguments to UTF-16 strings and sorting them. See @@ -366,9 +362,9 @@ Js.Array2.sortInPlace(numbers) == [1, 10, 2, 20, 3, 30] numbers == [1, 10, 2, 20, 3, 30] ``` */ +@send external sortInPlace: t<'a> => t<'a> = "sort" -@send /** Sorts the given array in place and returns the sorted array. *This function modifies the original array.* @@ -399,10 +395,9 @@ let reverseNumeric = (n1, n2) => n2 - n1 Js.Array2.sortInPlaceWith(numbers, reverseNumeric) == [30, 20, 10, 3, 2, 1] ``` */ +@send external sortInPlaceWith: (t<'a>, ('a, 'a) => int) => t<'a> = "sort" -@send -@variadic /** Starting at position `~pos`, remove `~remove` elements and then add the elements from the `~add` array. Returns an array consisting of the removed @@ -426,9 +421,9 @@ Js.Array2.spliceInPlace(arr3, ~pos=9, ~remove=2, ~add=["x", "y", "z"]) == [] arr3 == ["a", "b", "c", "d", "e", "f", "x", "y", "z"] ``` */ +@send @variadic external spliceInPlace: (t<'a>, ~pos: int, ~remove: int, ~add: array<'a>) => t<'a> = "splice" -@send /** Removes elements from the given array starting at position `~pos` to the end of the array, returning the removed elements. *This function modifies the original @@ -444,9 +439,9 @@ Js.Array2.removeFromInPlace(arr, ~pos=4) == ["e", "f"] arr == ["a", "b", "c", "d"] ``` */ +@send external removeFromInPlace: (t<'a>, ~pos: int) => t<'a> = "splice" -@send /** Removes `~count` elements from the given array starting at position `~pos`, returning the removed elements. *This function modifies the original array.* @@ -462,9 +457,9 @@ Js.Array2.removeCountInPlace(arr, ~pos=2, ~count=3) == ["c", "d", "e"] arr == ["a", "b", "f"] ``` */ +@send external removeCountInPlace: (t<'a>, ~pos: int, ~count: int) => t<'a> = "splice" -@send /** Adds the given element to the array, returning the new number of elements in the array. *This function modifies the original array.* See @@ -479,10 +474,9 @@ Js.Array2.unshift(arr, "a") == 4 arr == ["a", "b", "c", "d"] ``` */ +@send external unshift: (t<'a>, 'a) => int = "unshift" -@send -@variadic /** Adds the elements in the second array argument at the beginning of the first array argument, returning the new number of elements in the array. *This @@ -498,6 +492,7 @@ Js.Array2.unshiftMany(arr, ["a", "b", "c"]) == 5 arr == ["a", "b", "c", "d", "e"] ``` */ +@send @variadic external unshiftMany: (t<'a>, array<'a>) => int = "unshift" /* Accessor functions @@ -505,7 +500,6 @@ external unshiftMany: (t<'a>, array<'a>) => int = "unshift" @send @deprecated("`append` is not type-safe. Use `concat` instead.") external append: (t<'a>, 'a) => t<'a> = "concat" -@send /** Concatenates the second array argument to the first array argument, returning a new array. The original arrays are not modified. See @@ -518,10 +512,9 @@ on MDN. Js.Array2.concat(["a", "b"], ["c", "d", "e"]) == ["a", "b", "c", "d", "e"] ``` */ +@send external concat: (t<'a>, t<'a>) => t<'a> = "concat" -@send -@variadic /** The second argument to `concatMany()` is an array of arrays; these are added at the end of the first argument, returning a new array. See @@ -543,9 +536,9 @@ Js.Array2.concatMany(["a", "b", "c"], [["d", "e"], ["f", "g", "h"]]) == [ ] ``` */ +@send @variadic external concatMany: (t<'a>, array>) => t<'a> = "concat" -@send /** Returns true if the given value is in the array, `false` otherwise. See [`Array.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes) @@ -558,9 +551,9 @@ Js.Array2.includes(["a", "b", "c"], "b") == true Js.Array2.includes(["a", "b", "c"], "x") == false ``` */ +@send external includes: (t<'a>, 'a) => bool = "includes" -@send /** Returns the index of the first element in the array that has the given value. If the value is not in the array, returns -1. See @@ -574,9 +567,9 @@ Js.Array2.indexOf([100, 101, 102, 103], 102) == 2 Js.Array2.indexOf([100, 101, 102, 103], 999) == -1 ``` */ +@send external indexOf: (t<'a>, 'a) => int = "indexOf" -@send /** Returns the index of the first element in the array with the given value. The search starts at position `~from`. See @@ -591,9 +584,9 @@ Js.Array2.indexOfFrom(["a", "b", "a", "c", "a"], "a", ~from=3) == 4 Js.Array2.indexOfFrom(["a", "b", "a", "c", "a"], "b", ~from=2) == -1 ``` */ +@send external indexOfFrom: (t<'a>, 'a, ~from: int) => int = "indexOf" -@send /** This function converts each element of the array to a string (via JavaScript) and concatenates them, separated by the string given in the first argument, @@ -610,9 +603,9 @@ Js.Array2.joinWith([2020, 9, 4], "/") == "2020/9/4" Js.Array2.joinWith([2.5, 3.6, 3e-2], ";") == "2.5;3.6;0.03" ``` */ +@send external joinWith: (t<'a>, string) => string = "join" -@send /** Returns the index of the last element in the array that has the given value. If the value is not in the array, returns -1. See @@ -626,9 +619,9 @@ Js.Array2.lastIndexOf(["a", "b", "a", "c"], "a") == 2 Js.Array2.lastIndexOf(["a", "b", "a", "c"], "x") == -1 ``` */ +@send external lastIndexOf: (t<'a>, 'a) => int = "lastIndexOf" -@send /** Returns the index of the last element in the array that has the given value, searching from position `~from` down to the start of the array. If the value is @@ -643,9 +636,9 @@ Js.Array2.lastIndexOfFrom(["a", "b", "a", "c", "a", "d"], "a", ~from=3) == 2 Js.Array2.lastIndexOfFrom(["a", "b", "a", "c", "a", "d"], "c", ~from=2) == -1 ``` */ +@send external lastIndexOfFrom: (t<'a>, 'a, ~from: int) => int = "lastIndexOf" -@send /** Returns a shallow copy of the given array from the `~start` index up to but not including the `~end_` position. Negative numbers indicate an offset from the @@ -662,26 +655,26 @@ Js.Array2.slice(arr, ~start=-3, ~end_=-1) == [104, 105] Js.Array2.slice(arr, ~start=9, ~end_=10) == [] ``` */ +@send external slice: (t<'a>, ~start: int, ~end_: int) => t<'a> = "slice" -@send /** Returns a copy of the entire array. Same as `Js.Array2.Slice(arr, ~start=0, ~end_=Js.Array2.length(arr))`. See [`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) on MDN. */ +@send external copy: t<'a> => t<'a> = "slice" -@send /** Returns a shallow copy of the given array from the given index to the end. See [`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) on MDN. */ +@send external sliceFrom: (t<'a>, int) => t<'a> = "slice" -@send /** Converts the array to a string. Each element is converted to a string using JavaScript. Unlike the JavaScript `Array.toString()`, all elements in a @@ -696,9 +689,9 @@ Js.Array2.toString([3.5, 4.6, 7.8]) == "3.5,4.6,7.8" Js.Array2.toString(["a", "b", "c"]) == "a,b,c" ``` */ +@send external toString: t<'a> => string = "toString" -@send /** Converts the array to a string using the conventions of the current locale. Each element is converted to a string using JavaScript. Unlike the JavaScript @@ -715,6 +708,7 @@ Js.Array2.toLocaleString([Js.Date.make()]) // returns "2020-3-19 10:52:11" for locale de_DE.utf8 ``` */ +@send external toLocaleString: t<'a> => string = "toLocaleString" /* Iteration functions @@ -723,7 +717,6 @@ external toLocaleString: t<'a> => string = "toLocaleString" external entries : 'a t -> (int * 'a) array_iter = "" [@@send] (* ES2015 *) */ -@send /** The first argument to `every()` is an array. The second argument is a predicate function that returns a boolean. The `every()` function returns `true` if the @@ -740,9 +733,9 @@ Js.Array2.every([6, 22, 8, 4], isEven) == true Js.Array2.every([6, 22, 7, 4], isEven) == false ``` */ +@send external every: (t<'a>, 'a => bool) => bool = "every" -@send /** The first argument to `everyi()` is an array. The second argument is a predicate function with two arguments: an array element and that element’s @@ -762,9 +755,9 @@ Js.Array2.everyi([6, -3, 5, 8], evenIndexPositive) == true Js.Array2.everyi([6, 3, -5, 8], evenIndexPositive) == false ``` */ +@send external everyi: (t<'a>, ('a, int) => bool) => bool = "every" -@send /** Applies the given predicate function (the second argument) to each element in the array; the result is an array of those elements for which the predicate @@ -779,9 +772,9 @@ let nonEmpty = s => s != "" Js.Array2.filter(["abc", "", "", "def", "ghi"], nonEmpty) == ["abc", "def", "ghi"] ``` */ +@send external filter: (t<'a>, 'a => bool) => t<'a> = "filter" -@send /** Each element of the given array are passed to the predicate function. The return value is an array of all those elements for which the predicate function @@ -800,10 +793,9 @@ let positiveOddElement = (item, index) => mod(index, 2) == 1 && item > 0 Js.Array2.filteri([6, 3, 5, 8, 7, -4, 1], positiveOddElement) == [3, 8] ``` */ +@send external filteri: (t<'a>, ('a, int) => bool) => t<'a> = "filter" -@send -@return({undefined_to_opt: undefined_to_opt}) /** Returns `Some(value)` for the first element in the array that satisifies the given predicate function, or `None` if no element satisifies the predicate. See @@ -818,12 +810,11 @@ Js.Array2.find([33, 22, -55, 77, -44], x => x < 0) == Some(-55) Js.Array2.find([33, 22, 55, 77, 44], x => x < 0) == None ``` */ +@send @return({undefined_to_opt: undefined_to_opt}) external find: (t<'a>, 'a => bool) => option<'a> = "find" /* ES2015 */ -@send -@return({undefined_to_opt: undefined_to_opt}) /** Returns `Some(value)` for the first element in the array that satisifies the given predicate function, or `None` if no element satisifies the predicate. The @@ -841,11 +832,11 @@ Js.Array2.findi([66, -33, 55, 88, 22], positiveOddElement) == Some(88) Js.Array2.findi([66, -33, 55, -88, 22], positiveOddElement) == None ``` */ +@send @return({undefined_to_opt: undefined_to_opt}) external findi: (t<'a>, ('a, int) => bool) => option<'a> = "find" /* ES2015 */ -@send /** Returns the index of the first element in the array that satisifies the given predicate function, or -1 if no element satisifies the predicate. See @@ -859,11 +850,11 @@ Js.Array2.findIndex([33, 22, -55, 77, -44], x => x < 0) == 2 Js.Array2.findIndex([33, 22, 55, 77, 44], x => x < 0) == -1 ``` */ +@send external findIndex: (t<'a>, 'a => bool) => int = "findIndex" /* ES2015 */ -@send /** Returns `Some(value)` for the first element in the array that satisifies the given predicate function, or `None` if no element satisifies the predicate. The @@ -881,11 +872,11 @@ Js.Array2.findIndexi([66, -33, 55, 88, 22], positiveOddElement) == 3 Js.Array2.findIndexi([66, -33, 55, -88, 22], positiveOddElement) == -1 ``` */ +@send external findIndexi: (t<'a>, ('a, int) => bool) => int = "findIndex" /* ES2015 */ -@send /** The `forEach()` function applies the function given as the second argument to each element in the array. The function you provide returns `unit`, and the @@ -902,9 +893,9 @@ on MDN. Js.Array2.forEach(["a", "b", "c"], x => Js.log(x)) == () ``` */ +@send external forEach: (t<'a>, 'a => unit) => unit = "forEach" -@send /** The `forEachi()` function applies the function given as the second argument to each element in the array. The function you provide takes an item in the array @@ -922,13 +913,13 @@ on MDN. Js.Array2.forEachi(["a", "b", "c"], (item, index) => Js.log2(index + 1, item)) == () ``` */ +@send external forEachi: (t<'a>, ('a, int) => unit) => unit = "forEach" /* commented out until bs has a plan for iterators external keys : 'a t -> int array_iter = "" [@@send] (* ES2015 *) */ -@send /** Applies the function (the second argument) to each item in the array, returning a new array. The result array does not have to have elements of the same type @@ -943,9 +934,9 @@ Js.Array2.map([12, 4, 8], x => x * x) == [144, 16, 64] Js.Array2.map(["animal", "vegetable", "mineral"], Js.String.length) == [6, 9, 7] ``` */ +@send external map: (t<'a>, 'a => 'b) => t<'b> = "map" -@send /** Applies the function (the second argument) to each item in the array, returning a new array. The function acceps two arguments: an item from the array and its @@ -962,9 +953,9 @@ let product = (item, index) => item * index Js.Array2.mapi([10, 11, 12], product) == [0, 11, 24] ``` */ +@send external mapi: (t<'a>, ('a, int) => 'b) => t<'b> = "map" -@send /** The `reduce()` function takes three parameters: an array, a *reducer function*, and a beginning accumulator value. The reducer function has two parameters: an @@ -996,9 +987,9 @@ Js.Array2.reduce( Js.Array2.reduce([2.0, 4.0], (acc, item) => item /. acc, 1.0) == 2.0 // 4.0 / (2.0 / 1.0) ``` */ +@send external reduce: (t<'a>, ('b, 'a) => 'b, 'b) => 'b = "reduce" -@send /** The `reducei()` function takes three parameters: an array, a *reducer function*, and a beginning accumulator value. The reducer function has three @@ -1031,9 +1022,9 @@ let sumOfEvens = (accumulator, item, index) => Js.Array2.reducei([2, 5, 1, 4, 3], sumOfEvens, 0) == 6 ``` */ +@send external reducei: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b = "reduce" -@send /** The `reduceRight()` function takes three parameters: an array, a *reducer function*, and a beginning accumulator value. The reducer function has two @@ -1063,9 +1054,9 @@ Js.Array2.reduceRight([10, 2, 4], sumOfSquares, 0) == 120 Js.Array2.reduceRight([2.0, 4.0], (acc, item) => item /. acc, 1.0) == 0.5 // 2.0 / (4.0 / 1.0) ``` */ +@send external reduceRight: (t<'a>, ('b, 'a) => 'b, 'b) => 'b = "reduceRight" -@send /** The `reduceRighti()` function takes three parameters: an array, a *reducer function*, and a beginning accumulator value. The reducer function has three @@ -1100,9 +1091,9 @@ let sumOfEvens = (accumulator, item, index) => Js.Array2.reduceRighti([2, 5, 1, 4, 3], sumOfEvens, 0) == 6 ``` */ +@send external reduceRighti: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b = "reduceRight" -@send /** Returns `true` if the predicate function given as the second argument to `some()` returns `true` for any element in the array; `false` otherwise. @@ -1116,9 +1107,9 @@ Js.Array2.some([3, 7, 5, 2, 9], isEven) == true Js.Array2.some([3, 7, 5, 1, 9], isEven) == false ``` */ +@send external some: (t<'a>, 'a => bool) => bool = "some" -@send /** Returns `true` if the predicate function given as the second argument to `somei()` returns `true` for any element in the array; `false` otherwise. The @@ -1139,6 +1130,7 @@ Js.Array2.somei(["ab", "cd", "ef", "gh"], sameLength) == true Js.Array2.somei(["a", "bc", "def", "gh"], sameLength) == false ``` */ +@send external somei: (t<'a>, ('a, int) => bool) => bool = "some" /* commented out until bs has a plan for iterators diff --git a/runtime/Js_bigint.res b/runtime/Js_bigint.res index 4288f1a40d..253daa3bb2 100644 --- a/runtime/Js_bigint.res +++ b/runtime/Js_bigint.res @@ -1,6 +1,5 @@ /*** JavaScript BigInt API */ -@val /** Parses the given `string` into a `bigint` using JavaScript semantics. Return the number as a `bigint` if successfully parsed. Uncaught syntax exception otherwise. @@ -31,6 +30,7 @@ try { } ``` */ +@val external fromStringExn: string => bigint = "BigInt" // Operations @@ -53,7 +53,6 @@ let lnot = x => lxor(x, -1n) external lsl: (bigint, bigint) => bigint = "%lslbigint" external asr: (bigint, bigint) => bigint = "%asrbigint" -@send /** Formats a `bigint` as a string. Return a `string` representing the given value. See [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN. @@ -65,9 +64,9 @@ See [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referen Js.BigInt.toString(123n)->Js.log ``` */ +@send external toString: bigint => string = "toString" -@send /** Returns a string with a language-sensitive representation of this BigInt value. @@ -78,4 +77,5 @@ Returns a string with a language-sensitive representation of this BigInt value. Js.BigInt.toString(123n)->Js.log ``` */ +@send external toLocaleString: bigint => string = "toLocaleString" diff --git a/runtime/Js_date.res b/runtime/Js_date.res index 0892211745..be4914110d 100644 --- a/runtime/Js_date.res +++ b/runtime/Js_date.res @@ -31,7 +31,6 @@ on MDN.) JavaScript stores dates as the number of milliseconds since the UNIX type t = Stdlib_Date.t -@send /** Returns the primitive value of this date, equivalent to `getTime()`. (See [`Date.valueOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf) @@ -43,9 +42,9 @@ on MDN.) Js.Date.valueOf(exampleDate) == 123456654321.0 ``` */ +@send external valueOf: t => float = "valueOf" -@new /** Returns a date representing the current time. See [`Date()` Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date) @@ -57,9 +56,9 @@ on MDN. let now = Js.Date.make() ``` */ +@new external make: unit => t = "Date" -@new /** Returns a date representing the given argument, which is a number of milliseconds since the epoch. See [`Date()` @@ -72,9 +71,9 @@ on MDN. Js.Date.fromFloat(123456654321.0) == exampleDate ``` */ +@new external fromFloat: float => t = "Date" -@new /** Returns a `Js.Date.t` represented by the given string. The string can be in “IETF-compliant RFC 2822 timestamps, and also strings in a version of ISO8601.” @@ -90,9 +89,9 @@ Js.Date.fromString("1973-11-29T21:30:54.321Z00:00") == exampleDate Js.Date.fromString("Thor, 32 Lok -19 60:70:80 XYZ") // returns NaN ``` */ +@new external fromString: string => t = "Date" -@new /** Returns a date representing midnight of the first day of the given month and year in the current time zone. Fractional parts of arguments are ignored. See @@ -106,9 +105,9 @@ on MDN. let november1 = Js.Date.makeWithYM(~year=2020.0, ~month=10.0, ()) ``` */ +@new external makeWithYM: (~year: float, ~month: float, unit) => t = "Date" -@new /** Returns a date representing midnight of the given date of the given month and year in the current time zone. Fractional parts of arguments are ignored. See @@ -116,9 +115,9 @@ year in the current time zone. Fractional parts of arguments are ignored. See Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date) on MDN. */ +@new external makeWithYMD: (~year: float, ~month: float, ~date: float, unit) => t = "Date" -@new /** Returns a date representing the given date of the given month and year, at zero minutes and zero seconds past the given `hours`, in the current time zone. @@ -126,10 +125,10 @@ Fractional parts of arguments are ignored. See [`Date()` Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date) on MDN. Fractional parts of the arguments are ignored. */ +@new external makeWithYMDH: (~year: float, ~month: float, ~date: float, ~hours: float, unit) => t = "Date" -@new /** Returns a date representing the given date of the given month and year, at zero seconds past the given time in hours and minutes in the current time zone. @@ -137,6 +136,7 @@ Fractional parts of arguments are ignored. See [`Date()` Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date) on MDN. */ +@new external makeWithYMDHM: ( ~year: float, ~month: float, @@ -146,7 +146,6 @@ external makeWithYMDHM: ( unit, ) => t = "Date" -@new /** Returns a date representing the given date of the given month and year, at the given time in hours, minutes, and seconds in the current time zone. Fractional @@ -168,6 +167,7 @@ Js.Date.makeWithYMDHMS( ) == exampleDate ``` */ +@new external makeWithYMDHMS: ( ~year: float, ~month: float, @@ -178,7 +178,6 @@ external makeWithYMDHMS: ( unit, ) => t = "Date" -@val("Date.UTC") /** Returns a float representing the number of milliseconds past the epoch for midnight of the first day of the given month and year in UTC. Fractional parts @@ -192,9 +191,9 @@ on MDN. let november1 = Js.Date.utcWithYM(~year=2020.0, ~month=10.0, ()) ``` */ +@val("Date.UTC") external utcWithYM: (~year: float, ~month: float, unit) => float = "" -@val("Date.UTC") /** Returns a float representing the number of milliseconds past the epoch for midnight of the given date of the given month and year in UTC. Fractional parts @@ -202,9 +201,9 @@ of arguments are ignored. See [`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC) on MDN. */ +@val("Date.UTC") external utcWithYMD: (~year: float, ~month: float, ~date: float, unit) => float = "" -@val("Date.UTC") /** Returns a float representing the number of milliseconds past the epoch for midnight of the given date of the given month and year, at zero minutes and @@ -213,9 +212,9 @@ See [`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC) on MDN. */ +@val("Date.UTC") external utcWithYMDH: (~year: float, ~month: float, ~date: float, ~hours: float, unit) => float = "" -@val("Date.UTC") /** Returns a float representing the number of milliseconds past the epoch for midnight of the given date of the given month and year, at zero seconds past @@ -224,6 +223,7 @@ arguments are ignored. See [`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC) on MDN. */ +@val("Date.UTC") external utcWithYMDHM: ( ~year: float, ~month: float, @@ -233,7 +233,6 @@ external utcWithYMDHM: ( unit, ) => float = "" -@val("Date.UTC") /** Returns a float representing the number of milliseconds past the epoch for midnight of the given date of the given month and year, at the given time in @@ -243,6 +242,7 @@ See [`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC) on MDN. */ +@val("Date.UTC") external utcWithYMDHMS: ( ~year: float, ~month: float, @@ -253,13 +253,12 @@ external utcWithYMDHMS: ( unit, ) => float = "" -@val("Date.now") /** Returns the current time as number of milliseconds since Unix epoch. */ +/** Returns the current time as number of milliseconds since Unix epoch. */ +@val("Date.now") external now: unit => float = "" @new @deprecated("Please use `fromString` instead") external parse: string => t = "Date" -@val("parse") -@scope("Date") /** Returns a float with the number of milliseconds past the epoch represented by the given string. The string can be in “IETF-compliant RFC 2822 timestamps, and @@ -269,9 +268,9 @@ string. According to the documentation on MDN, its use is discouraged. Returns `NaN` if passed invalid date string. */ +@val("parse") @scope("Date") external parseAsFloat: string => float = "" -@send /** Returns the day of the month for its argument. The argument is evaluated in the current time zone. See @@ -284,9 +283,9 @@ on MDN. Js.Date.getDate(exampleDate) == 29.0 ``` */ +@send external getDate: t => float = "getDate" -@send /** Returns the day of the week (0.0-6.0) for its argument, where 0.0 represents Sunday. The argument is evaluated in the current time zone. See @@ -299,9 +298,9 @@ on MDN. Js.Date.getDay(exampleDate) == 4.0 ``` */ +@send external getDay: t => float = "getDay" -@send /** Returns the full year (as opposed to the range 0-99) for its argument. The argument is evaluated in the current time zone. See @@ -314,9 +313,9 @@ on MDN. Js.Date.getFullYear(exampleDate) == 1973.0 ``` */ +@send external getFullYear: t => float = "getFullYear" -@send /** Returns the hours for its argument, evaluated in the current time zone. See [`Date.getHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours) @@ -328,9 +327,9 @@ on MDN. Js.Date.getHours(exampleDate) == 22.0 // Vienna is in GMT+01:00 ``` */ +@send external getHours: t => float = "getHours" -@send /** Returns the number of milliseconds for its argument, evaluated in the current time zone. See @@ -343,9 +342,9 @@ on MDN. Js.Date.getMilliseconds(exampleDate) == 321.0 ``` */ +@send external getMilliseconds: t => float = "getMilliseconds" -@send /** Returns the number of minutes for its argument, evaluated in the current time zone. See @@ -358,9 +357,9 @@ on MDN. Js.Date.getMinutes(exampleDate) == 30.0 ``` */ +@send external getMinutes: t => float = "getMinutes" -@send /** Returns the month (0.0-11.0) for its argument, evaluated in the current time zone. January is month zero. See @@ -373,9 +372,9 @@ on MDN. Js.Date.getMonth(exampleDate) == 10.0 ``` */ +@send external getMonth: t => float = "getMonth" -@send /** Returns the seconds for its argument, evaluated in the current time zone. See [`Date.getSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds) @@ -387,9 +386,9 @@ on MDN. Js.Date.getSeconds(exampleDate) == 54.0 ``` */ +@send external getSeconds: t => float = "getSeconds" -@send /** Returns the number of milliseconds since Unix epoch, evaluated in UTC. See [`Date.getTime`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime) @@ -401,9 +400,9 @@ on MDN. Js.Date.getTime(exampleDate) == 123456654321.0 ``` */ +@send external getTime: t => float = "getTime" -@send /** Returns the time zone offset in minutes from the current time zone to UTC. See [`Date.getTimezoneOffset`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset) @@ -415,9 +414,9 @@ on MDN. Js.Date.getTimezoneOffset(exampleDate) == -60.0 ``` */ +@send external getTimezoneOffset: t => float = "getTimezoneOffset" -@send /** Returns the day of the month of the argument, evaluated in UTC. See [`Date.getUTCDate`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate) @@ -429,9 +428,9 @@ on MDN. Js.Date.getUTCDate(exampleDate) == 29.0 ``` */ +@send external getUTCDate: t => float = "getUTCDate" -@send /** Returns the day of the week of the argument, evaluated in UTC. The range of the return value is 0.0-6.0, where Sunday is zero. See @@ -444,9 +443,9 @@ on MDN. Js.Date.getUTCDay(exampleDate) == 4.0 ``` */ +@send external getUTCDay: t => float = "getUTCDay" -@send /** Returns the full year (as opposed to the range 0-99) for its argument. The argument is evaluated in UTC. See @@ -459,9 +458,9 @@ on MDN. Js.Date.getUTCFullYear(exampleDate) == 1973.0 ``` */ +@send external getUTCFullYear: t => float = "getUTCFullYear" -@send /** Returns the hours for its argument, evaluated in the current time zone. See [`Date.getUTCHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours) @@ -473,9 +472,9 @@ on MDN. Js.Date.getUTCHours(exampleDate) == 21.0 ``` */ +@send external getUTCHours: t => float = "getUTCHours" -@send /** Returns the number of milliseconds for its argument, evaluated in UTC. See [`Date.getUTCMilliseconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds) @@ -487,9 +486,9 @@ on MDN. Js.Date.getUTCMilliseconds(exampleDate) == 321.0 ``` */ +@send external getUTCMilliseconds: t => float = "getUTCMilliseconds" -@send /** Returns the number of minutes for its argument, evaluated in UTC. See [`Date.getUTCMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes) @@ -501,9 +500,9 @@ on MDN. Js.Date.getUTCMinutes(exampleDate) == 30.0 ``` */ +@send external getUTCMinutes: t => float = "getUTCMinutes" -@send /** Returns the month (0.0-11.0) for its argument, evaluated in UTC. January is month zero. See @@ -516,9 +515,9 @@ on MDN. Js.Date.getUTCMonth(exampleDate) == 10.0 ``` */ +@send external getUTCMonth: t => float = "getUTCMonth" -@send /** Returns the seconds for its argument, evaluated in UTC. See [`Date.getUTCSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds) @@ -530,11 +529,11 @@ on MDN. Js.Date.getUTCSeconds(exampleDate) == 54.0 ``` */ +@send external getUTCSeconds: t => float = "getUTCSeconds" @send @deprecated("Use `getFullYear` instead.") external getYear: t => float = "getYear" -@send /** Sets the given `Date`’s day of month to the value in the second argument according to the current time zone. Returns the number of milliseconds since @@ -552,9 +551,9 @@ date1 == Js.Date.fromString("1973-11-15T21:30:54.321Z00:00") twoWeeksBefore == Js.Date.getTime(date1) ``` */ +@send external setDate: (t, float) => float = "setDate" -@send /** Sets the given `Date`’s year to the value in the second argument according to the current time zone. Returns the number of milliseconds since the epoch of @@ -571,9 +570,9 @@ date1 == Js.Date.fromString("1974-11-15T21:30:54.321Z00:00") nextYear == Js.Date.getTime(date1) ``` */ +@send external setFullYear: (t, float) => float = "setFullYear" -@send /** Sets the given `Date`’s year and month to the values in the labeled arguments according to the current time zone. Returns the number of milliseconds since @@ -591,9 +590,9 @@ date1 == Js.Date.fromString("1974-01-22T21:30:54.321Z00:00") future == Js.Date.getTime(date1) ``` */ +@send external setFullYearM: (t, ~year: float, ~month: float, unit) => float = "setFullYear" -@send /** Sets the given `Date`’s year, month, and day of month to the values in the labeled arguments according to the current time zone. Returns the number of @@ -611,10 +610,10 @@ date1 == Js.Date.fromString("1974-01-07T21:30:54.321Z00:00") future == Js.Date.getTime(date1) ``` */ +@send external setFullYearMD: (t, ~year: float, ~month: float, ~date: float, unit) => float = "setFullYear" -@send /** Sets the given `Date`’s hours to the value in the second argument according to the current time zone. Returns the number of milliseconds since the epoch of @@ -631,9 +630,9 @@ date1 == Js.Date.fromString("1973-11-29T22:30:54.321Z00:00") nextHour == Js.Date.getTime(date1) ``` */ +@send external setHours: (t, float) => float = "setHours" -@send /** Sets the given `Date`’s hours and minutes to the values in the labeled arguments according to the current time zone. Returns the number of @@ -651,9 +650,9 @@ date1 == Js.Date.fromString("1973-11-29T22:46:54.321Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setHoursM: (t, ~hours: float, ~minutes: float, unit) => float = "setHours" -@send /** Sets the given `Date`’s hours, minutes, and seconds to the values in the labeled arguments according to the current time zone. Returns the number of @@ -671,10 +670,10 @@ date1 == Js.Date.fromString("1973-11-29T22:46:37.321Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setHoursMS: (t, ~hours: float, ~minutes: float, ~seconds: float, unit) => float = "setHours" -@send /** Sets the given `Date`’s hours, minutes, seconds, and milliseconds to the values in the labeled arguments according to the current time zone. Returns the number @@ -699,6 +698,7 @@ date1 == Js.Date.fromString("1973-11-29T22:46:37.494Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setHoursMSMs: ( t, ~hours: float, @@ -708,7 +708,6 @@ external setHoursMSMs: ( unit, ) => float = "setHours" -@send /** Sets the given `Date`’s milliseconds to the value in the second argument according to the current time zone. Returns the number of milliseconds since @@ -726,9 +725,9 @@ date1 == Js.Date.fromString("1973-11-29T21:30:54.494Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setMilliseconds: (t, float) => float = "setMilliseconds" -@send /** Sets the given `Date`’s minutes to the value in the second argument according to the current time zone. Returns the number of milliseconds since the epoch of @@ -745,9 +744,9 @@ date1 == Js.Date.fromString("1973-11-29T21:34:54.494Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setMinutes: (t, float) => float = "setMinutes" -@send /** Sets the given `Date`’s minutes and seconds to the values in the labeled arguments according to the current time zone. Returns the number of @@ -765,9 +764,9 @@ date1 == Js.Date.fromString("1973-11-29T21:34:56.494Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setMinutesS: (t, ~minutes: float, ~seconds: float, unit) => float = "setMinutes" -@send /** Sets the given `Date`’s minutes, seconds, and milliseconds to the values in the labeled arguments according to the current time zone. Returns the number of @@ -791,10 +790,10 @@ date1 == Js.Date.fromString("1973-11-29T21:34:56.789Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setMinutesSMs: (t, ~minutes: float, ~seconds: float, ~milliseconds: float, unit) => float = "setMinutes" -@send /** Sets the given `Date`’s month to the value in the second argument according to the current time zone. Returns the number of milliseconds since the epoch of @@ -811,9 +810,9 @@ date1 == Js.Date.fromString("1973-12-29T21:34:56.789Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setMonth: (t, float) => float = "setMonth" -@send /** Sets the given `Date`’s month and day of month to the values in the labeled arguments according to the current time zone. Returns the number of @@ -831,9 +830,9 @@ date1 == Js.Date.fromString("1973-12-08T21:34:56.789Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setMonthD: (t, ~month: float, ~date: float, unit) => float = "setMonth" -@send /** Sets the given `Date`’s seconds to the value in the second argument according to the current time zone. Returns the number of milliseconds since the epoch of @@ -850,9 +849,9 @@ date1 == Js.Date.fromString("1973-12-29T21:30:56.321Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setSeconds: (t, float) => float = "setSeconds" -@send /** Sets the given `Date`’s seconds and milliseconds to the values in the labeled arguments according to the current time zone. Returns the number of @@ -870,9 +869,9 @@ date1 == Js.Date.fromString("1973-12-29T21:30:56.789Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setSecondsMs: (t, ~seconds: float, ~milliseconds: float, unit) => float = "setSeconds" -@send /** Sets the given `Date`’s value in terms of milliseconds since the epoch. Returns the number of milliseconds since the epoch of the updated `Date`. *This @@ -890,9 +889,9 @@ date1 == Js.Date.fromString("1976-04-19T12:37:12.101Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setTime: (t, float) => float = "setTime" -@send /** Sets the given `Date`’s day of month to the value in the second argument according to UTC. Returns the number of milliseconds since the epoch of the @@ -909,9 +908,9 @@ date1 == Js.Date.fromString("1973-11-15T21:30:54.321Z00:00") twoWeeksBefore == Js.Date.getTime(date1) ``` */ +@send external setUTCDate: (t, float) => float = "setUTCDate" -@send /** Sets the given `Date`’s year to the value in the second argument according to UTC. Returns the number of milliseconds since the epoch of the updated `Date`. @@ -928,9 +927,9 @@ date1 == Js.Date.fromString("1974-11-15T21:30:54.321Z00:00") nextYear == Js.Date.getTime(date1) ``` */ +@send external setUTCFullYear: (t, float) => float = "setUTCFullYear" -@send /** Sets the given `Date`’s year and month to the values in the labeled arguments according to UTC. Returns the number of milliseconds since the epoch of the @@ -947,9 +946,9 @@ date1 == Js.Date.fromString("1974-01-22T21:30:54.321Z00:00") future == Js.Date.getTime(date1) ``` */ +@send external setUTCFullYearM: (t, ~year: float, ~month: float, unit) => float = "setUTCFullYear" -@send /** Sets the given `Date`’s year, month, and day of month to the values in the labeled arguments according to UTC. Returns the number of milliseconds since @@ -967,10 +966,10 @@ date1 == Js.Date.fromString("1974-01-07T21:30:54.321Z00:00") future == Js.Date.getTime(date1) ``` */ +@send external setUTCFullYearMD: (t, ~year: float, ~month: float, ~date: float, unit) => float = "setUTCFullYear" -@send /** Sets the given `Date`’s hours to the value in the second argument according to UTC. Returns the number of milliseconds since the epoch of the updated `Date`. @@ -987,9 +986,9 @@ date1 == Js.Date.fromString("1973-11-29T22:30:54.321Z00:00") nextHour == Js.Date.getTime(date1) ``` */ +@send external setUTCHours: (t, float) => float = "setUTCHours" -@send /** Sets the given `Date`’s hours and minutes to the values in the labeled arguments according to UTC. Returns the number of milliseconds since the epoch @@ -1006,9 +1005,9 @@ date1 == Js.Date.fromString("1973-11-29T22:46:54.321Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setUTCHoursM: (t, ~hours: float, ~minutes: float, unit) => float = "setUTCHours" -@send /** Sets the given `Date`’s hours, minutes, and seconds to the values in the labeled arguments according to UTC. Returns the number of milliseconds since @@ -1027,10 +1026,10 @@ date1 == Js.Date.fromString("1973-11-29T22:46:37.321Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setUTCHoursMS: (t, ~hours: float, ~minutes: float, ~seconds: float, unit) => float = "setUTCHours" -@send /** Sets the given `Date`’s hours, minutes, seconds, and milliseconds to the values in the labeled arguments according to UTC. Returns the number of milliseconds @@ -1055,6 +1054,7 @@ date1 == Js.Date.fromString("1973-11-29T22:46:37.494Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setUTCHoursMSMs: ( t, ~hours: float, @@ -1064,7 +1064,6 @@ external setUTCHoursMSMs: ( unit, ) => float = "setUTCHours" -@send /** Sets the given `Date`’s milliseconds to the value in the second argument according to UTC. Returns the number of milliseconds since the epoch of the @@ -1081,9 +1080,9 @@ date1 == Js.Date.fromString("1973-11-29T21:30:54.494Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setUTCMilliseconds: (t, float) => float = "setUTCMilliseconds" -@send /** Sets the given `Date`’s minutes to the value in the second argument according to the current time zone. Returns the number of milliseconds since the epoch of @@ -1100,9 +1099,9 @@ date1 == Js.Date.fromString("1973-11-29T21:34:54.494Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setUTCMinutes: (t, float) => float = "setUTCMinutes" -@send /** Sets the given `Date`’s minutes and seconds to the values in the labeled arguments according to UTC. Returns the number of milliseconds since the epoch @@ -1119,9 +1118,9 @@ date1 == Js.Date.fromString("1973-11-29T21:34:56.494Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setUTCMinutesS: (t, ~minutes: float, ~seconds: float, unit) => float = "setUTCMinutes" -@send /** Sets the given `Date`’s minutes, seconds, and milliseconds to the values in the labeled arguments according to UTC. Returns the number of milliseconds since @@ -1145,6 +1144,7 @@ date1 == Js.Date.fromString("1973-11-29T21:34:56.789Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setUTCMinutesSMs: ( t, ~minutes: float, @@ -1153,7 +1153,6 @@ external setUTCMinutesSMs: ( unit, ) => float = "setUTCMinutes" -@send /** Sets the given `Date`’s month to the value in the second argument according to UTC. Returns the number of milliseconds since the epoch of the updated `Date`. @@ -1170,9 +1169,9 @@ date1 == Js.Date.fromString("1973-12-29T21:34:56.789Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setUTCMonth: (t, float) => float = "setUTCMonth" -@send /** Sets the given `Date`’s month and day of month to the values in the labeled arguments according to UTC. Returns the number of milliseconds since the epoch @@ -1189,9 +1188,9 @@ date1 == Js.Date.fromString("1973-12-08T21:34:56.789Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setUTCMonthD: (t, ~month: float, ~date: float, unit) => float = "setUTCMonth" -@send /** Sets the given `Date`’s seconds to the value in the second argument according to UTC. Returns the number of milliseconds since the epoch of the updated @@ -1208,9 +1207,9 @@ date1 == Js.Date.fromString("1973-12-29T21:30:56.321Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setUTCSeconds: (t, float) => float = "setUTCSeconds" -@send /** Sets the given `Date`’s seconds and milliseconds to the values in the labeled arguments according to UTC. Returns the number of milliseconds since the epoch @@ -1227,15 +1226,16 @@ date1 == Js.Date.fromString("1973-12-29T21:30:56.789Z00:00") futureTime == Js.Date.getTime(date1) ``` */ +@send external setUTCSecondsMs: (t, ~seconds: float, ~milliseconds: float, unit) => float = "setUTCSeconds" -@send /** Same as [`setTime()`](#settime). */ +/** Same as [`setTime()`](#settime). */ +@send external setUTCTime: (t, float) => float = "setTime" @send @deprecated("Use `setFullYear` instead") external setYear: (t, float) => float = "setYear" -@send /** Returns the date (day of week, year, month, and day of month) portion of a `Date` in English. See @@ -1248,11 +1248,11 @@ on MDN. Js.Date.toDateString(exampleDate) == "Thu Nov 29 1973" ``` */ +@send external toDateString: t => string = "toDateString" @send @deprecated("Use `toUTCString` instead") external toGMTString: t => string = "toGMTString" -@send /** Returns a simplified version of the ISO 8601 format for the date. See [`Date.toISOString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) @@ -1264,6 +1264,7 @@ on MDN. Js.Date.toISOString(exampleDate) == "1973-11-29T21:30:54.321Z" ``` */ +@send external toISOString: t => string = "toISOString" @send @@ -1273,15 +1274,14 @@ external toISOString: t => string = "toISOString" ) external toJSON: t => string = "toJSON" -@send /** Returns a string representation of the given date. See [`Date.toJSON`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON) on MDN. */ +@send external toJSONUnsafe: t => string = "toJSON" -@send /** Returns the year, month, and day for the given `Date` in the current locale format. See @@ -1295,11 +1295,11 @@ Js.Date.toLocaleDateString(exampleDate) == "11/29/1973" // for en_US.utf8 Js.Date.toLocaleDateString(exampleDate) == "29.11.73" // for de_DE.utf8 ``` */ +@send external toLocaleDateString: t => string = "toLocaleDateString" /* TODO: has overloads with somewhat poor browser support */ -@send /** Returns the time and date for the given `Date` in the current locale format. See @@ -1313,11 +1313,11 @@ Js.Date.toLocaleString(exampleDate) == "11/29/1973, 10:30:54 PM" // for en_US.ut Js.Date.toLocaleString(exampleDate) == "29.11.1973, 22:30:54" // for de_DE.utf8 ``` */ +@send external toLocaleString: t => string = "toLocaleString" /* TODO: has overloads with somewhat poor browser support */ -@send /** Returns the time of day for the given `Date` in the current locale format. See [`Date.toLocaleTimeString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString) @@ -1330,11 +1330,11 @@ Js.Date.toLocaleString(exampleDate) == "10:30:54 PM" // for en_US.utf8 Js.Date.toLocaleString(exampleDate) == "22:30:54" // for de_DE.utf8 ``` */ +@send external toLocaleTimeString: t => string = "toLocaleTimeString" /* TODO: has overloads with somewhat poor browser support */ -@send /** Returns a string representing the date and time of day for the given `Date` in the current locale and time zone. See @@ -1349,9 +1349,9 @@ Js.Date.toString( ) == "Thu Nov 29 1973 22:30:54 GMT+0100 (Central European Standard Time)" ``` */ +@send external toString: t => string = "toString" -@send /** Returns a string representing the time of day for the given `Date` in the current locale and time zone. See @@ -1364,9 +1364,9 @@ on MDN. Js.Date.toTimeString(exampleDate) == "22:30:54 GMT+0100 (Central European Standard Time)" ``` */ +@send external toTimeString: t => string = "toTimeString" -@send /** Returns a string representing the date and time of day for the given `Date` in the current locale and UTC (GMT time zone). See @@ -1379,4 +1379,5 @@ on MDN. Js.Date.toUTCString(exampleDate) == "Thu, 29 Nov 1973 21:30:54 GMT" ``` */ +@send external toUTCString: t => string = "toUTCString" diff --git a/runtime/Js_dict.resi b/runtime/Js_dict.resi index 8baa9407d0..086aabd3c6 100644 --- a/runtime/Js_dict.resi +++ b/runtime/Js_dict.resi @@ -59,7 +59,6 @@ Js.Dict.get(ages, "Paul") == None */ let get: (t<'a>, key) => option<'a> -@get_index /** `Js.Dict.unsafeGet(key)` returns the value if the key exists, otherwise an `undefined` value is returned. Use this only when you are sure the key exists (i.e. when having used the `keys()` function to check that the key is valid). @@ -70,9 +69,9 @@ Js.Dict.unsafeGet(ages, "Fred") == 49 Js.Dict.unsafeGet(ages, "Paul") // returns undefined ``` */ +@get_index external unsafeGet: (t<'a>, key) => 'a = "" -@set_index /** `Js.Dict.set(dict, key, value)` sets the key/value in the dictionary `dict`. If the key does not exist, and entry will be created for it. @@ -89,9 +88,9 @@ Js.Dict.set(ages, "David", 66) Js.log(ages == Js.Dict.fromList(list{("Maria", 31), ("Vinh", 22), ("Fred", 49), ("David", 66)})) ``` */ +@set_index external set: (t<'a>, key, 'a) => unit = "" -@val /** Returns all the keys in the dictionary `dict`. @@ -101,9 +100,11 @@ Returns all the keys in the dictionary `dict`. Js.Dict.keys(ages) == ["Maria", "Vinh", "Fred"] ``` */ +@val external keys: t<'a> => array = "Object.keys" -@obj /** Returns an empty dictionary. */ +/** Returns an empty dictionary. */ +@obj external empty: unit => t<'a> = "" /** Experimental internal function */ diff --git a/runtime/Js_float.res b/runtime/Js_float.res index 0b632058ce..430318e9b6 100644 --- a/runtime/Js_float.res +++ b/runtime/Js_float.res @@ -26,14 +26,12 @@ Provide utilities for JS float. */ -@val /** The special value "Not a Number". See [`NaN`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN) on MDN. */ +@val external _NaN: float = "NaN" -@val -@scope("Number") /** Tests if the given value is `_NaN` @@ -41,10 +39,9 @@ Note that both `_NaN = _NaN` and `_NaN == _NaN` will return `false`. `isNaN` is therefore necessary to test for `_NaN`. Return `true` if the given value is `_NaN`, `false` otherwise. See [`isNaN`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN) on MDN. */ +@val @scope("Number") external isNaN: float => bool = "isNaN" -@val -@scope("Number") /** Tests if the given value is finite. Return `true` if the given value is a finite number, `false` otherwise. See [`isFinite`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite) on MDN. @@ -65,9 +62,9 @@ Js.Float.isFinite(Js.Float._NaN) Js.Float.isFinite(1234.) ``` */ +@val @scope("Number") external isFinite: float => bool = "isFinite" -@send /** Formats a `float` using exponential (scientific) notation. Return a `string` representing the given value in exponential notation. Raise @@ -83,9 +80,9 @@ Js.Float.toExponential(77.1234)->Js.log Js.Float.toExponential(77.)->Js.log ``` */ +@send external toExponential: float => string = "toExponential" -@send /** Formats a `float` using exponential (scientific) notation. `digits` specifies how many digits should appear after the decimal point. The value must be in @@ -101,9 +98,9 @@ See [`toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re Js.Float.toExponentialWithPrecision(77.1234, ~digits=2)->Js.log ``` */ +@send external toExponentialWithPrecision: (float, ~digits: int) => string = "toExponential" -@send /** Formats a `float` using fixed point notation. Return a `string` representing the given value in fixed-point notation (usually). Raise RangeError if digits is not @@ -119,9 +116,9 @@ Js.Float.toFixed(12345.6789)->Js.log Js.Float.toFixed(1.2e21)->Js.log ``` */ +@send external toFixed: float => string = "toFixed" -@send /** Formats a `float` using fixed point notation. `digits` specifies how many digits should appear after the decimal point. The value must be in the range [0, 20] @@ -142,9 +139,9 @@ Js.Float.toFixedWithPrecision(12345.6789, ~digits=1)->Js.log Js.Float.toFixedWithPrecision(0., ~digits=2)->Js.log ``` */ +@send external toFixedWithPrecision: (float, ~digits: int) => string = "toFixed" -@send /** Formats a `float` using some fairly arbitrary rules. Return a `string` representing the given value in fixed-point (usually). `toPrecision` differs @@ -164,11 +161,11 @@ Js.Float.toPrecision(12345.6789)->Js.log Js.Float.toPrecision(1.2e21)->Js.log ``` */ +@send external toPrecision: float => string = "toPrecision" /* equivalent to `toString` I think */ -@send /** Formats a `float` using some fairly arbitrary rules. `digits` specifies how many digits should appear in total. The value must between 0 and some arbitrary number @@ -196,9 +193,9 @@ Js.Float.toPrecisionWithPrecision(12345.6789, ~digits=1)->Js.log Js.Float.toPrecisionWithPrecision(0., ~digits=2)->Js.log ``` */ +@send external toPrecisionWithPrecision: (float, ~digits: int) => string = "toPrecision" -@send /** Formats a `float` as a string. Return a `string` representing the given value in fixed-point (usually). See [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN. @@ -210,9 +207,9 @@ fixed-point (usually). See [`toString`](https://developer.mozilla.org/en-US/docs Js.Float.toString(12345.6789)->Js.log ``` */ +@send external toString: float => string = "toString" -@send /** Formats a `float` as a string. `radix` specifies the radix base to use for the formatted number. The value must be in the range [2, 36] (inclusive). Return a @@ -236,9 +233,9 @@ Js.Float.toStringWithRadix(3735928559., ~radix=16)->Js.log Js.Float.toStringWithRadix(123.456, ~radix=36)->Js.log ``` */ +@send external toStringWithRadix: (float, ~radix: int) => string = "toString" -@val /** Parses the given `string` into a `float` using JavaScript semantics. Return the number as a `float` if successfully parsed, `_NaN` otherwise. @@ -271,4 +268,5 @@ Js.Float.fromString("hello") Js.Float.fromString("100a") ``` */ +@val external fromString: string => float = "Number" diff --git a/runtime/Js_global.res b/runtime/Js_global.res index ed0f9a7b97..5af3149f98 100644 --- a/runtime/Js_global.res +++ b/runtime/Js_global.res @@ -32,7 +32,6 @@ type intervalId = Stdlib_Global.intervalId /** Identify timeout started by `Js.Global.setTimeout`. */ type timeoutId = Stdlib_Global.timeoutId -@val /** Clear an interval started by `Js.Global.setInterval` @@ -57,9 +56,9 @@ let cancel = () => Js.Nullable.iter(interval.contents, (. intervalId) => Js.Global.clearInterval(intervalId)) ``` */ +@val external clearInterval: intervalId => unit = "clearInterval" -@val /** Clear a timeout started by `Js.Global.setTimeout`. @@ -80,9 +79,9 @@ let procrastinate = mins => { } ``` */ +@val external clearTimeout: timeoutId => unit = "clearTimeout" -@val /** Repeatedly executes a callback with a specified interval (in milliseconds) between calls. Returns a `Js.Global.intervalId` that can be passed to @@ -103,9 +102,9 @@ let tick = () => { Js.Global.setInterval(tick, 1000) ``` */ +@val external setInterval: (unit => unit, int) => intervalId = "setInterval" -@val /** Repeatedly executes a callback with a specified interval (in milliseconds) between calls. Returns a `Js.Global.intervalId` that can be passed to @@ -126,9 +125,9 @@ let tick = () => { Js.Global.setIntervalFloat(tick, 1000.0) ``` */ +@val external setIntervalFloat: (unit => unit, float) => intervalId = "setInterval" -@val /** Execute a callback after a specified delay (in milliseconds). Returns a `Js.Global.timeoutId` that can be passed to `Js.Global.clearTimeout` to cancel @@ -144,9 +143,9 @@ let message = "Timed out!" Js.Global.setTimeout(() => Js.log(message), 1000) ``` */ +@val external setTimeout: (unit => unit, int) => timeoutId = "setTimeout" -@val /** Execute a callback after a specified delay (in milliseconds). Returns a `Js.Global.timeoutId` that can be passed to `Js.Global.clearTimeout` to cancel @@ -162,36 +161,37 @@ let message = "Timed out!" Js.Global.setTimeoutFloat(() => Js.log(message), 1000.0) ``` */ +@val external setTimeoutFloat: (unit => unit, float) => timeoutId = "setTimeout" -@val /** URL-encodes a string. See [`encodeURI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI) on MDN. */ +@val external encodeURI: string => string = "encodeURI" -@val /** Decodes a URL-enmcoded string produced by `encodeURI` See [`decodeURI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI) on MDN. */ +@val external decodeURI: string => string = "decodeURI" -@val /** URL-encodes a string, including characters with special meaning in a URI. See [`encodeURIComponent`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) on MDN. */ +@val external encodeURIComponent: string => string = "encodeURIComponent" -@val /** Decodes a URL-enmcoded string produced by `encodeURIComponent` See [`decodeURIComponent`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent) on MDN. */ +@val external decodeURIComponent: string => string = "decodeURIComponent" diff --git a/runtime/Js_int.res b/runtime/Js_int.res index f375b0535a..cf6cc7cf46 100644 --- a/runtime/Js_int.res +++ b/runtime/Js_int.res @@ -35,7 +35,6 @@ comes with `NAN` /* + conversion */ -@send /** Formats an `int` using exponential (scientific) notation. Returns a `string` representing the given value in exponential notation. @@ -50,9 +49,9 @@ See [`toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re Js.log(Js.Int.toExponential(77)) ``` */ +@send external toExponential: int => string = "toExponential" -@send /** Formats an `int` using exponential (scientific) notation. `digits` specifies how many digits should appear after the decimal point. The value must be in the range \[0, 20\] (inclusive). @@ -74,9 +73,9 @@ Js.log(Js.Int.toExponentialWithPrecision(77, ~digits=2)) Js.log(Js.Int.toExponentialWithPrecision(5678, ~digits=2)) ``` */ +@send external toExponentialWithPrecision: (int, ~digits: int) => string = "toExponential" -@send /** Formats an `int` using some fairly arbitrary rules. Returns a `string` representing the given value in fixed-point (usually). @@ -93,9 +92,9 @@ See [`toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe Js.log(Js.Int.toPrecision(123456789)) ``` */ +@send external toPrecision: int => string = "toPrecision" -@send /** Formats an `int` using some fairly arbitrary rules. `digits` specifies how many digits should appear in total. The value must between 0 and some arbitrary number that's hopefully at least larger than 20 (for Node it's 21. Why? Who knows). @@ -121,9 +120,9 @@ Js.log(Js.Int.toPrecisionWithPrecision(123456789, ~digits=2)) Js.log(Js.Int.toPrecisionWithPrecision(0, ~digits=2)) ``` */ +@send external toPrecisionWithPrecision: (int, ~digits: int) => string = "toPrecision" -@send /** Formats an `int` as a `string`. Returns a `string` representing the given value in fixed-point (usually). @@ -137,9 +136,9 @@ See [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referen Js.log(Js.Int.toString(123456789)) ``` */ +@send external toString: int => string = "toString" -@send /** Formats an `int` as a `string`. `radix` specifies the radix base to use for the formatted number. The value must be in the range \[2, 36\] (inclusive). Returns @@ -162,6 +161,7 @@ Js.log(Js.Int.toStringWithRadix(3735928559, ~radix=16)) Js.log(Js.Int.toStringWithRadix(123456, ~radix=36)) ``` */ +@send external toStringWithRadix: (int, ~radix: int) => string = "toString" external toFloat: int => float = "%floatofint" diff --git a/runtime/Js_json.resi b/runtime/Js_json.resi index 8afa7e5430..4dce84f7ea 100644 --- a/runtime/Js_json.resi +++ b/runtime/Js_json.resi @@ -30,7 +30,8 @@ Efficient JSON encoding using JavaScript API /* ## Types */ -@unboxed /** The JSON data structure */ +/** The JSON data structure */ +@unboxed type rec t = Stdlib_JSON.t = | Boolean(bool) | @as(null) Null @@ -106,7 +107,8 @@ let decodeNull: t => option> JSON values. */ -@val /** `null` is the singleton null JSON value. */ +/** `null` is the singleton null JSON value. */ +@val external null: t = "null" /** `string(s)` makes a JSON string of the `string` `s`. */ @@ -144,8 +146,6 @@ external objectArray: array> => t = "%identity" /* ## String conversion */ -@val -@scope("JSON") /** `parseExn(s)` parses the `string` `s` into a JSON data structure. Returns a JSON data structure. @@ -196,10 +196,9 @@ let getIds = s => { Js.log(getIds(` { "ids" : [1, 2, 3 ] } `)) ``` */ +@val @scope("JSON") external parseExn: string => t = "parse" -@val -@scope("JSON") /** `stringify(json)` formats the JSON data structure as a `string`. Returns the string representation of a given JSON data structure. @@ -219,10 +218,9 @@ Js.Dict.set(dict, "likes", Js.Json.stringArray(["ReScript", "ocaml", "js"])) Js.log(Js.Json.stringify(Js.Json.object_(dict))) ``` */ +@val @scope("JSON") external stringify: t => string = "stringify" -@val -@scope("JSON") /** `stringifyWithSpace(json)` formats the JSON data structure as a `string`. Returns the string representation of a given JSON data structure with spacing. @@ -242,10 +240,9 @@ Js.Dict.set(dict, "likes", Js.Json.stringArray(["ReScript", "ocaml", "js"])) Js.log(Js.Json.stringifyWithSpace(Js.Json.object_(dict), 2)) ``` */ +@val @scope("JSON") external stringifyWithSpace: (t, @as(json`null`) _, int) => string = "stringify" -@val -@scope("JSON") /** `stringifyAny(value)` formats any value into a JSON string. @@ -256,6 +253,7 @@ external stringifyWithSpace: (t, @as(json`null`) _, int) => string = "stringify" Js.log(Js.Json.stringifyAny(["hello", "world"])) ``` */ +@val @scope("JSON") external stringifyAny: 'a => option = "stringify" /** diff --git a/runtime/Js_math.res b/runtime/Js_math.res index 15e5649cba..8768193681 100644 --- a/runtime/Js_math.res +++ b/runtime/Js_math.res @@ -29,146 +29,129 @@ because ReScript variable names cannot begin with a capital letter. (Module names begin with upper case.) */ -@val -@scope("Math") /** Euler's number; ≈ 2.718281828459045. See [`Math.E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/E) on MDN. */ +@val @scope("Math") external _E: float = "E" -@val -@scope("Math") /** Natural logarithm of 2; ≈ 0.6931471805599453. See [`Math.LN2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN2) on MDN. */ +@val @scope("Math") external _LN2: float = "LN2" -@val -@scope("Math") /** Natural logarithm of 10; ≈ 2.302585092994046. See [`Math.LN10`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN10) on MDN. */ +@val @scope("Math") external _LN10: float = "LN10" -@val -@scope("Math") /** Base 2 logarithm of E; ≈ 1.4426950408889634. See [`Math.LOG2E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG2E) on MDN. */ +@val @scope("Math") external _LOG2E: float = "LOG2E" -@val -@scope("Math") /** Base 10 logarithm of E; ≈ 0.4342944819032518. See [`Math.LOG10E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG10E) on MDN. */ +@val @scope("Math") external _LOG10E: float = "LOG10E" -@val -@scope("Math") /** Pi - ratio of the circumference to the diameter of a circle; ≈ 3.141592653589793. See [`Math.PI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI) on MDN. */ +@val @scope("Math") external _PI: float = "PI" -@val -@scope("Math") /** Square root of 1/2; ≈ 0.7071067811865476. See [`Math.SQRT1_2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2) on MDN. */ +@val @scope("Math") external _SQRT1_2: float = "SQRT1_2" -@val -@scope("Math") /** Square root of 2; ≈ 1.4142135623730951. See [`Math.SQRT2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT2) on MDN. */ +@val @scope("Math") external _SQRT2: float = "SQRT2" -@val -@scope("Math") /** Absolute value for integer argument. See [`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) on MDN. */ +@val @scope("Math") external abs_int: int => int = "abs" -@val -@scope("Math") /** Absolute value for float argument. See [`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) on MDN. */ +@val @scope("Math") external abs_float: float => float = "abs" -@val -@scope("Math") /** Arccosine (in radians) of argument; returns `NaN` if the argument is outside the range [-1.0, 1.0]. See [`Math.acos`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos) on MDN. */ +@val @scope("Math") external acos: float => float = "acos" -@val -@scope("Math") /** Hyperbolic arccosine (in radians) of argument; returns `NaN` if the argument is less than 1.0. See [`Math.acosh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh) on MDN. */ +@val @scope("Math") external acosh: float => float = "acosh" -@val -@scope("Math") /** Arcsine (in radians) of argument; returns `NaN` if the argument is outside the range [-1.0, 1.0]. See [`Math.asin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin) on MDN. */ +@val @scope("Math") external asin: float => float = "asin" -@val -@scope("Math") /** Hyperbolic arcsine (in radians) of argument. See [`Math.asinh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh) on MDN. */ +@val @scope("Math") external asinh: float => float = "asinh" -@val -@scope("Math") /** Arctangent (in radians) of argument. See [`Math.atan`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan) on MDN. */ +@val @scope("Math") external atan: float => float = "atan" -@val -@scope("Math") /** Hyperbolic arctangent (in radians) of argument; returns `NaN` if the argument is is outside the range [-1.0, 1.0]. Returns `-Infinity` and `Infinity` for @@ -176,10 +159,9 @@ arguments -1.0 and 1.0. See [`Math.atanh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh) on MDN. */ +@val @scope("Math") external atanh: float => float = "atanh" -@val -@scope("Math") /** Returns the angle (in radians) of the quotient `y /. x`. It is also the angle between the *x*-axis and point (*x*, *y*). See @@ -196,19 +178,17 @@ Js.Math.atan2(~x=-5.0, ~y=5.0, ()) == 3.0 *. Js.Math._PI /. 4.0 Js.Math.atan2(~x=-0.0, ~y=-5.0, ()) == -.Js.Math._PI /. 2.0 ``` */ +@val @scope("Math") external atan2: (~y: float, ~x: float, unit) => float = "atan2" -@val -@scope("Math") /** Cube root. See [`Math.cbrt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt) on MDN */ +@val @scope("Math") external cbrt: float => float = "cbrt" -@val -@scope("Math") /** Returns the smallest integer greater than or equal to the argument. This function may return values not representable by `int`, whose range is @@ -227,6 +207,7 @@ Js.Math.unsafe_ceil_int(-3.1) == -3 Js.Math.unsafe_ceil_int(1.0e15) // result is outside range of int datatype ``` */ +@val @scope("Math") external unsafe_ceil_int: float => int = "ceil" @deprecated("Please use `unsafe_ceil_int` instead") let unsafe_ceil = unsafe_ceil_int @@ -258,8 +239,6 @@ let ceil_int = (f: float): int => @deprecated("Please use `ceil_int` instead") let ceil = ceil_int -@val -@scope("Math") /** Returns the smallest integral value greater than or equal to the argument. The result is a `float` and is not restricted to the `int` data type range. @@ -276,10 +255,9 @@ Js.Math.ceil_float(-3.1) == -3.0 Js.Math.ceil_float(2_150_000_000.3) == 2_150_000_001.0 ``` */ +@val @scope("Math") external ceil_float: float => float = "ceil" -@val -@scope("Math") /** Number of leading zero bits of the argument's 32 bit int representation. See [`Math.clz32`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32) @@ -293,48 +271,43 @@ Js.Math.clz32(-1) == 0 Js.Math.clz32(255) == 24 ``` */ +@val @scope("Math") external clz32: int => int = "clz32" -@val -@scope("Math") /** Cosine of argument, which must be specified in radians. See [`Math.cos`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos) on MDN. */ +@val @scope("Math") external cos: float => float = "cos" -@val -@scope("Math") /** Hyperbolic cosine of argument, which must be specified in radians. See [`Math.cosh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh) on MDN. */ +@val @scope("Math") external cosh: float => float = "cosh" -@val -@scope("Math") /** Natural exponentional; returns *e* (the base of natural logarithms) to the power of the given argument. See [`Math.exp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp) on MDN. */ +@val @scope("Math") external exp: float => float = "exp" -@val -@scope("Math") /** Returns *e* (the base of natural logarithms) to the power of the given argument minus 1. See [`Math.expm1`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1) on MDN. */ +@val @scope("Math") external expm1: float => float = "expm1" -@val -@scope("Math") /** Returns the largest integer less than or equal to the argument. This function may return values not representable by `int`, whose range is -2147483648 to @@ -353,6 +326,7 @@ Js.Math.unsafe_floor_int(-3.7) == -4 Js.Math.unsafe_floor_int(1.0e15) // result is outside range of int datatype ``` */ +@val @scope("Math") external unsafe_floor_int: float => int = "floor" @deprecated("Please use `unsafe_floor_int` instead") let unsafe_floor = unsafe_floor_int @@ -384,8 +358,6 @@ let floor_int = f => @deprecated("Please use `floor_int` instead") let floor = floor_int -@val -@scope("Math") /** Returns the largest integral value less than or equal to the argument. The result is a `float` and is not restricted to the `int` data type range. See @@ -401,10 +373,9 @@ Js.Math.floor_float(-3.1) == -4.0 Js.Math.floor_float(2_150_000_000.3) == 2_150_000_000.0 ``` */ +@val @scope("Math") external floor_float: float => float = "floor" -@val -@scope("Math") /** Round to nearest single precision float. See [`Math.fround`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround) @@ -417,21 +388,18 @@ Js.Math.fround(5.5) == 5.5 Js.Math.fround(5.05) == 5.050000190734863 ``` */ +@val @scope("Math") external fround: float => float = "fround" -@val -@scope("Math") /** Returns the square root of the sum of squares of its two arguments (the Pythagorean formula). See [`Math.hypot`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot) on MDN. */ +@val @scope("Math") external hypot: (float, float) => float = "hypot" -@val -@variadic -@scope("Math") /** Returns the square root of the sum of squares of the numbers in the array argument (generalized Pythagorean equation). Using an array allows you to @@ -445,20 +413,18 @@ on MDN. Js.Math.hypotMany([3.0, 4.0, 12.0]) == 13.0 ``` */ +@val @variadic @scope("Math") external hypotMany: array => float = "hypot" -@val -@scope("Math") /** 32-bit integer multiplication. Use this only when you need to optimize performance of multiplication of numbers stored as 32-bit integers. See [`Math.imul`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul) on MDN. */ +@val @scope("Math") external imul: (int, int) => int = "imul" -@val -@scope("Math") /** Returns the natural logarithm of its argument; this is the number *x* such that *e**x* equals the argument. Returns `NaN` for negative @@ -473,10 +439,9 @@ Js.Math.log(Js.Math._E) == 1.0 Js.Math.log(100.0) == 4.605170185988092 ``` */ +@val @scope("Math") external log: float => float = "log" -@val -@scope("Math") /** Returns the natural logarithm of one plus the argument. Returns `NaN` for arguments less than -1. See @@ -490,10 +455,9 @@ Js.Math.log1p(Js.Math._E -. 1.0) == 1.0 Js.Math.log1p(99.0) == 4.605170185988092 ``` */ +@val @scope("Math") external log1p: float => float = "log1p" -@val -@scope("Math") /** Returns the base 10 logarithm of its argument. Returns `NaN` for negative arguments. See @@ -508,10 +472,9 @@ Js.Math.log10(0.01) == -2.0 Js.Math.log10(Js.Math.sqrt(10.0)) == 0.5 ``` */ +@val @scope("Math") external log10: float => float = "log10" -@val -@scope("Math") /** Returns the base 2 logarithm of its argument. Returns `NaN` for negative arguments. See @@ -526,87 +489,73 @@ Js.Math.log2(0.125) == -3.0 Js.Math.log2(Js.Math._SQRT2) == 0.5000000000000001 // due to precision ``` */ +@val @scope("Math") external log2: float => float = "log2" -@val -@scope("Math") /** Returns the maximum of its two integer arguments. See [`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) on MDN. */ +@val @scope("Math") external max_int: (int, int) => int = "max" -@val -@variadic -@scope("Math") /** Returns the maximum of the integers in the given array. See [`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) on MDN. */ +@val @variadic @scope("Math") external maxMany_int: array => int = "max" -@val -@scope("Math") /** Returns the maximum of its two floating point arguments. See [`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) on MDN. */ +@val @scope("Math") external max_float: (float, float) => float = "max" -@val -@variadic -@scope("Math") /** Returns the maximum of the floating point values in the given array. See [`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) on MDN. */ +@val @variadic @scope("Math") external maxMany_float: array => float = "max" -@val -@scope("Math") /** Returns the minimum of its two integer arguments. See [`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) on MDN. */ +@val @scope("Math") external min_int: (int, int) => int = "min" -@val -@variadic -@scope("Math") /** Returns the minimum of the integers in the given array. See [`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) on MDN. */ +@val @variadic @scope("Math") external minMany_int: array => int = "min" -@val -@scope("Math") /** Returns the minimum of its two floating point arguments. See [`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) on MDN. */ +@val @scope("Math") external min_float: (float, float) => float = "min" -@val -@variadic -@scope("Math") /** Returns the minimum of the floating point values in the given array. See [`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) on MDN. */ +@val @variadic @scope("Math") external minMany_float: array => float = "min" -@val -@scope("Math") -@deprecated("use `pow_float` instead, the return type may be not int") /** Raises the given base to the given exponent. (Arguments and result are integers.) See @@ -619,10 +568,9 @@ on MDN. Js.Math.pow_int(~base=3, ~exp=4) == 81 ``` */ +@val @scope("Math") @deprecated("use `pow_float` instead, the return type may be not int") external pow_int: (~base: int, ~exp: int) => int = "pow" -@val -@scope("Math") /** Raises the given base to the given exponent. (Arguments and result are floats.) Returns `NaN` if the result would be imaginary. See @@ -639,15 +587,15 @@ Js.Math.pow_float(~base=625.0, ~exp=-0.5) == 0.04 Js.Float.isNaN(Js.Math.pow_float(~base=-2.0, ~exp=0.5)) == true ``` */ +@val @scope("Math") external pow_float: (~base: float, ~exp: float) => float = "pow" -@val -@scope("Math") /** Returns a random number in the half-closed interval [0,1). See [`Math.random`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random) on MDN. */ +@val @scope("Math") external random: unit => float = "random" /** @@ -658,8 +606,6 @@ on MDN. */ let random_int = (min, max) => floor(random() *. Js_int.toFloat(max - min)) + min -@val -@scope("Math") /** Rounds its argument to nearest integer. For numbers with a fractional portion of exactly 0.5, the argument is rounded to the next integer in the direction @@ -678,85 +624,76 @@ Js.Math.unsafe_round(-3.5) == -3 Js.Math.unsafe_round(2_150_000_000_000.3) // out of range for int ``` */ +@val @scope("Math") external unsafe_round: float => int = "round" -@val -@scope("Math") /** Rounds to nearest integral value (expressed as a float). See [`Math.round`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round) on MDN. */ +@val @scope("Math") external round: float => float = "round" -@val -@scope("Math") /** Returns the sign of its integer argument: -1 if negative, 0 if zero, 1 if positive. See [`Math.sign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign) on MDN. */ +@val @scope("Math") external sign_int: int => int = "sign" -@val -@scope("Math") /** Returns the sign of its float argument: -1.0 if negative, 0.0 if zero, 1.0 if positive. See [`Math.sign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign) on MDN. */ +@val @scope("Math") external sign_float: float => float = "sign" -@val -@scope("Math") /** Sine of argument, which must be specified in radians. See [`Math.sin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin) on MDN. */ +@val @scope("Math") external sin: float => float = "sin" -@val -@scope("Math") /** Hyperbolic sine of argument, which must be specified in radians. See [`Math.sinh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh) on MDN. */ +@val @scope("Math") external sinh: float => float = "sinh" -@val -@scope("Math") /** Square root. If the argument is negative, this function returns `NaN`. See [`Math.sqrt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt) on MDN. */ +@val @scope("Math") external sqrt: float => float = "sqrt" -@val -@scope("Math") /** Tangent of argument, which must be specified in radians. Returns `NaN` if the argument is positive infinity or negative infinity. See [`Math.cos`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos) on MDN. */ +@val @scope("Math") external tan: float => float = "tan" -@val -@scope("Math") /** Hyperbolic tangent of argument, which must be specified in radians. See [`Math.tanh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh) on MDN. */ +@val @scope("Math") external tanh: float => float = "tanh" -@val -@scope("Math") /** Truncates its argument; i.e., removes fractional digits. This function may return values not representable by `int`, whose range is -2147483648 to @@ -766,13 +703,13 @@ exactly. See [`Math.trunc`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc) on MDN. */ +@val @scope("Math") external unsafe_trunc: float => int = "trunc" -@val -@scope("Math") /** Truncates its argument; i.e., removes fractional digits. See [`Math.trunc`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc) on MDN. */ +@val @scope("Math") external trunc: float => float = "trunc" diff --git a/runtime/Js_null.resi b/runtime/Js_null.resi index cb521ea4fb..bdca318358 100644 --- a/runtime/Js_null.resi +++ b/runtime/Js_null.resi @@ -30,8 +30,8 @@ type t<+'a> = Primitive_js_extern.null<'a> = Value('a) | @as(null) Null /** Constructs a value of `Js.null<'a>` containing a value of `'a`. */ external return: 'a => t<'a> = "%identity" -@deprecated("Use = Js.null directly ") /** Returns `true` if the given value is empty (`null`), `false` otherwise. */ +@deprecated("Use = Js.null directly ") let test: t<'a> => bool /** The empty value, `null` */ diff --git a/runtime/Js_obj.res b/runtime/Js_obj.res index 75d75d7442..5b8896068d 100644 --- a/runtime/Js_obj.res +++ b/runtime/Js_obj.res @@ -26,10 +26,10 @@ Provides functions for inspecting and manipulating native JavaScript objects */ -@obj /** `empty()` returns the empty object `{}` */ +/** `empty()` returns the empty object `{}` */ +@obj external empty: unit => {..} = "" -@val /** `assign(target, source)` copies properties from source to target. Properties in `target` will be overwritten by properties in `source` if they have the same key. @@ -63,6 +63,7 @@ Js.log(obj) Js.log(target) ``` */ +@val external assign: ({..}, {..}) => {..} = "Object.assign" /* TODO: diff --git a/runtime/Js_re.res b/runtime/Js_re.res index f81c5bf96e..4b0cb9fa83 100644 --- a/runtime/Js_re.res +++ b/runtime/Js_re.res @@ -173,8 +173,7 @@ let result = Js.Re.exec_(re, "The Quick Brown Fox Jumps Over The Lazy Dog") See [`RegExp.prototype.exec()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec) on MDN. */ -@send -@return(null_to_opt) +@send @return(null_to_opt) external exec_: (t, string) => option = "exec" /** diff --git a/runtime/Js_string.res b/runtime/Js_string.res index 1e24d021ca..5c00df67ce 100644 --- a/runtime/Js_string.res +++ b/runtime/Js_string.res @@ -28,7 +28,6 @@ type t = string -@val /** `make(value)` converts the given value to a `string`. @@ -39,9 +38,9 @@ Js.String2.make(3.5) == "3.5" Js.String2.make([1, 2, 3]) == "1,2,3" ``` */ +@val external make: 'a => t = "String" -@val /** `fromCharCode(n)` creates a `string` containing the character corresponding to that number; `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)`. See [`String.fromCharCode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode) on MDN. @@ -55,19 +54,18 @@ Js.String2.fromCharCode(0xd55c) == `한` Js.String2.fromCharCode(-64568) == `ψ` ``` */ +@val external fromCharCode: int => t = "String.fromCharCode" -@val -@variadic /** `fromCharCodeMany([n1, n2, n3])` creates a `string` from the characters corresponding to the given numbers, using the same rules as `fromCharCode`. See [`String.fromCharCode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode) on MDN. */ +@val @variadic external fromCharCodeMany: array => t = "String.fromCharCode" -@val /** `fromCodePoint(n)` creates a `string` containing the character corresponding to that numeric code point. If the number is not a valid code point, it raises @@ -87,10 +85,9 @@ Js.String2.fromCodePoint(0xd55c) == `한` Js.String2.fromCodePoint(0x1f63a) == `😺` ``` */ +@val external fromCodePoint: int => t = "String.fromCodePoint" -@val -@variadic /** `fromCodePointMany([n1, n2, n3])` creates a `string` from the characters corresponding to the given code point numbers, using the same rules as @@ -105,11 +102,11 @@ on MDN. Js.String2.fromCodePointMany([0xd55c, 0xae00, 0x1f63a]) == `한글😺` ``` */ +@val @variadic external fromCodePointMany: array => t = "String.fromCodePoint" /* String.raw: ES2015, meant to be used with template strings, not directly */ -@get /** `length(s)` returns the length of the given `string`. See [`String.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length) @@ -121,9 +118,9 @@ on MDN. Js.String2.length("abcd") == 4 ``` */ +@get external length: t => int = "length" -@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 @@ -137,6 +134,7 @@ Js.String2.get("Reason", 4) == "o" Js.String2.get(`Rẽasöń`, 5) == `ń` ``` */ +@get_index external get: (t, int) => t = "" /** @@ -231,8 +229,7 @@ on MDN. Js.String.concatMany(["2nd", "3rd", "4th"], "1st") == "1st2nd3rd4th" ``` */ -@send -@variadic +@send @variadic external concatMany: (t, array) => t = "concat" let concatMany = (arg1, obj) => concatMany(obj, arg1) @@ -447,8 +444,7 @@ Js.String.match_(/(\d+)-(\d+)-(\d+)/, "Today is 2018-04-05.") == Js.String.match_(/b[aeiou]g/, "The large container.") == None ``` */ -@send -@return(null_to_opt) +@send @return(null_to_opt) external match_: (t, Js_re.t) => option>> = "match" let match_ = (arg1, obj) => match_(obj, arg1) diff --git a/runtime/Js_string2.res b/runtime/Js_string2.res index d7e466e676..bd90837608 100644 --- a/runtime/Js_string2.res +++ b/runtime/Js_string2.res @@ -26,7 +26,6 @@ type t = string -@val /** `make(value)` converts the given value to a `string`. @@ -37,9 +36,9 @@ Js.String2.make(3.5) == "3.5" Js.String2.make([1, 2, 3]) == "1,2,3" ``` */ +@val external make: 'a => t = "String" -@val /** `fromCharCode(n)` creates a `string` containing the character corresponding to that number; `n` ranges from 0 to 65535.If out of range, the lower 16 bits of @@ -58,10 +57,9 @@ Js.String2.fromCharCode(0xd55c) == `한` Js.String2.fromCharCode(-64568) == `ψ` ``` */ +@val external fromCharCode: int => t = "String.fromCharCode" -@val -@variadic /** `fromCharCodeMany([n1, n2, n3])` creates a `string` from the characters corresponding to the given numbers, using the same rules as `fromCharCode`. @@ -69,9 +67,9 @@ corresponding to the given numbers, using the same rules as `fromCharCode`. See [`String.fromCharCode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode) on MDN. */ +@val @variadic external fromCharCodeMany: array => t = "String.fromCharCode" -@val /** `fromCodePoint(n)` creates a `string` containing the character corresponding to that numeric code point. If the number is not a valid code point, it raises @@ -91,10 +89,9 @@ Js.String2.fromCodePoint(0xd55c) == `한` Js.String2.fromCodePoint(0x1f63a) == `😺` ``` */ +@val external fromCodePoint: int => t = "String.fromCodePoint" -@val -@variadic /** `fromCodePointMany([n1, n2, n3])` creates a `string` from the characters corresponding to the given code point numbers, using the same rules as @@ -109,11 +106,11 @@ on MDN. Js.String2.fromCodePointMany([0xd55c, 0xae00, 0x1f63a]) == `한글😺` ``` */ +@val @variadic external fromCodePointMany: array => t = "String.fromCodePoint" /* String.raw: ES2015, meant to be used with template strings, not directly */ -@get /** `length(s)` returns the length of the given `string`. @@ -126,9 +123,9 @@ on MDN. Js.String2.length("abcd") == 4 ``` */ +@get external length: t => int = "length" -@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 @@ -142,9 +139,9 @@ Js.String2.get("Reason", 4) == "o" Js.String2.get(`Rẽasöń`, 5) == `ń` ``` */ +@get_index external get: (t, int) => t = "" -@send /** `charAt(s, n)` gets the character at index `n` within string `s`. If `n` is negative or greater than the length of `s`, it returns the empty string. If the @@ -162,9 +159,9 @@ Js.String2.charAt("Reason", 12) == "" Js.String2.charAt(`Rẽasöń`, 5) == `ń` ``` */ +@send external charAt: (t, int) => t = "charAt" -@send /** `charCodeAt(s, n)` 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 @@ -182,9 +179,9 @@ Js.String2.charCodeAt(`😺`, 0) == 0xd83d->Belt.Int.toFloat Js.String2.codePointAt(`😺`, 0) == Some(0x1f63a) ``` */ +@send external charCodeAt: (t, int) => float = "charCodeAt" -@send /** `codePointAt(s, n)` returns the code point at position `n` within string `s` as a `Some(value)`. The return value handles code points greater than or equal to @@ -201,9 +198,9 @@ Js.String2.codePointAt(`¿😺?`, 1) == Some(0x1f63a) Js.String2.codePointAt("abc", 5) == None ``` */ +@send external codePointAt: (t, int) => option = "codePointAt" -@send /** `concat(original, append)` returns a new `string` with `append` added after `original`. @@ -217,10 +214,9 @@ on MDN. Js.String2.concat("cow", "bell") == "cowbell" ``` */ +@send external concat: (t, t) => t = "concat" -@send -@variadic /** `concatMany(original, arr)` returns a new `string` consisting of each item of an array of strings added to the `original` string. @@ -234,9 +230,9 @@ on MDN. Js.String2.concatMany("1st", ["2nd", "3rd", "4th"]) == "1st2nd3rd4th" ``` */ +@send @variadic external concatMany: (t, array) => t = "concat" -@send /** ES2015: `endsWith(str, substr)` returns `true` if the `str` ends with `substr`, `false` otherwise. @@ -251,9 +247,9 @@ Js.String2.endsWith("ReScript", "Script") == true Js.String2.endsWith("C++", "Script") == false ``` */ +@send external endsWith: (t, t) => bool = "endsWith" -@send /** `endsWithFrom(str, ending, len)` returns `true` if the first len characters of `str` end with `ending`, `false` otherwise. If `len` is greater than or equal @@ -272,9 +268,9 @@ Js.String2.endsWithFrom("abcde", "cde", 99) == true Js.String2.endsWithFrom("example.dat", "ple", 7) == true ``` */ +@send external endsWithFrom: (t, t, int) => bool = "endsWith" -@send /** ES2015: `includes(str, searchValue)` returns `true` if `searchValue` is found anywhere within `str`, false otherwise. @@ -291,9 +287,9 @@ Js.String2.includes("programmer", "pro") == true Js.String2.includes("programmer.dat", "xyz") == false ``` */ +@send external includes: (t, t) => bool = "includes" -@send /** ES2015: `includes(str, searchValue start)` returns `true` if `searchValue` is found anywhere within `str` starting at character number `start` (where 0 is @@ -310,9 +306,9 @@ Js.String2.includesFrom("programmer", "gram", 4) == false Js.String2.includesFrom(`대한민국`, `한`, 1) == true ``` */ +@send external includesFrom: (t, t, int) => bool = "includes" -@send /** ES2015: `indexOf(str, searchValue)` returns the position at which `searchValue` was first found within `str`, or -1 if `searchValue` is not in `str`. @@ -329,9 +325,9 @@ Js.String2.indexOf("beekeeper", "ee") == 1 Js.String2.indexOf("bookseller", "xyz") == -1 ``` */ +@send external indexOf: (t, t) => int = "indexOf" -@send /** `indexOfFrom(str, searchValue, start)` returns the position at which `searchValue` was found within `str` starting at character position `start`, or @@ -350,9 +346,9 @@ Js.String2.indexOfFrom("bookseller", "sell", 2) == 4 Js.String2.indexOfFrom("bookseller", "sell", 5) == -1 ``` */ +@send external indexOfFrom: (t, t, int) => int = "indexOf" -@send /** `lastIndexOf(str, searchValue)` returns the position of the last occurrence of `searchValue` within `str`, searching backwards from the end of the string. @@ -370,9 +366,9 @@ Js.String2.lastIndexOf("beekeeper", "ee") == 4 Js.String2.lastIndexOf("abcdefg", "xyz") == -1 ``` */ +@send external lastIndexOf: (t, t) => int = "lastIndexOf" -@send /** `lastIndexOfFrom(str, searchValue, start)` returns the position of the last occurrence of `searchValue` within `str`, searching backwards from the given @@ -391,11 +387,11 @@ Js.String2.lastIndexOfFrom("beekeeper", "ee", 3) == 1 Js.String2.lastIndexOfFrom("abcdefg", "xyz", 4) == -1 ``` */ +@send external lastIndexOfFrom: (t, t, int) => int = "lastIndexOf" /* extended by ECMA-402 */ -@send /** `localeCompare(reference, comparison)` returns - a negative value if reference comes before comparison in sort order @@ -413,10 +409,9 @@ Js.String2.localeCompare("cat", "cat") == 0.0 Js.String2.localeCompare("CAT", "cat") > 0.0 ``` */ +@send external localeCompare: (t, t) => float = "localeCompare" -@send -@return({null_to_opt: null_to_opt}) /** `match(str, regexp)` matches a `string` against the given `regexp`. If there is no match, it returns `None`. For regular expressions without the g modifier, if @@ -439,9 +434,9 @@ Js.String2.match_("Today is 2018-04-05.", /(\d+)-(\d+)-(\d+)/) == Js.String2.match_("The large container.", /b[aeiou]g/) == None ``` */ +@send @return({null_to_opt: null_to_opt}) external match_: (t, Js_re.t) => option>> = "match" -@send /** `normalize(str)` returns the normalized Unicode string using Normalization Form Canonical (NFC) Composition. Consider the character ã, which can be represented @@ -453,9 +448,9 @@ See [`String.normalize`](https://developer.mozilla.org/en-US/docs/Web/JavaScript on MDN. See also [Unicode technical report #15](https://unicode.org/reports/tr15/) for details. */ +@send external normalize: t => t = "normalize" -@send /** ES2015: `normalize(str, form)` returns the normalized Unicode string using the specified form of normalization, which may be one of: @@ -467,9 +462,9 @@ specified form of normalization, which may be one of: See [`String.normalize`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize) on MDN. See also [Unicode technical report #15](https://unicode.org/reports/tr15/) for details. */ +@send external normalizeByForm: (t, t) => t = "normalize" -@send /** `repeat(str, n)` returns a `string` that consists of `n` repetitions of `str`. Raises `RangeError` if `n` is negative. @@ -484,9 +479,9 @@ Js.String2.repeat("ha", 3) == "hahaha" Js.String2.repeat("empty", 0) == "" ``` */ +@send external repeat: (t, int) => t = "repeat" -@send /** ES2015: `replace(str, substr, newSubstr)` returns a new `string` which is identical to `str` except with the first matching instance of `substr` replaced @@ -503,9 +498,9 @@ Js.String2.replace("old string", "old", "new") == "new string" Js.String2.replace("the cat and the dog", "the", "this") == "this cat and the dog" ``` */ +@send external replace: (t, t, t) => t = "replace" -@send /** `replaceByRe(str, regex, replacement)` returns a new `string` where occurrences matching regex have been replaced by `replacement`. @@ -520,9 +515,9 @@ Js.String2.replaceByRe("vowels be gone", /[aeiou]/g, "x") == "vxwxls bx gxnx" Js.String2.replaceByRe("Juan Fulano", /(\w+) (\w+)/, "$2, $1") == "Fulano, Juan" ``` */ +@send external replaceByRe: (t, Js_re.t, t) => t = "replace" -@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 @@ -542,9 +537,9 @@ let matchFn = (matchPart, _offset, _wholeString) => Js.String2.toUpperCase(match Js.String2.unsafeReplaceBy0(str, re, matchFn) == "bEAUtIfUl vOwEls" ``` */ +@send external unsafeReplaceBy0: (t, Js_re.t, (t, int, t) => t) => t = "replace" -@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. @@ -567,9 +562,9 @@ let matchFn = (_match, part1, _offset, _wholeString) => { Js.String2.unsafeReplaceBy1(str, re, matchFn) == "Jony is 41" ``` */ +@send external unsafeReplaceBy1: (t, Js_re.t, (t, t, int, t) => t) => t = "replace" -@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. @@ -595,9 +590,9 @@ let matchFn = (_match, p1, p2, _offset, _wholeString) => { Js.String2.unsafeReplaceBy2(str, re, matchFn) == "42" ``` */ +@send external unsafeReplaceBy2: (t, Js_re.t, (t, t, t, int, t) => t) => t = "replace" -@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. @@ -608,9 +603,9 @@ matched. See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN. */ +@send external unsafeReplaceBy3: (t, Js_re.t, (t, t, t, t, int, t) => t) => t = "replace" -@send /** `search(str, regexp)` returns the starting position of the first match of `regexp` in the given `str`, or -1 if there is no match. @@ -625,9 +620,9 @@ Js.String2.search("testing 1 2 3", /\d+/) == 8 Js.String2.search("no numbers", /\d+/) == -1 ``` */ +@send external search: (t, Js_re.t) => int = "search" -@send /** `slice(str, from:n1, to_:n2)` returns the substring of `str` starting at character `n1` up to but not including `n2`. @@ -646,9 +641,9 @@ Js.String2.slice("abcdefg", ~from=-4, ~to_=-2) == "de" Js.String2.slice("abcdefg", ~from=5, ~to_=1) == "" ``` */ +@send external slice: (t, ~from: int, ~to_: int) => t = "slice" -@send /** `sliceToEnd(str, from:n)` returns the substring of `str` starting at character `n` to the end of the string. @@ -665,9 +660,9 @@ Js.String2.sliceToEnd("abcdefg", ~from=-2) == "fg" Js.String2.sliceToEnd("abcdefg", ~from=7) == "" ``` */ +@send external sliceToEnd: (t, ~from: int) => t = "slice" -@send /** `split(str, delimiter)` splits the given `str` at every occurrence of `delimiter` and returns an array of the resulting substrings. @@ -684,9 +679,9 @@ Js.String2.split("good::bad as great::awful", "::") == ["good", "bad as great", Js.String2.split("has-no-delimiter", ";") == ["has-no-delimiter"] ``` */ +@send external split: (t, t) => array = "split" -@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. @@ -696,9 +691,9 @@ splitAtMost "ant/bee/cat/dog/elk" "/" ~limit: 0 = [| |];; splitAtMost "ant/bee/cat/dog/elk" "/" ~limit: 9 = [|"ant"; "bee"; "cat"; "dog"; "elk"|];; ``` */ +@send external splitAtMost: (t, t, ~limit: int) => array = "split" -@send /** `splitByRe(str, regex)` splits the given `str` at every occurrence of `regex` and returns an array of the resulting substrings. @@ -717,9 +712,9 @@ Js.String2.splitByRe("art; bed , cog ;dad", /\s*[,;]\s*TODO/) == [ ] ``` */ +@send external splitByRe: (t, Js_re.t) => array> = "split" -@send /** `splitByReAtMost(str, regex, ~limit:n)` splits the given `str` at every occurrence of `regex` and returns an array of the first `n` resulting @@ -748,9 +743,9 @@ Js.String2.splitByReAtMost("one: two: three: four", /\s*:\s*TODO/, ~limit=8) == ] ``` */ +@send external splitByReAtMost: (t, Js_re.t, ~limit: int) => array> = "split" -@send /** ES2015: `startsWith(str, substr)` returns `true` if the `str` starts with `substr`, `false` otherwise. @@ -766,9 +761,9 @@ Js.String2.startsWith("ReScript", "") == true Js.String2.startsWith("JavaScript", "Re") == false ``` */ +@send external startsWith: (t, t) => bool = "startsWith" -@send /** ES2015: `startsWithFrom(str, substr, n)` returns `true` if the `str` starts with `substr` starting at position `n`, false otherwise. If `n` is negative, @@ -785,9 +780,9 @@ Js.String2.startsWithFrom("ReScript", "", 2) == true Js.String2.startsWithFrom("JavaScript", "Scri", 2) == false ``` */ +@send external startsWithFrom: (t, t, int) => bool = "startsWith" -@send /** `substr(str, ~from:n)` returns the substring of `str` from position `n` to the end of the string. @@ -808,9 +803,9 @@ Js.String2.substr("abcdefghij", ~from=-3) == "hij" Js.String2.substr("abcdefghij", ~from=12) == "" ``` */ +@send external substr: (t, ~from: int) => t = "substr" -@send /** `substrAtMost(str, ~from: pos, ~length: n)` returns the substring of `str` of length `n` starting at position `pos`. @@ -832,9 +827,9 @@ Js.String2.substrAtMost("abcdefghij", ~from=-3, ~length=4) == "hij" Js.String2.substrAtMost("abcdefghij", ~from=12, ~length=2) == "" ``` */ +@send external substrAtMost: (t, ~from: int, ~length: int) => t = "substr" -@send /** `substring(str, ~from: start, ~to_: finish)` returns characters `start` up to but not including finish from `str`. @@ -852,9 +847,9 @@ Js.String2.substring("playground", ~from=6, ~to_=3) == "ygr" Js.String2.substring("playground", ~from=4, ~to_=12) == "ground" ``` */ +@send external substring: (t, ~from: int, ~to_: int) => t = "substring" -@send /** `substringToEnd(str, ~from: start)` returns the substring of `str` from position `start` to the end. @@ -871,9 +866,9 @@ Js.String2.substringToEnd("playground", ~from=-3) == "playground" Js.String2.substringToEnd("playground", ~from=12) == "" ``` */ +@send external substringToEnd: (t, ~from: int) => t = "substring" -@send /** `toLowerCase(str)` converts `str` to lower case using the locale-insensitive case mappings in the Unicode Character Database. Notice that the conversion can @@ -892,17 +887,17 @@ Js.String2.toLowerCase(`ΣΠ`) == `σπ` Js.String2.toLowerCase(`ΠΣ`) == `πς` ``` */ +@send external toLowerCase: t => t = "toLowerCase" -@send /** `toLocaleLowerCase(str)` converts `str` to lower case using the current locale. See [`String.toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase) on MDN. */ +@send external toLocaleLowerCase: t => t = "toLocaleLowerCase" -@send /** `toUpperCase(str)` converts `str` to upper case using the locale-insensitive case mappings in the Unicode Character Database. Notice that the conversion can @@ -920,17 +915,17 @@ Js.String2.toUpperCase(`Straße`) == `STRASSE` Js.String2.toUpperCase(`πς`) == `ΠΣ` ``` */ +@send external toUpperCase: t => t = "toUpperCase" -@send /** `toLocaleUpperCase(str)` converts `str` to upper case using the current locale. See [`String.to:LocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase) on MDN. */ +@send external toLocaleUpperCase: t => t = "toLocaleUpperCase" -@send /** `trim(str)` returns a string that is `str` with whitespace stripped from both ends. Internal whitespace is not removed. @@ -945,11 +940,11 @@ Js.String2.trim(" abc def ") == "abc def" Js.String2.trim("\n\r\t abc def \n\n\t\r ") == "abc def" ``` */ +@send external trim: t => t = "trim" /* HTML wrappers */ -@send /** `anchor(anchorText, anchorName)` creates a string with an HTML `` element with name attribute of `anchorName` and `anchorText` as its content. Please do @@ -964,9 +959,9 @@ on MDN. Js.String2.anchor("Page One", "page1") == "Page One" ``` */ +@send external anchor: (t, t) => t = "anchor" -@send /** ES2015: `link(linkText, urlText)` creates a string with an HTML `` element with href attribute of `urlText` and `linkText` as its content. Please do not @@ -980,6 +975,7 @@ on MDN. Js.String2.link("Go to page two", "page2.html") == "Go to page two" ``` */ +@send external link: (t, t) => t = "link" /* FIXME: we should not encourage people to use [%identity], better diff --git a/runtime/Js_typed_array.res b/runtime/Js_typed_array.res index 246c865b79..753c14fa72 100644 --- a/runtime/Js_typed_array.res +++ b/runtime/Js_typed_array.res @@ -45,7 +45,8 @@ module ArrayBuffer = { type t = array_buffer - @new /** takes length. initializes elements to 0 */ + /** takes length. initializes elements to 0 */ + @new external make: int => t = "ArrayBuffer" /* ArrayBuffer.isView: seems pointless with a type system */ @@ -269,7 +270,8 @@ module Int8Array = { @val external _BYTES_PER_ELEMENT: int = "Int8Array.BYTES_PER_ELEMENT" @new external make: array => t = "Int8Array" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Int8Array" /** @@ -280,12 +282,12 @@ module Int8Array = { @new external fromBufferOffset: (array_buffer, int) => t = "Int8Array" - @new /** raise Js.Exn.Error raises Js exception param offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Int8Array" @new external fromLength: int => t = "Int8Array" @@ -392,22 +394,24 @@ module Uint8Array = { @val external _BYTES_PER_ELEMENT: int = "Uint8Array.BYTES_PER_ELEMENT" @new external make: array => t = "Uint8Array" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Uint8Array" - @new /** + /** **raise** Js.Exn.Error raise Js exception **param** offset is in bytes */ + @new external fromBufferOffset: (array_buffer, int) => t = "Uint8Array" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Uint8Array" @new external fromLength: int => t = "Uint8Array" @@ -514,7 +518,8 @@ module Uint8ClampedArray = { @val external _BYTES_PER_ELEMENT: int = "Uint8ClampedArray.BYTES_PER_ELEMENT" @new external make: array => t = "Uint8ClampedArray" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Uint8ClampedArray" /** @@ -525,12 +530,12 @@ module Uint8ClampedArray = { @new external fromBufferOffset: (array_buffer, int) => t = "Uint8ClampedArray" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Uint8ClampedArray" @new external fromLength: int => t = "Uint8ClampedArray" @@ -637,22 +642,24 @@ module Int16Array = { @val external _BYTES_PER_ELEMENT: int = "Int16Array.BYTES_PER_ELEMENT" @new external make: array => t = "Int16Array" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Int16Array" - @new /** + /** **raise** Js.Exn.Error raise Js exception **param** offset is in bytes */ + @new external fromBufferOffset: (array_buffer, int) => t = "Int16Array" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Int16Array" @new external fromLength: int => t = "Int16Array" @@ -759,22 +766,24 @@ module Uint16Array = { @val external _BYTES_PER_ELEMENT: int = "Uint16Array.BYTES_PER_ELEMENT" @new external make: array => t = "Uint16Array" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Uint16Array" - @new /** + /** **raise** Js.Exn.Error raise Js exception **param** offset is in bytes */ + @new external fromBufferOffset: (array_buffer, int) => t = "Uint16Array" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Uint16Array" @new external fromLength: int => t = "Uint16Array" @@ -881,22 +890,24 @@ module Int32Array = { @val external _BYTES_PER_ELEMENT: int = "Int32Array.BYTES_PER_ELEMENT" @new external make: array => t = "Int32Array" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Int32Array" - @new /** + /** **raise** Js.Exn.Error raise Js exception **param** offset is in bytes */ + @new external fromBufferOffset: (array_buffer, int) => t = "Int32Array" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Int32Array" @new external fromLength: int => t = "Int32Array" @@ -1006,22 +1017,24 @@ module Uint32Array = { @val external _BYTES_PER_ELEMENT: int = "Uint32Array.BYTES_PER_ELEMENT" @new external make: array => t = "Uint32Array" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Uint32Array" - @new /** + /** **raise** Js.Exn.Error raise Js exception **param** offset is in bytes */ + @new external fromBufferOffset: (array_buffer, int) => t = "Uint32Array" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Uint32Array" @new external fromLength: int => t = "Uint32Array" @@ -1131,22 +1144,24 @@ module Float32Array = { @val external _BYTES_PER_ELEMENT: int = "Float32Array.BYTES_PER_ELEMENT" @new external make: array => t = "Float32Array" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Float32Array" - @new /** + /** **raise** Js.Exn.Error raise Js exception **param** offset is in bytes */ + @new external fromBufferOffset: (array_buffer, int) => t = "Float32Array" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Float32Array" @new external fromLength: int => t = "Float32Array" @@ -1257,22 +1272,24 @@ module Float64Array = { @val external _BYTES_PER_ELEMENT: int = "Float64Array.BYTES_PER_ELEMENT" @new external make: array => t = "Float64Array" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Float64Array" - @new /** + /** **raise** Js.Exn.Error raise Js exception **param** offset is in bytes */ + @new external fromBufferOffset: (array_buffer, int) => t = "Float64Array" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Float64Array" @new external fromLength: int => t = "Float64Array" diff --git a/runtime/Js_typed_array2.res b/runtime/Js_typed_array2.res index 077ed84d8d..873517c72f 100644 --- a/runtime/Js_typed_array2.res +++ b/runtime/Js_typed_array2.res @@ -40,7 +40,8 @@ module ArrayBuffer = { type t = array_buffer - @new /** takes length. initializes elements to 0 */ + /** takes length. initializes elements to 0 */ + @new external make: int => t = "ArrayBuffer" /* ArrayBuffer.isView: seems pointless with a type system */ @@ -105,13 +106,15 @@ module Int8Array = { @send external lastIndexOf: (t, elt) => int = "lastIndexOf" @send external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external slice: (t, ~start: int, ~end_: int) => t = "slice" @send external copy: t => t = "slice" @send external sliceFrom: (t, int) => t = "slice" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external subarray: (t, ~start: int, ~end_: int) => t = "subarray" @send external subarrayFrom: (t, int) => t = "subarray" @@ -157,22 +160,24 @@ module Int8Array = { @val external _BYTES_PER_ELEMENT: int = "Int8Array.BYTES_PER_ELEMENT" @new external make: array => t = "Int8Array" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Int8Array" - @new /** + /** **raise** Js.Exn.Error raise Js exception **param** offset is in bytes */ + @new external fromBufferOffset: (array_buffer, int) => t = "Int8Array" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Int8Array" @new external fromLength: int => t = "Int8Array" @@ -226,13 +231,15 @@ module Uint8Array = { @send external lastIndexOf: (t, elt) => int = "lastIndexOf" @send external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external slice: (t, ~start: int, ~end_: int) => t = "slice" @send external copy: t => t = "slice" @send external sliceFrom: (t, int) => t = "slice" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external subarray: (t, ~start: int, ~end_: int) => t = "subarray" @send external subarrayFrom: (t, int) => t = "subarray" @@ -278,22 +285,24 @@ module Uint8Array = { @val external _BYTES_PER_ELEMENT: int = "Uint8Array.BYTES_PER_ELEMENT" @new external make: array => t = "Uint8Array" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Uint8Array" - @new /** + /** **raise** Js.Exn.Error raise Js exception **param** offset is in bytes */ + @new external fromBufferOffset: (array_buffer, int) => t = "Uint8Array" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Uint8Array" @new external fromLength: int => t = "Uint8Array" @@ -347,13 +356,15 @@ module Uint8ClampedArray = { @send external lastIndexOf: (t, elt) => int = "lastIndexOf" @send external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external slice: (t, ~start: int, ~end_: int) => t = "slice" @send external copy: t => t = "slice" @send external sliceFrom: (t, int) => t = "slice" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external subarray: (t, ~start: int, ~end_: int) => t = "subarray" @send external subarrayFrom: (t, int) => t = "subarray" @@ -399,22 +410,24 @@ module Uint8ClampedArray = { @val external _BYTES_PER_ELEMENT: int = "Uint8ClampedArray.BYTES_PER_ELEMENT" @new external make: array => t = "Uint8ClampedArray" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Uint8ClampedArray" - @new /** + /** **raise** Js.Exn.Error raise Js exception **param** offset is in bytes */ + @new external fromBufferOffset: (array_buffer, int) => t = "Uint8ClampedArray" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Uint8ClampedArray" @new external fromLength: int => t = "Uint8ClampedArray" @@ -468,13 +481,15 @@ module Int16Array = { @send external lastIndexOf: (t, elt) => int = "lastIndexOf" @send external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external slice: (t, ~start: int, ~end_: int) => t = "slice" @send external copy: t => t = "slice" @send external sliceFrom: (t, int) => t = "slice" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external subarray: (t, ~start: int, ~end_: int) => t = "subarray" @send external subarrayFrom: (t, int) => t = "subarray" @@ -520,22 +535,24 @@ module Int16Array = { @val external _BYTES_PER_ELEMENT: int = "Int16Array.BYTES_PER_ELEMENT" @new external make: array => t = "Int16Array" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Int16Array" - @new /** + /** **raise** Js.Exn.Error raise Js exception **param** offset is in bytes */ + @new external fromBufferOffset: (array_buffer, int) => t = "Int16Array" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Int16Array" @new external fromLength: int => t = "Int16Array" @@ -589,13 +606,15 @@ module Uint16Array = { @send external lastIndexOf: (t, elt) => int = "lastIndexOf" @send external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external slice: (t, ~start: int, ~end_: int) => t = "slice" @send external copy: t => t = "slice" @send external sliceFrom: (t, int) => t = "slice" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external subarray: (t, ~start: int, ~end_: int) => t = "subarray" @send external subarrayFrom: (t, int) => t = "subarray" @@ -641,22 +660,24 @@ module Uint16Array = { @val external _BYTES_PER_ELEMENT: int = "Uint16Array.BYTES_PER_ELEMENT" @new external make: array => t = "Uint16Array" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Uint16Array" - @new /** + /** **raise** Js.Exn.Error raise Js exception **param** offset is in bytes */ + @new external fromBufferOffset: (array_buffer, int) => t = "Uint16Array" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Uint16Array" @new external fromLength: int => t = "Uint16Array" @@ -710,13 +731,15 @@ module Int32Array = { @send external lastIndexOf: (t, elt) => int = "lastIndexOf" @send external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external slice: (t, ~start: int, ~end_: int) => t = "slice" @send external copy: t => t = "slice" @send external sliceFrom: (t, int) => t = "slice" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external subarray: (t, ~start: int, ~end_: int) => t = "subarray" @send external subarrayFrom: (t, int) => t = "subarray" @@ -762,22 +785,24 @@ module Int32Array = { @val external _BYTES_PER_ELEMENT: int = "Int32Array.BYTES_PER_ELEMENT" @new external make: array => t = "Int32Array" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Int32Array" - @new /** + /** **raise** Js.Exn.Error raise Js exception **param** offset is in bytes */ + @new external fromBufferOffset: (array_buffer, int) => t = "Int32Array" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Int32Array" @new external fromLength: int => t = "Int32Array" @@ -831,13 +856,15 @@ module Uint32Array = { @send external lastIndexOf: (t, elt) => int = "lastIndexOf" @send external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external slice: (t, ~start: int, ~end_: int) => t = "slice" @send external copy: t => t = "slice" @send external sliceFrom: (t, int) => t = "slice" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external subarray: (t, ~start: int, ~end_: int) => t = "subarray" @send external subarrayFrom: (t, int) => t = "subarray" @@ -883,22 +910,24 @@ module Uint32Array = { @val external _BYTES_PER_ELEMENT: int = "Uint32Array.BYTES_PER_ELEMENT" @new external make: array => t = "Uint32Array" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Uint32Array" - @new /** + /** **raise** Js.Exn.Error raise Js exception **param** offset is in bytes */ + @new external fromBufferOffset: (array_buffer, int) => t = "Uint32Array" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Uint32Array" @new external fromLength: int => t = "Uint32Array" @@ -955,13 +984,15 @@ module Float32Array = { @send external lastIndexOf: (t, elt) => int = "lastIndexOf" @send external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external slice: (t, ~start: int, ~end_: int) => t = "slice" @send external copy: t => t = "slice" @send external sliceFrom: (t, int) => t = "slice" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external subarray: (t, ~start: int, ~end_: int) => t = "subarray" @send external subarrayFrom: (t, int) => t = "subarray" @@ -1007,22 +1038,24 @@ module Float32Array = { @val external _BYTES_PER_ELEMENT: int = "Float32Array.BYTES_PER_ELEMENT" @new external make: array => t = "Float32Array" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Float32Array" - @new /** + /** **raise** Js.Exn.Error raise Js exception **param** offset is in bytes */ + @new external fromBufferOffset: (array_buffer, int) => t = "Float32Array" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Float32Array" @new external fromLength: int => t = "Float32Array" @@ -1076,13 +1109,15 @@ module Float64Array = { @send external lastIndexOf: (t, elt) => int = "lastIndexOf" @send external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external slice: (t, ~start: int, ~end_: int) => t = "slice" @send external copy: t => t = "slice" @send external sliceFrom: (t, int) => t = "slice" - @send /** `start` is inclusive, `end_` exclusive */ + /** `start` is inclusive, `end_` exclusive */ + @send external subarray: (t, ~start: int, ~end_: int) => t = "subarray" @send external subarrayFrom: (t, int) => t = "subarray" @@ -1128,22 +1163,24 @@ module Float64Array = { @val external _BYTES_PER_ELEMENT: int = "Float64Array.BYTES_PER_ELEMENT" @new external make: array => t = "Float64Array" - @new /** can throw */ + /** can throw */ + @new external fromBuffer: array_buffer => t = "Float64Array" - @new /** + /** **raise** Js.Exn.Error raise Js exception **param** offset is in bytes */ + @new external fromBufferOffset: (array_buffer, int) => t = "Float64Array" - @new /** **raise** Js.Exn.Error raises Js exception **param** offset is in bytes, length in elements */ + @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Float64Array" @new external fromLength: int => t = "Float64Array" diff --git a/runtime/Js_undefined.resi b/runtime/Js_undefined.resi index 6b379c62f2..4decaa10c2 100644 --- a/runtime/Js_undefined.resi +++ b/runtime/Js_undefined.resi @@ -30,8 +30,8 @@ type t<+'a> = Primitive_js_extern.undefined<'a> /** Constructs a value of `Js.undefined<'a>` containing a value of `'a`. */ external return: 'a => t<'a> = "%identity" -@deprecated("Use = Js.undefined directly") /** Returns `true` if the given value is empty (undefined), `false` otherwise. */ +@deprecated("Use = Js.undefined directly") let test: t<'a> => bool /** diff --git a/runtime/Primitive_exceptions.res b/runtime/Primitive_exceptions.res index d36281d2a1..0f00317c5d 100644 --- a/runtime/Primitive_exceptions.res +++ b/runtime/Primitive_exceptions.res @@ -86,10 +86,10 @@ module Dict = { @set_index external set: (dict<'a>, string, 'a) => unit = "" - @get_index /** It's the same as `Js.Dict.get` but it doesn't have runtime overhead to check if the key exists. */ + @get_index external dangerouslyGetNonOption: (dict<'a>, string) => option<'a> = "" } diff --git a/runtime/Primitive_object.res b/runtime/Primitive_object.res index cb976d3f2b..1cd4f44658 100644 --- a/runtime/Primitive_object.res +++ b/runtime/Primitive_object.res @@ -41,8 +41,6 @@ module O = { for (var x in o) { foo(x) }} `) - @scope(("Object", "prototype", "hasOwnProperty")) - @val /** JS objects are not guaranteed to have `Object` in their prototype chain so calling `some_obj.hasOwnProperty(key)` can sometimes throw @@ -50,6 +48,7 @@ module O = { objects are created via `Object.create(null)`. The only safe way to call this function is directly, e.g. `Object.prototype.hasOwnProperty.call(some_obj, key)`. */ + @scope(("Object", "prototype", "hasOwnProperty")) @val external hasOwnProperty: (t, key) => bool = "call" @get_index external get_value: (t, key) => t = "" diff --git a/runtime/Stdlib_Array.resi b/runtime/Stdlib_Array.resi index fff252d987..249334a3bc 100644 --- a/runtime/Stdlib_Array.resi +++ b/runtime/Stdlib_Array.resi @@ -212,8 +212,7 @@ someArray->Array.pushMany(["yay", "wehoo"]) someArray->assertEqual(["hi", "hello", "yay", "wehoo"]) ``` */ -@variadic -@send +@variadic @send external pushMany: (array<'a>, array<'a>) => unit = "push" /** @@ -357,8 +356,7 @@ someArray->Array.unshiftMany(["yay", "wehoo"]) someArray->assertEqual(["yay", "wehoo", "hi", "hello"]) ``` */ -@variadic -@send +@variadic @send external unshiftMany: (array<'a>, array<'a>) => unit = "unshift" /** @@ -396,8 +394,7 @@ let someArray = array1->Array.concatMany([array2, array3]) Console.log(someArray) // ["hi", "hello", "yay", "wehoo"] ``` */ -@variadic -@send +@variadic @send external concatMany: (array<'a>, array>) => array<'a> = "concat" /** @@ -501,8 +498,7 @@ external join: (array, string) => string = "join" ->assertEqual("One -- Two -- Three") ``` */ -@deprecated("Use `join` instead") -@send +@deprecated("Use `join` instead") @send external joinWith: (array, string) => string = "join" /** @@ -532,8 +528,7 @@ external joinUnsafe: (array<'a>, string) => string = "join" ->assertEqual("1 -- 2 -- 3") ``` */ -@deprecated("Use `joinUnsafe` instead") -@send +@deprecated("Use `joinUnsafe` instead") @send external joinWithUnsafe: (array<'a>, string) => string = "join" @send external lastIndexOf: (array<'a>, 'a) => int = "lastIndexOf" let lastIndexOfOpt: (array<'a>, 'a) => option diff --git a/runtime/Stdlib_BigInt.res b/runtime/Stdlib_BigInt.res index 05ea2a917d..085dc767a9 100644 --- a/runtime/Stdlib_BigInt.res +++ b/runtime/Stdlib_BigInt.res @@ -8,7 +8,6 @@ type t = bigint @val external fromString: string => bigint = "BigInt" -@val /** Parses the given `string` into a `bigint` using JavaScript semantics. Return the number as a `bigint` if successfully parsed. Uncaught syntax exception otherwise. @@ -33,6 +32,7 @@ switch BigInt.fromStringExn("a") { } ``` */ +@val external fromStringExn: string => bigint = "BigInt" @val external fromInt: int => bigint = "BigInt" @val external fromFloat: float => bigint = "BigInt" @@ -43,7 +43,6 @@ let fromFloat = (value: float) => { } } -@send /** Formats a `bigint` as a string. Return a `string` representing the given value. See [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN. @@ -54,12 +53,12 @@ See [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referen BigInt.toString(123n)->assertEqual("123") ``` */ +@send external toString: (bigint, ~radix: int=?) => string = "toString" @deprecated("Use `toString` with `~radix` instead") @send external toStringWithRadix: (bigint, ~radix: int) => string = "toString" -@send /** Returns a string with a language-sensitive representation of this BigInt value. @@ -69,6 +68,7 @@ Returns a string with a language-sensitive representation of this BigInt value. BigInt.toString(123n)->assertEqual("123") ``` */ +@send external toLocaleString: bigint => string = "toLocaleString" @val external toFloat: bigint => float = "Number" diff --git a/runtime/Stdlib_Console.resi b/runtime/Stdlib_Console.resi index 5c0f4f8d8d..a2aa9f028e 100644 --- a/runtime/Stdlib_Console.resi +++ b/runtime/Stdlib_Console.resi @@ -99,8 +99,7 @@ Console.assertMany(false, ["Hello", "World"]) Console.assertMany(value == 42, [1, 2, 3]) ``` */ -@val -@variadic +@val @variadic external assertMany: (bool, array<_>) => unit = "console.assert" /** @@ -240,8 +239,7 @@ Console.debugMany(["Hello", "World"]) Console.debugMany([1, 2, 3]) ``` */ -@val -@variadic +@val @variadic external debugMany: array<_> => unit = "console.debug" type dirOptions = { @@ -403,8 +401,7 @@ Console.errorMany(["Hello", "World"]) Console.errorMany([1, 2, 3]) ``` */ -@val -@variadic +@val @variadic external errorMany: array<_> => unit = "console.error" /** @@ -498,8 +495,7 @@ Console.infoMany(["Hello", "World"]) Console.infoMany([1, 2, 3]) ``` */ -@val -@variadic +@val @variadic external infoMany: array<_> => unit = "console.info" /** @@ -594,8 +590,7 @@ Console.logMany(["Hello", "World"]) Console.logMany([1, 2, 3]) ``` */ -@val -@variadic +@val @variadic external logMany: array<_> => unit = "console.log" /** @@ -787,6 +782,5 @@ Console.warnMany(["Hello", "World"]) Console.warnMany([1, 2, 3]) ``` */ -@val -@variadic +@val @variadic external warnMany: array<_> => unit = "console.warn" diff --git a/runtime/Stdlib_Date.resi b/runtime/Stdlib_Date.resi index dc3ca837cc..33bbf4ce4e 100644 --- a/runtime/Stdlib_Date.resi +++ b/runtime/Stdlib_Date.resi @@ -1356,8 +1356,7 @@ Date.fromString("")->Date.toJSON // None ``` */ -@return(nullable) -@send +@return(nullable) @send external toJSON: t => option = "toJSON" /** diff --git a/runtime/Stdlib_Error.resi b/runtime/Stdlib_Error.resi index 87c095eb37..ad7f05b367 100644 --- a/runtime/Stdlib_Error.resi +++ b/runtime/Stdlib_Error.resi @@ -35,8 +35,7 @@ let error = Error.make("error") Console.log(error->Error.stack) // Logs `stack` if it exists on `someError` ``` */ -@deprecated("Use `JsError.stack` instead") -@get +@deprecated("Use `JsError.stack` instead") @get external stack: t => option = "stack" /** @@ -50,8 +49,7 @@ let error = Error.SyntaxError.make("Some message here") Console.log(error->Error.message) // Logs "Some message here" to the console ``` */ -@deprecated("Use `JsError.message` instead") -@get +@deprecated("Use `JsError.message` instead") @get external message: t => option = "message" /** @@ -65,8 +63,7 @@ let error = Error.SyntaxError.make("Some message here") Console.log(error->Error.name) // Logs "SyntaxError" to the console ``` */ -@deprecated("Use `JsError.name` instead") -@get +@deprecated("Use `JsError.name` instead") @get external name: t => option = "name" /** @@ -74,8 +71,7 @@ external name: t => option = "name" See [`Error.prototype.fileName`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName) on MDN. */ -@deprecated("Use `JsError.fileName` instead") -@get +@deprecated("Use `JsError.fileName` instead") @get external fileName: t => option = "fileName" /** @@ -90,8 +86,7 @@ Console.log(error->Error.message) // Logs "Some message here" to the console Console.log(error->Error.name) // Logs "Error" to the console, because this is a regular error ``` */ -@deprecated("Use `JsError.make` instead") -@new +@deprecated("Use `JsError.make` instead") @new external make: string => t = "Error" module EvalError: { @@ -100,8 +95,7 @@ module EvalError: { See [`EvalError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError) on MDN. */ - @deprecated("Use `JsError.EvalError.make` instead") - @new + @deprecated("Use `JsError.EvalError.make` instead") @new external make: string => t = "EvalError" } module RangeError: { @@ -110,8 +104,7 @@ module RangeError: { See [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) on MDN. */ - @deprecated("Use `JsError.RangeError.make` instead") - @new + @deprecated("Use `JsError.RangeError.make` instead") @new external make: string => t = "RangeError" } module ReferenceError: { @@ -120,8 +113,7 @@ module ReferenceError: { See [`ReferenceError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError) on MDN. */ - @deprecated("Use `JsError.ReferenceError.make` instead") - @new + @deprecated("Use `JsError.ReferenceError.make` instead") @new external make: string => t = "ReferenceError" } module SyntaxError: { @@ -130,8 +122,7 @@ module SyntaxError: { See [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) on MDN. */ - @deprecated("Use `JsError.SyntaxError.make` instead") - @new + @deprecated("Use `JsError.SyntaxError.make` instead") @new external make: string => t = "SyntaxError" } module TypeError: { @@ -140,8 +131,7 @@ module TypeError: { See [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) on MDN. */ - @deprecated("Use `JsError.TypeError.make` instead") - @new + @deprecated("Use `JsError.TypeError.make` instead") @new external make: string => t = "TypeError" } module URIError: { @@ -150,8 +140,7 @@ module URIError: { See [`URIError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError) on MDN. */ - @deprecated("Use `JsError.URIError.make` instead") - @new + @deprecated("Use `JsError.URIError.make` instead") @new external make: string => t = "URIError" } diff --git a/runtime/Stdlib_Float.resi b/runtime/Stdlib_Float.resi index 7bdc0bab49..8b653af100 100644 --- a/runtime/Stdlib_Float.resi +++ b/runtime/Stdlib_Float.resi @@ -208,8 +208,7 @@ Float.parseIntWithRadix("12", ~radix=13) // 15.0 Float.parseIntWithRadix("17", ~radix=40)->Float.isNaN // true ``` */ -@deprecated("Use `parseInt` instead") -@val +@deprecated("Use `parseInt` instead") @val external parseIntWithRadix: ('a, ~radix: int) => float = "parseInt" /** @@ -251,8 +250,7 @@ Float.toExponentialWithPrecision(5678.0, ~digits=2) // "5.68e+3" - `RangeError`: If `digits` less than 0 or greater than 10. */ -@deprecated("Use `toExponential` instead") -@send +@deprecated("Use `toExponential` instead") @send external toExponentialWithPrecision: (float, ~digits: int) => string = "toExponential" /** @@ -294,8 +292,7 @@ Float.toFixedWithPrecision(300.0, ~digits=1) // "300.0" - `RangeError`: If `digits` is less than 0 or larger than 100. */ -@deprecated("Use `toFixed` instead") -@send +@deprecated("Use `toFixed` instead") @send external toFixedWithPrecision: (float, ~digits: int) => string = "toFixed" /** @@ -340,8 +337,7 @@ Implementations are allowed to support larger and smaller values as well. ECMA-262 only requires a precision of up to 21 significant digits. */ -@deprecated("Use `toPrecision` instead") -@send +@deprecated("Use `toPrecision` instead") @send external toPrecisionWithPrecision: (float, ~digits: int) => string = "toPrecision" /** @@ -375,8 +371,7 @@ Float.toStringWithRadix(123456.0, ~radix=36) // "2n9c" `RangeError`: if `radix` is less than 2 or greater than 36. */ -@deprecated("Use `toString` with `~radix` instead") -@send +@deprecated("Use `toString` with `~radix` instead") @send external toStringWithRadix: (float, ~radix: int) => string = "toString" /** diff --git a/runtime/Stdlib_Int.resi b/runtime/Stdlib_Int.resi index 915a685f68..3963be3cb2 100644 --- a/runtime/Stdlib_Int.resi +++ b/runtime/Stdlib_Int.resi @@ -103,8 +103,7 @@ Int.toExponentialWithPrecision(5678, ~digits=2) // "5.68e+3" - `RangeError`: If `digits` less than 0 or greater than 10. */ -@deprecated("Use `toExponential` instead") -@send +@deprecated("Use `toExponential` instead") @send external toExponentialWithPrecision: (int, ~digits: int) => string = "toExponential" /** @@ -146,8 +145,7 @@ Int.toFixedWithPrecision(300, ~digits=1) // "300.0" - `RangeError`: If `digits` is less than 0 or larger than 100. */ -@deprecated("Use `toFixed` instead") -@send +@deprecated("Use `toFixed` instead") @send external toFixedWithPrecision: (int, ~digits: int) => string = "toFixed" /** @@ -190,8 +188,7 @@ Implementations are allowed to support larger and smaller values as well. ECMA-262 only requires a precision of up to 21 significant digits. */ -@send -@deprecated("Use `toPrecision` instead") +@send @deprecated("Use `toPrecision` instead") external toPrecisionWithPrecision: (int, ~digits: int) => string = "toPrecision" /** @@ -235,8 +232,7 @@ Int.toStringWithRadix(123456, ~radix=36) // "2n9c" `RangeError`: if `radix` is less than 2 or greater than 36. */ -@deprecated("Use `toString` instead") -@send +@deprecated("Use `toString` instead") @send external toStringWithRadix: (int, ~radix: int) => string = "toString" /** diff --git a/runtime/Stdlib_JSON.resi b/runtime/Stdlib_JSON.resi index 9b816feb02..cc8703c004 100644 --- a/runtime/Stdlib_JSON.resi +++ b/runtime/Stdlib_JSON.resi @@ -60,8 +60,7 @@ try { - Raises a SyntaxError (Exn.t) if the string isn't valid JSON. */ -@raises(Exn.t) -@val +@raises(Exn.t) @val external parseExn: (string, ~reviver: (string, t) => t=?) => t = "JSON.parse" /** @@ -97,9 +96,7 @@ try { - Raises a SyntaxError if the string isn't valid JSON. */ -@deprecated("Use `parseExn` with optional parameter instead") -@raises(Exn.t) -@val +@deprecated("Use `parseExn` with optional parameter instead") @raises(Exn.t) @val external parseExnWithReviver: (string, (string, t) => t) => t = "JSON.parse" /** @@ -171,8 +168,7 @@ JSON.stringifyWithIndent(json, 2) // } ``` */ -@deprecated("Use `stringify` with optional parameter instead") -@val +@deprecated("Use `stringify` with optional parameter instead") @val external stringifyWithIndent: (t, @as(json`null`) _, int) => string = "JSON.stringify" /** @@ -204,8 +200,7 @@ JSON.stringifyWithReplacer(json, replacer) // {"foo":"BAR","hello":"WORLD","someNumber":42} ``` */ -@deprecated("Use `stringify` with optional parameter instead") -@val +@deprecated("Use `stringify` with optional parameter instead") @val external stringifyWithReplacer: (t, (string, t) => t) => string = "JSON.stringify" /** @@ -241,8 +236,7 @@ JSON.stringifyWithReplacerAndIndent(json, replacer, 2) // } ``` */ -@deprecated("Use `stringify` with optional parameters instead") -@val +@deprecated("Use `stringify` with optional parameters instead") @val external stringifyWithReplacerAndIndent: (t, (string, t) => t, int) => string = "JSON.stringify" /** @@ -265,8 +259,7 @@ JSON.stringifyWithFilter(json, ["foo", "someNumber"]) // {"foo":"bar","someNumber":42} ``` */ -@deprecated("Use `stringify` with optional parameter instead") -@val +@deprecated("Use `stringify` with optional parameter instead") @val external stringifyWithFilter: (t, array) => string = "JSON.stringify" /** @@ -292,8 +285,7 @@ JSON.stringifyWithFilterAndIndent(json, ["foo", "someNumber"], 2) // } ``` */ -@deprecated("Use `stringify` with optional parameters instead") -@val +@deprecated("Use `stringify` with optional parameters instead") @val external stringifyWithFilterAndIndent: (t, array, int) => string = "JSON.stringify" /** @@ -362,8 +354,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Raises a TypeError if the value contains circular references. - Raises a TypeError if the value contains `BigInt`s. */ -@raises(Exn.t) -@val +@raises(Exn.t) @val external stringifyAny: ('a, ~replacer: replacer=?, ~space: int=?) => option = "JSON.stringify" @@ -406,9 +397,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Raises a TypeError if the value contains circular references. - Raises a TypeError if the value contains `BigInt`s. */ -@deprecated("Use `stringifyAny` with optional parameter instead") -@raises(Exn.t) -@val +@deprecated("Use `stringifyAny` with optional parameter instead") @raises(Exn.t) @val external stringifyAnyWithIndent: ('a, @as(json`null`) _, int) => option = "JSON.stringify" /** @@ -455,9 +444,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Raises a TypeError if the value contains circular references. - Raises a TypeError if the value contains `BigInt`s. */ -@deprecated("Use `stringifyAny` with optional parameter instead") -@raises -@val +@deprecated("Use `stringifyAny` with optional parameter instead") @raises @val external stringifyAnyWithReplacer: ('a, (string, t) => t) => option = "JSON.stringify" /** @@ -505,9 +492,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Raises a TypeError if the value contains circular references. - Raises a TypeError if the value contains `BigInt`s. */ -@deprecated("Use `stringifyAny` with optional parameters instead") -@raises -@val +@deprecated("Use `stringifyAny` with optional parameters instead") @raises @val external stringifyAnyWithReplacerAndIndent: ('a, (string, t) => t, int) => option = "JSON.stringify" @@ -546,9 +531,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Raises a TypeError if the value contains circular references. - Raises a TypeError if the value contains `BigInt`s. */ -@deprecated("Use `stringifyAny` with optional parameter instead") -@raises -@val +@deprecated("Use `stringifyAny` with optional parameter instead") @raises @val external stringifyAnyWithFilter: ('a, array) => string = "JSON.stringify" /** @@ -601,9 +584,7 @@ switch BigInt.fromInt(0)->JSON.stringifyAny { - Raises a TypeError if the value contains circular references. - Raises a TypeError if the value contains `BigInt`s. */ -@deprecated("Use `stringifyAny` with optional parameters instead") -@raises -@val +@deprecated("Use `stringifyAny` with optional parameters instead") @raises @val external stringifyAnyWithFilterAndIndent: ('a, array, int) => string = "JSON.stringify" module Classify: { diff --git a/runtime/Stdlib_Math.resi b/runtime/Stdlib_Math.resi index a90e90cd4d..a515274078 100644 --- a/runtime/Stdlib_Math.resi +++ b/runtime/Stdlib_Math.resi @@ -212,8 +212,7 @@ module Int: { assertEqual(Math.Int.minMany([])->Int.toFloat->Float.isFinite, false) ``` */ - @variadic - @val + @variadic @val external minMany: array => int = "Math.min" /** @@ -243,8 +242,7 @@ module Int: { assertEqual(Math.Int.maxMany([])->Int.toFloat->Float.isFinite, false) ``` */ - @variadic - @val + @variadic @val external maxMany: array => int = "Math.max" /** @@ -599,8 +597,7 @@ assertEqual(Math.hypotMany([3.0, 4.0, 5.0]), 7.0710678118654755) assertEqual(Math.hypotMany([]), 0.0) ``` */ -@variadic -@val +@variadic @val external hypotMany: array => float = "Math.hypot" /** @@ -698,8 +695,7 @@ assertEqual(Math.minMany([-1.0, -2.0]), -2.0) assertEqual(Math.minMany([])->Float.isFinite, false) ``` */ -@variadic -@val +@variadic @val external minMany: array => float = "Math.min" /** @@ -729,8 +725,7 @@ assertEqual(Math.maxMany([-1.0, -2.0]), -1.0) assertEqual(Math.maxMany([])->Float.isFinite, false) ``` */ -@variadic -@val +@variadic @val external maxMany: array => float = "Math.max" /** diff --git a/runtime/Stdlib_Object.res b/runtime/Stdlib_Object.res index f2304cf1ef..f21e4ff52b 100644 --- a/runtime/Stdlib_Object.res +++ b/runtime/Stdlib_Object.res @@ -88,8 +88,7 @@ external assign: ({..}, {..}) => {..} = "Object.assign" See [Object.assign on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) or [ECMAScript Language Specification](https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign). */ -@variadic -@val +@variadic @val external assignMany: ({..}, array<{..}>) => {..} = "Object.assign" @val external copy: (@as(json`{}`) _, {..} as 'a) => 'a = "Object.assign" diff --git a/runtime/Stdlib_Promise.resi b/runtime/Stdlib_Promise.resi index a1fd1def74..9f77faced8 100644 --- a/runtime/Stdlib_Promise.resi +++ b/runtime/Stdlib_Promise.resi @@ -24,8 +24,7 @@ See [`Promise.resolve`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/ let p = Promise.resolve(5) // promise ``` */ -@val -@scope("Promise") +@val @scope("Promise") external resolve: 'a => t<'a> = "resolve" /** @@ -49,8 +48,7 @@ TestError("some rejected value") ->ignore ``` */ -@scope("Promise") -@val +@scope("Promise") @val external reject: exn => t<_> = "reject" /** @@ -111,8 +109,7 @@ promise ->ignore ``` */ -@scope("Promise") -@val +@scope("Promise") @val external withResolvers: unit => promiseAndResolvers<_> = "withResolvers" /** @@ -268,8 +265,7 @@ race(promises)->then(winner => { }) ``` */ -@scope("Promise") -@val +@scope("Promise") @val external race: array> => t<'a> = "race" /** @@ -295,8 +291,7 @@ any(promises)->then(winner => { }) ``` */ -@scope("Promise") -@val +@scope("Promise") @val external any: array> => t<'a> = "any" /** @@ -317,43 +312,37 @@ all(promises) ->ignore ``` */ -@scope("Promise") -@val +@scope("Promise") @val external all: array> => t> = "all" /** `all2((p1, p2))`. Like `all()`, but with a fixed size tuple of 2 */ -@scope("Promise") -@val +@scope("Promise") @val external all2: ((t<'a>, t<'b>)) => t<('a, 'b)> = "all" /** `all3((p1, p2, p3))`. Like `all()`, but with a fixed size tuple of 3 */ -@scope("Promise") -@val +@scope("Promise") @val external all3: ((t<'a>, t<'b>, t<'c>)) => t<('a, 'b, 'c)> = "all" /** `all4((p1, p2, p3, p4))`. Like `all()`, but with a fixed size tuple of 4 */ -@scope("Promise") -@val +@scope("Promise") @val external all4: ((t<'a>, t<'b>, t<'c>, t<'d>)) => t<('a, 'b, 'c, 'd)> = "all" /** `all5((p1, p2, p3, p4, p5))`. Like `all()`, but with a fixed size tuple of 5 */ -@scope("Promise") -@val +@scope("Promise") @val external all5: ((t<'a>, t<'b>, t<'c>, t<'d>, t<'e>)) => t<('a, 'b, 'c, 'd, 'e)> = "all" /** `all6((p1, p2, p4, p5, p6))`. Like `all()`, but with a fixed size tuple of 6 ")*/ -@scope("Promise") -@val +@scope("Promise") @val external all6: ((t<'a>, t<'b>, t<'c>, t<'d>, t<'e>, t<'f>)) => t<('a, 'b, 'c, 'd, 'e, 'f)> = "all" @tag("status") @@ -386,22 +375,19 @@ allSettled(promises) ->ignore ``` */ -@scope("Promise") -@val +@scope("Promise") @val external allSettled: array> => t>> = "allSettled" /** `allSettled2((p1, p2))`. Like `allSettled()`, but with a fixed size tuple of 2 */ -@scope("Promise") -@val +@scope("Promise") @val external allSettled2: ((t<'a>, t<'b>)) => t<(settledResult<'a>, settledResult<'b>)> = "allSettled" /** `allSettled3((p1, p2, p3))`. Like `allSettled()`, but with a fixed size tuple of 3 */ -@scope("Promise") -@val +@scope("Promise") @val external allSettled3: ((t<'a>, t<'b>, t<'c>)) => t<( settledResult<'a>, settledResult<'b>, @@ -411,8 +397,7 @@ external allSettled3: ((t<'a>, t<'b>, t<'c>)) => t<( /** `allSettled4((p1, p2, p3, p4))`. Like `allSettled()`, but with a fixed size tuple of 4 */ -@scope("Promise") -@val +@scope("Promise") @val external allSettled4: ((t<'a>, t<'b>, t<'c>, t<'d>)) => t<( settledResult<'a>, settledResult<'b>, @@ -423,8 +408,7 @@ external allSettled4: ((t<'a>, t<'b>, t<'c>, t<'d>)) => t<( /** `allSettled5((p1, p2, p3, p4, p5))`. Like `allSettled()`, but with a fixed size tuple of 5 */ -@scope("Promise") -@val +@scope("Promise") @val external allSettled5: ((t<'a>, t<'b>, t<'c>, t<'d>, t<'e>)) => t<( settledResult<'a>, settledResult<'b>, @@ -436,8 +420,7 @@ external allSettled5: ((t<'a>, t<'b>, t<'c>, t<'d>, t<'e>)) => t<( /** `allSettled6((p1, p2, p4, p5, p6))`. Like `allSettled()`, but with a fixed size tuple of 6 ")*/ -@scope("Promise") -@val +@scope("Promise") @val external allSettled6: ((t<'a>, t<'b>, t<'c>, t<'d>, t<'e>, t<'f>)) => t<( settledResult<'a>, settledResult<'b>, diff --git a/runtime/Stdlib_RegExp.resi b/runtime/Stdlib_RegExp.resi index 3b327a1eb4..b249ae65bf 100644 --- a/runtime/Stdlib_RegExp.resi +++ b/runtime/Stdlib_RegExp.resi @@ -117,8 +117,7 @@ switch regexp->RegExp.exec("ReScript is pretty cool, right?") { } ``` */ -@deprecated("Use `fromString` instead") -@new +@deprecated("Use `fromString` instead") @new external fromStringWithFlags: (string, ~flags: string) => t = "RegExp" /** @@ -155,8 +154,7 @@ switch regexp->RegExp.exec("ReScript is pretty cool, right?") { } ``` */ -@return(nullable) -@send +@return(nullable) @send external exec: (t, string) => option = "exec" /** diff --git a/runtime/Stdlib_String.resi b/runtime/Stdlib_String.resi index c74996dea3..84ad5cfdb2 100644 --- a/runtime/Stdlib_String.resi +++ b/runtime/Stdlib_String.resi @@ -76,8 +76,7 @@ String.fromCharCodeMany([189, 43, 190, 61]) == "½+¾=" String.fromCharCodeMany([65, 66, 67]) == "ABC" ``` */ -@variadic -@val +@variadic @val external fromCharCodeMany: array => string = "String.fromCharCode" /** @@ -119,8 +118,7 @@ String.fromCodePointMany([0xd55c, 0xae00, 0x1f63a]) == `한글😺` `fromCharCode([1, -5])`. */ -@variadic -@val +@variadic @val external fromCodePointMany: array => string = "String.fromCodePoint" external equal: (string, string) => bool = "%equal" @@ -250,8 +248,7 @@ See [`String.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Re String.concatMany("1st", ["2nd", "3rd", "4th"]) == "1st2nd3rd4th" ``` */ -@variadic -@send +@variadic @send external concatMany: (string, array) => string = "concat" /** @@ -442,8 +439,7 @@ String.match("The optional example", %re("/(foo)?(example)/")) == Some([Some("ex String.match("The large container.", %re("/b[aeiou]g/")) == None ``` */ -@return(nullable) -@send +@return(nullable) @send external match: (string, Stdlib_RegExp.t) => option = "match" /** @@ -595,8 +591,7 @@ let matchFn = (~match, ~offset as _, ~input as _) => String.toUpperCase(match) String.unsafeReplaceRegExpBy0(str, re, matchFn) == "bEAUtIfUl vOwEls" ``` */ -@deprecated("Use `replaceRegExpBy0Unsafe` instead") -@send +@deprecated("Use `replaceRegExpBy0Unsafe` instead") @send external unsafeReplaceRegExpBy0: ( string, Stdlib_RegExp.t, @@ -619,8 +614,7 @@ let matchFn = (~match as _, ~group1, ~offset as _, ~input as _) => { String.unsafeReplaceRegExpBy1(str, re, matchFn) == "Jony is 41" ``` */ -@deprecated("Use `replaceRegExpBy1Unsafe` instead") -@send +@deprecated("Use `replaceRegExpBy1Unsafe` instead") @send external unsafeReplaceRegExpBy1: ( string, Stdlib_RegExp.t, @@ -646,8 +640,7 @@ let matchFn = (~match as _, ~group1, ~group2, ~offset as _, ~input as _) => { String.unsafeReplaceRegExpBy2(str, re, matchFn) == "42" ``` */ -@deprecated("Use `replaceRegExpBy2Unsafe` instead") -@send +@deprecated("Use `replaceRegExpBy2Unsafe` instead") @send external unsafeReplaceRegExpBy2: ( string, Stdlib_RegExp.t, @@ -659,8 +652,7 @@ external unsafeReplaceRegExpBy2: ( has three group parameters. See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) on MDN. */ -@deprecated("Use `replaceRegExpBy3Unsafe` instead") -@send +@deprecated("Use `replaceRegExpBy3Unsafe` instead") @send external unsafeReplaceRegExpBy3: ( string, Stdlib_RegExp.t, diff --git a/runtime/Stdlib_Symbol.resi b/runtime/Stdlib_Symbol.resi index 3a2bf3bf17..9b55a61d3a 100644 --- a/runtime/Stdlib_Symbol.resi +++ b/runtime/Stdlib_Symbol.resi @@ -38,8 +38,7 @@ Otherwise a new Symbol gets created and registered with key. Symbol.getFor("sym1")->assertEqual(Symbol.getFor("sym1")) ``` */ -@val -@scope("Symbol") +@val @scope("Symbol") external getFor: string => option = "for" /** @@ -55,8 +54,7 @@ let globalSym = Symbol.getFor("sym1") // Global symbol globalSym->Option.flatMap(Symbol.description)->assertEqual(Some("sym1")) ``` */ -@val -@scope("Symbol") +@val @scope("Symbol") external keyFor: t => option = "keyFor" /** diff --git a/tests/gentype_tests/typescript-react-example/src/Comments.res b/tests/gentype_tests/typescript-react-example/src/Comments.res index e70c756021..af278c6c1c 100644 --- a/tests/gentype_tests/typescript-react-example/src/Comments.res +++ b/tests/gentype_tests/typescript-react-example/src/Comments.res @@ -1,4 +1,5 @@ -@genType /** A module for deciding on a subject matter for a poem.*/ +/** A module for deciding on a subject matter for a poem.*/ +@genType module DecideSubject = { type payload = { /** A hint to use as a guide when thinking of your poem.*/ @@ -16,7 +17,8 @@ module DecideSubject = { systemPrompt: string, } - @genType /** Decide on a subject matter for a poem.*/ + /** Decide on a subject matter for a poem.*/ + @genType let _placeholder = ( @ocaml.doc("The runner specification") run: string, @ocaml.doc("The number of times to cycle through the runner") times: int, diff --git a/tests/syntax_tests/data/printer/comments/expected/docComments.res.txt b/tests/syntax_tests/data/printer/comments/expected/docComments.res.txt index bae9ae907e..da0925339e 100644 --- a/tests/syntax_tests/data/printer/comments/expected/docComments.res.txt +++ b/tests/syntax_tests/data/printer/comments/expected/docComments.res.txt @@ -20,17 +20,14 @@ type h = int @foo let x = 10 /** doc comment and attribute */ -@foo -let x = 10 +@foo let x = 10 /** doc comment and 3 attributes */ -@foo -@bar -@baz -let x = 10 +@foo @bar @baz let x = 10 /** doc comment and 0 attributes */ let x = 10 type pathItem = {} -/** Issue 6844: doc comment before "and" */ and operation = {} +/** Issue 6844: doc comment before "and" */ +and operation = {} diff --git a/tests/syntax_tests/data/printer/expr/expected/DocComments.res.txt b/tests/syntax_tests/data/printer/expr/expected/DocComments.res.txt index 1ec6c528d7..6f9b61a2bc 100644 --- a/tests/syntax_tests/data/printer/expr/expected/DocComments.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/DocComments.res.txt @@ -1,16 +1,32 @@ -let doc1: (/** ddd */ ~x: int) => int = (~x) => x + 1 +let doc1: ( + /** ddd */ + ~x: int, +) => int = (~x) => x + 1 let doc2: /** ddd */ int => int = x => x + 1 let doc3: /** ddd */ int => int = x => x + 1 -let doc4: (/** ddd */ ~x: int, /** eee */ n) => int = (~x) => x + 1 +let doc4: ( + /** ddd */ + ~x: int, + /** eee */ n, +) => int = (~x) => x + 1 module M: { - let foo: (/** xxdoc */ ~x: int, /** yydoc */ ~y: int) => int + let foo: ( + /** xxdoc */ + ~x: int, + /** yydoc */ + ~y: int, + ) => int } = { let foo = (~x, ~y) => x + y } @val -external ex: (/** ddd */ ~x: int, /** eee */ n) => int = "ex" +external ex: ( + /** ddd */ + ~x: int, + /** eee */ n, +) => int = "ex" /** A */ module rec A: { diff --git a/tests/tests/src/arith_syntax.res b/tests/tests/src/arith_syntax.res index f47f4e8665..e4e2980ba7 100644 --- a/tests/tests/src/arith_syntax.res +++ b/tests/tests/src/arith_syntax.res @@ -1,10 +1,16 @@ type rec expression = - | /** non-negative integer constant */ Numeral(float) - | /** Addition [e1 + e2] */ Plus(expression, expression) - | /** Difference [e1 - e2] */ Minus(expression, expression) - | /** Product [e1 * e2] */ Times(expression, expression) - | /** Quotient [e1 / e2] */ Divide(expression, expression) - | /** Opposite value [-e] */ Negate(expression) + | /** non-negative integer constant */ + Numeral(float) + | /** Addition [e1 + e2] */ + Plus(expression, expression) + | /** Difference [e1 - e2] */ + Minus(expression, expression) + | /** Product [e1 * e2] */ + Times(expression, expression) + | /** Quotient [e1 / e2] */ + Divide(expression, expression) + | /** Opposite value [-e] */ + Negate(expression) | Variable(string) let rec str = e => diff --git a/tests/tests/src/demo_page.res b/tests/tests/src/demo_page.res index 85737bfcba..bcdb0adc91 100644 --- a/tests/tests/src/demo_page.res +++ b/tests/tests/src/demo_page.res @@ -42,7 +42,8 @@ type component type attrs type component_class -@obj /** make a json object */ +/** make a json object */ +@obj external config: (~display_name: string=?, ~render: unit => component, unit) => config = "" /** make a json object */ @obj diff --git a/tests/tests/src/external_ppx.res b/tests/tests/src/external_ppx.res index 18473997d4..8c6d0e3a53 100644 --- a/tests/tests/src/external_ppx.res +++ b/tests/tests/src/external_ppx.res @@ -1,10 +1,10 @@ @obj external make_config: (~length: int, ~width: int) => unit = "" -@obj /** Note that {[ 'a . length: 'a -> width:int -> unit ]} is a syntax error -- check where it is allowed */ +@obj external make_config: (~length: 'a, ~width: int) => unit = "" @obj external opt_make: (~length: int, ~width: int=?) => (_ as 'event) = "" diff --git a/tests/tests/src/mt.res b/tests/tests/src/mt.res index 73f9da5a1b..9b7c9cba09 100644 --- a/tests/tests/src/mt.res +++ b/tests/tests/src/mt.res @@ -18,9 +18,10 @@ @val @variadic external dump: array<'a> => unit = "console.log" -@val @module("assert") /** There is a problem -- +/** There is a problem -- it does not return [unit] */ +@val @module("assert") external throws: (unit => unit) => unit = "throws" let assert_equal = eq diff --git a/tests/tests/src/mutual_non_recursive_type.res b/tests/tests/src/mutual_non_recursive_type.res index 9f5cc15f0b..4b3a740bfb 100644 --- a/tests/tests/src/mutual_non_recursive_type.res +++ b/tests/tests/src/mutual_non_recursive_type.res @@ -8,6 +8,8 @@ open U type t = | Ta(t) /* * u compilation error [nonrec applices to all] */ | Tb(int) -and u = | /** one attribute nonrecursive will affect all */ H(t) /* refers to old t */ +and u = + | /** one attribute nonrecursive will affect all */ + H(t) /* refers to old t */ let v: u = H(OT) diff --git a/tests/tests/src/ocaml_compat/Ocaml_Array.resi b/tests/tests/src/ocaml_compat/Ocaml_Array.resi index 74a7c24724..da0cca40c3 100644 --- a/tests/tests/src/ocaml_compat/Ocaml_Array.resi +++ b/tests/tests/src/ocaml_compat/Ocaml_Array.resi @@ -80,8 +80,7 @@ let sub: (array<'a>, int, int) => array<'a> /** [Array.copy a] returns a copy of [a], that is, a fresh array containing the same elements as [a]. */ -@deprecated("Use Core instead. This will be removed in v13") -@send +@deprecated("Use Core instead. This will be removed in v13") @send external copy: array<'a> => array<'a> = "slice" /** [Array.fill a ofs len x] modifies the array [a] in place, diff --git a/tests/tests/src/ocaml_compat/Ocaml_String.resi b/tests/tests/src/ocaml_compat/Ocaml_String.resi index a5bc660235..e541233a1c 100644 --- a/tests/tests/src/ocaml_compat/Ocaml_String.resi +++ b/tests/tests/src/ocaml_compat/Ocaml_String.resi @@ -12,8 +12,7 @@ external length: string => int = "%string_length" You can also write [s.[n]] instead of [String.get s n]. Raise [Invalid_argument] if [n] not a valid index in [s]. */ -@deprecated("Use Core instead. This will be removed in v13") -@send +@deprecated("Use Core instead. This will be removed in v13") @send external get: (string, int) => char = "codePointAt" /** [String.make n c] returns a fresh string of length [n], @@ -78,8 +77,7 @@ let mapi: ((int, char) => char, string) => string trailing whitespace character in the argument, return the original string itself, not a copy. @since 4.00.0 */ -@deprecated("Use Core instead. This will be removed in v13") -@send +@deprecated("Use Core instead. This will be removed in v13") @send external trim: string => string = "trim" /** Return a copy of the argument, with special characters diff --git a/tests/tests/src/test_ffi.res b/tests/tests/src/test_ffi.res index 3a8d421b0c..ededddffbc 100644 --- a/tests/tests/src/test_ffi.res +++ b/tests/tests/src/test_ffi.res @@ -1,6 +1,7 @@ -@val("console.log") /** we should also allow js function call from an external js module +/** we should also allow js function call from an external js module */ +@val("console.log") external log: 'a => unit = "?ignore" @scope("console") external log2: 'a => unit = "log" diff --git a/tests/tests/src/test_js_ffi.res b/tests/tests/src/test_js_ffi.res index 80e87e3688..4f01f15eff 100644 --- a/tests/tests/src/test_js_ffi.res +++ b/tests/tests/src/test_js_ffi.res @@ -1,6 +1,7 @@ -@val("console.log") /** we should also allow js function call from an external js module +/** we should also allow js function call from an external js module */ +@val("console.log") external log: 'a => unit = "%ignore" let v = u => { diff --git a/tests/tools_tests/src/DocExtractionRes.res b/tests/tools_tests/src/DocExtractionRes.res index b9c7f25cf8..e86ab142e3 100644 --- a/tests/tools_tests/src/DocExtractionRes.res +++ b/tests/tools_tests/src/DocExtractionRes.res @@ -28,7 +28,12 @@ let \"SomeConstant" = 12 module SomeInnerModule = { /*** Another module level docstring here.*/ type status = - | /** If this is started or not */ Started(t) | /** Stopped? */ Stopped | /** Now idle.*/ Idle + | /** If this is started or not */ + Started(t) + | /** Stopped? */ + Stopped + | /** Now idle.*/ + Idle /** These are all the valid inputs.*/ type validInputs = [#something | #"needs-escaping" | #withPayload(int) | #status(status)] @@ -53,7 +58,8 @@ module AnotherModule = { | /** This has inline records...*/ SomeStuff({ offline: bool, - /** Is the user online? */ online?: bool, + /** Is the user online? */ + online?: bool, }) open ReactDOM diff --git a/tests/tools_tests/src/expected/DocExtractionRes.res.json b/tests/tools_tests/src/expected/DocExtractionRes.res.json index 02d688135b..c2120b9798 100644 --- a/tests/tools_tests/src/expected/DocExtractionRes.res.json +++ b/tests/tools_tests/src/expected/DocExtractionRes.res.json @@ -155,7 +155,7 @@ "docstrings": ["These are all the valid inputs."], "source": { "filepath": "src/DocExtractionRes.res", - "line": 34, + "line": 39, "col": 3 } }, @@ -167,7 +167,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 36, + "line": 41, "col": 3 } }] @@ -179,7 +179,7 @@ "docstrings": ["Mighty fine module here too!"], "source": { "filepath": "src/DocExtractionRes.res", - "line": 39, + "line": 44, "col": 8 }, "items": [ @@ -190,7 +190,7 @@ "docstrings": ["This links another module. Neat."], "source": { "filepath": "src/DocExtractionRes.res", - "line": 43, + "line": 48, "col": 10 }, "items": [] @@ -203,7 +203,7 @@ "docstrings": ["Testing what this looks like."], "source": { "filepath": "src/DocExtractionRes.res", - "line": 47, + "line": 52, "col": 3 } }, @@ -215,7 +215,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 49, + "line": 54, "col": 7 }, "detail": @@ -239,7 +239,7 @@ "docstrings": ["Trying how it looks with an inline record in a variant."], "source": { "filepath": "src/DocExtractionRes.res", - "line": 52, + "line": 57, "col": 3 }, "detail": @@ -275,7 +275,7 @@ "docstrings": ["Callback to get the DOM root..."], "source": { "filepath": "src/DocExtractionRes.res", - "line": 62, + "line": 68, "col": 3 } }] @@ -299,7 +299,7 @@ "docstrings": ["The type t is stuff."], "source": { "filepath": "src/DocExtractionRes.res", - "line": 69, + "line": 75, "col": 3 } }, @@ -311,7 +311,7 @@ "docstrings": ["The maker of stuff!"], "source": { "filepath": "src/DocExtractionRes.res", - "line": 71, + "line": 77, "col": 3 }, "detail": @@ -335,7 +335,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 99, + "line": 105, "col": 13 }, "items": [ @@ -347,7 +347,7 @@ "docstrings": ["main type of this module"], "source": { "filepath": "src/DocExtractionRes.res", - "line": 107, + "line": 113, "col": 3 } }, @@ -359,7 +359,7 @@ "docstrings": ["function from t to t"], "source": { "filepath": "src/DocExtractionRes.res", - "line": 109, + "line": 115, "col": 3 }, "detail": @@ -396,7 +396,7 @@ "docstrings": ["main type"], "source": { "filepath": "src/DocExtractionRes.res", - "line": 123, + "line": 129, "col": 3 } }, @@ -408,7 +408,7 @@ "docstrings": ["identity function"], "source": { "filepath": "src/DocExtractionRes.res", - "line": 128, + "line": 134, "col": 7 }, "detail": @@ -432,7 +432,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 131, + "line": 137, "col": 13 }, "items": [ @@ -444,7 +444,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 132, + "line": 138, "col": 3 }, "detail": @@ -478,7 +478,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 136, + "line": 142, "col": 7 }, "detail": @@ -499,7 +499,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 139, + "line": 145, "col": 8 }, "items": [ @@ -523,7 +523,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 141, + "line": 147, "col": 9 }, "detail":