引用模块类型签名

时间:2016-01-13 13:41:08

标签: ocaml

我试图引用模块签名中的类型来构建另一种类型。

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。我不太清楚该怎么做。

1 个答案:

答案 0 :(得分:4)

简而言之,您应该使用Cipher_impl.local_t代替Cipher.local_t

模块类型(aka signature)只是模块接口的规范。当您需要类型时,需要引用特定模块中的特定类型,而不是签名。