在 utop 中加载具有依赖关系的模块

Loading a module with dependencies in utop

我有两个模块 A.mlB.ml 像这样:

A.ml:

type t = int
let from_int (i : int) : t = i

B.ml:

open A
let my_t : t = from_int 0

我可以通过调用 ocamlc A.ml B.ml 来编译它们,但是我不知道如何在 utop 中加载它们以便交互使用 my_t。使用:

你必须先编译 a.ml :

  ocamlc -c a.ml  // yields a.cmo

在 utop 中:

  #load "a.cmo";;
  #use "b.ml";;