caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Olivier Andrieu <andrieu@ijm.jussieu.fr>
To: matthieu.dubuget@laposte.net
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Coercion of arrays of objects (and some other containers)
Date: Wed, 13 Apr 2005 16:11:19 +0200 (CEST)	[thread overview]
Message-ID: <20050413.161119.115918255.andrieu@ijm.jussieu.fr> (raw)
In-Reply-To: <425CBE46.5000306@laposte.net>

 Matthieu Dubuget [Wed, 13 Apr 2005]:
 > I'm sorry, but I feel stupid.
 > 
 > The variance and covariance terms/notions appear often in this
 > list, and seems to be very basic notions.
 > 
 > I tried to find explanation on internet but did not succeed.
 > 
 > Could somebody point me some links  to understand, please?

I do not have a link but the idea (as I understand it) is simple :

This concerns parameterized types ('a t) and how a subtyping relation
on the parameter can yield a subtyping relation on the type.

When the parameter is covariant :
  if a is a subtype of b then a t is a subtype of b t

When the parameter is contravariant :
  if a is a subtype of b then b t is a subtype of a t

For instance lists are covariant. [`A|`B|`C] is a supertype of [`A|`B]
so a [`A|`B|`C] list is a supertype of [`A|`B] list.

Function arguments are contravariant : ([`A|`B] -> unit) is a
supertype of ([`A|`B|`C] -> unit). When you have a function that
accepts A B or C, you can also view it as a function that accepts just
A or B (qui peut le plus peut le moins).

Records with mutable fields (or arrays) are neither covariant nor
contravariant. 

Well maybe my terminology isn't quite correct but I hope you get the
idea.

-- 
   Olivier


      reply	other threads:[~2005-04-13 14:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-13  0:14 Martin Jambon
2005-04-13  0:49 ` [Caml-list] " Olivier Andrieu
2005-04-13  0:59 ` Jacques Garrigue
2005-04-13  6:37   ` Matthieu Dubuget
2005-04-13 14:11     ` 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=20050413.161119.115918255.andrieu@ijm.jussieu.fr \
    --to=andrieu@ijm.jussieu.fr \
    --cc=caml-list@inria.fr \
    --cc=matthieu.dubuget@laposte.net \
    /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).