From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id pAONrW0i010414 for ; Fri, 25 Nov 2011 00:53:32 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Am4BAJLYzk5KfVIqimdsb2JhbABDmlyQDwgiAQEBCgkNBxIGIYFyAQEBAwESAiwBGxILAQMBCwYFCxohIgERAQUBChIGExIQh2MIl1oKi2OCZoRUPYhxAgUKg1WHAwSUSopWgwI9g3c X-IronPort-AV: E=Sophos;i="4.69,568,1315173600"; d="scan'208";a="120784621" Received: from mail-ww0-f42.google.com ([74.125.82.42]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 25 Nov 2011 00:53:27 +0100 Received: by wwo28 with SMTP id 28so1549990wwo.3 for ; Thu, 24 Nov 2011 15:53:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=d+O2TXUsspZaFqKaDXXe8cl4NEiX6KJSVJ1gP7h068E=; b=bfZBsHN2pqTWVw8p8WD8rILA5eZLiEjDlDCA8vOCTczCi4V9I7knOFIDTNgPFMh0ug MXFyDaRfmGaCMxDp3Ro9LFOb2WwxfPzSdYUXuoLEYgX2OIRIOCHZ/GQBNj0dubPYHEOy LJnE+YlxOvf0OQqFOdiT5EWaj4FKVzCcrYJ8E= Received: by 10.227.59.204 with SMTP id m12mr2762461wbh.10.1322178806079; Thu, 24 Nov 2011 15:53:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.203.134 with HTTP; Thu, 24 Nov 2011 15:53:05 -0800 (PST) In-Reply-To: <4ECE9C09.3030705@yahoo.fr> References: <4ECE725E.7050102@yahoo.fr> <4ECE9C09.3030705@yahoo.fr> From: Gabriel Scherer Date: Fri, 25 Nov 2011 00:53:05 +0100 Message-ID: To: =?ISO-8859-1?Q?Michael_Gr=FCnewald?= Cc: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id pAONrW0i010414 Subject: Re: [Caml-list] Deleting a type alias while including a module Here is how I understand the situation: > module type XARRAY = > sig > type 'a xarray > type 'a t = 'a xarray > end > (XArray : XARRAY with type 'a t := 'a XArray.xarray ) > Type declarations do not match: > type 'a t = 'a XArray.xarray > is not included in > type 'a t = 'a xarray When you seal a module with a signature that has an abstract type (the type ('a xarray) in the XARRAY signature), you get a "fresh" abstract type is a result. The typer is here giving the following complain: - you told me in the XARRAY signature that ('a t) would always be equal to ('a xarray) - in this example you also ask for ('a t) to be equal with 'a XArray.xarray, the type of the previously defined module - but by definition the ('a xarray) type of the current sealing is a fresh abstract type, thus different of all previous types If you want to equate ('a t = something) while still respecting the (type 'a t = 'a xarray) signature contract, you have to first make ('a xarray) a defined type rather than abstract type: # module Test = (XArray : XARRAY with type 'a xarray = 'a XArray.xarray);; module Test : sig type 'a xarray = 'a XArray.xarray type 'a t = 'a xarray end Then you can substitute 'a t without breaking the weakened interface contract: # module Test = (XArray : XARRAY with type 'a xarray = 'a XArray.xarray and type 'a t := 'a XArray.xarray);; module Test : sig type 'a xarray = 'a XArray.xarray end If you wish to get an abstract type again, you can seal it after the fact, but this requires to know the whole result type signature (here it's only (sig type 'a xarray end)): # module Test : sig type 'a xarray end = (XArray : XARRAY with type 'a xarray = 'a XArray.xarray and type 'a t := 'a XArray.xarray);; module Test : sig type 'a xarray en 2011/11/24 Michael Grünewald : > As a complement to my previous message, here is a minimal (well, short!) > example displaying the behavior I cannot go around: > > ----8<--- example starts here ---- > module type XARRAY = > sig >  type 'a xarray >  type 'a t = 'a xarray > end > > module XArray : XARRAY = > struct >  type 'a xarray = 'a >  type 'a t = 'a xarray > end > > module UseXArray = > struct >  include (XArray : XARRAY with type 'a t := 'a XArray.xarray ) > end > ----8<---- example ends here ---- > Trying to compile this file yields the following error: > > File "include_substitute.ml", line 15, characters 20-61: > Error: In this `with' constraint, the new definition of t >       does not match its original definition in the constrained signature: >       Type declarations do not match: >         type 'a t = 'a XArray.xarray >       is not included in >         type 'a t = 'a xarray > > (OCaml 3.12.1 on FreeBSD/amd64) > > -- > Caml-list mailing list.  Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > >