Hi Nick,

You can wrap the different key types in an existential:

type local_key = LK : 'a * (module Cipher with type local_t = 'a) -> LK

type self_t = local_key list

Cheers,
Nicolas



On Thu, Jan 14, 2016 at 12:14 PM, Nick Betteridge <lists.nick.betteridge@gmail.com> wrote:
Hi,

I'm trying to create a functor for different type of cipher which have
the same signature. The functor compiles Ok, but I can't work out how to
phrase my self_t to build up a list of local key types. Could anyone
suggest a way forward? Thanks, Nick.


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_impl.local_t list;
  }

--
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs