我想定义一个 interface PROPERTY,以及至少 2 个模块Type并Formula与之匹配:
module type PROPERTY =
sig
type t
val top : t
val bot : t
val to_string: t -> string
val union: t -> t -> t
val intersection: t -> t -> t
end
module Type = (struct
type t =
| Tbot
| Tint
| Tbool
| Ttop
...
end: PROPERTY)
module Formula = (struct
type t =
| Fbot
| Ftop
| Fplus of int * Type.t
...
let union =
... Type.union ...
...
end: PROPERTY)
有两个要求:
1)我希望Type可以在外部调用的构造函数(如有必要,所有程序)
2) 某些值的一部分Formula包含 的值Types,例如Fplus (5, Type.Tint)类型为Formula;还有一些函数Formula需要调用一些函数Type,例如Formula.union需要调用Type.union
谁能告诉我如何修改上述声明以满足我的要求?如有必要,可以添加额外的模块...