Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 2.37 KB

instructions.md

File metadata and controls

46 lines (35 loc) · 2.37 KB

Instructions to set a OCaml programming environment

To install and set up the OCaml compilers and REPL following the instructions on the OCaml website.

To set up opam and to use other tools, you can also read this tutorial or this chapter from OCaml Programming.

Set up an editor

If you want to use emacs or vim as OCaml editor, install the package user-setup via opam

$ opam user-setup install

This package will install all the needed dependencies and the configuration for your editor. To see the status of the configuration use the command

opam-user-setup status

If you want to use vscode as OCaml editor, install the OCaml OCaml Platform extension from the market. Remember to install LSP server for OCaml using

$ opam install ocaml-lsp-server

Create our OCaml Project

For simple programs you can directly load our code in the OCaml toplevel or compile it using the compiler. For simple projects you can also use ocamlbuild.

For larger projects it is convenient using a build system. The most popular modern system for building OCaml is dune that can be installed via opam.

See here to see how create a simple project using dune.

You can also use the template at https://github.com/mjambon/dune-starter :

$ git clone https://github.com/mjambon/dune-starter
$ cp -a dune-starter/proj my-project
$ cd my-project
$ git init

Here are also some tools that can generate a project structure for you:

  • spin is a Reasonml and OCaml project generator. It provides templates for many kinds of projects.
  • drom is a wrapper over opam/dune in an attempt to provide a cargo-like user experience.
  • oskel is a skeleton generator for OCaml that provides templates for libraries and binary.

They can be install via opam.