Install OCaml and the Tuareg mode on Ubuntu 14.04

By Rémi GATTAZ RICM3 Polytech

Install OCaml

Installing Ocaml is the easy part of this How to. Just like any program, you just need to type the following in a terminal :

$ sudo apt-get install ocaml

You can already test this by launching the programm and try to execute an OCaml command.

$ ocaml
        OCaml version 4.01.0

# 1+1;;
- : int = 2

Install the Tuareg mode

The Tuareg mod is an extension (a mode) for the text editor called Emacs. So if you haven't installed it yet, execute the following command :

$ sudo apt-get install emacs

First, we will download the extension files and place them where they will need to be.

$ mkdir ~/.elisp
$ cd ~/.elisp
$ wget https://forge.ocamlcore.org/frs/download.php/1304/tuareg-2.0.7.tar.gz
$ tar zxf tuareg-2.0.7.tar.gz
$ mv tuareg-2.0.7.tar.gz tuareg-mode
$ rm tuareg-2.0.7.tar.gz

Now, open/create the file ~/.emacs with your favorite editor (vi or nano for example)

$ vi ~/.emacs

and place the following in it :

(add-to-list 'load-path "~/.elisp/tuareg-mode")
(autoload 'tuareg-mode "tuareg" "Major mode for editing Caml code" t)
(autoload 'camldebug "camldebug" "Run the Caml debugger" t)
(autoload 'tuareg-imenu-set-imenu "tuareg-imenu" 
    "Configuration of imenu for tuareg" t) 

(add-hook 'tuareg-mode-hook 'tuareg-imenu-set-imenu)

(setq auto-mode-alist 
    (append '(("\\.ml[ily]?$" . tuareg-mode)
        ("\\.topml$" . tuareg-mode))
            auto-mode-alist))

And that's it, the tuareg mode is now installed. The next time you open Emacs, the mode will be started.

Comments powered by Disqus