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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 0EED1BC0A for ; Thu, 1 Mar 2007 18:03:48 +0100 (CET) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.224]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l21H3kYj024436 for ; Thu, 1 Mar 2007 18:03:47 +0100 Received: by wr-out-0506.google.com with SMTP id i11so727147wra for ; Thu, 01 Mar 2007 09:03:46 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; 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; b=KHdAk3cWWp+VudhFpjz235dYbXFixwLJ0fKpMyGWiPho5guBhjcK1JG7YMdmHxFSSPlokGaQGVXQGRKDZMu2m1GZO1LNovYdjZBkZDL2b6irb92DQ4xLWn9TkuKWfLqRTF3NDfz/RizyH9eQW+oUHgBVpW0x63muc963ILfAuSM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=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; b=J7XxRFszGiShbsTrI1qwLY4OLQZg7FkGhSWpZQ+YNfPXrm6zgRplWsb1Jkdv3FT8goPGcQdetBnhdu0wmCpFPi3/ctEmXydu+r8wVvGDcwN51nHcFdjFpOowZphvc2X87kBAl+RhqZiNs4m6Jywku270sDee14ofG34hzyLdVio= Received: by 10.114.75.1 with SMTP id x1mr80902waa.1172768624278; Thu, 01 Mar 2007 09:03:44 -0800 (PST) Received: by 10.115.106.4 with HTTP; Thu, 1 Mar 2007 09:03:44 -0800 (PST) Message-ID: <95513600703010903n18ae6a7bo34c84eeca04fefdd@mail.gmail.com> Date: Thu, 1 Mar 2007 18:03:44 +0100 From: "Olivier Andrieu" Sender: oandrieu@gmail.com To: micha Subject: Re: [Caml-list] phantom type thing question Cc: caml-list@inria.fr In-Reply-To: <20070301174026.5b1c2ba2@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <45E6A0E6.80502@fantasymail.de> <95513600703010547t1f098d80p7bbff2f2c85d79a5@mail.gmail.com> <20070301174026.5b1c2ba2@localhost> X-Google-Sender-Auth: 715c4aca0e3b1d6d X-Miltered: at concorde with ID 45E70772.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; andrieu:01 oandrieu:01 andrieu:01 oandrieu:01 subtyping:01 annotation:01 subtyping:01 -'a:01 -'a:01 val:01 encodes:01 subtype:01 subtype:01 wrote:01 wrote:01 On 3/1/07, micha wrote: > Am Thu, 1 Mar 2007 14:47:47 +0100 > schrieb "Olivier Andrieu" : > > > On 3/1/07, micha wrote: > > > > > if you want subtyping, you'll need to add a variance annotation to > > your type parameter. Otherwise since your type sym is abstract, you'll > > get no subtyping at all. In this case you probably want a > > contravariant type parameter: > > > > type -'a sym > > o.k., but after reading section 6.8.1 of the manual I don't see why it > needs to be -'a and not +'a > > > > that should be: > > val get_image_width : [> xpm] sym -> int your parameter encodes some "capabilities": you want the function get_image_width to accept values that have the tag `xpm and possibly more tags, hence the [> ] in the type of the function. In other words, you want the type xpm sym to be a subtype of [xpm|`xpm8] sym (for instance), so that get_image_width accept boths. Since [xpm|`xpm8] is a subtype of xpm sym (the other way around), that means the parameter needs to be contravariant.