[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Stéphane_Lescuyer <lescuyer@l...> |
| Subject: | Re: [Caml-list] Variants & structural ordering |
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