ml-in-barcelona / jsoo-react

js_of_ocaml bindings for ReactJS. Based on ReasonReact.
https://ml-in-barcelona.github.io/jsoo-react
MIT License
138 stars 19 forks source link

Experiment: Use Js_of_ocaml.Js to write bindings #18

Closed jchavarri closed 5 years ago

jchavarri commented 5 years ago

As part of the discussion in #14 one idea was to write the bindings using jsoo Js module.

This PR explores the idea with a few functions. There is though a lot of unsafety and escape hatches, plus it requires knowing and understanding how all these Js_of_ocaml.Js functions and types work.

A couple of examples:

I am not sure this is the right path to follow. It seems to impose a much higher barrier of entry to potential contributors and the theoretical gains in safety are mostly gone due to the unavoidable unsafety in many cases.

@benschinn I wonder what your thoughts are? 🙂

schinns commented 5 years ago

Thanks for tagging me here, I was very interested in what using just jsoo would look like. 😃

I really like that this reduces or eliminates .js and .c code, and you only need to reference the lib/React.re and interface file.

I do agree that this approach could be a barrier for potential contributors. For example the converKeyToJs is much less idiomatic and doesn't appear very typesafe.

I will have to mull over a bit more on what the best approach might be.

jchavarri commented 5 years ago

@benschinn Thanks for your feedback! I really appreciate it.

Based on this, I am inclined to explore next how a non-jsoo solution would look like. It seems that a lightweight eslint config (that we can tweak as needed) could take us a long way 🤔

jchavarri commented 5 years ago

Closing this as eslint has been set up already by @benschinn in #20 :)