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 TAA01983; Fri, 2 Jul 2004 19:48:26 +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 TAA02288 for ; Fri, 2 Jul 2004 19:48:25 +0200 (MET DST) Received: from herd.plethora.net (herd.plethora.net [205.166.146.1]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i62HmNEV025679 for ; Fri, 2 Jul 2004 19:48:24 +0200 Received: from bhurt.plethora.net (bhurt.plethora.net [205.166.146.49]) by herd.plethora.net (8.11.6/8.10.1) with ESMTP id i62HmFi21501; Fri, 2 Jul 2004 12:48:16 -0500 (CDT) Date: Fri, 2 Jul 2004 12:54:40 -0500 (CDT) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: Martin Berger cc: The Caml Trade Subject: Re: [Caml-list] Y combinator and type-checking In-Reply-To: <40E59D30.1080202@dcs.qmul.ac.uk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at nez-perce with ID 40E59FE7.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 combinator:01 annotate:01 inferred:01 3.07:01 val:01 ocaml:01 caml:01 rec:01 rec:01 wrote:03 types:03 redirect:95 let:04 let:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, 2 Jul 2004, Martin Berger wrote: > now i annotate the definition above with the types just > inferred: > > let rec y ( f : ( 'a -> 'b ) -> 'a -> 'b ) > : ( ( 'a -> 'b ) -> 'a -> 'b ) -> 'a -> 'b > = f (fun x -> (y f) x );; This is where your mistake is. Don't duplicate the type of f. Instead, you should have done: let rec y (f : ('a -> 'b) -> 'a -> 'b) : 'a -> 'b = f (fun x -> (y f) x);; And now it works: $ ocaml Objective Caml version 3.07 # let rec y (f : ('a -> 'b) -> 'a -> 'b) : 'a -> 'b = f (fun x -> (y f) x);; val y : (('a -> 'b) -> 'a -> 'b) -> 'a -> 'b = # -- "Usenet is like a herd of performing elephants with diarrhea -- massive, difficult to redirect, awe-inspiring, entertaining, and a source of mind-boggling amounts of excrement when you least expect it." - Gene Spafford Brian ------------------- 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