Frequently Asked Questions
This page will be populated with reasonable questions, asked during the lecture or the exercises, or sent as feedback.How do I get command line history and completion for ocaml
?
Just use rlwrap
(installed on ZID machines). Either call
ocaml
as follows:
$ rlwrap ocaml
or set following alias (e.g., in your .bashrc
):
alias ocaml="rlwrap ocaml"
How to use ocamlbuild
?
There a different applications of ocamlbuild
:
- Compiling the file
prog.ml
as bytecode executable:
$ ocamlbuild prog.byte
- Compiling an interpreter
name.top
in which some modules are preloaded. First create a filename.mltop
containing one module per line that should be preloaded on startup. Second
$ ocamlbuild name.top
How can I customize my own interpreter?
Every time an interpreter is started (either ocaml
or
something like name.top
from above) the current directory
is checked for the file .ocamlinit
. If it exists, its content
is executed as if you would have typed it in the interpreter. (Alternatively
the flag -init <file>
can be used to load the file
file
.)
This is for example useful to change to the directory _build
on startup (which is the default output location of ocamlbuild
).
The corresponding toplevel directive is #cd "_build";;
.