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 p2SBU3Jd027742 for ; Mon, 28 Mar 2011 13:30:03 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMCACZwkE1RZ90wkWdsb2JhbAClSxQBAQEBCQsLBxQDIsJ8hWkEjHc X-IronPort-AV: E=Sophos;i="4.63,255,1299452400"; d="scan'208";a="79290457" Received: from mtaout02-winn.ispmail.ntl.com ([81.103.221.48]) by mail3-smtp-sop.national.inria.fr with ESMTP; 28 Mar 2011 13:29:58 +0200 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20110328112957.MMUB6199.mtaout02-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com>; Mon, 28 Mar 2011 12:29:57 +0100 Received: from romulus.metastack.com ([81.102.132.77]) by aamtaout02-winn.ispmail.ntl.com (InterMail vG.3.00.04.00 201-2196-133-20080908) with ESMTP id <20110328112956.IZEL25842.aamtaout02-winn.ispmail.ntl.com@romulus.metastack.com>; Mon, 28 Mar 2011 12:29:56 +0100 Received: from remus.metastack.local ([172.16.0.1]) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id p2SBTreB024659 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Mon, 28 Mar 2011 12:29:53 +0100 Received: from Remus.metastack.local ([fe80::547c:3c42:e1da:eda2]) by Remus.metastack.local ([fe80::547c:3c42:e1da:eda2%11]) with mapi; Mon, 28 Mar 2011 12:29:53 +0100 From: David Allsopp To: Guillaume Yziquel , Alain Frisch CC: caml-list Thread-Topic: [Caml-list] Re: module typing issue Thread-Index: AQHL6sjgGT8J0i0YbEKMp09xW6WxSJQ+GUyAgAAY1ICAAA+egIAABMCAgAAiCICAA+uzAIAALJSAgAAfAWA= Date: Mon, 28 Mar 2011 11:29:51 +0000 Message-ID: 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> In-Reply-To: <20110328103325.GH20598@localhost> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 Organization: MetaStack Solutions Ltd. X-Scanned-By: MIMEDefang 2.65 on 81.102.132.77 X-Cloudmark-Analysis: v=1.1 cv=R50lirqlHffDPPkwUlkuVa99MrvKdVWo//yz83qex8g= c=1 sm=0 a=GIoHEcz2c30A:10 a=8nJEP1OIZ-IA:10 a=xqWC_Br6kY4A:10 a=ZOzjf2MOAAAA:8 a=_oGlhdV_g9eJ4P-DzLoA:9 a=JEMC3SXMuEqDv97oM9mzWvToD68A:4 a=wPNLvfGTeEIA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p2SBU3Jd027742 Subject: RE: [Caml-list] Re: module typing issue Guillaume Yziquel wrote: > Le Monday 28 Mar 2011 à 09:53:52 (+0200), Alain Frisch a écrit : > > On 03/25/2011 08:01 PM, Guillaume Yziquel wrote: > > >type error = private int > > > > > >external get_error : unit -> error = "zzz" > > > > > >You get some error level that you can pattern match as an int, and > > >this also enforces that all values of type error come from a call to > > >get_error. > > > > You need to coerce explicitly from type error to type int (... :> > > int), so this is not really different from defining error as an > > abstract type and exposing a function error->int. > > > > -- Alain > > Yes, doesn't work for private ints. However, it works for stuff like that, > though it's not exactly the same thing as a 'private int': > > # type t = private A | B;; > type t = private A | B > # let x : t = Obj.magic 0;; > val x : t = A > # match x with A -> true | _ -> false;; > - : bool = true > # A;; > Error: Cannot create values of the private type t > > I thought it also worked on for ints, and in a sense, I'm surprised that > you cannot pattern match private ints as ints without a coercion. I asked a similar question when private ints were introduced in OCaml 3.11 - full explanation from Jacques as to why in: https://sympa-roc.inria.fr/wws/arc/caml-list/2008-10/msg00375.html David