melange-re / melange

A mixture of tooling combined to produce JavaScript from OCaml & Reason
https://melange.re
Other
838 stars 52 forks source link

Is ocaml-ctypes or gen_js_api for Melange possible? #565

Open jchavarri opened 1 year ago

jchavarri commented 1 year ago

I wonder if something like yallop/ocaml-ctypes or LexiFi/gen_js_api would be possible for Melange. "Externalizing" the bindings creation outside the compiler would remove complexity from Melange itself. And from user perspective, it would bring some benefits, like no more need to use [@bs] attributes when defining callbacks in bindings.

Would it be possible? If yes, what kind of primitives should Melange expose for it to happen? Also, what kind of trade-offs would exist? One thing that comes to mind is the zero-cost JS object creation functions exposed by bs.abstract that libraries like reason-react take advantage from. Another disadvantage is the fragmentation caused on bindings.

anmonteiro commented 1 year ago

Even better would be to get https://github.com/ocsigen/ts2ocaml running.