OCaml Installation Advice

From Xen
(Redirected from OCaml Advice)

Editable Top-Level

OCaml provides a top-level (entered by running "ocaml") which is an excellent way to test code snippets. However, the ordinary interface lacks any editing features. This is most easily remedied using the ledit program by adding:

alias ocaml="ledit ocaml"

to your startup scripts.



Although the OCaml distribution provides a simple editing mode for emacs, the Tuareg mode is better in many ways, including reliability.

Type Throwback

Types in ML programs are almost always inferred by the ML compiler. This greatly improves brevity but the lack of type information can be a hindrance to the programmer when developing software in ML. OCaml addresses this issue by providing a mechanism for type throwback. To use type throwback with emacs you can install the ocaml-mode package and then compile your code using the -dtypes compiler option. The key combination C-c C-t then brings up the inferred type of the current subexpression.


ocaIDE is a nice ocaml pluggin for Eclipse. You can go to the definition of any function in holding CTRL + left click. You can also have code auto-completion with CTRL+SPACE.