Typed Racket only follows control flow like you've written inside
expressions, not at the top-level of a module. So this program will
work correctly:

#lang typed/racket
(define (f)
  (define ls (port->list read (open-input-string "1 2 3 4")))
  (unless (andmap number? ls)
    (error "ls not read correctly"))
  (for ([n ls])
    (displayln (* n n))))
(f)

Sam

On Mon, Dec 12, 2016 at 10:03 AM, Winston Weinert <winston+...@ml1.net> wrote:
> Hi, the following code listing gives me this TR error:
>
> ; /home/winston/code/practice/snippets/tr.rkt:7:16: Type Checker: type 
> mismatch
> ;   expected: Number
> ;   given: Any
> ;   in: n
> ; /home/winston/code/practice/snippets/tr.rkt:7:18: Type Checker: type 
> mismatch
> ;   expected: Number
> ;   given: Any
> ;   in: n
> ; Type Checker: Summary: 2 errors encountered
>
>
> How do I fix this type guard?
>
> Here is the code listing:
>
> #lang typed/racket
>
> (define ls (port->list read (open-input-string "1 2 3 4")))
> (unless (andmap number? ls)
>   (error "ls not read correctly"))
> (for ([n ls])
>   (displayln (* n n)))
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to