Learning OCaml

Notes from an OCaml learner

OCaml needs better documentation. Some of the Jane Street OCaml packages are documented. Some do not seem to be well-documented.

For example, stdio doesn't seem to have any documentation. I gather this is because the package replaces functions in the standard library. That is, it is assumed people understand the functions via proxy.

It is not obvious how one uses the Jane Street OCaml packages in utop, at least under Linux in 2019.

The following assumes that you have managed to get OCaml installed and executing eval $(opam config env) sets up everything correctly in your environment.

The key is to run #require "base";; in utop. The following sequence should work:

#require "core";;
open Base;;
List.map ~f:String.length ["Hello"; "World!"];;

The List.map above is Base.List.map, as desired.

If you don't run #require "core";; you will get the message: Error: Unbound module Base.

#ocaml #learningocaml #utop