I recently figured out how to get an alternative REPL which has some things that UTop doesn’t. It’s the Jupyter console, which runs in a terminal (and is less well-known than the Jupyter notebook).
Here’s how to set it up:
- install jupyter by a method that works for your OS.
opam install jupyter
- set up ocaml as a kernel for jupyter, as explained in the package doc:
jupyter kernelspec install --name ocaml-jupyter "$(opam config var share)/jupyter"
jupyter kernelspec listfind the new kernel directory and edit the JSON file there, for instance to include a custom
.ocamlinit. In mine I added
- enable vi edit mode by
echo "c.ZMQTerminalInteractiveShell.editing_mode='vi'" >> ~/.jupyter/jupyter_console_config.py(entirely non optional )
Then start your new REPL by
jupyter console --kernel=ocaml-jupyter. Thanks to the cool ocaml jupyter package, it will use Merlin to autocomplete, it will let you browse history in the usual jupyter way, and it will have a vi_mode !
You can also use various editor plugins to send code cells to the ocaml-jupyter kernel directly from an editing buffer. Right now, this solution is missing the
UTop.set_create_implicits automatic binding of previous outputs, but that is not a huge problem. Overall, pretty neat in my book!