From: "Conglun Yao" <yaoconglun@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] conjunctive type in polymorphic variants
Date: Thu, 9 Oct 2008 11:09:17 +0100 [thread overview]
Message-ID: <f7b50d2a0810090309v2f956298i6704d416e714d1b8@mail.gmail.com> (raw)
In-Reply-To: <95513600810090143y137a17bcib8a4a7a25c06d6ca@mail.gmail.com>
Nicolas and Olivier,
Thanks for your quick reply, it makes sense!
Conglun
On Thu, Oct 9, 2008 at 9:43 AM, Olivier Andrieu <oandrieu@nerim.net> wrote:
> 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
>
prev parent reply other threads:[~2008-10-09 10:09 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
2008-10-09 10:09 ` Conglun Yao [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=f7b50d2a0810090309v2f956298i6704d416e714d1b8@mail.gmail.com \
--to=yaoconglun@gmail.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