Closed
Description
I seem to be hitting an edge case when trying to pass unit
to an uncurried function. My intention is to create a Js.Promise.t(unit)
representing the completion of a side-effect.
let x: Js.Promise.t(unit) =
Js.Promise.make((~resolve, ~reject) => {
/* causes compile error:
*
* Found uncurried application [@bs] with arity 1, where arity 0 was expected.
* This has type: `(. unit) => unit`, but somewhere wanted `(. unit) => 'a`
*
* and gets turned into `resolve(.)` by refmt
*/
//resolve(. ());
/* works as expected
*/
let nil = ();
resolve(. nil);
/* mysteriously works. maybe because "zero-arity" functions don't exist,
* they are actually unary functions taking unit, so `ignore` has inferred
* type `unit => unit`
*/
resolve(. ignore());
/* but then why not this? perhaps because the above only applies when currying.
*/
//resolve(.);
});
Metadata
Metadata
Assignees
Labels
No labels