reasonml / reason

Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems
http://reasonml.github.io
MIT License
10.12k stars 428 forks source link

`bs` and `bs.obj` ppx apply deeply #2584

Open bobzhang opened 4 years ago

bobzhang commented 4 years ago

When using [@bs] to uncurry a function it is applied deeply. Probably it's better to apply it only on the most shallow level:

[@bs] uncurriedFun({
  normalFun(1)
});

In this case the output of the ppx is that normalFun is also called uncurried.

A similar thing happens with [@bs.obj]. All fields (even if it's part of the field expression) are converted to objects.

example:

[%bs.obj]
{
  test: {actually_a_record: 1}
}

cc @jfrolich moved from https://github.com/BuckleScript/bucklescript/issues/4306

bobzhang commented 4 years ago

note the bs attribute looks good to me.

let u =(.f0,f1)=>
f0(. {
  f1(1)
});

The inferred type is

let u: (. (. 'a) => 'b, int => 'a) => 'b;