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=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 36587BC69 for ; Thu, 8 Feb 2007 19:13:42 +0100 (CET) Received: from pih-relay05.plus.net (pih-relay05.plus.net [212.159.14.132]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l18IDfwm030770 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Thu, 8 Feb 2007 19:13:42 +0100 Received: from [80.229.56.224] (helo=[10.0.0.5]) by pih-relay05.plus.net with esmtp (Exim) id 1HFDm6-0007GJ-9A for caml-list@yquem.inria.fr; Thu, 08 Feb 2007 18:13:38 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] More intelligent match warnings Date: Thu, 8 Feb 2007 18:06:49 +0000 User-Agent: KMail/1.9.5 References: <005501c74bab$369f5150$6a7ba8c0@treble> In-Reply-To: <005501c74bab$369f5150$6a7ba8c0@treble> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200702081806.49536.jon@ffconsultancy.com> X-Miltered: at concorde with ID 45CB6855.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; decidable:01 avoided:01 variants:01 unions:01 val:01 ocaml:01 ocaml:01 frog:98 polymorphic:01 wrote:01 caml-list:01 int:01 int:01 match:02 match:02 On Thursday 08 February 2007 18:01, David Allsopp wrote: > Are these two cases decidable in the general case? It depends how general you make your proposal. In this case, the error can be avoided by writing better code, using a single pattern match. When does "in general" make that impossible? You can also do something similar using polymorphic variants to implement unions of sum types: # type a = [`A] type bc = [`B | `C];; let f : [ a | bc ] -> int = function | `A -> 0 | #bc as b -> match b with | `B -> 1 | `C -> 2;; val f : [< `A | `B | `C ] -> int = Here, the value matching #bc is known to be either `B or `C but not `A. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. OCaml for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists