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 0041B7EC6E for ; Wed, 29 Jan 2014 00:16:24 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of agarwal1975@gmail.com) identity=pra; client-ip=209.85.216.48; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="agarwal1975@gmail.com"; x-sender="agarwal1975@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of agarwal1975@gmail.com designates 209.85.216.48 as permitted sender) identity=mailfrom; client-ip=209.85.216.48; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="agarwal1975@gmail.com"; x-sender="agarwal1975@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-qa0-f48.google.com) identity=helo; client-ip=209.85.216.48; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="agarwal1975@gmail.com"; x-sender="postmaster@mail-qa0-f48.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApIDAIo56FLRVdgwlGdsb2JhbABAGoNEVrQsiFSBCAgWDgEBAQEHCwsJEiqCJQEBAQMBQAEbHQEDAQsGBQsNLiEBAREBBQEcBhOHcAEDCQgNNp1pjFyDCZJyChknDWSHOBEBBQyMXoIVB4Q4BIlJjHOBbIEyiyyDVBgpgxuBXB4 X-IPAS-Result: ApIDAIo56FLRVdgwlGdsb2JhbABAGoNEVrQsiFSBCAgWDgEBAQEHCwsJEiqCJQEBAQMBQAEbHQEDAQsGBQsNLiEBAREBBQEcBhOHcAEDCQgNNp1pjFyDCZJyChknDWSHOBEBBQyMXoIVB4Q4BIlJjHOBbIEyiyyDVBgpgxuBXB4 X-IronPort-AV: E=Sophos;i="4.95,739,1384297200"; d="scan'208";a="55653351" Received: from mail-qa0-f48.google.com ([209.85.216.48]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 29 Jan 2014 00:16:24 +0100 Received: by mail-qa0-f48.google.com with SMTP id f11so1445433qae.21 for ; Tue, 28 Jan 2014 15:16:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=p4k4xqFNmT0br5zoA1OQ4Vn5HI07cy3+pKqNEvbavqw=; b=VSPmKwZkQ7OcbjmoBuL2m8vIV4/73T/Em5dX7tV9sLavJFcnzjSonFGTeix5jDGo6q 2DCGEB3rh5Vropnw0VNkZCSOC+Z1W1Alk7rEebLsIBv1OVlLNr2P0BVCsSHvlZSDsIK9 osp9V3uowj9UakU0vOHD7ztrk8+OXhe6b62dXTTLpFlxCCacT1nWhPaRUIp3dJ+JxTQt ZXxHO+5HIkQzMJ9uC+oTXkU9nl5nt5fQPnAJsFjBYI+IxCy6Rvr+4dLb32HQMT9+d45F 5C7P23FxHDfSEE6iN5MnbqUv2LUAEY/i5Qkw9o6qaDAIh6thzZ199JMbY1MFc2uMGfVm cTzg== X-Received: by 10.224.76.70 with SMTP id b6mr6979496qak.19.1390950982936; Tue, 28 Jan 2014 15:16:22 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.67.131 with HTTP; Tue, 28 Jan 2014 15:16:02 -0800 (PST) In-Reply-To: References: From: Ashish Agarwal Date: Tue, 28 Jan 2014 18:16:02 -0500 Message-ID: To: Gabriel Scherer Cc: Caml List Content-Type: multipart/alternative; boundary=001a11c305423ced3004f1100347 Subject: Re: [Caml-list] ocaml 4.00.1 and 4.01.0 behave differently on module type constraint --001a11c305423ced3004f1100347 Content-Type: text/plain; charset=ISO-8859-1 IIUC compiling this in older versions requires making the constraint `with type t = private Foo.t`. However, garrigue says this is not semantically correct and has deprecated this. Okay. Thanks. On Tue, Jan 28, 2014 at 4:43 PM, Gabriel Scherer wrote: > The change of behavior was part of PR#6090: > http://caml.inria.fr/mantis/view.php?id=6090 > It was a case of the type-checker refusing more programs than necessary. > > My understanding of the compatibility story of the type-system is that > future versions will not rule out semantically valid programs accepted > by previous ones (note that buggy programs previously accepted could > be ruled out), but may accept strictly more semantically valid > programs. If you need to be sure that your code compile under older > versions, you should test them explicitely. > > On Tue, Jan 28, 2014 at 10:19 PM, Ashish Agarwal > wrote: > > Is the following an expected change from OCaml 4.00.1 to 4.01.0? > > > > Module Foo defines a private type and this module is included in Common. > The > > signature within Common is defined using `module type of` with a > constraint. > > The different behavior shown below occurs when the private type is a > record, > > but not if it is a base type like string or int. In that case, the code > > compiles with both 4.00.1 and 4.01.0. > > > > $ cat a.ml > > module Foo : sig > > type t = private {a:int} > > end = struct > > type t = {a:int} > > end > > > > module Common : sig > > module F : module type of Foo with type t = Foo.t > > end = struct > > module F = Foo > > end > > > > $ ocaml -version > > The OCaml toplevel, version 4.01.0 > > > > $ ocaml a.ml > > (* no errors *) > > > > Now, change version of OCaml being used. > > > > $ ocaml -version > > The OCaml toplevel, version 4.00.1 > > > > $ ocaml a.ml > > File "a.ml", line 9, characters 6-33: > > Error: Signature mismatch: > > Modules do not match: > > sig module F : sig type t = Foo.t = private { a : int; } end end > > is not included in > > sig module F : sig type t = Foo.t = { a : int; } end end > > In module F: > > Modules do not match: > > sig type t = Foo.t = private { a : int; } end > > is not included in > > sig type t = Foo.t = { a : int; } end > > In module F: > > Type declarations do not match: > > type t = Foo.t = private { a : int; } > > is not included in > > type t = Foo.t = { a : int; } > > File "a.ml", line 8, characters 37-51: Expected declaration > > File "a.ml", line 2, characters 7-26: Actual declaration > > A private type would be revealed. > > > --001a11c305423ced3004f1100347 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
IIUC compiling this in older versions requires making the = constraint `with type t =3D private Foo.t`. However, garrigue says this is = not semantically correct and has deprecated this. Okay. Thanks.



