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 VAA21040 for caml-red; Wed, 20 Sep 2000 21:52:31 +0200 (MET DST) 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 JAA01866 for ; Wed, 20 Sep 2000 09:31:57 +0200 (MET DST) Received: from ext.lri.fr (ext.lri.fr [129.175.15.4]) by nez-perce.inria.fr (8.10.0/8.10.0) with ESMTP id e8K7VuX28436 for ; Wed, 20 Sep 2000 09:31:56 +0200 (MET DST) Received: from pc803.lri.fr (IDENT:root@pc803 [129.175.8.114]) by ext.lri.fr (8.9.3/jtpda-5.3.2) with ESMTP id JAA01654 ; Wed, 20 Sep 2000 09:31:55 +0200 (MET DST) Received: by pc803.lri.fr (8.9.3/feuille) id JAA22592 ; Wed, 20 Sep 2000 09:31:55 +0200 X-Authentication-Warning: localhost.localdomain: filliatr set sender to filliatr@pc803 using -f From: Jean-Christophe Filliatre MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <14792.26603.589374.730149@pc803> Date: Wed, 20 Sep 2000 09:31:55 +0200 (MEST) To: luther@dpt-info.u-strasbg.fr CC: caml-list@inria.fr Subject: Re: Modules, type de modules et type polymorphes. In-Reply-To: <20000919142939.A3312@lambda.u-strasbg.fr> References: <20000919142939.A3312@lambda.u-strasbg.fr> X-Mailer: VM 6.49 under Emacs 20.4.1 Reply-To: Jean-Christophe.Filliatre@lri.fr (Jean-Christophe Filliatre) Sender: weis@pauillac.inria.fr > quel est le probleme de ceci ? > What is the problem with the following ? > > bash-2.04$ ocaml > Objective Caml version 3.00 > > # module type T_A = sig > val string_of_a : 'a -> string > end;; > module type T_A = sig val string_of_a : 'a -> string end > # module A : T_A = struct > let string_of_a = string_of_int > end;; > Signature mismatch: > Modules do not match: > sig val string_of_a : int -> string end > is not included in > T_A > Values do not match: > val string_of_a : int -> string > is not included in > val string_of_a : 'a -> string Une fonction de type int -> string ne peut pas être appelée avec un argument d'un type quelconque. Donc votre module A ne peut avoir l'interface T_A qui déclare que string_of_a accepte un argument d'un type quelconque. Dit autrement, si le module A était effectivement de type T_A, alors A.string_of_a aurait le type 'a -> string et je pourrais écrire A.string_of_a "tagada", qui n'a pas de sens. Plus précisément, et c'est peut-être là l'origine de votre problème, la quantification universelle sur 'a est faite au niveau du type de string_of_a (et de manière plus générale pour chaque déclaration dans la signature) et non au niveau du type de module. En ce sens, il n'y a pas de polymorphisme au niveau du langage de module. En revanche, vous pouvez écrire module type T_A = sig type a val string_of_a : a -> string end puis module A : T_A = struct type a = int let string_of_a = string_of_int end [ No English translation, I apologize. ] -- Jean-Christophe FILLIATRE mailto:Jean-Christophe.Filliatre@lri.fr http://www.lri.fr/~filliatr