From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.5 required=5.0 tests=AWL,SPF_SOFTFAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 0B762BC37 for ; Wed, 13 May 2009 21:12:20 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsABAOG4CkrVhjEYkGdsb2JhbACXFwEBAQEJCQwHEQO4SoQCBQ X-IronPort-AV: E=Sophos;i="4.41,189,1241388000"; d="scan'208";a="26118250" Received: from ihsmtp02voda.lis.interhost.com (HELO ihsmtp02cons.lis.interhost.com) ([213.134.49.24]) by mail2-smtp-roc.national.inria.fr with ESMTP; 13 May 2009 21:12:06 +0200 Received: from [192.168.1.64] ([77.54.249.136]) by ihsmtp02cons.lis.interhost.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 13 May 2009 20:09:03 +0100 Message-ID: <4A0B1B81.8090700@inescporto.pt> Date: Wed, 13 May 2009 20:12:01 +0100 From: Hugo Ferreira User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Shared types: dependency in modules with polymorphic type Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 13 May 2009 19:09:03.0607 (UTC) FILETIME=[47C5D070:01C9D3FE] X-Spam: no; 0.00; parametrize:01 sig:01 val:01 val:01 struct:01 sig:01 struct:01 polymorphic:01 polymorphic:01 signatures:01 dependency:01 int:01 int:01 interfaces:01 data:02 Hello, I have had to parametrize several modules an am now having trouble using these interfaces. I have the following situation: The following signatures and module are a generic data container. I want to use this container in another module. module type VB = sig type 'a t val empty : 'a t val add : 'a t -> 'a -> 'a t end module VB1 : VB = struct type 'a t = 'a list let empty = [] let add l e = e :: l end The following interface and module use the generic container. It also stipulates what type will be used in the polymorphic type. module type U = sig type instance = int type t val zero : instance val one : instance val empty : t val do_something : t -> instance -> t end module Make_U (Vb : VB) : U = struct type instance = int type t = instance Vb.t let zero = 0 let one = 1 let empty = Vb.empty let do_something ts inst = Vb.add ts inst end module U1 = Make_U ( VB1 ) If I use and access all U1's elements via its interface I have no problems. However I need to use VB1 to access and manipulate the U1.t set in order to manipulate U1.instance types so... let _ = (* let vb0 = VB1.empty in let vb1 = VB1.add vb0 U1.zero in *) let vb1 = U1.empty in let vb2 = U1.do_something vb1 U1.one in let vb3 = VB1.add vb2 U1.zero in () I get errors: all uses of Vb1.t fail. For example using the first two lines and commenting the third I get the error: This expression has type U1.instance VB1.t but is here used with type U1.t = Make_U(VB1).t vb1: U1.instance VB1.t Or in the case above as is, I get: This expression has type U1.t = Make_U(VB1).t but is here used with type 'a VB1.t vb2: U1.t My question is: is their any way I may organize the modules or indicate shared types in order to use a (very extensive) VB interface (Or VB1 module)? Specifically how do I enforce the shared type: U1.instance VB1.t = U1.t = Make_U(VB1).t TIA, Hugo F.