[plt-scheme] In Typed Scheme, type for sub1 doesn't include (Integer -> Integer)

From: Todd O'Bryan (toddobryan at gmail.com)
Date: Mon Apr 20 11:23:35 EDT 2009

Any reason why?

The following doesn't work:

(: ! (Integer -> Integer))
(define (! n)
   [(zero? n) 1]
   [else (* n
            (! (sub1 n)))]))

but change (sub1 n) to (- n 1) and it works fine.

Also, is there any way to define subtypes? For example, could I define
a "natural-number" type that's limited to non-negative integers?


P.S. Typed Scheme is fun to play with. :-)

Posted on the users mailing list.