[PRL] Type question...

Riccardo Pucella riccardo at ccs.neu.edu
Wed Oct 3 23:33:45 EDT 2007


>> (let ((fact (lambda (num)
>>                 ((lambda (f n) (f f n))
>>                  (lambda (g m)
>>                    (if (< m 2) 1
>>                        (* m (g g (- m 1))))) num))))
>>    (fact 5))

> I believe it's the (f f n) and (g g (- m 1)) that shoot you down.
> There's no simple type for a function that accepts itself as an
> argument.

Right; as Carl says, just look at (lambda (f n) (f f n))

The best type you could give it is the recursive type:
   (\mu Z.( Z x a -> b)) x a -> b

(Where a is the type of n, and b is the result type of the lambda.

  Cheers,
  R






More information about the PRL mailing list