Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: uncurry 0 #949

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ Unreleased
([#1017](https://github.com/melange-re/melange/pull/1017))
- BREAKING(core): only allow strings in `{j| ... |j}` interpolation
([#1024](https://github.com/melange-re/melange/pull/1024))
- BREAKING(ppx): use `[@u0]` for 0-arity uncurried application instead of `()`
([#949](https://github.com/melange-re/melange/pull/949))
- Melange wouldn't previously allow to invoke a 1-argument uncurried
function with `()` (`unit`). After this change, 0-arity functions must be
applied with `[@u0]`. Melange will issue an alert if old 0-arity
functions are applied with `[@u]` to help upgrade codebases.

2.2.0 2023-12-05
---------------
Expand Down
32 changes: 16 additions & 16 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jscomp/others/node_fs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module Watch = struct
f:
([ `change of
(string (*eventType*) -> Node.string_buffer (* filename *) -> unit[@u])
| `error of (unit -> unit[@u]) ]
| `error of (unit -> unit[@u0]) ]
[@mel.string]) ->
t = "on"
[@@mel.send]
Expand Down
2 changes: 1 addition & 1 deletion jscomp/runtime/caml_external_polyfill.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ open struct
module Js = Js_internal
end

let getGlobalThis : (unit -> global[@u]) =
let getGlobalThis : (unit -> global[@u0]) =
[%raw
{| function(){
if (typeof globalThis !== 'undefined') return globalThis;
Expand Down
12 changes: 6 additions & 6 deletions jscomp/stdlib/camlinternalLazy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ type 'a concrete = {

exception Undefined

external fnToVal : (unit -> 'a [@u]) -> 'a = "%identity"
external valToFn : 'a -> (unit -> 'a [@u]) = "%identity"
external fnToVal : (unit -> 'a [@u0]) -> 'a = "%identity"
external valToFn : 'a -> (unit -> 'a [@u0]) = "%identity"
external castToConcrete : 'a lazy_t -> 'a concrete = "%identity"
external of_concrete : 'a concrete -> 'a lazy_t = "%identity"

Expand All @@ -46,15 +46,15 @@ let is_val (type a ) (l : a lazy_t) : bool =



let forward_with_closure (type a ) (blk : a concrete) (closure : unit -> a [@u]) : a =
let result = closure () [@u] in
let forward_with_closure (type a ) (blk : a concrete) (closure : unit -> a [@u0]) : a =
let result = closure () [@u0] in
(* do set_field BEFORE set_tag *)
blk.value <- result;
blk.tag<- true;
result


let raise_undefined = (fun [@u] () -> raise Undefined)
let raise_undefined = (fun [@u0] () -> raise Undefined)

(* Assume [blk] is a block with tag lazy *)
let force_lazy_block (type a ) (blk : a t) : a =
Expand All @@ -64,7 +64,7 @@ let force_lazy_block (type a ) (blk : a t) : a =
try
forward_with_closure blk closure
with e ->
blk.value <- fnToVal (fun [@u] () -> raise e);
blk.value <- fnToVal (fun [@u0] () -> raise e);
raise e


Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/demo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ let ui_layout
with e -> ()
end;
let fmt v = toFixed v 2 in
set_interval (fun [@u] () ->
set_interval (fun [@u0] () ->

grid##dataSource #=
( array_map data (fun [@u] {ticker; price } ->
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/demo_binding.ml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class type textArea =
end[@u]


external set_interval : (unit -> unit [@u]) -> float -> unit = "setInterval"
external set_interval : (unit -> unit [@u0]) -> float -> unit = "setInterval"
[@@mel.module "@runtime", "Runtime"]

external toFixed : float -> int -> string = "toFixed" [@@mel.send]
6 changes: 3 additions & 3 deletions jscomp/test/dist/jscomp/test/event_ffi.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jscomp/test/dist/jscomp/test/exception_raise_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions jscomp/test/dist/jscomp/test/ffi_arity_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 49 additions & 49 deletions jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jscomp/test/dist/jscomp/test/ppx_apply_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions jscomp/test/dist/jscomp/test/raw_output_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions jscomp/test/dist/jscomp/test/re_or_res/reactTestUtils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions jscomp/test/dist/jscomp/test/uncurry_glob_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading