Ocaml未绑定模块 [英] Ocaml unbound module

查看:396
本文介绍了Ocaml未绑定模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习Ocaml语言,但是当我想编译它们时,我的模块有问题。
所以,我有一个名为Door的模块,另一个名为Case的模块。我有一个类型参数与其他模块:

I'm learning Ocaml language but i have a problem with my modules when i want to compile them. So, I have a module with the name Door and an other one with the name Case. Into each one, i have a type paramater with the other module :

Door.mli
type t = bool -> Case.u -> t

Case.mli
type u = bool -> Door.t -> u

当我想编译时,我有这个错误:
Filedoor.mli ,第14行,字符23-29:
错误:未绑定模块案例

When i want to compile, i have this error : File "door.mli", line 14, characters 23-29: Error: Unbound module Case

您有想法吗?

感谢你

推荐答案

你有两个相互递归的模块,这总是棘手的。让他们工作的一种方法是使用模块rec A ...和B ... 在同一个文件中定义它们。

You have two mutually recursive modules, which is always tricky. One way to get them to work is to define them in the same file using module rec A ... and B ....

但是,你也有你的类型是循环的问题。定义:

However, you also have the problem that your types are cyclic. The definition:

type t = bool -> Case.u -> t

。您可以通过在编译器或解释器命令行中指定 -rectypes 来接受它。

is not normally accepted by OCaml either. You can get it to be accepted by specifying -rectypes on the compiler or interpreter command line.

你会发现这些结构很难使用。他们很难定义的原因是,他们通常不是你想要的。如果可能,您可以尝试从更简单的类型开始。

I fear that you'll find these structures to be difficult to work with. The reason they're difficult to define is that they're not usually what you want. You might try starting with more straightforward types if possible.

这篇关于Ocaml未绑定模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