[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Brian Hurt <bhurt@s...> |
| Subject: | Re: [Caml-list] Y combinator and type-checking |
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 = <fun>
#
--
"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