caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: skaller@ozemail.com.au
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] tpyping question
Date: Mon, 11 Aug 2003 11:46:15 +0900	[thread overview]
Message-ID: <20030811114615Y.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <1060564412.7474.11.camel@localhost.localdomain>

From: skaller <skaller@ozemail.com.au>

> type x = [`A | `B of int | `V of float];;
> let g (a:x) = a;;
> let f a = match a with
> | `A -> g a
> (* | `B _ *) | _ -> g a;;
> 
> Compiles fine, but gives an error if the comments are
> removed.

Indeed, there seems to be a bug here, since the non-commented version
should be equivalent to

# let f a = match a with
  | `A ->  g a
  | `B _ -> g a
  | _ -> g a;;
val f : x -> x = <fun>

I will investigate this.
On the other hand, this code is meaningless, as _ is more general
than `B _, and the order of or-patterns is not significant.

If the code you really intended was

  let f a = match a with
    | `A ->  g a
    | `B _ -> g a

then the answer is in the manual:

  let f = function `A | `B _ as a -> g a

Jacques Garrigue

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2003-08-11  2:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-11  1:13 skaller
2003-08-11  2:46 ` Jacques Garrigue [this message]
2003-08-11  4:30   ` skaller
2003-08-12  3:24   ` Jacques Garrigue
2003-08-11  2:51 ` Oleg Trott
2003-08-11  4:39   ` skaller
2003-08-11  5:18     ` Karl Zilles
2003-08-11 18:13       ` Karl Zilles
2003-08-11 18:16       ` skaller
2003-08-11 19:02         ` Remi Vanicat
2003-08-12  4:25           ` skaller
2003-08-11 19:02         ` Tiphaine Turpin

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=20030811114615Y.garrigue@kurims.kyoto-u.ac.jp \
    --to=garrigue@kurims.kyoto-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=skaller@ozemail.com.au \
    /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).