[racket] typed racket error
I’m trying to make a multiplication function that can take either all numbers or all numbers and one vector, and have it not matter what order they come in. To do this, I’m using match with list-no-order:
#lang typed/racket
(require plot/typed/utils)
(define listof-number?
(make-predicate (Listof Number)))
(: my* (case->
(-> One)
(Number Number * -> Number)
((Vectorof Real) Real * -> (Vectorof Real))
(Real (Vectorof Real) Real * -> (Vectorof Real))
(Real Real (Vectorof Real) Real * -> (Vectorof Real))
(Real Real Real (Vectorof Real) Real * -> (Vectorof Real))
(Real Real Real Real (Vectorof Real) Real * -> (Vectorof Real))))
; if I could, I would do this:
; (Real * (Vectorof Real) Real * -> (Vectorof Real))
(define my*
(case-lambda
[() 1]
[args (match args
[(list-no-order (? vector? v) (? real? ns) ...)
(v* v (apply * ns))]
[(? listof-number? ns)
(apply * ns)])]))
It’s giving me these errors:
. Type Checker: Expected One, but got Number in: (apply * ns) ; why is it expecting One there?
. Type Checker: Expected (Vectorof Real), but got Any in: v ; the type shouldn’t be Any, it should at least
; be VectorTop, and with the type annotation
; for my* should tell it that all of the
; vectors are (Vectorof Real), right?
. Type Checker: Bad arguments to function in apply: ; shouldn’t it be able to tell that ns is a
Domains: Number * ; (Listof Number), especially since
Arguments: (Listof Any) * ; listof-number? was defined with
in: (apply * ns) ; make-predicate?
. Type Checker: Expected One, but got (Vectorof Real) in: (v* v (apply * ns)) ; why is it expecting One?
. Type Checker: Expected Number, but got (Vectorof Real) in: (v* v (apply * ns)) ;why is it expecting Number?
. Type Checker: Expected (Vectorof Real), but got Number in: (apply * ns);whyis it expecting (Vectorof Real)?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140420/4371da0c/attachment.html>