From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 6E3E17FCE8 for ; Thu, 14 Jan 2016 12:24:24 +0100 (CET) IronPort-PHdr: 9a23:IJAPax951gs3S/9uRHKM819IXTAuvvDOBiVQ1KB80egcTK2v8tzYMVDF4r011RmSDdudu6MP0bGempujcFJDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXsq3G/pQQfBg/4fVIsYL+lRMiC3o/tjKibwN76XUZhvHKFe7R8LRG7/036l/I9ps9cEJs30QbDuXBSeu5blitCLFOXmAvgtI/rpMYwuwwZgf8q9tZBXKPmZOx4COUAVHV1BVso/9XmvgXvSg6G531UEjlH00kAPw+QyhDxXd/bvzfmu/B81CaXdZnyTKsoQnKk7qxoDhXllDsKLT81/2z/hcl5jaYdqxWk8U9R2YnRNaeUP/16d7iVWtEXSWMJdM9LH3hHA4i7a4IUSe0DMOpR6YP0vXMKoAu/CwjqD+TqnGwbzkTq1LE3hrxyWTrN2xYtSpdT6Xk= Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=nicolas.ojeda.bar@lexifi.com; spf=None smtp.mailfrom=nicolas.ojeda.bar@lexifi.com; spf=None smtp.helo=postmaster@mx30.yaziba.net Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of nicolas.ojeda.bar@lexifi.com) identity=pra; client-ip=82.138.71.21; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="nicolas.ojeda.bar@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of nicolas.ojeda.bar@lexifi.com) identity=mailfrom; client-ip=82.138.71.21; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="nicolas.ojeda.bar@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mx30.yaziba.net) identity=helo; client-ip=82.138.71.21; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="nicolas.ojeda.bar@lexifi.com"; x-sender="postmaster@mx30.yaziba.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AmAQBohJdWnBVHilJehAxtBohVowyRexgBCYVtAoE0BzwQAQEBAQEBAQEQAQEBAQEICwkJIS6CLYIIAQEDAQECDxEERwsFCwsEBxodAgIhAQYMAQUBChIGExIQh3cDCggECqFugTE+MYtIjR0DCoMWAQEBAQEFAQEBAQEBHYZXhH6CT4I1gnCBSQWGJAyQZoVEhSt0gXiCKIxZhnmGFBEkgRUCESiCUYFlcQGGMAEBAQ X-IPAS-Result: A0AmAQBohJdWnBVHilJehAxtBohVowyRexgBCYVtAoE0BzwQAQEBAQEBAQEQAQEBAQEICwkJIS6CLYIIAQEDAQECDxEERwsFCwsEBxodAgIhAQYMAQUBChIGExIQh3cDCggECqFugTE+MYtIjR0DCoMWAQEBAQEFAQEBAQEBHYZXhH6CT4I1gnCBSQWGJAyQZoVEhSt0gXiCKIxZhnmGFBEkgRUCESiCUYFlcQGGMAEBAQ X-IronPort-AV: E=Sophos;i="5.22,294,1449529200"; d="scan'208,217";a="160371155" Received: from mx30.yaziba.net ([82.138.71.21]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 14 Jan 2016 12:24:23 +0100 Received: from mta10.int.yaziba.net (unknown [217.117.151.14]) by mx30.yaziba.net (mx10.yaziba.net) with ESMTP id 2BF3A1A74D5 for ; Thu, 14 Jan 2016 12:24:23 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mta10.int.yaziba.net (Postfix) with ESMTP id 1D09DCA653 for ; Thu, 14 Jan 2016 12:24:23 +0100 (CET) X-Virus-Scanned: amavisd-new at mta10.int.yaziba.net Received: from mta10.int.yaziba.net ([127.0.0.1]) by localhost (mta10.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dr02UWL7qJSb for ; Thu, 14 Jan 2016 12:24:22 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mta10.int.yaziba.net (Postfix) with ESMTP id E4B39CA735 for ; Thu, 14 Jan 2016 12:24:22 +0100 (CET) X-Virus-Scanned: amavisd-new at mta10.int.yaziba.net Received: from mta10.int.yaziba.net ([127.0.0.1]) by localhost (mta10.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id LdyLkPgoBMmR for ; Thu, 14 Jan 2016 12:24:22 +0100 (CET) Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by mta10.int.yaziba.net (Postfix) with ESMTPSA id B645ECA653 for ; Thu, 14 Jan 2016 12:24:22 +0100 (CET) Received: by mail-wm0-f48.google.com with SMTP id f206so338541550wmf.0 for ; Thu, 14 Jan 2016 03:24:22 -0800 (PST) X-Gm-Message-State: ALoCoQk95dSpagLpYLyCUkzvsnmDS/A18q31SL+GeWHQk58vCkzqcXogUqR4eA/IIT9TW9tjVlx9YCpz/DE8k34fANupcz4+JA== X-Received: by 10.28.220.68 with SMTP id t65mr29304725wmg.92.1452770662518; Thu, 14 Jan 2016 03:24:22 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.107.25 with HTTP; Thu, 14 Jan 2016 03:24:03 -0800 (PST) In-Reply-To: <569782FC.1020904@gmail.com> References: <569782FC.1020904@gmail.com> From: Nicolas Ojeda Bar Date: Thu, 14 Jan 2016 12:24:03 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Nick Betteridge Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=001a114b30fa479eb305294987ba X-VRSPAM-SCORE: -51 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrfeekiedrkeelgddvtdcutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpjgetkgfkueetnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenogfuuhhsphgvtghtffhomhgrihhnucdlgeelmdenucfjughrpegjfhfhfffkuffvtgesrgdtreertddtjeenucfhrhhomheppfhitgholhgrshcuqfhjvggurgcuuegrrhcuoehnihgtohhlrghsrdhojhgvuggrrdgsrghrsehlvgigihhfihdrtghomheqnecuffhomhgrihhnpehinhhrihgrrdhfrhdphigrhhhoohdrtghomhenucfrrghrrghmpehmohguvgepshhmthhpohhuth X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht Subject: Re: [Caml-list] Referencing a functor type --001a114b30fa479eb305294987ba Content-Type: text/plain; charset=UTF-8 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 > --001a114b30fa479eb305294987ba Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Nick,

