[racket] Weird typed racket error

From: Alexander D. Knauth (alexander at knauth.org)
Date: Sat Apr 19 21:05:29 EDT 2014

Here’s the program:
#lang typed/racket

(require plot/typed plot/typed/utils)

(: vector-x ((Vectorof Real) -> Real))
(: vector-y ((Vectorof Real) -> Real))
(: vector-z ((Vectorof Real) -> Real))
(define (vector-x v) (vector-ref v 0))
(define (vector-y v) (vector-ref v 1))
(define (vector-z v) (vector-ref v 2))

(: sphere3d (#:posn (Vectorof Real) #:r Nonnegative-Real [#:color Plot-Color] -> renderer3d))
(define (sphere3d #:posn #{ctr.posn : (Vectorof Real)} #:r #{r : Nonnegative-Real} #:color [#{color : Plot-Color} "black"])
  (let: ([ctr.x : Real (vector-x ctr.posn)]
         [ctr.y : Real (vector-y ctr.posn)]
         [ctr.z : Real (vector-z ctr.posn)])
    (isosurface3d (λ: ([x : Real] [y : Real] [z : Real])
                    (let: ([posn : (Vectorof Real) (vector x y z)])
                      (vmag^2 (v- posn ctr.posn))))
                  (ann (sqr r) Real)
                  (ann (- ctr.x r) (U Real False)) (ann (+ ctr.x r) (U Real False))
                  (ann (- ctr.y r) (U Real False)) (ann (+ ctr.y r) (U Real False))
                  (ann (- ctr.z r) (U Real False)) (ann (+ ctr.z r) (U Real False))
                  #:line-style 'transparent
                  #:color color)))

And it returns these errors:
. Type Checker: Expected (Vectorof Real), but got Plot-Color in: (define (sphere3d …) …)
. Type Checker: Expected Nonnegative-Real, but got True in: (define (sphere3d …) …)
. Type Checker: Expected Plot-Color, but got (Vectorof Real) in: (define (sphere3d …) …)
. Type Checker: Expected (Vectorof Real), but got False in: (define (sphere3d …) …)
. Type Checker: Expected Nonnegative-Real, but got False in: (define (sphere3d …) …)
. Type Checker: Expected Plot-Color, but got (Vectorof Real) in: (define (sphere3d …) …)

Why am I getting these?  Is it somehow mixing up the arguments?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140419/c11704b4/attachment.html>

Posted on the users mailing list.