Hello,
I want to create bindings for this simple library:
https://www.npmjs.com/package/docopt
The easy part was declaring the functions to execute and declare that they return a plain JS object (AKA POJO), so far so god. This is what I has:
type options = Js.t({.});
[@bs.module "docopt"][@bs.val]
external docopt : string => args = "docopt";
let parse = str => docopt(str) |> argsFromJs;
However, when I want to turn those into an ocaml/reason record is where I start having problems. For example, this is what I tried:
[@bs.deriving jsConverter]
type args = {
upgrade: bool,
get: bool
};
let options = Docopt.parse(help) |> argsFromJs;
That gives me a type error obviously:
Error: This expression has type
Js.t(({.. get: bool, upgrade: bool} as 'a)) => args
but an expression was expected of type
ReasonRancherCli.Docopt.args => 'b
Type Js.t('a) is not compatible with type
ReasonRancherCli.Docopt.args = ReasonRancherCli.Docopt.args
Im not sure how should I do this…
Should I try to make the bindings as a Functor and provide a type record to it, or what is the correct approach here ?