Oh btw, you can put these directives in your ~/.ocamlinit file that probably already was created by opam. I.e. add all the packages that contain modules you frequently want to use in utop there. Mine looks like this currently:
(* Added by OPAM. *) let () =
try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")
with Not_found -> ()
;;
#require "yojson";;
#require "core_extended";;
For technical reasons, the entry point to Core’s API used to be Core.Std. They now use module aliases, which makes the Std sub-module unnecessary. You should now do open Core instead of open Core.Std.
I think one of the things that you should know is that the function application syntax (other languages call that invocation) is quite different. You don’t write down the function name and then surround the arguments with parens as in foo(a, b). Instead you just write foo a b which means that you apply a to foo, which gives you a new (unnamed) function, which you apply to b. The fact that Time.now () has () is due to the fact that every function must take 1 argument even if it doesn’t really need any arguments, so there is a special value, (), pronounced “unit” that can be passed to that function.
I personally think this syntax is incredibly neat and elegant but opinions differ.
let local = lazy
begin match Sys.getenv "TZ" with
| Some zone_name ->
find_exn zone_name
| None ->
let localtime_t =
input_tz_file ~zonename:"/etc/localtime" ~filename:"/etc/localtime"
in
(* load the matching zone file from the real zone cache so that we can serialize
it properly. The file loaded from /etc/localtime won't have a name we can use
on the other side to find the right zone. *)
match Zone_cache.find_or_load_matching localtime_t with
| Some t -> t
| None -> localtime_t
end
Unix does not make timezone handling simple or efficient, sadly…