caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Prevost <j.prevost@cs.cmu.edu>
To: tim@fungible.com (Tim Freeman)
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Polymorphic variants as type parameters
Date: 30 Aug 2002 12:27:16 -0400 (68.560 UMT)	[thread overview]
Message-ID: <86fzww2ty3.fsf@laurelin.dementia.org> (raw)
In-Reply-To: <20020830155016.90B527F63@lobus.fungible.com>

>>>>> "tf" == Tim Freeman <tim@fungible.com> writes:

    tf> Here's some code that I'd like to be able to compile:

           type eventtype = [`VECTOR | `SCALAR | `UNIT]
           type +'a eventid
           constraint 'a = [> eventtype ]
           type scalar_eventid = [`SCALAR] eventid

    tf> Unfortunately it gives me an error:


The problem is that when you say [> `X | `Y | `Z] you describe a type
that contains at *least* `X, `Y, and `Z, and possibly others.  This
type is typical for an argument type to a function.  Think of this as
"greater or equal to the type [`X|`Y|`Z]".

When you want a type that may contain possibly `X or `Y or `Z but
nothing besides those, you should write [< `X | `Y | `Z].  This is
like "less than or equal to the type [`X|`Y|`Z]".

Using this I get:

# type eventtype = [`VECTOR | `SCALAR | `UNIT]
  type +'a eventid constraint 'a = [< eventtype ]
  type scalar_eventid = [`SCALAR] eventid;;
type eventtype = [ `VECTOR | `SCALAR | `UNIT]
type +'a eventid constraint 'a = [< eventtype]
type scalar_eventid = [ `SCALAR] eventid

John.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2002-08-30 16:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-30 15:34 Tim Freeman
2002-08-30 16:27 ` John Prevost [this message]
2002-08-30 17:08   ` Tim Freeman

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=86fzww2ty3.fsf@laurelin.dementia.org \
    --to=j.prevost@cs.cmu.edu \
    --cc=caml-list@inria.fr \
    --cc=tim@fungible.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;
as well as URLs for NNTP newsgroup(s).