From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA00181 for caml-red; Thu, 11 Jan 2001 10:33:50 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA09517 for ; Thu, 11 Jan 2001 10:29:59 +0100 (MET) Received: from isis.lip6.fr (isis.lip6.fr [132.227.60.2]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f0B9TxT00339 for ; Thu, 11 Jan 2001 10:29:59 +0100 (MET) Received: from spi.lip6.fr (IDENT:root@spi.lip6.fr [132.227.83.55]) by isis.lip6.fr (8.11.0/jtpda-5.3.2) with ESMTP id f0B9TvV12342 ; Thu, 11 Jan 2001 10:29:57 +0100 Received: from baltazard.lip6.fr (root@baltazard.lip6.fr [132.227.82.102]) by spi.lip6.fr (8.8.7/jtpda-5.2) with ESMTP id KAA06347 ; Thu, 11 Jan 2001 10:30:03 +0100 Received: from (boulme@localhost) by baltazard.lip6.fr (8.9.3/jtpda-5.2) id KAA02719 ; Thu, 11 Jan 2001 10:29:55 +0100 Message-Id: <200101110929.KAA02719@baltazard.lip6.fr> X-Mailer: exmh version 2.1.1 10/15/1999 To: "Mattias Waldau" Cc: caml-list@inria.fr Subject: Re: Why can't I use val mover : < move : int -> unit; .. > list -> unit ? In-Reply-To: Your message of "Wed, 10 Jan 2001 13:39:47 +0100." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 11 Jan 2001 10:29:55 +0100 From: "Sylvain BOULM'E" Sender: weis@pauillac.inria.fr Hi, Lists are polymorphic but they are uniform : elements of a list must have all the same type (which can be any type). Hence, "mover" is a function that expects a list of objects, all of the same type, and which type contains a method "move". Thus, with q: p1d_1 p: p1d_2 Expression "[q;q]" is of type "p1d_1 list" and "[p;p]" is of type "p1d_2 list", thus "mover [q;q]" and "mover [p;p]" are well-typed. But "[p;q]" is not well-typed. Here, p1d_2 is subtype of p1d_1 : you can coerce p to have the type p1d_1. Thus "[(p:>p1d_1);q]" is of type p1d_1 list. And "mover [(p:>p1d_1);q]" is well-typed. Sylvain.