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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id A7FEDBDCB for ; Wed, 7 Sep 2005 15:34:13 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j87DYDsn024413 for ; Wed, 7 Sep 2005 15:34:13 +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 PAA23126 for ; Wed, 7 Sep 2005 15:34:12 +0200 (MET DST) Received: from mallaury.nerim.net (smtp-103-wednesday.noc.nerim.net [62.4.17.103]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j87DYCcw024409 for ; Wed, 7 Sep 2005 15:34:12 +0200 Received: from karryall.dnsalias.org (karryall.dnsalias.org [213.41.180.99]) by mallaury.nerim.net (Postfix) with ESMTP id 7A93D4F400; Wed, 7 Sep 2005 15:34:03 +0200 (CEST) Received: by karryall.dnsalias.org (Postfix, from userid 500) id D0D6B596F83; Wed, 7 Sep 2005 15:34:11 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17182.60496.806816.26157@karryall.dnsalias.org> Date: Wed, 7 Sep 2005 15:34:08 +0200 From: Olivier Andrieu To: david.baelde@ens-lyon.org Cc: caml-list@inria.fr Subject: Re: [Caml-list] -'a (doc request) In-Reply-To: <53c655920509070548e11912e@mail.gmail.com> References: <53c655920509070548e11912e@mail.gmail.com> X-Mailer: VM 7.19 under Emacs 21.4.1 X-Miltered: at nez-perce with ID 431EEC55.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 431EEC54.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; andrieu:01 oandrieu:01 ijm:01 caml-list:01 -'a:01 mli:01 -'a:01 variance:01 annotation:01 optionally:01 variance:01 subtyping:01 coercions:01 api:01 subtyping: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=none autolearn=disabled version=3.0.3 david baelde [Wednesday 7 September 2005] : > > I just saw in cairo.mli a type declaration which I don't understand: > type -'a surface > What's the difference with 'a ? This is a variance annotation. From the manual: ,---- | 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 `---- So it means the `surface' type is contravariant wrt the parameter. This allows the caml API to reflect the subtyping relations of the underlying C type. Typically, you have constructor functions: val image_surface_create : ... -> [ `Any | `Image ] surface val surface_create_for_channel : ... -> [ `Any | `PDF ] surface , functions that work on any kind of surface: val surface_flush : [> `Any ] surface -> unit and some functions that are specific to a subtype of surface: val image_surface_get_width : [> `Image ] surface -> int HTH, -- Olivier