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 62A797EC6E for ; Tue, 28 Jan 2014 22:20:10 +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.179; 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.179 as permitted sender) identity=mailfrom; client-ip=209.85.216.179; 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-qc0-f179.google.com) identity=helo; client-ip=209.85.216.179; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="agarwal1975@gmail.com"; x-sender="postmaster@mail-qc0-f179.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArIDAIEe6FLRVdizlGdsb2JhbABag0RWtCGJXwgWDgEBAQEHCwsJEiqCbAEbHgMSCQddAREBBQEiiAMBAxGbHIMIjFyDCZMOChknDWSHOBEBBQyRKQ+BegSJSY5fkDIYKYR3Hg X-IPAS-Result: ArIDAIEe6FLRVdizlGdsb2JhbABag0RWtCGJXwgWDgEBAQEHCwsJEiqCbAEbHgMSCQddAREBBQEiiAMBAxGbHIMIjFyDCZMOChknDWSHOBEBBQyRKQ+BegSJSY5fkDIYKYR3Hg X-IronPort-AV: E=Sophos;i="4.95,738,1384297200"; d="scan'208";a="55621286" Received: from mail-qc0-f179.google.com ([209.85.216.179]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 28 Jan 2014 22:20:09 +0100 Received: by mail-qc0-f179.google.com with SMTP id e16so1502372qcx.10 for ; Tue, 28 Jan 2014 13:20:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=Adm1t40oWth8ID1ojTht/aJrFAxH0A13W7dXhelz3tA=; b=aDPu/LlOrEvLX5iZYcvsRs5ig3mH3hw3jwJonked2sBPIOqx3hcIw/z4GzhkzzvDbf y3jlpKIzqF9Fkueq7gYODYRPZgSDyuLDoee/Q/L522aWOv9faZDX2AwAihvZ7nmxk8tf 2gNilAFQuFO4h9KC/OwArtTCIeKrxpYFDPRzIN0T80lrs83oJyFEEJ5+9ATiM6w0AHMF Wo/buCBu0YA65dNqShYbdkfsnh921MluHHMIEkfLkqiz/6ZU7ghsJ5Q2TISV9yelYmXd OhaDbHLdezwEebESsmplaw+X8gsS9Tx5ZpjOBPeTUZzuSNmsiTPF4QNquWu4UEeC0ALg leDg== X-Received: by 10.224.76.70 with SMTP id b6mr6245710qak.19.1390944008830; Tue, 28 Jan 2014 13:20:08 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.67.131 with HTTP; Tue, 28 Jan 2014 13:19:48 -0800 (PST) From: Ashish Agarwal Date: Tue, 28 Jan 2014 16:19:48 -0500 Message-ID: To: Caml List Content-Type: multipart/alternative; boundary=001a11c305428c839d04f10e6375 Subject: [Caml-list] ocaml 4.00.1 and 4.01.0 behave differently on module type constraint --001a11c305428c839d04f10e6375 Content-Type: text/plain; charset=ISO-8859-1 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. --001a11c305428c839d04f10e6375 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
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 u= sing `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 lik= e string or int. In that case, the code compiles with both 4.00.1 and 4.01.= 0.

$ cat a.ml=A0
mod= ule Foo : sig
=A0 type t =3D private {a:int}
end =3D st= ruct
=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.
<= div>
$ ocaml -version
The OCaml toplevel, version 4= .00.1

$ ocaml a.ml
File= "a.ml", line 9, characters 6-33:
Error: Signature mismatch:
=A0 =A0 =A0 =A0Modules do not m= atch:
=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 en= d
=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 n= ot 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 =A0i= s not included in
=A0 =A0 =A0 =A0 =A0type t =3D Foo.t =3D { a : i= nt; }
=A0 =A0 =A0 =A0File "a.ml&= quot;, 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.

--001a11c305428c839d04f10e6375--