Reputation: 93
I'm trying to reference a type in a module signature to build another type.
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;
}
When I compile this, I get 'Error: Unbound module Cipher' for self_t. I'm not too sure what to do here.
Upvotes: 4
Views: 395
Reputation: 35280
In short, you should use Cipher_impl.local_t
instead of Cipher.local_t
A module type (aka signature) is just a specification of module interface. When you need a type, you need to refer to a particular type in a particular module, not in the signature.
Upvotes: 4