caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Olivier Andrieu <oandrieu@ijm.jussieu.fr>
To: david.baelde@ens-lyon.org
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] -'a (doc request)
Date: Wed, 7 Sep 2005 15:34:08 +0200	[thread overview]
Message-ID: <17182.60496.806816.26157@karryall.dnsalias.org> (raw)
In-Reply-To: <53c655920509070548e11912e@mail.gmail.com>

 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


      parent reply	other threads:[~2005-09-07 13:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-07 12:48 david baelde
2005-09-07 13:00 ` [Caml-list] " David MENTRE
2005-09-07 13:34 ` Olivier Andrieu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17182.60496.806816.26157@karryall.dnsalias.org \
    --to=oandrieu@ijm.jussieu.fr \
    --cc=caml-list@inria.fr \
    --cc=david.baelde@ens-lyon.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).