I think I have skimmed every page on How to bind a JS library for OCaml 3-4 times by now, but there is still something I do not understand regarding how all this fits together.
Why we do need this phantom type Js.t ?
Why does ##. seem to assume Js.t everywhere ?
How do we get rid of the Js.t i.e. convert to pure-OCaml type ? Is it just Us.Unsafe.{inject, coerce} ?
When is it safe to use Js.Unsafe.{inject, coerce} ?
What else should I read? At this point, I think I’ve written a few thousand lines of code directly using the Js_of_ocaml.Js.* definitions; I’ve also defined my own Js objects via class type object = ... , as well as constructed my own Js objects via object%js (and passed them to JS rust).
Nevertheless, I still don’t feel I understand what Js.t does (i.e. my understanding is more"trial/error" than “from first principles”). Any other suggested reading ?
I’m assuming you mean phantom type parameter 'a in 'a Js.t…
The phantom type is used to type properties (including their read-write permissions) and methods.
Why does ##. seem to assume Js.t everywhere ?
##. just expect a Js.t on the LHS.
For example, o##.prop expect the value o to be of type <prop : 'a Js.prop> Js.t and returns a value of type 'a