caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Nicolas Ojeda Bar <nicolas.ojeda.bar@lexifi.com>
To: Nick Betteridge <lists.nick.betteridge@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Referencing a functor type
Date: Thu, 14 Jan 2016 12:24:03 +0100	[thread overview]
Message-ID: <CADK7aFPXbQdYZd6aniEvmTD5onQLksOABHU-nvpojAiLOWB6Rg@mail.gmail.com> (raw)
In-Reply-To: <569782FC.1020904@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1566 bytes --]

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
>

[-- Attachment #2: Type: text/html, Size: 2553 bytes --]

  reply	other threads:[~2016-01-14 11:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-14 11:14 Nick Betteridge
2016-01-14 11:24 ` Nicolas Ojeda Bar [this message]
2016-01-18  7:49   ` Nick Betteridge
2016-01-18 14:45     ` Runhang Li
2016-01-18 16:02       ` Nick Betteridge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADK7aFPXbQdYZd6aniEvmTD5onQLksOABHU-nvpojAiLOWB6Rg@mail.gmail.com \
    --to=nicolas.ojeda.bar@lexifi.com \
    --cc=caml-list@inria.fr \
    --cc=lists.nick.betteridge@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).