How to install ocaml on Mac

If you want to play with the language, I would recommend:

opam install utop

which will install a very nice interpreter for ocaml. Then you can do:

utop

and start typing in OCaml expressions:

utop # 1 + 4;;
- : int = 5

For compiling OCaml applications I would recommend the dune build system.

1 Like

See also: https://dev.realworldocaml.org/install.html

If you just want to see if your OCaml toplevel is working you can do a quick test from the terminal:

$ ocaml
        OCaml version 4.06.0
# 1 + 4;;
- : int = 5
# exit 0;;
$

(The ;; token tells the toplevel to evaluate what you’ve typed since the last evaluation.)

1 Like

hi, can you help me? I use Mac with the system 10.13.6. But I can’t install Graphics package, how can I install it? I have tried lots of methods, but failed…thanks

how does one make sure one has installed the newest version of ocaml?

Install any version of opam you like (from brew or macports) and then you can use opam to build the latest release version (which is 4.08.1).