Getting Started OCaml: Setting up utop with Base
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
.