Filesystem support in Reason



I am trying to port an existing OCaml codebase that uses a bit of the OCaml Unix module, specifically Unix.stat, Unix.getcwd, Unix.chdir and Unix.mkdir. For getcwd I’ve found Node.Process.cwd, but I cannot seem to find an equivalent for stat nor chdir nor mkdir (though I found Node.Fs with some file creation support, but not directories). Perhaps I need to call out to external Node functions? (Unfortunately, I know very little node.)

Any pointers (heh) would be appreciated!


If you are porting to run your app with Node.js instead of compiling a native program, then you will have to write bindings to Node’s standard library.


Most of what you need should be here:

chdir is in process.


I would totally rather compile a native program…but all I could find was using bsb to produce JS to run under Node. Kindly point me in the right direction?

I’m porting to Reason to avoid the mess that is OCaml on Windows.


Reason is OCaml. It’s the same compiler :slight_smile:

Reason targets native compilation with the esy/dune toolchain and JavaScript compilation with the BuckleScript toolchain. If you’re interested in the former, check out . Windows support is good. But just to clarify–if you use esy to target native compilation on Windows–you could easily also use OCaml syntax instead of Reason syntax. It supports both.


Oh shoot, I did mean I was sticking with OCaml and just using the Reason project’s tools, that is specifically I was using bsb. I didn’t mean Reason the language itself, that was my bad.

I’ll try out esy/dune instead! Honestly this spun out of trying to setup reason-vscode in Visual Studio Code for OCaml support…lol, but it reminded me I needed to move to something else for better Windows support.


Yes! I have a working build of my existing project using esy and dune, with very minimal changes. Moreover, it built and ran on Windows, and the file I/O worked. Thank you so much!