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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 558807F8C9 for ; Mon, 18 Jan 2016 08:49:44 +0100 (CET) IronPort-PHdr: 9a23:ZfBw8x0a8ihfO6EYsmDT+DRfVm0co7zxezQtwd8ZsegeKfad9pjvdHbS+e9qxAeQG96LtbQV1qGP6/uocFdDyKjCmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBybrysXNWC0YLmiqvro8abSj4LrQT+SIs6FA+xowTVu5teqqpZAYF19CH0pGBVcf9d32JiKAHbtR/94sCt4MwrqHwI6Lpyv/JHBIP7dKM8RKcQKzYrP2l9zsTx/U3FTACI4nIHFGIUnxZBRQLM9jn+U4fwvCq8ve14jnq0J8rzGJY1Ujfqxap3VBLyiSsIOnZt9GDMltc2iqNQo1SrqgBjzpTVbI6YHPV7d6LZO9gdQDwSDY5qSyVdD9bkPMM0BO0bMLMAog== Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=lists.nick.betteridge@gmail.com; spf=Pass smtp.mailfrom=lists.nick.betteridge@gmail.com; spf=None smtp.helo=postmaster@mail-wm0-f50.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of lists.nick.betteridge@gmail.com) identity=pra; client-ip=74.125.82.50; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="lists.nick.betteridge@gmail.com"; x-sender="lists.nick.betteridge@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of lists.nick.betteridge@gmail.com designates 74.125.82.50 as permitted sender) identity=mailfrom; client-ip=74.125.82.50; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="lists.nick.betteridge@gmail.com"; x-sender="lists.nick.betteridge@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wm0-f50.google.com) identity=helo; client-ip=74.125.82.50; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="lists.nick.betteridge@gmail.com"; x-sender="postmaster@mail-wm0-f50.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BhAQAPmJxWlDJSfUpdhHmIVqFihwiMQIYPAoEjPBABAQEBAQEBARABAQEBBwsLCR8wgi2CCAEBBBIRBBkBGxwBAQMMBgULDwIFFgsCAgkDAgECARERAQUBHAYNCAEBHodjAQMSBKBmgTE+MYtIgWqCeYZuChknDVaCcQEBAQEBAQEDAQEBAQEBFwEFCgRyilSEVYMfgUkFlxqNX4kcDoVXjRE1gRc5gjAigWRyhx8BAQE X-IPAS-Result: A0BhAQAPmJxWlDJSfUpdhHmIVqFihwiMQIYPAoEjPBABAQEBAQEBARABAQEBBwsLCR8wgi2CCAEBBBIRBBkBGxwBAQMMBgULDwIFFgsCAgkDAgECARERAQUBHAYNCAEBHodjAQMSBKBmgTE+MYtIgWqCeYZuChknDVaCcQEBAQEBAQEDAQEBAQEBFwEFCgRyilSEVYMfgUkFlxqNX4kcDoVXjRE1gRc5gjAigWRyhx8BAQE X-IronPort-AV: E=Sophos;i="5.22,311,1449529200"; d="scan'208";a="197849961" Received: from mail-wm0-f50.google.com ([74.125.82.50]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 18 Jan 2016 08:49:43 +0100 Received: by mail-wm0-f50.google.com with SMTP id n5so49721433wmn.0 for ; Sun, 17 Jan 2016 23:49:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=4/y8US4mwtjpVwVW4RSGaAgINDudgJUuF4lvYRUOz1s=; b=LWeuJTqJ7lADgnTOY8wUngTENGrRJPvoknPn+E6eagruSMcJ5CbNX0KCtI0/PKNANp xdOrRJ78lMnZzAid1bz9fCtR1CpdmyQN0yMkaVLQ2/Q81X+ikOFP97iJ27MnxKrLagXR QCoi38wQkGPE8DpZbnnx6xQau5H9Gfl0k6Y3EfLis6eUttd4oFC+JbKSBcnJN/eOYsnQ cm0Wc63/T/lM5rate8dw4grEa24vZ+XvHZ711LdJF0IBINsg+GnMd0se/0yZUkMGlg2q Lp8AHVjm6MW3T9N3eBpagr/iwXyyYIyH6J1FRFRBausvZ17HxcInIwx8nrVc2IEJhfcV lViw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=4/y8US4mwtjpVwVW4RSGaAgINDudgJUuF4lvYRUOz1s=; b=OJc88itrwGtu8Zt7CCaTsJPrRy8kwOT87Q+T2KQDMn8V53AQYH13EX8wI5nbr6dngA e3XxCQeiESemj6ChM/luN65Bm6CrHAY83HxzUD6DOrO7j4wdSf2V21kXkX50qHgliVHo jePMm1PYcR9CQdZqAIXSN95buHi7q1pS5L8i8dwpMSnz55nlYId5T5lCO7fv9Hq5K9lo D0ZbPgpTBYxGWXWPwdTB9+C/yZKoK5IMp6HBFUIP0DyXo7BOQ+ch9ZAx/5HnuZzRL74t AG7xKjCkPVhoYbsr5jNFW46U6xdu5MO4FV5ZUJm6nMght9U7/VI/WGABrCPPAMh+QpC3 7RZA== X-Gm-Message-State: ALoCoQmxruOlo9XZhEKWdFvY1+GUkmQ6MRkvKJZD/aR0GlnTIxubb6iXPJXsCQt7n4A4O06nVeMWNHbVIa3maIgY5GbCZzppFA== X-Received: by 10.195.12.226 with SMTP id et2mr21746733wjd.34.1453103383559; Sun, 17 Jan 2016 23:49:43 -0800 (PST) Received: from [192.168.1.12] (buzzheavyyear.plus.com. [80.229.27.245]) by smtp.gmail.com with ESMTPSA id u12sm14384890wmu.10.2016.01.17.23.49.42 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 17 Jan 2016 23:49:42 -0800 (PST) To: Nicolas Ojeda Bar References: <569782FC.1020904@gmail.com> Cc: caml-list@inria.fr From: Nick Betteridge Message-ID: <569C9915.4060707@gmail.com> Date: Mon, 18 Jan 2016 07:49:41 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Referencing a functor type Hi Nicolas, everyone, I'm having problems in reconstituting the variables - I'm pretty sure I need to do some form of 'casting'. As a recap, I've re-written everything below with a simple use-case - forming the GADTs works perfectly: 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 local_key = LK : 'a * (module Cipher with type local_t = 'a) -> local_key type cipher_module = CM : (module Cipher with type local_t = 'a) -> cipher_module type self_t = { mutable modules : cipher_module list; mutable locals : local_key list } module C1x = Make_cipher (Cipher1) module C2x = Make_cipher (Cipher2) let () = let cs1 = ( module C1x : Cipher with type local_t = Cipher1.local_t) in let cs2 = ( module C2x : Cipher with type local_t = Cipher2.local_t) in let module C1 = (val cs1 : Cipher with type local_t = Cipher1.local_t) in let module C2 = (val cs2 : Cipher with type local_t = Cipher2.local_t) in let local1 = C1.local_create () in let local2 = C2.local_create () in let l_k1 = LK (local1, cs1) in let l_k2 = LK (local2, cs2) in let cm1 = CM (cs1) in let cm2 = CM (cs2) in let cslist = [cm1;cm2] in ignore (C1.local_sign local1 (Cstruct.create 23)); let self = { modules = [cm1;cm2]; locals = [l_k1;l_k2]; } in let CM cs1' = cm1 in let module C1' = (val cs1' : Cipher with type local_t = 'a) in let LK (local1', cs1') = l_k1 in let signature = C1'.local_sign local1' (Cstruct.create 23) in Printf.printf "OK" An error is given for 'let signature = ....' Error: This expression has type a#1 but an expression was expected of type C1'.local_t = a#0 I've spent quite a while trying to figure this out and playing around with various permutations and am simply getting nowhere! Cheers Nick