在 utop 中测试是否 运行

Test if running in utop

我在我的 .ocamlinit 中添加了几行以使 utop 提示不那么令人讨厌:

#require "react";;
#require "lambda-term";;
UTop.prompt := fst (React.S.create LTerm_text.(eval [
    S "\n";
    B_bold true;
    B_fg (LTerm_style.cyan);
    S "# ";
]));;

(我不明白那里发生的一切......我只是在网上找到它并对其进行了调整。)

但现在如果我使用常规 ocaml 顶层,我会得到:

Error: Unbound module UTop

我可以向 .ocamlinit 添加测试以跳过这些行,除非我是 运行 utop 吗?我可以将它们放在仅由 utop 加载的附加文件中吗?

如果添加 #require "utop";; 会怎样?