From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.6 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 4CF7DBC37 for ; Fri, 29 May 2009 17:38:17 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsECADmeH0pDww/NmGdsb2JhbACQSYEmhiUBAQEBAQgJDAcRqQyBE49XAQUDAYQIBQ X-IronPort-AV: E=Sophos;i="4.41,272,1241388000"; d="scan'208";a="40791438" Received: from web111513.mail.gq1.yahoo.com ([67.195.15.205]) by mail4-smtp-sop.national.inria.fr with SMTP; 29 May 2009 17:38:16 +0200 Received: (qmail 40000 invoked by uid 60001); 29 May 2009 15:38:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1243611494; bh=pFkzaQymf6IEFibip4IYKyB9eOCATcMcSOLMbA20Hrw=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding; b=ZRnDW2MgMKHoYKahBustOvFZJd7HXUUxyghOQQjcR14yibgf6fQtt/tD8yLtAJgkHVGKwDbD17ub4XUks0kf63XHmPgL9Oivq/OlwRDDEWgztUcTtfimcqLHxzPvtEtWTq3Po0HkecInq7D1YGQ7VkwhoPGFafNZ00nWbKd6D7U= DomainKey-Signature:a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding; b=HlXMxLOIymGVGYgxcdVOE5gRs0tg56S0KCKzfdtHKj/Xv/rNfZSXf0W79eJD1KLVta3A3xuSHWKbzycRYJlvePnKSJoocSG6yB1Rxq+pIwXazs9s4zbPyxmk7L3VpQQbGx+WrMmho/M/W/P1v184Z01nrra8fBxxwohjlZi89ac=; Message-ID: <827671.74618.qm@web111513.mail.gq1.yahoo.com> X-YMail-OSG: iai74xMVM1mKXfNyV5buAESxcpRzqgOhOKJdI9J3UbAc4l9fgipi04a3IOAl4ZIY1GE0hUYxlKBr1y3XPhLJSJaPns5zqzqds33.0WBWsM_Ui2XGayvmI3PsWfWvcOroXi9GpovAQEXJTMRw6XVKlO9hGncWof2ApR4nRrrsL1aBwUnTK5X_WSpNnvPc62T2N9INQTVNMuZTSbEnH8ePgmgoDHCgru5F3oGRYy_mHh0ln6GPdYOokAYpvZbxsjam.Cl_MdrP.tiP7X_SEfntbrGyIvlXaAidLoXS4ZoxxT1DMEItWn7d4O4_5yhF9m6e_nnlHg-- Received: from [213.205.71.63] by web111513.mail.gq1.yahoo.com via HTTP; Fri, 29 May 2009 08:38:14 PDT X-Mailer: YahooMailClassic/5.3.9 YahooMailWebService/0.7.289.10 Date: Fri, 29 May 2009 08:38:14 -0700 (PDT) From: Dario Teixeira Subject: RE: [Caml-list] Width subtyping To: David Allsopp Cc: 'OCaml List' MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; subtyping:01 variants:01 variants:01 cheers:01 polymorphic:01 caml-list:01 functions:01 functions:01 constructor:01 width:97 match:02 match:02 refine:03 raise:03 pattern:04 Hi,=0A=0A> This way you're always dealing with the same product type,=0A> b= ut the sum type tells you which fields are actually valid.=0A> Of course, i= t relies on there being an obvious sentinel=0A> value for unused fields (ot= herwise you just end up with 'a=0A> option everywhere) and I still don't th= ink it's that neat as=0A> you can still match against fields which aren't v= alid but at=0A> least the type system prevents you from being handed an=0A>= illegal value. The benefit is that you don't need special=0A> "get" functi= ons (just a match on type t to extract the t'=0A> value from each construct= or). I can't get my head around how=0A> private polymorphic variants work t= o see if they can refine=0A> this further...=0A=0AThis is indeed a reasonab= le solution for many classes of problems.=0AHowever, the need for a sentine= l value for unused fields makes it=0Asomewhat heavyweight for those record = variants where just one field=0Ais valid. Moreover, this solution requires= outside functions that=0Ashould only operate on T1 (for example) to "volun= tarily" check by=0Apattern matching that the t they are getting is indeed a= T1 (and=0Apresumably raise failure otherwise). The object-based solution = can=0Aat least automatically take care of this (though it has other problem= s).=0A=0ACheers,=0ADario=0A=0A=0A=0A