On Tue,= Jan 28, 2014 at 4:43 PM, Gabriel Scherer <gabriel.scherer@gmail.c= om> wrote:
The change of behavior was part of PR#6090:<= br> =A0 http://caml.inria.fr/mantis/view.php?id=3D6090
It was a case of the type-checker refusing more programs than necessary.

My understanding of the compatibility story of the type-system is that
future versions will not rule out semantically valid programs accepted
by previous ones (note that buggy programs previously accepted could
be ruled out), but may accept strictly more semantically valid
programs. If you need to be sure that your code compile under older
versions, you should test them explicitely.

On Tue, Jan 28, 2014 at 10:19 PM, Ashish Agarwal <agarwal1975@gmail.com> wrote:
> Is the following an expected change from OCaml 4.00.1 to 4.01.0?
>
> Module Foo defines a private type and this module is included in Commo= n. The
> signature within Common is defined using `module type of` with a const= raint.
> The different behavior shown below occurs when the private type is a r= ecord,
> but not if it is a base type like string or int. In that case, the cod= e
> compiles with both 4.00.1 and 4.01.0.
>
> $ cat a.ml
> module Foo : sig
> =A0 type t =3D private {a:int}
> end =3D struct
> =A0 type t =3D {a:int}
> end
>
> module Common : sig
> =A0 module F : module type of Foo with type t =3D Foo.t
> end =3D struct
> =A0 module F =3D Foo
> end
>
> $ ocaml -version
> The OCaml toplevel, version 4.01.0
>
> $ ocaml a.ml
> (* no errors *)
>
> Now, change version of OCaml being used.
>
> $ ocaml -version
> The OCaml toplevel, version 4.00.1
>
> $ ocaml a.ml
> File "a.ml", l= ine 9, characters 6-33:
> Error: Signature mismatch:
> =A0 =A0 =A0 =A0Modules do not match:
> =A0 =A0 =A0 =A0 =A0sig module F : sig type t =3D Foo.t =3D private { a= : int; } end end
> =A0 =A0 =A0 =A0is not included in
> =A0 =A0 =A0 =A0 =A0sig module F : sig type t =3D Foo.t =3D { a : int; = } end end
> =A0 =A0 =A0 =A0In module F:
> =A0 =A0 =A0 =A0Modules do not match:
> =A0 =A0 =A0 =A0 =A0sig type t =3D Foo.t =3D private { a : int; } end > =A0 =A0 =A0 =A0is not included in
> =A0 =A0 =A0 =A0 =A0sig type t =3D Foo.t =3D { a : int; } end
> =A0 =A0 =A0 =A0In module F:
> =A0 =A0 =A0 =A0Type declarations do not match:
> =A0 =A0 =A0 =A0 =A0type t =3D Foo.t =3D private { a : int; }
> =A0 =A0 =A0 =A0is not included in
> =A0 =A0 =A0 =A0 =A0type t =3D Foo.t =3D { a : int; }
> =A0 =A0 =A0 =A0File "a.= ml", line 8, characters 37-51: Expected declaration
> =A0 =A0 =A0 =A0File "a.= ml", line 2, characters 7-26: Actual declaration
> =A0 =A0 =A0 =A0A private type would be revealed.
>

--001a11c305423ced3004f1100347--