en | de

Funktionale Programmierung

Bachelorstudium

VO2 + PS1  WS 2007/2008  no LVA number

Frequently Asked Questions

This page will be populated with reasonable questions, asked during lecture or exercises, or sent via feedback. Disclaimer: We do not take responsibility for the content of externally linked resources.

How to structure an OCaml program in order to test a function?

Every code that is not a let declaration (i.e., defines some new value) is executed from top to bottom. E.g.,
let main () =
 ...
;;
does nothing except defining a function called main. A full program would also need a call to this function, i.e., main ();;. (Notice that the name is completely arbitrary. There is no need for a function called main.)

My installation does not contain ocamlbuild. What do I do?

Either you update to at least version 3.10 of OCaml (since version 3.10 ocamlbuild is part of the OCaml distribution), or you use ocamlc (see `man ocamlc' or the OCaml manual).
Further remarks:
  • For Fedora users an update to OCaml 3.10 is very easy using yum.
  • Thanks to Richard Weinberger an RPM for SUSE as well as a 1-click-installer for SUSE 10.3 are available.

Why don't we use an IDE?

If you don't know what an IDE is, never mind. For the others: yes IDEs are useful, but everybody has her preferred one and this course is not about learning how to use an IDE. Hence only tools that are included in every (recent) OCaml installation are used.

How do I use the provided w<week>.tar.bz2 files?

Assume the file is w04.tar.bz2 (meaning that the content corresponds to week 4 of the lecture). After downloading the archive extract it using

$ tar -xjf w04.tar.bz2

This will create a directory w04 in the current directory.

$ cd w04/

There are *.ml (and maybe *.mli) files for the modules used during the lecture. Additionally there are three files
  • w04.itarget: which can be used as in `$ ocamlbuild w04.otarget' to generate all *.cmo (and maybe *.cmi) files in a subdirectory called  _build.
  • w04.mltop: which can be used as in `$ ocamlbuild w04.top' to generate the byte-code executable w04.top being an OCaml interpreter where all the modules of week 4 are already loaded (use `$ ./w04.top' to run it).
  • .ocamlinit: which contains commands that should always be executed during startup of any OCaml interpreter in the current directory.

How to use ocamlbuild under Windows?

  1. Install cygwin from http://www.cygwin.com/ by choosing `Install or update now!'.
  2. Download the `Source distribution for Windows and Unix systems' from http://caml.inria.fr/download.en.html and save it to some directory reachable by cygwin.
  3. Start cygwin and change to the above directory. Unpack the archive and change to the resulting directory. Type
     $ ./configure
    
    to configure the installation. Then type
     $ make world
    
    to compile all OCaml tools (make sure that some `make' packages have been installed during the installation of cygwin). And finally install via
     $ umask 022
     $ make install
    
    Now ocaml and ocamlbuild can be used via cygwin.