From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p2SCNvlk031352 for ; Mon, 28 Mar 2011 14:23:57 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmECAAd9kE3B/BfVkWdsb2JhbAClUQEBAQEJCwsHFAMiwnOFaQSMd4NU X-IronPort-AV: E=Sophos;i="4.63,255,1299452400"; d="scan'208";a="79294642" Received: from msa04.smtpout.orange.fr (HELO msa.smtpout.orange.fr) ([193.252.23.213]) by mail3-smtp-sop.national.inria.fr with ESMTP; 28 Mar 2011 14:23:51 +0200 Received: from [192.168.1.63] ([83.204.241.208]) by mwinf5d16 with ME id QcPp1g00V4WVC3X03cPq8e; Mon, 28 Mar 2011 14:23:50 +0200 Message-ID: <4D907DD6.2030507@frisch.fr> Date: Mon, 28 Mar 2011 14:23:50 +0200 From: Alain Frisch User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 To: Guillaume Yziquel CC: David Allsopp , caml-list References: <89643D7F-B0F9-4452-BBAF-0445D9D3CA4E@gmail.com> <639CCD2C-402F-4754-B942-B460FD908A95@gmail.com> <63968844-AD95-4359-80F0-E9E071CF6518@mpi-sws.org> <20110325164240.GT10028@localhost> <46B666E2-4575-4E79-ACF1-FE0789C0C76B@mpi-sws.org> <20110325190129.GU10028@localhost> <4D903E90.4080907@frisch.fr> <20110328103325.GH20598@localhost> <20110328115831.GW20598@localhost> In-Reply-To: <20110328115831.GW20598@localhost> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Re: module typing issue On 03/28/2011 01:58 PM, Guillaume Yziquel wrote: > Yes an no. From a type inference perspective, that's right. However, you > can already do such pattern matching on private row types for variant > types. > > module X : sig > type t = private [< `A ] > val x : t > end = struct > type t = [ `A ] > let x = `A > end > > match X.x with `A -> () > > and the X.x is correctly unified with `A. So the type inference issue is > solved in this case. Private row types are not the same as private type abbreviations. The syntax might be a source of confusion here, but the keyword "private" really means three different things: - Private type declarations: constructors/labels are available for deconstructing values (pattern matching, dot notation), not for building values. - Private type abbreviations (where the abbreviated type is not an object type or a polymorphic variant type): the behavior is very much the same as an abstract type, except that the abbreviation is a subtype of the abbreviated type (and the compiler can use the concrete type to choose a runtime representation of -- e.g. for records of floats -- and to trigger optimizations). - Private row types: you can think of the 'private' annotation as a way to name (as an abstract type) the implicit row type variable of the abbreviated type. There is no hiding as for type abbreviation and no access control as for private type declarations. The syntax for private type abbreviation and private row types is the same; they are distinguished only in the type-checker. As far as I know, there is no way to create a private type abbreviation on a object or variant type. Alain