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 VAA30736; Wed, 14 Apr 2004 21:38:29 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 VAA30086 for ; Wed, 14 Apr 2004 21:38:28 +0200 (MET DST) Received: from postfix4-2.free.fr (postfix4-2.free.fr [213.228.0.176]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i3EJdTjq012339 for ; Wed, 14 Apr 2004 21:39:29 +0200 Received: from sequoia.mondomaineamoi.megalo (lns-th2-7-82-64-98-109.adsl.proxad.net [82.64.98.109]) by postfix4-2.free.fr (Postfix) with ESMTP id B8DEE93B13; Wed, 14 Apr 2004 21:38:26 +0200 (CEST) Received: from sequoia.mondomaineamoi.megalo (localhost.mondomaineamoi.megalo [127.0.0.1]) by sequoia.mondomaineamoi.megalo (8.12.9p2/8.12.2) with ESMTP id i3EJcQ62025889; Wed, 14 Apr 2004 21:38:26 +0200 (CEST) (envelope-from stephane@sequoia.mondomaineamoi.megalo) Received: (from stephane@localhost) by sequoia.mondomaineamoi.megalo (8.12.9p2/8.12.5/Submit) id i3EJb5DC025888; Wed, 14 Apr 2004 21:37:05 +0200 (CEST) Date: Wed, 14 Apr 2004 21:37:05 +0200 From: Stephane Legrand To: "Seth J. Fogarty" Cc: caml-list@inria.fr Subject: Re: [Caml-list] '_a out of nowhere? (list.reverse) Message-ID: <20040414193705.GL75847@sequoia.mondomaineamoi.megalo> Reply-To: stephane@freebsd-fr.org References: <20040414190532.GQ10439@students.uiuc.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20040414190532.GQ10439@students.uiuc.edu> User-Agent: Mutt/1.4.2.1i X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 val:01 val:01 char:01 emploi:99 developpeur:99 ocaml:01 ocaml:01 int:01 int:01 wrote:03 behavior:03 sys:03 perl:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 352 On Wed, Apr 14, 2004 at 02:05:32PM -0500, Seth J. Fogarty wrote: > # let cons x y = x::y > # and flip f x y = f y x ;; > val cons : 'a -> 'a list -> 'a list = > val flip : ('a -> 'b -> 'c) -> 'b -> 'a -> 'c = > # let reverse = List.fold_left (flip cons) [];; > val reverse : '_a list -> '_a list = > # reverse [1;2;3];; > - : int list = [3; 2; 1] > # reverse ['a';'b';'c'];; > This expression has type char but is here used with type int > > I've encountered similar things with references, but never with something as > basic as a fold_left. Can someone tell me why this is happening? This, to me, > is very wrong behavior. This is on Debian's OCaml 3.07. Try this: # let cons x y = x::y # and flip f x y = f y x ;; # let reverse = List.fold_left (flip cons) [];; # reverse ['a';'b';'c'];; # reverse [1;2;3];; In your example, when you first use reverse with an integer list, you definitely have a reverse with : val reverse : int list -> int list = Regards, Stephane. -- Je recherche un emploi de développeur/admin. sys. (FreeBSD,Linux,PHP,Perl,MySQL,OCaml,Tcl/Tk...) ==> www.freebsd-fr.org/~stephane/cv.pdf <== ------------------- 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