0

如果我有一个包含的实现 ( .re) 文件

module IntMap =
  Map.Make {
    type t = int;
    let compare = compare;
  };

type foo = IntMap.t string;

如何将签名添加foo到接口(.rei)文件?类似于 OCaml 的

module IntMap = Map.S with type key = int
type foo = string IntMap.t

我希望它是

module IntMap =
  Map.S {
    type t = int;
  };

type foo = IntMap.t string;

但这会导致{.

4

1 回答 1

1

我怀疑您的问题的根本原因是您发布的 OCaml 代码无效。它应该是

module IntMap: Map.S with type key = int

等价的原因是

module IntMap: Map.S with type key = int;
type foo = IntMap.t string;

不是很不同:)

此外,如果您不知道,reason-tools是一个很棒的工具,可以为您在 Reason 和 OCaml 之间进行转换。它确实需要有效的输入;)

于 2017-09-05T11:34:45.240 回答