DOKK / manpages / debian 12 / utop / utop.1.en
UTOP(1) General Commands Manual UTOP(1)

utop - Universal toplevel for OCaml

utop [ options ] [ object-files ] [ script-file ]

utop is a enhanced toplevel for OCaml with many features, including context sensitive completion.

When you start utop what you see is the prompt followed by a bar containing words. This is the completion bar, it contains the possible completion and is updated as you type. The highlighted word in the completion bar is the selected word. You can navigate using the keys Alt+Left and Alt+Right and you can complete using the currently selected word by pressing Alt+Tab (you can configure these bindings in the file ~/.config/lambda-term-inputrc , see lambda-term-inputrc(5) for details).

utop supports completion on:


* directives and directive arguments
* identifiers
* record fields
* variants
* function labels
* object methods

Colors are by default configured for terminals with dark colors, such as white on black, so the prompt may looks too bright on light colors terminals. You can change that by setting the color profile of utop. For that type:


UTop.set_profile UTop.Light;;

You can then add this line to your ~/.config/utop/init.ml file.

To turn off utop's advanced prompt features, add the following to init.ml to turn off respectively (a) colors and the upper information line, and (b) the lower boxed list of possible completions:


#utop_prompt_dummy;;
UTop.set_show_box false

You can enable basic syntax highlighting in utop by writing a ~/.utoprc file. See utoprc(5) for that.

Finally utop can run in emacs. For that you have to add the following line to your ~/.emacs file:


(autoload 'utop "utop" "Toplevel for OCaml" t)

then you can run utop by pressing M-x and typing "utop". utop support completion in emacs mode. Just press Tab to complete a word. You can also integrate it with the tuareg, caml or typerex mode. For that add the following lines to your ~/.emacs file:


(autoload 'utop-minor-mode "utop" "Minor mode for utop" t)
(add-hook 'tuareg-mode-hook 'utop-minor-mode)

See utop --help for the the list of available options. There is considerable overlap with options available for ocaml(1).

A commonly used option is -require package to load package into the execution environment. It is equivalent to using #require from inside utop(1).

Show absolute filenames in error message.
Add dir to the list of include directories.
Load file instead of default init file.
Use commuting label mode.
Deactivate applicative functors.
Do not compile assertion checks.
Ignore non-optional labels in types.
Do not add default directory to the list of include directories.
Pipe abstract syntax trees through preprocessor command.
Check principality of type inference.
Make strings immutable.
Shorten paths in types (the default).
Do not shorten paths in types.
Allow arbitrary recursive types.
Read script from standard input.
Left-hand part of a sequence must have type unit.
Do not compile bounds checking on array and string access.
Print version and exit.
Print version number and exit.
Enable or disable warnings according to list.
Enable or disable error status for warnings according to list. See option -w for the syntax of list. Default setting is -a+31.
Show description of warning numbers.
Run in emacs mode.
Hide identifiers starting with a '_' (the default).
Show identifiers starting with a '_'.
Don't add implicit bindings for expressions (the default).
Add implicit bindings: expr;; -> let _0 = expr;;
Disable autoloading of files in $OCAML_TOPLEVEL_PATH/autoload.
Load this package.
Dump OCaml AST after rewriting.
Dump OCaml source after rewriting.
Display this list of options.
Display this list of options.

~/.config/utop/init.ml

The initialization file of the toplevel.
~/.ocamlinit
The alternative initialization file of the toplevel.
~/.utoprc
The configuration file for utop. See utoprc(5).
~/.config/lambda-term-inputrc
The file containing key bindings. See lambda-term-inputrc(5).

Jérémie Dimino <jeremie@dimino.org>

utoprc(5), lambda-term-inputrc(5), ocaml(1).

August 2011