From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA31542; Mon, 19 Nov 2001 10:54:05 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA31295 for ; Mon, 19 Nov 2001 10:54:04 +0100 (MET) Received: from serveur4.labri.fr (serveur4.labri.u-bordeaux.fr [147.210.8.81]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id fAJ9s3b11533 for ; Mon, 19 Nov 2001 10:54:03 +0100 (MET) Received: (from vanicat@localhost) by serveur4.labri.fr (8.11.6/8.11.6) id fAJ9s2L03996; Mon, 19 Nov 2001 10:54:02 +0100 X-Authentication-Warning: serveur4.labri.fr: vanicat set sender to vanicat@labri.u-bordeaux.fr using -f To: caml-list@inria.fr Subject: Re: [Caml-list] Re: [Q]: Co(ntra)variance and subtyping? References: From: Remi VANICAT In-Reply-To: Date: 19 Nov 2001 10:54:02 +0100 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.104 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Alain Frisch writes: > Now, if you don't have the definition of a type constructor - say > it is an abstract type from your point of view - > you can't tell what its variance is w.r.t one of its arguments. > So OCaml allows to specify this information in module interface; > for instance, in map.mli: > > module type S = > sig > type key > (* The type of the map keys. *) > type (+'a) t > (* The type of maps from type [key] to type ['a]. *) > ... > > > The '+' means that type t is covariant: a map from type key to type > t1 can be coerced to a map from type key to type t2 if and only > if t1 is a subtype of t2. > > (I don't know why other modules such as Queue do not give variance > information ...) because Queue are neither covariant nor contravariant : - a Queue contain things, so it can't be contravariant, - you can add things to queue, so it can't be covariant infact, most of the mutable thing are neither contravariant nor covariant. -- Rémi Vanicat vanicat@labri.u-bordeaux.fr http://dept-info.labri.u-bordeaux.fr/~vanicat ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr