[plt-scheme] typed scheme intro

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Thu Apr 8 15:41:52 EDT 2010

I'm trying to run the mag program described in:


but it doesn't look quite right: the addition of the squared
components appears to be missing.

Furthermore, when I do change it to:

(: mag (pt -> Real))
(define (mag p)
  (sqrt (+ (sqr (pt-x p))
           (sqr (pt-y p)))))

I get a type error because I can't convince the type checker that the
result of the addition will be a positive real.  I worked around by

(: mag (pt -> Real))
(define (mag p)
  (real-part (sqrt (+ (sqr (pt-x p))
                           (sqr (pt-y p))))))

Am I missing something?

Posted on the users mailing list.