Functional Programming

bachelor program

VO2 + PS1  WS 2015/2016  703024 + 703025

Frequently Asked Questions

This page will be populated with reasonable questions, asked during the lecture or the exercises, or sent as feedback.

How can I access course material from outside

Install a VPN.

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 as bytecode executable:
    $ ocamlbuild prog.byte
  • Compiling an interpreter in which some modules are preloaded. First create a file name.mltop containing one module per line that should be preloaded on startup. Second
    $ ocamlbuild
  • Prepare a (hidden) file .ocamlinit containing the directive #cd "_build";
  • Start the interpreter with ./

How can I customize my own interpreter?

Every time an interpreter is started (either ocaml or something like 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";;.