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

*To*: Michael Vanier <address@hidden>*Subject*: Re: in defense of types*From*: Pixel <address@hidden>*Date*: 30 May 2002 12:56:10 +0200*Cc*: address@hidden, address@hidden*In-reply-to*: <200205300555.g4U5t5q13913@orchestra.cs.caltech.edu>*References*: <20020529172958.1945.qmail@mail.archub.org><200205292327.g4TNRaL11580@orchestra.cs.caltech.edu><6616qo7s.fsf@kldp.org><200205300555.g4U5t5q13913@orchestra.cs.caltech.edu>*Sender*: address@hidden*User-agent*: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

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 ??

**Follow-Ups**:**Re: in defense of types***From:*Matthias Felleisen <matthias@ccs.neu.edu>

**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>

- Prev by Date:
**Re: Accumulator Reduc** - 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):