From: "Olivier Andrieu" <oandrieu@nerim.net>
To: "Conglun Yao" <yaoconglun@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] conjunctive type in polymorphic variants
Date: Thu, 9 Oct 2008 10:43:37 +0200 [thread overview]
Message-ID: <95513600810090143y137a17bcib8a4a7a25c06d6ca@mail.gmail.com> (raw)
In-Reply-To: <f7b50d2a0810082115v6a604241l598c828611614c77@mail.gmail.com>
Hi,
On Thu, Oct 9, 2008 at 06:15, Conglun Yao <yaoconglun@gmail.com> wrote:
> Sorry, I can't fully understand the source code, but it seems we can
> only define a polymorphic variant with only one additional type
> declaration, like
> `A of int or `A of (int * int)
> rather than `A of int * int
That's correct.
> It looks wired, as we can directly define
> type t = [ `A of int * int | `B of string ] in toploop or a *.ml file.
yes, that's because ocaml handle the "of int * int" a bit differently
in regular and
polymorphic variant declarations:
- in the regular variant the * is a separator between constructor
arguments (thus two arguments)
- polymorphic variants only have one argument, so int * int is
treated as a whole type expression and * is the "tupling" operator
So yes, this looks wired in the ocaml parser.
--
Olivier
next prev parent reply other threads:[~2008-10-09 8:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-09 4:15 Conglun Yao
2008-10-09 7:22 ` [Caml-list] " Nicolas Pouillard
2008-10-09 8:43 ` Olivier Andrieu [this message]
2008-10-09 10:09 ` Conglun Yao
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=95513600810090143y137a17bcib8a4a7a25c06d6ca@mail.gmail.com \
--to=oandrieu@nerim.net \
--cc=caml-list@yquem.inria.fr \
--cc=yaoconglun@gmail.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