The title is very autoexplicative. I want to use Options module from OCaml, that doesn’t exists on Reason. How can I? I searched on Google but found nothing.
How can I use a OCaml module that's not available in Reason?
To install an ocaml dependency you can use opam.
But for this module Options you can use directly Belt.Option
In addition to the excellent options provided by @maarekj, you could copy in the module(s) directly into your project as long as the licensing works out. This can be easy if the module has no other dependencies or a path to frustration if it has a deep tree of dependencies.
If you want to use Bucklescript, you can only use the opam solution if you’re compiling to native btw! Compiling to JS using Bucklescript won’t work there, you’d have to use js_of_ocaml to compile to JS.
Definitely check out Belt, inside Bucklescript, and if you find anything missing open an issue!
This is one of the bits that’s confusing me most about the ReasonML and OCaml ecosystems. (Assuming we want to use another library that isn’t yet in Belt). Why is the opam library only suitable for compiling to native? Does bucklescript not compile Reason syntax and Ocaml to js?
If we use Reason are we basically shut off from the Ocaml ecosytem?
Reason + OCaml work very well with both native and JS targets via opam if you use dune to compile with the standard compiler for native and js_of_ocaml for JS compilation.
If you want to use Bucklescript for JS compilation pulling code in from other opam packages requires extra work as bsb needs its own build instructions.
That’s currently true for Bucklescript but not if you use js_of_ocaml! There’s a big trade-off, though, between opam vs npm integration convenience.
Thanks it is just bucklescript that is limiting the compilation of reason to native? What specifically are the things limiting it - couldn’t see this in the docs - thought I may have missed it.