From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p55DIZXl011941 for ; Sun, 5 Jun 2011 15:18:35 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai8CAPiA603RVaA0kGdsb2JhbAA9AQMSpjMIFAEBAQEJCQ0HFAQhiHGiDY5egzeJGwEBAwaGGwSGcooHhVyFYzyBL4If X-IronPort-AV: E=Sophos;i="4.65,322,1304287200"; d="scan'208";a="110271054" Received: from mail-pw0-f52.google.com ([209.85.160.52]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-MD5; 05 Jun 2011 15:18:30 +0200 Received: by pwi4 with SMTP id 4so2448577pwi.39 for ; Sun, 05 Jun 2011 06:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:subject:mime-version:content-type:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to:x-mailer; bh=/E5BfprrcdmoRRjAkK6NVYvZeDb7CDDsCDZXkDqrwog=; b=h4LSFDLY6+odXZXcFJjNa/dHOoBouHk47nFuXGbIscm1R4vhBkJ3IkCSgalOvp7KfJ CxmNJuMAyNfgboLe9s0b0j2+6bLG2p73Yxli3uvfZnE/Kd/KtCvmb9n9hcBYxrHde/9t Q/Y3G7XVk/oVSCywOwDstjNaxzlS1jbiplX0U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=G1qbYouOcX10aXdV0ZPcVdPL6Pj8QQxZc6qrzVBoUP3KDNRkAIh+NeX/V2fHVuuLhL dii56LVTAalhSPXjPIjlBancEmFSGUt7K85cHNjZxZzhBrs8xYl39DpMN/O9GRme0O1l +vhQtcY4kqZxJyypTLWR0avCYPeggFIJU2Q+c= Received: by 10.142.240.14 with SMTP id n14mr555033wfh.360.1307279908084; Sun, 05 Jun 2011 06:18:28 -0700 (PDT) Received: from tet.garrigue.jp (58x158x128x157.ap58.ftth.ucom.ne.jp [58.158.128.157]) by mx.google.com with ESMTPS id y2sm2944469pbi.35.2011.06.05.06.18.26 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 05 Jun 2011 06:18:27 -0700 (PDT) Sender: Jacques Garrigue Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Jacques Garrigue In-Reply-To: <4DEA5272.9040905@wp.pl> Date: Sun, 5 Jun 2011 22:18:24 +0900 Cc: caml-list Message-Id: <299C6C20-7A2D-481D-9FD2-320DC6DACFD4@math.nagoya-u.ac.jp> References: <4DEA5272.9040905@wp.pl> To: Dawid Toton X-Mailer: Apple Mail (2.1084) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p55DIZXl011941 Subject: Re: [Caml-list] Constrain module type to reuse a sum type On 2011/06/05, at 0:42, Dawid Toton wrote: > I have a functor F which itself applies its own arguments to some other functors. Results R of these applications contain sum types. These R are exposed in the outcome of F in two ways: as types carried by the functions defined by F and all R packed into a wrapper module. I'd like to tell the compiler that each sum type is equal in both contexts. > > The problem boils down to the following: > > B.ml: > > module type A = sig type a = A end > module A = struct type a = A end > > module E = A > > type want_equal = A.a as 'a constraint 'a = E.a > > B.mli: > > module type A = sig type a = A end > module A : A > > module type E = A (*with type a = A.a*) > module E : E > > type want_equal = A.a as 'a constraint 'a = E.a > > > There are no problems with the module implementation. I can see right types in the output of ocamlc -i . > But the interface is wrong, since it is forgotten that the sum types in E and A are the same. > > I have put a constraint in a comment - this is what I'm trying to achieve. Your constraint (in comment) is the right one. Unfortunately, it was not allowed up to 3.12.0 (a full definition, including constructors, was required). The upcoming 3.12.1 will allow it. Jacques Garrigue