Reputation: 53
I created a module like this:
module Foo =
struct
class foo =
object(this)
...
end
let (><) (f1:foo) (f2:foo) = ...
end
After that I opened this module in a different file and tried to use operator ><, but ocamlc threw an error: "Error: Unbound value ><", but in utop this operator works right.
open Foo
let x = new Foo.foo;;
let y = new Foo.foo;;
let z = x >< y;;
Maybe this problem connected with options to ocamlc, I compiled like this
ocamlfind ocamlc -linkpkg -thread -package core Foo.ml test.ml -o main
where Foo.ml is a file with module Foo, test.ml contains usage of operator.
So, does OCaml support this way of using operators or I made something wrong?
Upvotes: 2
Views: 210
Reputation: 66808
If you have a module named Foo defined in a file named Foo, the name of the inner module is Foo.Foo
. In OCaml the outermost level of a file forms a module named after the file.
You can say include Foo.Foo
. Or you can remove the module Foo
wrapper from the file Foo
.
Upvotes: 3