From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: Dario Teixeira <darioteixeira@yahoo.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Difference between [ `A ] and [< `A ]
Date: Wed, 11 May 2011 08:44:06 +0900 [thread overview]
Message-ID: <35C81D78-50FE-47D2-93E2-F48FF4AEED3F@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <719085.83949.qm@web111512.mail.gq1.yahoo.com>
On 2011/05/11, at 1:46, Dario Teixeira wrote:
> Hi,
>
> I've seen OCaml code "in the wild" where both of the following signatures
> are present: (the type parameter for 't' is a phantom type)
>
> val foo: [< `A ] t -> unit
> val bar: [ `A ] t -> unit
>
> But is there any practical difference between [ `A ] and [< `A ] given
> that there is only one element in the set?
In this particular case the two types are almost equivalent.
The only counterexample I could find is unifying with the following
private row type:
type leA = private [< `A]
leA is unifiable with [< `A] but not with [`A].
The difference becomes more significant when there is an argument.
For instance, [< `A of int] and [< `A of bool] are unifiable, giving [< `A of int & bool],
but [`A of int] cannot be unified with [`A of bool].
Note that some old versions of OCaml did some "singleton promotion", i.e.
[< `A of int] was automatically converted to [`A of int].
This was removed as an unnecessary complication, and also because you
might actually want to distinguish the two for private row types.
Jacques Garrigue
next prev parent reply other threads:[~2011-05-10 23:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-10 16:46 Dario Teixeira
2011-05-10 23:44 ` Jacques Garrigue [this message]
2011-05-11 15:47 ` Christophe Raffalli
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=35C81D78-50FE-47D2-93E2-F48FF4AEED3F@math.nagoya-u.ac.jp \
--to=garrigue@math.nagoya-u.ac.jp \
--cc=caml-list@inria.fr \
--cc=darioteixeira@yahoo.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