From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id EF95CBC6C for ; Tue, 5 Feb 2008 18:25:35 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAANkqqEfAXQImh2dsb2JhbACQLAEBAQgKKZZohgA X-IronPort-AV: E=Sophos;i="4.25,308,1199660400"; d="scan'208";a="8795554" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 05 Feb 2008 18:25:35 +0100 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m15HPZOc031239 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Tue, 5 Feb 2008 18:25:35 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAEgqqEdA6aa2i2dsb2JhbACQLAEBAQgEBAkKEQWWbIYA X-IronPort-AV: E=Sophos;i="4.25,308,1199660400"; d="scan'208";a="22234880" Received: from py-out-1112.google.com ([64.233.166.182]) by mail4-smtp-sop.national.inria.fr with ESMTP; 05 Feb 2008 18:25:34 +0100 Received: by py-out-1112.google.com with SMTP id u52so3839416pyb.10 for ; Tue, 05 Feb 2008 09:25:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=B2C8kHhRcGu/vXskw8RTBVkNgkpAe/MAh4qjAM3Ho9E=; b=Ob8+7ODBErDY/Kc2cqGhQcx75RA1gFo3hI4rp6mrq0XwCO+x1AaM3SkdTV+5Y4Rtn/D3TsqmxJo2VMErFp4vVSTfcIxPwLHEy9Y/wCB5dCsbbVYDx3zL5hDGjTilWhEW2kJBYqdgVg3VjS2VqAfdFszfYzgA33y+gi6Py8uZcBk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=EhTNmYIreb8wXa2n6OIcKgrefMCfvOLdVZbeB/p4KMPoDr7VUqclHjfJzRp/SjofT8kcAtCe317N6H8udwvmMaoALs+3xp33mIfdPxcfMs/K8tvCdUwOG1Klnj6p4B8ONKLhmxdxWNhwIreYxsDpIogP9j1iiaCCI3D+9x1aOAs= Received: by 10.65.180.9 with SMTP id h9mr16166992qbp.41.1202232332442; Tue, 05 Feb 2008 09:25:32 -0800 (PST) Received: by 10.65.232.4 with HTTP; Tue, 5 Feb 2008 09:25:32 -0800 (PST) Message-ID: Date: Tue, 5 Feb 2008 18:25:32 +0100 From: "=?ISO-8859-1?Q?St=E9phane_Lescuyer?=" Sender: steki.kun@gmail.com To: "Damien Guichard" Subject: Re: [Caml-list] Variants & structural ordering Cc: "Liste de diffusion OCaml" In-Reply-To: <20080205165714.DE06A7000C0E@mwinf2354.orange.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <20080205165714.DE06A7000C0E@mwinf2354.orange.fr> X-Google-Sender-Auth: 38f34f89b8207e11 X-Miltered: at discorde with ID 47A89C0F.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lri:01 variants:01 damien:01 guichard:01 ocaml:01 variants:01 algebra:01 enumeration:01 berke:01 constructors:01 lri:01 polymorphic:01 caml-list:01 variant:02 caml:02 2008/2/5 Damien Guichard : > 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=E9phane L. http://www.lri.fr/~lescuyer