[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*To*: Pixel <address@hidden>*Subject*: Re: in defense of types*From*: Matthias Felleisen <address@hidden>*Date*: Thu, 30 May 2002 08:23:58 -0400 (EDT)*Cc*: Michael Vanier <address@hidden>, address@hidden, address@hidden*In-reply-to*: <lyadqhykdx.fsf@leia.mandrakesoft.com>*References*: <20020529172958.1945.qmail@mail.archub.org><200205292327.g4TNRaL11580@orchestra.cs.caltech.edu><6616qo7s.fsf@kldp.org><200205300555.g4U5t5q13913@orchestra.cs.caltech.edu> <lyadqhykdx.fsf@leia.mandrakesoft.com>*Sender*: address@hidden

Pixel, the point of Y is NOT to use let rec :) For people who need to see a typed version in ML that works for ALL types, see the last page of "The Little MLer". For those who need to see this in Java, take a look at the last page of "A Little Java, A Few Patterns." -- Matthias At 30 May 2002 12:56:10 +0200, Pixel wrote: > Michael Vanier <mvanier@cs.caltech.edu> writes: > > > > let z f = (fun x -> f (fun z -> x x z)) (fun x -> f (fun z -> x x z));; > > > > > > is not typable. since two 'x' in 'x x z' cannot have the same type. > > > The key point is distinguish the type of these instances of 'x'. > > > > > > # type 'a t = I of ('a t -> 'a);; > > > type 'a t = I of ('a t -> 'a) > > > # let z f = (function I x -> f (fun z -> x (I x) z)) > > > (I (function I x -> f (fun z -> x (I x) z)));; > > > val z : (('a -> 'b) -> 'a -> 'b) -> 'a -> 'b = <fun> > > > > > > voila! you can type it. Now, let's try simple example. > > > > This is a brilliant and non-obvious demonstration; thanks a lot! You saved > > me hours of scratching my head ;-) > > > > BTW I'm not sure what you mean when you say that Y is not usable in eager > > languages. You can define Y in scheme, which is eager. Do you mean in > > eager statically-typed languages? > > I don't understand either. And isn't this much simpler and working: > > let rec y f e = f (y f) e > let ffact f n = if n = 1 then 1 else n * f (n - 1) > ;; > y ffact 5 > > ??

**References**:**Re: in defense of types***From:*Paul Graham <pg@archub.org>

**Re: in defense of types***From:*Michael Vanier <mvanier@cs.caltech.edu>

**Re: in defense of types***From:*Jaeyoun Chung <jay@kldp.org>

**Re: in defense of types***From:*Michael Vanier <mvanier@cs.caltech.edu>

**Re: in defense of types***From:*Pixel <pixel@mandrakesoft.com>

- Prev by Date:
**RE: Macros and little languages** - Next by Date:
**Re: Macros and little languages** - Previous by thread:
**Re: in defense of types** - Next by thread:
**Re: in defense of types** - Index(es):