OCaml

An open source multi-paradigm programming language and toolchain.

What is OCaml?

OCaml is an industrial-strength programming language supporting functional, imperative and object-oriented styles.

OCaml installation

To install the OCaml tools, type on a terminal:

$ sudo dnf install ocaml ocaml-findlib 

The REPL (Read-Evaluate-Print-Loop) tool (ocaml), the library manager ( ocamlfind), the bytecode compiler (ocamlc), and the native-code compiler binaries (ocamlopt) will become available on the system.

OPAM

OPAM (OCaml Package Manager) is a source-based package manager for OCaml. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.

Installation

To install OPAM in your Fedora just:

$ sudo dnf install opam

Environment setup

You can use OPAM to install and manage your OCaml environment. First, it is necessary to add the environment variables in your default shell, OPAM does it for you when you run the init command, and after it, you can use eval in your first time to load the configuration.

$ opam init
# the console will ask if you want to really modify your ~/.bashrc (or default), use 'y' to confirm.
$ eval $(opam env)

After adding the environment variables in your default shell you can install the desired version of OCaml compiler using the switch command and you can load the new environment variables running eval soon after it.

$ opam switch create 4.12.0
$ eval $(opam env)

Now you can check if your OCaml version is the one you installed.

$ ocaml -version

References


Authors: Camilo Cunha de Azevedo