# [plt-scheme] typed scheme intro

What type annotations did you put, exactly? I tried changing the
result of mag to Number and otherwise leaving it as is (from the docs)
and I get this:
Welcome to DrScheme, version 4.2.5.6-svn8apr2010 [3m].
Language: typed/scheme; memory limit: 512 MB.
. Type Checker: No function domains matched in function application:
Domains: Exact-Nonnegative-Integer
Number
Arguments: Number Number
in: (sqrt (sqr (pt-x p)) (sqr (pt-y p)))
Robby
On Thu, Apr 8, 2010 at 3:11 PM, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:
>* Those are both bugs. The return type of `mag' should be `Number', as
*>* the untyped version indicates. I've fixed this in SVN.
*>*
*>* sam th
*>*
*>* On Thu, Apr 8, 2010 at 3:41 PM, Danny Yoo <dyoo at cs.wpi.edu> wrote:
*>>* I'm trying to run the mag program described in:
*>>*
*>>* http://docs.plt-scheme.org/ts-guide/quick.html
*>>*
*>>* 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
*>>* doing:
*>>*
*>>* (: mag (pt -> Real))
*>>* (define (mag p)
*>>* (real-part (sqrt (+ (sqr (pt-x p))
*>>* (sqr (pt-y p))))))
*>>*
*>>*
*>>* Am I missing something?
*>>* _________________________________________________
*>>* For list-related administrative tasks:
*>>* http://list.cs.brown.edu/mailman/listinfo/plt-scheme
*>>*
*>*
*>*
*>*
*>* --
*>* sam th
*>* samth at ccs.neu.edu
*>* _________________________________________________
*>* For list-related administrative tasks:
*>* http://list.cs.brown.edu/mailman/listinfo/plt-scheme
*>*
*