From: Pietro Abate <Pietro.Abate@anu.edu.au>
To: caml-list@yquem.inria.fr, OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Variable pattern matching tuple
Date: Tue, 19 Sep 2006 11:40:33 +1000 [thread overview]
Message-ID: <20060919014033.GA24064@pulp.rsise.anu.edu.au> (raw)
In-Reply-To: <6dbd4d000609181826p6beca937y515903dc76628fc3@mail.gmail.com>
On Mon, Sep 18, 2006 at 09:26:15PM -0400, Denis Bueno wrote:
> What is the reason that expression A won't compile? Can't one variable
> stand for a tuple in a pattern-matching clause?
somebody was discussing a similar issue on the beginners
mailing list this week:
type 'a withint = Withint of ('a * int);;
type 'a withint = Withint of ('a * int)
let foo = Withint ("hi there", 4);;
val foo : string withint = Withint ("hi there", 4)
match foo with Withint d -> d;; ;;
- : string * int = ("hi there", 4)
if you want to pattern match the tuple you need to add parenthesis
in the type declaration.
have a look here for a detailed explanation:
http://www.archivesat.com/Ocaml_Beginners/thread1620469.htm
:)
p
--
++ Blog: http://blog.rsise.anu.edu.au/?q=pietro
++
++ "All great truths begin as blasphemies." -George Bernard Shaw
++ Please avoid sending me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
prev parent reply other threads:[~2006-09-19 1:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-19 1:26 Denis Bueno
2006-09-19 1:40 ` Pietro Abate [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=20060919014033.GA24064@pulp.rsise.anu.edu.au \
--to=pietro.abate@anu.edu.au \
--cc=caml-list@inria.fr \
--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