From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p54Fgoou017971 for ; Sat, 4 Jun 2011 17:42:50 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApACAH5R6k3UTWUIi2dsb2JhbAAyCxaESqF8FAEBAQoLCwcSBiG4EIJ6AY0eBYErg2yBCpU3iwI X-IronPort-AV: E=Sophos;i="4.65,320,1304287200"; d="scan'208";a="96055990" Received: from mx4.wp.pl ([212.77.101.8]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 04 Jun 2011 17:42:45 +0200 Received: (wp-smtpd smtp.wp.pl 22196 invoked from network); 4 Jun 2011 17:42:43 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1307202163; bh=WHoQcX5BBJgVB9IdzCWfrmR+MQDgiFvkizgFWNDZ7YQ=; h=From:To:Subject; b=gEJXaZPfyLANYhUu+4z2q5o4HUf3xfKQsJ2luXhErqfr4I+zK/etXzSbfoWBBGoiZ h75LZc0sHernSzE6UNItoPjD9xA6eyVBIUs5HdtBDbP6wgvxPAUft/2hmvxWQj3w+d bqE6yctMG9uAZBo1djIrSfT7PbfVwM/N5e4zCyGs= Received: from 18-161.2-0.pl (HELO [192.168.1.101]) (d0@[91.189.18.161]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with AES256-SHA encrypted SMTP for ; 4 Jun 2011 17:42:43 +0200 Message-ID: <4DEA5272.9040905@wp.pl> Date: Sat, 04 Jun 2011 17:42:42 +0200 From: Dawid Toton User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 MIME-Version: 1.0 To: caml-list Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-WP-AV: skaner antywirusowy poczty Wirtualnej Polski S. A. X-WP-SPAM: NO 0000000 [4eOU] Subject: [Caml-list] Constrain module type to reuse a sum type 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. In my real case, the module type A is a big signature that comes from somewhere else. The mentioned functor F should require as little changes as possible for each change of the module type that corresponds to the module type A in the above example. This is why I'm looking for a way to constrain A to obtain E. How to do this? I would be grateful for any comments. If the code is simplified too much, I can post something more similar to my real code. Dawid