OCaml By Examples

Language Basics

Project Management

  • dune
  • dune-release
  • opam pin

Advanced Ocaml

  • functors
  • monads

Libraries

dune

dune-project

A dune-project file is at the root of any project, it allows to set configuration for any executable or library in the project.
(lang dune 2.8)

(implicit_transitive_deps false)

dune

A dune allows you to declare an executable or a library.
(executable
 (name main)
 (libraries core))

.ocamlformat

You need an `.ocamlformat` file (that can be empty) at the root for `ocamlformat` to work.

console

You can run utop with your library thanks to e dune.
$ dune build
$ dune exec
$ dune utop src/lib/my_module

utop # open My_module;;

utop # My_module.Toolkit.(do_stuff (from_int 3));;
- : float = 259200000.
next: dune-release