-
Notifications
You must be signed in to change notification settings - Fork 471
Switch on uncurried #6864
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
Switch on uncurried #6864
Conversation
382d49b to
e6309ba
Compare
|
As one datapoint, the rescript-vscode tests give identical results on this PR w.r.t. master. |
| 3 [2m│[0m | ||
|
|
||
| This uncurried function has type (. ~f: 'a => 'a, unit) => int | ||
| This uncurried function has type (~f: 'a => 'a, unit) => int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a separate PR, we should change "This uncurried function has ..." to "This function has ...".
| let getOpt = Belt_Option.mapWithDefault; | ||
| function getOpt(opt, $$default, foo) { | ||
| return Belt_Option.mapWithDefault(opt, $$default, foo); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this and at the ImmutableArray example, it seems that some optimization was lost here.
This is the ReScript code:
let getOpt = (opt, default, foo) => opt->Option.mapWithDefault(default, foo)| let even = odd; | ||
| function even(y) { | ||
| return odd(y); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
| let h = function (i, j) { | ||
| if (i === j) { | ||
| return mkNode("Zero", i, "One"); | ||
| return mkVar(i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again inlining lost
| })); | ||
| return Belt_Set.fromArray(Belt_MapDict.keysToArray(m.data), Icmp); | ||
| let x = Belt_MapDict.keysToArray(m.data); | ||
| return Belt_Set.fromArray(x, Icmp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A temporary variable x is created here now which wasn't the case before.
| b("File \"bs_poly_mutable_set_test.res\", line 95, characters 4-11", Belt_MutableSet.subset(bb, v)); | ||
|
|
||
| b("File \"bs_poly_mutable_set_test.res\", line 96, characters 4-11", Belt_MutableSet.isEmpty(Belt_MutableSet.intersect(aa, bb))); | ||
| let d$1 = Belt_MutableSet.intersect(aa, bb); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
0a94cf7 to
3ec26e2
Compare
e6309ba to
a8ee1d5
Compare
3ec26e2 to
970e6fc
Compare
a8ee1d5 to
c21f7d0
Compare
970e6fc to
be5eec8
Compare
c21f7d0 to
62f162e
Compare
be5eec8 to
71f0b69
Compare
62f162e to
94c4ccf
Compare
71f0b69 to
a6018e2
Compare
94c4ccf to
bbf66b6
Compare
e418d93 to
c57264c
Compare
bbf66b6 to
2410c1c
Compare
c57264c to
da89285
Compare
2410c1c to
31f0783
Compare
da89285 to
23f2d70
Compare
31f0783 to
8c84d67
Compare
|
To test, I tried to compile a large project of ours. |
I assume it depends on the types only? Should be easy to add back the types. |
|
Yes, patching it to replace However, the result doesn't run. The compiler now emits ...
title: JsxRuntime.jsx((function (prim) {
return ReactIntl.FormattedMessage;
}), {
...instead of ...
title: JsxRuntime.jsx(ReactIntl.FormattedMessage, {
...Would have to investigate where this was introduced, can look into it tomorrow. |
|
My guess is that either some external is wrong, or there's a compiler bug on the arity of the external. |
|
@cristianoc You guessed correctly! I created #6880 for this. |
d8a21bd to
a460b1f
Compare
Let me know what other issues are left now. |
|
@cknitt could you add back the types needed in a separate PR perhaps? |
Add a `-curried` option, and give an error whenever neither `-curried` not `-uncurried` are used. Then change the build and test files to always specify curried/uncurried.
a460b1f to
49ac039
Compare
Yes, will do. |
No other issues left from my point of view. |
Build the compiler in uncurried mode, following on from #6764
This PR only changes the way the compiler is built, so it's easier to take a look at any differences in the generated code.
No
Curryruntime is used in the library/tests now.