Version française
Home     About     Download     Resources     Contact us    
Browse thread
OCaml's long range graphical direction?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sven LUTHER <luther@d...>
Subject: [Caml-list] Re: OCaml's long range graphical direction?
On Tue, Feb 13, 2001 at 08:47:05AM +0900, Jacques Garrigue wrote:
> From: Nicolas barnier <barnier@recherche.enac.fr>
> > 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 <structure expression>" 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