caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Hurt <bhurt@spnz.org>
To: Martin Berger <martinb@dcs.qmul.ac.uk>
Cc: The Caml Trade <caml-list@inria.fr>
Subject: Re: [Caml-list] Y combinator and type-checking
Date: Fri, 2 Jul 2004 12:54:40 -0500 (CDT)	[thread overview]
Message-ID: <Pine.LNX.4.44.0407021252550.4202-100000@localhost.localdomain> (raw)
In-Reply-To: <40E59D30.1080202@dcs.qmul.ac.uk>

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


  reply	other threads:[~2004-07-02 17:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-02 17:36 Martin Berger
2004-07-02 17:54 ` Brian Hurt [this message]
2004-07-06 23:24   ` [Caml-list] Why type infenere enter infinte loop here? Andy Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0407021252550.4202-100000@localhost.localdomain \
    --to=bhurt@spnz.org \
    --cc=caml-list@inria.fr \
    --cc=martinb@dcs.qmul.ac.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).