You can wrap the diff= erent key types in an existential:

type local_key =3D LK = : 'a * (module Cipher with type local_t =3D 'a) -> LK
<= div>
type self_t =3D local_key list

Cheers,
<= /div>
Nicolas



On Thu, Jan 14, 2016 at 12:14 PM, Nick B= etteridge <lists.nick.betteridge@gmail.com> wr= ote:
Hi,

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


module type Cipher =3D sig

=C2=A0 type local_t
=C2=A0 type remote_t

=C2=A0 val local_create : unit -> local_t
=C2=A0 val local_sign : local_t -> Cstruct.t -> Cstruct.t
=C2=A0 val remote_create : Cstruct.t -> remote_t
=C2=A0 val remote_validate : remote_t -> Cstruct.t -> bool

end

module Make_cipher :

=C2=A0 functor (Cipher_impl : Cipher) ->
=C2=A0 =C2=A0 sig
=C2=A0 =C2=A0 =C2=A0 type local_t =3D Cipher_impl.local_t
=C2=A0 =C2=A0 =C2=A0 type remote_t =3D Cipher_impl.remote_t
=C2=A0 =C2=A0 =C2=A0 val local_create : unit -> local_t
=C2=A0 =C2=A0 =C2=A0 val local_sign : local_t -> Cstruct.t -> Cstruct= .t
=C2=A0 =C2=A0 =C2=A0 val remote_create : Cstruct.t -> remote_t
=C2=A0 =C2=A0 =C2=A0 val remote_validate : remote_t -> Cstruct.t -> b= ool
=C2=A0 =C2=A0 end

type self_t =3D
=C2=A0 {
=C2=A0 =C2=A0 mutable modules : (module Cipher) list;
=C2=A0 =C2=A0 mutable locals : Cipher_impl.local_t list;
=C2=A0 }

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

--001a114b30fa479eb305294987ba--