From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] More intelligent match warnings
Date: Thu, 8 Feb 2007 18:06:49 +0000 [thread overview]
Message-ID: <200702081806.49536.jon@ffconsultancy.com> (raw)
In-Reply-To: <005501c74bab$369f5150$6a7ba8c0@treble>
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 = <fun>
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
next prev parent reply other threads:[~2007-02-08 18:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-08 18:01 David Allsopp
2007-02-08 18:06 ` Jon Harrop [this message]
2007-02-08 19:08 ` [Caml-list] " Luc Maranget
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=200702081806.49536.jon@ffconsultancy.com \
--to=jon@ffconsultancy.com \
--cc=caml-list@yquem.inria.fr \
/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).