caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Dario Teixeira <darioteixeira@yahoo.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Union of type variables
Date: Mon, 2 Feb 2009 09:07:41 -0800 (PST)	[thread overview]
Message-ID: <778474.28487.qm@web111507.mail.gq1.yahoo.com> (raw)
In-Reply-To: <725185.7305.qm@web111505.mail.gq1.yahoo.com>

Hi,

> Obviously I would like to get rid of this kludge.  The signature and
> implementation for "union" should be something like the (syntactically
> incorrect) code below.  But is it at all possible to declare an union
> of type variables?  (which presupposes they are polymorphic variants)
> 
> val union: 'x t -> 'y t -> [> 'x |
> 'y ] t
> let union x y = Union (x, y)

In the meantime I realised what the problem was.  I neglected to take
into account the open nature of polymorphic variants, meaning that as
long as the phantom type variable is open, then the following code is
enough to do what I want:

val union: 'a t -> 'a t -> 'a t
let union x y = Union (x, y)


Cheers,
Dario Teixeira






      reply	other threads:[~2009-02-02 17:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-31 16:55 Dario Teixeira
2009-02-02 17:07 ` Dario Teixeira [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=778474.28487.qm@web111507.mail.gq1.yahoo.com \
    --to=darioteixeira@yahoo.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;
as well as URLs for NNTP newsgroup(s).