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 F01197EE4B for ; Thu, 10 Oct 2013 19:32:50 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of martindemello@gmail.com) identity=pra; client-ip=209.85.220.182; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="martindemello@gmail.com"; x-sender="martindemello@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of martindemello@gmail.com designates 209.85.220.182 as permitted sender) identity=mailfrom; client-ip=209.85.220.182; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="martindemello@gmail.com"; x-sender="martindemello@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-vc0-f182.google.com) identity=helo; client-ip=209.85.220.182; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="martindemello@gmail.com"; x-sender="postmaster@mail-vc0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnoCAHPjVlLRVdy2m2dsb2JhbABZgz9SrkiSKTmBGwgWDgEBAQEBBgsLCRQogiUBAQUnGQEbEgsBAwwGBQsDCg0hIgERAQUBChIGEwgKCIdZAQMPDJtfjFWDCoQVChknAwpkiQEBBQyPOweEIwOJPI5JgS+OaBgphG4c X-IPAS-Result: AnoCAHPjVlLRVdy2m2dsb2JhbABZgz9SrkiSKTmBGwgWDgEBAQEBBgsLCRQogiUBAQUnGQEbEgsBAwwGBQsDCg0hIgERAQUBChIGEwgKCIdZAQMPDJtfjFWDCoQVChknAwpkiQEBBQyPOweEIwOJPI5JgS+OaBgphG4c X-IronPort-AV: E=Sophos;i="4.90,1073,1371074400"; d="scan'208";a="36458144" Received: from mail-vc0-f182.google.com ([209.85.220.182]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 10 Oct 2013 19:32:49 +0200 Received: by mail-vc0-f182.google.com with SMTP id im17so1926313vcb.13 for ; Thu, 10 Oct 2013 10:32:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=IQuxpRhWf3nTShQeJ3gywzzFt+kbUBAY16UqBAg2Pdc=; b=VRqaL692rJvHyJf7BazA1F2kKyU3sAWtbwH5TwSrIQEHk2qrn2nSnz+Nn9unwrZBP+ 6ckv+kHSn+SjveloagqOgzSGK0GAZFM5zXEpa8XC8RtuDiwfD2aaM55b6n6WQ+PthgV/ CrIFVLo+RGygcimF7qRffSjUSabjyG+E29asXLGRUjyVOtA36duG5dQGl0IXcPfTEn2x EF0yqBOkJM957UhnFNXlgmDEm55FYMX2PivyXWWWZIFMS4TGzDcU+isLwKRoQ1df/tUH 7ZREqM1rwGDpq/4dRTak4ouSt+BDyRjSJ0USxOnJawpHSIaWsygwPV9C7qePGBHd6woB 73gQ== MIME-Version: 1.0 X-Received: by 10.220.79.204 with SMTP id q12mr15744754vck.20.1381426369199; Thu, 10 Oct 2013 10:32:49 -0700 (PDT) Received: by 10.220.162.197 with HTTP; Thu, 10 Oct 2013 10:32:49 -0700 (PDT) In-Reply-To: References: Date: Thu, 10 Oct 2013 10:32:49 -0700 Message-ID: From: Martin DeMello To: David House Cc: David Allsopp , OCaml List Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] exhaustiveness checking within a submatch Thanks. So I guess the answer boils down to "possible but not worth it", which makes sense. martin On Thu, Oct 10, 2013 at 1:09 AM, David House wrote: > This does actually work with polymorphic variants, as long as you > rename the thing in the submatch: > > match f with `A -> 1 | `B -> 2 | (`C | `D as foo) -> match foo with `C > -> 3 | `D -> 4 > > On 10 October 2013 09:07, David Allsopp wrote: >> Martin DeMello wrote: >>> Just curious as to why the compiler can't handle this, since in theory >>> everything is statically deducible: >>> >>> # type test = A | B | C | D;; >>> type test = A | B | C | D >>> >>> # let f = A;; >>> val f : test = A >>> >>> # match f with A -> 1 | B -> 2 | C | D -> ( match f with C -> 3 | D -> >>> 4);; >>> Characters 40-71: >>> Warning >>> 8: this pattern-matching is not exhaustive. >>> Here is an >>> example of a value that is not matched: >>> (A|B) >>> Characters 40-71: >>> Warning 8: this pattern-matching is not exhaustive. >>> Here is an example of a value that is not matched: >>> (A|B) >>> - : int = 1 >> >> http://caml.inria.fr/pub/ml-archives/caml-list/2007/02/d35648b13d76f1717edbf41101dc913f.en.html >> >> >> David >> >> -- >> Caml-list mailing list. Subscription management and archives: >> https://sympa.inria.fr/sympa/arc/caml-list >> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >> Bug reports: http://caml.inria.fr/bin/caml-bugs > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs