Ocaml 简化函数返回模块

Ocaml 简化函数返回模块,ocaml,Ocaml,此函数应该能够简化,删除不必要的let模块T=…。但是怎么做?!我不断地遇到语法错误。小费 let make_module dice_results : (module Tellstory.T) = let dice_calls = ref 0 in (* nr of times dice has been called *) let module T = Tellstory.Make(struct let dice n = let result = List.nt

此函数应该能够简化,删除不必要的
let模块T=…
。但是怎么做?!我不断地遇到语法错误。小费

let make_module dice_results : (module Tellstory.T) =
  let dice_calls = ref 0 in (* nr of times dice has been called *)
  let module T = Tellstory.Make(struct
    let dice n = 
      let result = List.nth dice_results (!dice_calls) in
      dice_calls := !dice_calls + 1;
      result
  end) in
  (module T)

我无法检查您的模块,但这是一个灵感的示例:

let make_module () : (module Unit) =
  (module Comparable.Make (struct type t = int with compare, sexp end))
看起来以下各项应该可以工作:

let make_module dice_results : (module Tellstory.T) =
  let dice_calls = ref 0 in (* nr of times dice has been called *)
  (module Tellstory.Make(struct
    let dice n = 
      let result = List.nth dice_results (!dice_calls) in
      dice_calls := !dice_calls + 1;
      result
  end))

没错,但Vim中的syntastic不同意。不知道为什么…:P