OCaml library code?


I’ve tried to do my homework and read a bunch about ReScript after the relaunch / rebrand, but I still ended up unsure about this question: can I still use OCaml libraries in ReScript code for the indefinite future? Is use of OCaml libraries emphatically going to remain viable in ReScript “forever”?

I guess the answer must be “no” since the idea is to make development of the ReScript language and compiler easier by eliminating certain features? Or have I misunderstood where the benefit comes from exactly?

Thanks for your advice!

You will be able to use vanilla ocaml files (OCaml 4.06) within a ReScript project, but for Js compilation you won’t be able to use any builtin modules that require C bindings, and use the provided Js equivalents instead.

Library wise, you will not be able to use opam libraries. You’d need to port libraries over to the ReScript build system and make sure to extract the code in a way that fits to the ReScript conventions. E.g. lots of ReScript modules are built for the pipe-first approach, so it’s highly recommended to design apis in a t-first manner to avoid mixed piping styles and make the JS output more predictable.

The OCaml support is there so that our users can share a subset of their native codebases with their frontend projects (shared domain types, pure ocaml business logic etc). We have quite a few production users that rely on that feature, so it will be supported in the future.

Just be aware that docs and libraries etc we’ll provide in the future will all be maintained in ReScript syntax, so you’d probably need to learn ReScript syntax as well.

Hope this helps!


Thanks! Is that more like “we can’t see this changing over the foreseeable future, say 5 years or so”, or “we’re saying we expect this to be supported ‘forever’”? I don’t remember where I got this from, but something I read from one of the prominent people involved gave me the impression that it’s more the former than the latter?

To be clear, I’ve no complaint or feeling of entitlement if it’s more like “supported for the foreseeable future / probably more than 5 years” than “forever”. Every person and company putting in the enormous effort that they do into a project like this will have their own priorities, which is all fine – I’d just like to be sure I understand what the real position is on a fundamental issue like this.

Edit: I think it was the following sentence from here that gave me pause:

We won’t remove OCaml and Reason support from BuckleScript for a long time, whatever the surface emphasis might be.

It immediately goes on to say:

Will I be able to continue writing OCaml/Reason and compile to JS in the future?
It follows from our previous guarantee that yes, you will still be able to.

So I think the reason I am still left unsure is that I don’t understand how that does follow from the previous guarantee if that guarantee is only “for a long time” as opposed to ‘forever’?

@ryyppy any further comment on this?

Again I feel I should be clear that I don’t have any criticism of anybody working on ReScript or their goals or plans, I’m just trying to figure out what intentions are about what I can and can’t rely on over what time periods.