Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can ocaml's REPL supports auto-complete etc.?

Tags:

ocaml

Are there any other ways to make ocaml support auto-complete, etc. except using rlwrap ?

Sincerely!

like image 711
z_axis Avatar asked Nov 02 '11 03:11

z_axis


2 Answers

Fairly recently a system named utop was announced on the OCaml mailing list. It's a replacement for the OCaml top level with many advanced features. It appears to be hosted at OcamlCore.org:

http://forge.ocamlcore.org/projects/utop/

I haven't tried it, but it sounds great.

I use rlwrap, myself.

like image 86
Jeffrey Scofield Avatar answered Nov 20 '22 05:11

Jeffrey Scofield


You may use the ocaml toplevel from inside an Emacs buffer, which gets you solid rlwrap-like editing features, plus anything you have in your Emacs config, including potential non-ocaml-specific completion modes.

Besides Jérémie Dimino's utop that Jeffrey already cited, there are other, older projects relative to the OCaml toplevel. They're not all providing completion, but you may still be interested in them:

  • Zheng Li's Enhtop (README) that provides directives for browsing the current toplevel environment
  • Peng Zang's Enhtop+, an incremental patch over Enhtop, which comes with a tuareg-plus mode providing extra tuareg features, including ocaml-aware completion, that are also available from an Emacs toplevel buffer

(Related, but not toplevel-oriented, is Jun Furuse's Ocamlspotter that allows to get precise where-was-this-name-defined information for OCaml files in Emacs)

All those projects come as patches to the OCaml sources. This means that to install them, you must download the sources of the OCaml compiler, patch them, compile, and use the result as your OCaml install (it may be optionally possible to keep an existing OCaml install, patch and compile the same version of the compiler separately, and selectively use/replace the interesting executables). This also means that there is a maintenance burden on the patch developper, which has to follow OCaml compiler upgrades, and that you may be constrained in which versions of OCaml to use. In a nutshell, there are not easy to deploy.

like image 27
gasche Avatar answered Nov 20 '22 05:11

gasche