简体   繁体   English

OCaml:顶层目录中父目录的未绑定模块

[英]OCaml: Unbound module from parent directory in toplevel

I'm trying to load a module from a parent directory into the top level interpretor. 我正在尝试将模块从父目录加载到顶级解释器中。

#load "../Syntax.cmo";;
open Syntax

let foo = bar

Where bar is in Syntax. bar在语法中。 I have module Syntax in the parent directory. 我在父目录中有模块语法。 Loading module Syntax does not cause any problems, but the open line throws an error: 加载模块语法不会引起任何问题,但是空行会引发错误:

Error: Unbound module Syntax

I have also tried removing the open: 我也尝试过删除打开的内容:

#load "../Syntax.cmo";;
let foo = Syntax.bar

But that gives me the same error as Syntax is in the parent directory. 但这给了我与父目录中语法相同的错误。

Is there anyway around this? 有没有办法解决?

You shouldn't use relative paths, instead use #directory directive: 您不应使用相对路径,而应使用#directory指令:

#directory "..";;
#load "Syntax.cmo";;
let foo = Syntax.bar;;

Even better, define your library using oasis, or some other high-level tools, and use #require to load your libraries, instead of tackling with low-level directives. 更好的是,使用oasis或其他一些高级工具来定义您的库,并使用#require加载您的库,而不是处理低级指令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM