OCaml - 签名,模块和类型

时间:2016-05-01 05:06:31

标签: ocaml

我有一个关于签名类型的基本问题。如果我有两个ocaml文件,如:

istr.ml

type t = int

let get_string f v = f v

和fstr.ml

type t = float

let get_string f v = f v

和签名

stri.mli

module type STR =
  sig

    type t

    val get_string: (t -> string) -> t -> string

  end

上述签名中的类型t是什么?它是多态的吗?

1 个答案:

答案 0 :(得分:1)

它是一种隐藏实现的抽象类型,并阻止用户直接使用它。请参阅module systemRWO
但我不确定您当前的示例是否可行,因为您的代码示例似乎不在模块中。

相关问题