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 NAA08739; Thu, 15 Feb 2001 13:27:16 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 NAA08752 for ; Thu, 15 Feb 2001 13:27:15 +0100 (MET) Received: from dpt-info.u-strasbg.fr (dpt-info.u-strasbg.fr [130.79.6.1]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f1FCRFj13025 for ; Thu, 15 Feb 2001 13:27:15 +0100 (MET) Received: from lambda.u-strasbg.fr (lambda.u-strasbg.fr [130.79.90.63]) by dpt-info.u-strasbg.fr (8.9.3/8.9.3) with ESMTP id NAA00756; Thu, 15 Feb 2001 13:21:40 +0100 Received: from luther by lambda.u-strasbg.fr with local (Exim 3.22 #1 (Debian)) id 14TNPR-0007T7-00; Thu, 15 Feb 2001 13:21:17 +0100 Date: Thu, 15 Feb 2001 13:21:17 +0100 To: Jacques Garrigue Cc: barnier@recherche.enac.fr, qrczak@knm.org.pl, caml-list@inria.fr Subject: [Caml-list] Re: OCaml's long range graphical direction? Message-ID: <20010215132117.C28656@lambda.u-strasbg.fr> References: <20010209102801K.garrigue@kurims.kyoto-u.ac.jp> <3A87F898.D0D00FF7@recherche.enac.fr> <20010213084705X.garrigue@kurims.kyoto-u.ac.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.12i In-Reply-To: <20010213084705X.garrigue@kurims.kyoto-u.ac.jp>; from garrigue@kurims.kyoto-u.ac.jp on Tue, Feb 13, 2001 at 08:47:05AM +0900 From: Sven LUTHER Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, Feb 13, 2001 at 08:47:05AM +0900, Jacques Garrigue wrote: > From: Nicolas barnier > > Marcin 'Qrczak' Kowalczyk wrote: > > > > > > What are variance annotations in OCaml? > > > > Perniciously stolen on the OCaml CVS server (file "Changes"), but I lack > > the new doc ;-): > > > > Objective Caml 3.01: > > -------------------- > > > > New language features: > > - Variables are allowed in "or" patterns, e.g. > > match l with [t] | [_;t] -> ... t ... > > - "include " to re-export all components of a > > structure inside another structure. > > - Variance annotation on parameters of type declarations, e.g. > > type (+'a,-'b,'c) t (covariant in 'a, contravariant in 'b, invariant in 'c) > > Yes, this is the syntax. > Practically, this means that you can now mix object and variant > subtyping with both datatypes and abstract types. > > For instance, suppose that you have two types c and d, d subtype of c. > In ocaml 3.00, to coerce a list of d's to a list of c's, you would > have to write > List.map (fun x -> (x : d :> c)) l > In ocaml 3.01, you can do it directly > (l : d list :> c list) > because list is a covariant type, which you can see from its definition. > > Not only that, but thanks to explicit variance annotations, even > abstract datatypes, like maps from the Map module, can be traversed by > subtyping. > My remark on a lesser need for "hacked" coercions is a side-effect of > that. Are there any papers on the subject available ? Friendly, Sven Luther ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr