Binding for high-order fn


Through bindings We need some syntax like util.promisify(hdiDeployer.deploy)(t, e)
But bindings tried was converting it to util.promisify(hdiDeployer.deploy, t, e)

The function to be converted is

let promisify: (string, Js.Dict.t(string)) => Js.Promise.t(Type.hdiResult) = [%raw
      (t, e) => "
      const util = require(\"util\");
      const hdiDeployer = require(\"XYZ\");
      return util.promisify(hdiDeployer.deploy)(t, e);

is there some way to model this function to util.promisify(hdiDeployer.deploy)(t, e) ?


You want to look into guaranteed uncurrying.

Here is a snippet that both converts your external libraries to externals and uses guaranteed uncurrying of callbacks:

// maybe you have a better way to do this?
type callback('input, 'result) =
  ('input, (. Js.Nullable.t(Js.Promise.error), 'result) => unit) => unit;

type hdiResult;
[@bs.module "./XYZ"] external deploy: callback(string, hdiResult) = "deploy";

[@bs.module "util"]
external promisify:
  callback('input, 'result) => (. 'input) => Js.Promise.t('result) =

  (promisify(deploy))(. "this is my result")
  |> then_(hdiResult => hdiResult |> Js.Console.log |> resolve)
  |> catch(hdiResult => hdiResult |> Js.Console.log |> resolve)