From: "Conglun Yao" <yaoconglun@gmail.com>
To: caml-list@inria.fr
Subject: conjunctive type in polymorphic variants
Date: Thu, 9 Oct 2008 05:15:16 +0100 [thread overview]
Message-ID: <f7b50d2a0810082115v6a604241l598c828611614c77@mail.gmail.com> (raw)
Hi all,
I have just met a strange problem (it might have already been
answered, but I can't find the it) while using camlp4 to generate a
polymorphic type like:
type t = [ `A of int * int | `B of string ]
error msg "The present constructor A has a conjunctive type" is thrown
by the compiler.
I followed the ocaml source code, found in ocaml-3.10.2/typing/typetexp.ml
Line 290, it does the following check in add_field function:
if List.length stl > 1 || c && stl <> [] then
raise(Error(styp.ptyp_loc, Present_has_conjunction l));
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
It looks wired, as we can directly define
type t = [ `A of int * int | `B of string ] in toploop or a *.ml file.
Or I have some mis-understanding in this part.
Thanks for any help.
Best regards,
Conglun
next reply other threads:[~2008-10-09 4:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-09 4:15 Conglun Yao [this message]
2008-10-09 7:22 ` [Caml-list] " Nicolas Pouillard
2008-10-09 8:43 ` Olivier Andrieu
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=f7b50d2a0810082115v6a604241l598c828611614c77@mail.gmail.com \
--to=yaoconglun@gmail.com \
--cc=caml-list@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