我试图在模块签名中引用一个类型来构建另一种类型。
module type Cipher = sig
type local_t
type remote_t
val local_create : unit -> local_t
val local_sign : local_t -> Cstruct.t -> Cstruct.t
val remote_create : Cstruct.t -> remote_t
val remote_validate : remote_t -> Cstruct.t -> bool
end
module Make_cipher :
functor (Cipher_impl : Cipher) ->
sig
type local_t = Cipher_impl.local_t
type remote_t = Cipher_impl.remote_t
val local_create : unit -> local_t
val local_sign : local_t -> Cstruct.t -> Cstruct.t
val remote_create : Cstruct.t -> remote_t
val remote_validate : remote_t -> Cstruct.t -> bool
end
type self_t =
{
mutable modules : (module Cipher) list;
mutable locals : Cipher.local_t list;
}
当我编译这个时,我得到 self_t 的“错误:未绑定(bind)模块密码”。我不太确定在这里做什么。
最佳答案
简而言之,您应该使用 Cipher_impl.local_t
而不是 Cipher.local_t
模块类型(又名签名)只是模块接口(interface)的规范。当您需要一个类型时,您需要在特定模块中引用特定类型,而不是在签名中。
关于ocaml - 引用模块类型签名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34768230/