0

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. 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?

laifs
  • 197
  • 1
  • 2
  • 11

1 Answers1

1

You shouldn't use relative paths, instead use #directory directive:

#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.

ivg
  • 34,431
  • 2
  • 35
  • 63
  • Thank you for you response. I tried it out, and it though it stopped with the "Unbound module Syntax" error, it gave me a new "Unbound value Syntax.bar" error. – laifs Aug 04 '15 at 03:09
  • that's just mean that your `Syntax` module doesn't define or export `bar` value. – ivg Aug 04 '15 at 10:06
  • but the module Syntax does indeed contain bar. It has let bar a = a EDIT: never mind, it was a compilation error of Syntax, which I had not caught. Now it works. Thanks! :) – laifs Aug 04 '15 at 14:10