I'm playing with Racket-Stamps, which is a mix of typed and regular Racket.
I'm writing a new feature and the code below attempts to call a function with a list of Reals, however because this list comes from untyped racket, it is actually a list of Any:
(define bounding (make-parameter '()))
;; snip
(when (not (empty? (bounding)))
(let-values ([(x1 y1 x2 y2) (apply values (bounding))])
(send pr set-bounding x1 y1 x2 y2)))
And in another file that calls the code above:
(bounding '(-20 -100 100 2))
Here's the error:
Type Checker: Bad arguments to function in `apply': Domains: a b ... b #f * Arguments: (Listof Any) * in: (apply values (bounding))
So how do I convert the Listof Any
to a Listof Real
?
ann
function, so:(define bounding (make-parameter (ann '() (Listof Real))))
-- however I still get the error aboutapply
, maybe it's something to do withmake-parameter
andvalues
? – Eric Clackapply
isn't very smart for most cases in Typed Racket. Especially since you have an arbitrary-length list as input, and a fixed number of values (4 of them) expected as output. – Alex Knauthvalues
, it allows either zero things or one-or-more things, but not zero-or-more things. I would try to design this without using(apply values ...)
. – Alex Knauth(match-let ([(list x1 y1 x2 y2) (bounding)]) ...)
instead, does it work? – Alex Knauthmatch-let
works, many thanks Alex. – Eric Clack