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 EAA15876; Thu, 1 Jul 2004 04:38:58 +0200 (MET DST) 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 EAA15856 for ; Thu, 1 Jul 2004 04:38:53 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i612coSH020107 for ; Thu, 1 Jul 2004 04:38:51 +0200 Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2-20030924/3.7W) with ESMTP id LAA07712; Thu, 1 Jul 2004 11:38:44 +0900 (JST) Date: Thu, 01 Jul 2004 11:38:44 +0900 (JST) Message-Id: <20040701.113844.07258828.garrigue@kurims.kyoto-u.ac.jp> To: rich@annexia.org Cc: caml-list@inria.fr Subject: Re: [Caml-list] Re: Type unification problem From: Jacques GARRIGUE In-Reply-To: <20040630122116.GA8170@redhat.com> References: <20040630121625.GA8099@redhat.com> <20040630122116.GA8170@redhat.com> X-Mailer: Mew version 4.0.64 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 40E3793A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 unification:01 jacques:01 dbi:99 dbi:99 incompatible:01 annotate:01 stm:99 annotate:01 annotating:01 annotating:01 olabl:01 jacques:01 compiler:01 garrigue:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Richard Jones > > Why this error (below)? I can "fix" it by adding quite a lot of > > explicit types (I need one on every function which uses the > > Dbi.connection parameter). Is there a simpler way to fix it? If I look at the details of this error, I can see: map : ([> `String of 'c ] list -> 'c) -> string list; in the first type, and map : 'g. (Dbi.sql_t list -> 'g) -> 'g list; in the Dbi.statement part of the second type. These two types are incompatible: a polymorphic method type can only be unified with a method with the same polymorphism. Before calling a polymorphic method, you must make sure that its type is known to the compiler, otherwise you get the above kind of errors. The local solution is to annotate every polymorphic method call with the type of the object: (stm : Dbi.statement)#map ... But the system is more clever than that: you can simply annotate all parameters which may eventually yield a Dbi.statement, whenever this Dbi.statement is used for a polymorphic method call. This is probably why you found that annotating all Dbi.connection parameters worked. But you don't need to annotate all of them, just the ones where there is a polymorphic method call in the body. Note also that you can annotate with #Dbi.connection, to allow subclasses. (Actually, annotating all of them may be a good idea. Olabl had a warning had warning when calling a method on an object of unknown type.) Jacques Garrigue ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners