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 MAA18177 for caml-redistribution; Mon, 18 Jan 1999 12:04:52 +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 NAA25977 for ; Sat, 16 Jan 1999 13:21:37 +0100 (MET) Received: from miss.wu-wien.ac.at (miss.wu-wien.ac.at [137.208.107.17]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id NAA01197 for ; Sat, 16 Jan 1999 13:21:35 +0100 (MET) Received: (from mottl@localhost) by miss.wu-wien.ac.at (8.9.0/8.9.0) id NAA00134 for caml-list@inria.fr; Sat, 16 Jan 1999 13:21:35 +0100 (MET) From: Markus Mottl Message-Id: <199901161221.NAA00134@miss.wu-wien.ac.at> Subject: Problem binding type parameters in modules To: caml-list@inria.fr (OCAML) Date: Sat, 16 Jan 1999 13:21:35 +0100 (MET) X-Mailer: ELM [version 2.4 PL21] MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: weis Hello, sometimes one has the impression that there must be a simple solution, but one can just not see it... My problem (example code): --------------------------------------------------------------------------- module type FOO1 = sig type 'a foo val empty : 'a foo end module type FOO2 = sig type foo val empty : foo end (* ok *) module Foo1 : FOO1 = struct type 'a foo = 'a list let empty = [] end (* also ok *) module Foo2 : FOO2 = struct type foo = int list Lazy.t let empty = lazy [] end (* not ok *) module Bar : FOO1 = struct type 'a foo = 'a list Lazy.t let empty = lazy [] end --------------------------------------------------------------------------- The compiler will report an error, because it does not infer the type of "empty" in module "Bar" as specified in "FOO1". No matter what I have tried, I haven't succeed in binding the type parameter needed in "empty" to "'a" in type "foo", so that the module signatures would match. E.g.: --------------------------------------------------------------------------- (* also not ok *) module Bar : FOO1 = struct type 'a foo = 'a list Lazy.t let empty : 'a foo = lazy [] end --------------------------------------------------------------------------- The "'a" specified in "empty" is still not the same as in "'a foo". I have not yet tried to use a functor to bind the function to the correct type, but I think this should not be necessary. As one can see in the example, the type of "empty" is correctly inferred in "Foo1" and "Foo2". I do not understand, why the compiler does not do so in the last case. Am I overlooking any easy way out? Or is this even a bug? Best regards, Markus Mottl -- Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl