For a *.ml files compiled by rescript, what stdlibs is it allowed to use? Can someone point me to the docs/API ?
For example, in *.ml files it apperas:
String.length, String.sub: okay
Int.min : not okay
You can find the older standard library that ReScript inherits from OCaml here: rescript-compiler/jscomp/stdlib-406 at master · rescript-lang/rescript-compiler · GitHub
To your specific examples:
String.length is defined here: rescript-compiler/string.mli at b21f7345f5493cc766f637d8d395ae95bee10638 · rescript-lang/rescript-compiler · GitHub
And there is no
Int module in this version of the library.
Just fyi the documented libraries are the ones that are encouraged for use in ReScript: API | ReScript API
Suppose I have a *.ml file containing some shared data types that I want both OCaml and ReScript to use.
Suppose now, I want to define some helper functions on these data types, that both OCaml and ReScript can use.
Now I’m basically “forced” to use these old OCaml stdlibs that ReScript supports right? It’s not obvious to me what other choices I have.
Yeah, that’s pretty much the choice. You could try Tablecloth from the Darklang project, it’s intended to address this scenario: GitHub - darklang/tablecloth: A standard library with the same API in F#, Rescript and OCaml
But they explicitly call out that it’s probably not production-quality for anyone else.