caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David MENTRE <david.mentre@gmail.com>
To: david.baelde@ens-lyon.org
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] -'a (doc request)
Date: Wed, 7 Sep 2005 15:00:36 +0200	[thread overview]
Message-ID: <3d13dcfc05090706006a68eac4@mail.gmail.com> (raw)
In-Reply-To: <53c655920509070548e11912e@mail.gmail.com>

Hello David,

2005/9/7, david baelde <david.baelde@gmail.com>:
> 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.


  reply	other threads:[~2005-09-07 13:00 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 ` David MENTRE [this message]
2005-09-07 13:34 ` [Caml-list] " Olivier Andrieu

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=3d13dcfc05090706006a68eac4@mail.gmail.com \
    --to=david.mentre@gmail.com \
    --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).