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

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 <dhouse@janestreet.com> 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 <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
>
> --
> 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 17:32 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
2013-10-10 17:32     ` Martin DeMello [this message]

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=CAFrFfuGi2G4XUEZdEJY0mxqyGma7p6sVZVH2T201he2SmPHdaA@mail.gmail.com \
    --to=martindemello@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=dhouse@janestreet.com \
    --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).