caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David House <dhouse@janestreet.com>
To: David Allsopp <dra-news@metastack.com>
Cc: OCaml List <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] exhaustiveness checking within a submatch
Date: Thu, 10 Oct 2013 09:09:50 +0100	[thread overview]
Message-ID: <CAK=fH+ix_qm9cLniRmYvOH1KsZa0rLhkgcYSEJLxM+SHwgN9Tg@mail.gmail.com> (raw)
In-Reply-To: <E51C5B015DBD1348A1D85763337FB6D9CCC66B39@Remus.metastack.local>

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 <dra-news@metastack.com> 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

  reply	other threads:[~2013-10-10  8:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-10  8:00 Martin DeMello
2013-10-10  8:07 ` David Allsopp
2013-10-10  8:09   ` David House [this message]
2013-10-10 17:32     ` Martin DeMello

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK=fH+ix_qm9cLniRmYvOH1KsZa0rLhkgcYSEJLxM+SHwgN9Tg@mail.gmail.com' \
    --to=dhouse@janestreet.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=dra-news@metastack.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).