I have the following module signature A
:
module type A =
sig
type exp =
Int of int
| Var of string
end;;
which I am able to compile in order to get a.mli
and a.cmi
files. However, if I define B
:
module type B =
sig
val compute : A.exp -> A.exp
end;;
running ocamlc -i b.ml
produces the error Unbound type constructor A.exp
. Why is that?
OCaml gives you an outer module for free, corresponding to each source file. So you are defining a module type named AA Note that it's a module type , not a module.
It's possible your a.ml (and a.mli if you like) should contain just the following:
type exp = Int of int | Var of string
Then you can refer to A.exp from your b.ml file.
Also, note that a.mli is a source file. If you have an a.mli file, you need to compile it to create a.cmi.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.