是否有可能在没有创建“必须实现的新模块”的情况下在mli中模块化。 这个例子很有意思,但是,假设我有以下源文件int_wrapper.ml。 type t = Int64.t
let zero = Int64.of_string "0"
我想为它定义一个接口文件,但Int64.t很长,所以我想缩写它。 module I = Int64
val zero : int -> I.t
当
我试图编写一个函数,它需要一对有序的东西并生成另一个有序的东西(按照字典顺序定义)。 但是,我想要得到的“有序类型”是抽象的,而不是OCaml元组。 这很容易处理内联/匿名签名。 (* orderedPairSetInlineSig.ml *)
module type ORDERED_TYPE = sig
type t
val compare : t -> t -> int
我有以下的数据类型(请忽略了一个事实,这可能是方式更简单) type tKey = Key of int;;
type tBST = Null | Pos of node ref
and node = {mutable key : tKey;
mutable left : tBST;
mutable right : tBST};;
我有这个功能,它看