我怎样才能定义一个
Set
在OCaml中,是否也可以包含其类型的元素?
为了解释这个问题,我为很多数据类型做了一个类型声明,比如
type value =
Nil
| Int of int
| Float of float
| Complex of Complex.t
| String of string
| Regexp of regexp
| Char of char
| Bool of bool
| Range of (int*int) list
| Tuple of value array
| Lambda of code
| Set of ValueSet.t (* this isn't allowed in my case since module is declared later*)
ValueSet
稍后在同一文件中:
module ValueSet = Set.Make(struct type t = value let compare = Pervasives.compare end)
问题是
值集
有
value
价值
可以是一个
值集
所以我在编译的时候遇到了麻烦。
types.ml
(有自己的接口)
types.mli
但是没有
模块decl,因为我也不确定这是可能的)。
这个问题能以某种方式解决吗?