Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Manuel Fahndrich <maf@microsoft.com>
To: "'caml-list@inria.fr'" <caml-list@inria.fr>
Subject: # types and polymorphic variants
Date: Thu, 24 Feb 2000 12:51:11 -0800	[thread overview]
Message-ID: <783D93998201D311B0CF00805FEAA07B7E9115@RED-MSG-42> (raw)


What is the meaning of #foo, when foo is a polymorphic variant set?

type foo = [`A | `B | `C]

I assumed that it was the following:

	#foo = [<`A | `B | `C ]

that is a set containing at most `A | `B | `C. In other words a subtype of
foo.

But consider the following example.

type foo = [`A | `B | `C]

let foo1 (x : #foo as 'a) = x

let y1 = foo1 (`A : [`A])


let foo2 (x : [< `A | `B | `C] as 'a) = x

let y2 = foo2 (`A : [`A])


The complier tells me:

ocamlc -c -i ex1.ml

type foo = [`A|`B|`C]
val foo1 : (#foo as 'a) -> 'a
val y1 : foo
val foo2 : ([<`A|`B|`C] as 'a) -> 'a
val y2 : [`A]

The first function returns me only a foo, the second function returns me
[`A] as expected. Thus my question, what exactly does #foo stand for. I do
understand row variables, but the issue with the lower and upper bounds > <
in variant types seems new. Is there a paper describing these?

I seem to write types of the form [< `A | `B | `C] a lot. Shouldn't there be
an abbreviation for those as well? Maybe #<foo?


Thanks in advance for such a wonderfully expressive type system!

	Manuel



             reply	other threads:[~2000-02-25 12:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-24 20:51 Manuel Fahndrich [this message]
2000-02-26 14:10 ` Jacques Garrigue

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=783D93998201D311B0CF00805FEAA07B7E9115@RED-MSG-42 \
    --to=maf@microsoft.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