[plt-scheme] Recursive types and their specification

From: Noel Welsh (noelwelsh at yahoo.com)
Date: Tue Aug 9 10:58:44 EDT 2005

Hi all,

I have what is really a general PL question, but I think
might illustrate one way in which Scheme's
un/uni/dynamically typed behaviour may be useful, so I'm
asking here.  I'm writing a little program to control
Pacman.  As a demo I have written the following FSM:

  (define (policy)
            (lambda ()
               (lambda ()
                 (if (< (random) 0.4)
            (lambda ()
               (lambda ()
                 (if (< (random) 0.6)
            (lambda ()
               (lambda ()
                 (if (< (random) 0.4)
            (lambda ()
               (lambda ()
                 (if (< (random) 0.5)

The FSM returns two values: the action to take (up, down,
left, or right) and the continuation for the policy.  How
does one specify the type of the continuation?  It's a
function that returns two values, the first of which is an
action, and the second of which is a function that returns
two values, the first of which...

Is this something that would cause HM to blow up (I think
so)?  Does this show that Scheme is the One True Way?  Does
asking this question mean I have to revoke my LtU
editorship (Ehud, I know you read this list :)?


Email: noelwelsh <at> yahoo <dot> com   noel <at> untyped <dot> com
AIM: noelhwelsh
Blogs: http://monospaced.blogspot.com/  http://www.untyped.com/untyping/

Start your day with Yahoo! - make it your home page 

Posted on the users mailing list.