caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Stéphane Lescuyer" <lescuyer@lri.fr>
To: "Damien Guichard" <alphablock@orange.fr>
Cc: "Liste de diffusion OCaml" <caml-list@inria.fr>
Subject: Re: [Caml-list] Variants & structural ordering
Date: Tue, 5 Feb 2008 18:25:32 +0100	[thread overview]
Message-ID: <e9e94ac90802050925t45506404id7ced8f27f15e867@mail.gmail.com> (raw)
In-Reply-To: <20080205165714.DE06A7000C0E@mwinf2354.orange.fr>

2008/2/5 Damien Guichard <alphablock@orange.fr>:
> And the answer is: OCaml variants are certainly treated as an initial
> algebra, but not exactly as an enumeration, thus their relative order is not
> meaningfull to the compare function.

Actually it *is* meaningful, but as Berke pointed out, constant
constructors and variant expecting some arguments are treated (and
ordered) separately.
This is explained in detail in Sec. 18.3.4 of the manual
[http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html], and this
is why adding dummy arguments of type unit does the trick.
My point is that it's not as bad as it looks, since you have a way to
"control" (or at least predict) what the order between your different
values will be. This is a difference with polymorphic variants for
instance.
--
Stéphane L.
http://www.lri.fr/~lescuyer


  reply	other threads:[~2008-02-05 17:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-05 16:59 Damien Guichard
2008-02-05 17:25 ` Stéphane Lescuyer [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-02-05  8:21 Damien Guichard
2008-02-05  9:47 ` [Caml-list] " Berke Durak
2008-02-05  9:48 ` Oliver Bandel
2008-02-05 15:04 ` Jon Harrop
2008-02-06  8:21 ` Michaël Grünewald
2008-02-07 15:50 ` Damien Doligez

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=e9e94ac90802050925t45506404id7ced8f27f15e867@mail.gmail.com \
    --to=lescuyer@lri.fr \
    --cc=alphablock@orange.fr \
    --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;
as well as URLs for NNTP newsgroup(s).