From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: steph@glondu.net
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Union of polymorphic variants...
Date: Tue, 04 Dec 2007 22:57:12 +0900 (JST) [thread overview]
Message-ID: <20071204.225712.186423247.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <47554A47.0@glondu.net>
From: Stephane Glondu <steph@glondu.net>
> Why isn't possible to do the following?
>
> type b = [`A of [`B of bool]]
> type c = [`A of [`C of char]]
> type a = [b|c]
>
> I expect the last declaration to be equivalent to:
>
> type a = [`A of [`B of bool | `C of char]]
Because union of polymorphic variant is flat.
So the above requires the parameter of `A to be of type both
[`B of bool] and [`C of char].
The reason is that dispatch only looks at the head constructor:
let f = function
| #b as x -> fb x
| #c as x -> fc x
is actually
let f = function
| `A _ as x -> fb x
| `A _ as x -> fc x
which only types if both parameters have the same type.
Polymorphic variants are _not_ XML types.
Use ocamlduce for that :-)
Jacques
next prev parent reply other threads:[~2007-12-04 14:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-04 12:38 Stephane Glondu
2007-12-04 13:57 ` Jacques Garrigue [this message]
2007-12-04 14:33 ` [Caml-list] " Stephane Glondu
2007-12-05 2:17 ` Jacques GARRIGUE
2007-12-05 15:59 ` Stephane Glondu
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=20071204.225712.186423247.garrigue@math.nagoya-u.ac.jp \
--to=garrigue@math.nagoya-u.ac.jp \
--cc=caml-list@yquem.inria.fr \
--cc=steph@glondu.net \
/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