From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 8D728BDCB for ; Wed, 7 Sep 2005 15:00:38 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j87D0bDu022527 for ; Wed, 7 Sep 2005 15:00:38 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA22182 for ; Wed, 7 Sep 2005 15:00:37 +0200 (MET DST) Received: from nproxy.gmail.com (nproxy.gmail.com [64.233.182.200]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j87D0brD021274 for ; Wed, 7 Sep 2005 15:00:37 +0200 Received: by nproxy.gmail.com with SMTP id l37so503767nfc for ; Wed, 07 Sep 2005 06:00:36 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=lZuZ1TQuAxEcabRiTak9qtXL1rlYzy19OoILL5AckhO2nVSv0O5PaZC8rmOyk91iTWGlQPj4+t1ORzFnZMaJVVdYVKFqPAFvrt++CUM6ZCG9WkQ9b9tOnMZXZgCMdGCAOnzYhU/KOzmfJOXLRUeTWc4pz5s1d+OURULwwaxqL7Y= Received: by 10.48.30.19 with SMTP id d19mr370349nfd; Wed, 07 Sep 2005 06:00:36 -0700 (PDT) Received: by 10.48.42.9 with HTTP; Wed, 7 Sep 2005 06:00:36 -0700 (PDT) Message-ID: <3d13dcfc05090706006a68eac4@mail.gmail.com> Date: Wed, 7 Sep 2005 15:00:36 +0200 From: David MENTRE To: david.baelde@ens-lyon.org Subject: Re: [Caml-list] -'a (doc request) Cc: caml-list@inria.fr In-Reply-To: <53c655920509070548e11912e@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <53c655920509070548e11912e@mail.gmail.com> X-Miltered: at concorde with ID 431EE476.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 431EE475.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 -'a:01 mli:01 -'a:01 optionally:01 variance:01 subtyping:01 coercions:01 subtype:01 subtype:01 variance:01 annotation:01 supertype:01 annotations:01 annotations:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.3 Hello David, 2005/9/7, david baelde : > I just saw in cairo.mli a type declaration which I don't understand: > type -'a surface > What's the difference with 'a ? See http://caml.inria.fr/pub/docs/manual-ocaml/manual016.html#s:type-defs [the copy/paste is missing greek letters, look at the web page] The type variables appearing as type parameters can optionally be prefixed by + or - to indicate that the type constructor is covariant or contravariant with respect to this parameter. This variance information is used to decide subtyping relations when checking the validity of >: coercions (see section 6.7.5). For instance, type +'a t declares t as an abstract type that is covariant in its parameter; this means that if the type t is a subtype of the type s, then t t is a subtype of s t. Similarly, type -'a t declares that the abstract type t is contravariant in its parameter: if t is subtype of s, then s t is subtype of t t. If no + or - variance annotation is given, the type constructor is assumed invariant in the corresponding parameter. For instance, the abstract type declaration type 'a t means that t t is neither a subtype nor a supertype of s t if t is subtype of s. The variance indicated by the + and - annotations on parameters are required only for abstract types. For abbreviations, variant types or record types, the variance properties of the type constructor are inferred from its definition, and the variance annotations are only checked for conformance with the definition. Yours, d.