I’ve been developing a program analysis tool in OCaml, and would like to run Stan from the OCaml code. What is the best way to do so?
As of now, what I do is to first use OCaml’s binding for Python to run Python from OCaml. The particular binding I use is pyml. I then run Stan from Python. However, now that the Stan3 compiler is implemented in OCaml, I wonder if I can directly run Stan from OCaml. Also, is there any plan in the near future for developing an opam package for Stan? Thanks a lot!
There is not really any way to do this. While the compiler is in OCaml, the output of the compiler is C++ and the Stan algorithms and math libraries are both implemented in C++.
If you’re fine using a separate process to run the Stan program, you can do something similar to CmdStanPy/CmdStanR and run the stan model as a separate process and read in the output CSV it produces, then do whatever you want in OCaml from there