suppose we have an function
external map : 'a array -> ('a -> 'b [@bs]) -> 'b array = "map" [@@bs.val]
map [|1;2;|] (fun [@bs] x -> x + 1)
map [1,2] (fun x -> x + 1)
md5-f7c9437819d5b1b40b9286fce76555da
```js
map [1,2] (fun x -> x + 1)
It does add more complexity to the ffi , but the benefit seems to be very high
question, should we add ('a -> 'b [@bs.auto]) or just say we will do auto uncurry by default
Sometimes javascript does curry in some libraries, so if that is default then there needs to be a way to turn it off.
I honestly like the explicitness of needing to add [@bs] to force an uncurry, although I'd prefer that as a type to be honest, like ('a -> 'b) uncurried or something. That'd be too much I think though.
this is quite important, since it provides nice user land API, the general idea is that it is okay to write verbose external attributes, but the complexity should not leak to end users.
lets mark it explicit as below:
external map : 'a array -> ('a -> 'b [@bs.uncurry]) -> 'b array
external map : 'a array -> ('a -> 'b [@bs]) -> 'b array
For the first one, user will read it as `'a array -> ('a -> 'b ) -> 'b array', the compiler will automatically uncurry it to make sure it's correct.
For the second one, the user will read it as 'a array -> ('a -> 'b [@bs]) -> 'b array', user has to supply unhurried function via[@bs]
note with this, the syntactic sugar introduced in #1214 can share it with vallina ocaml
note we stick with explicit bs.uncurry, we will produce warnings later, explicit is better since we can only handle 2-order, not arbitrary high-order logic