[racket] the typed Values restriction

From: Sam Tobin-Hochstadt (samth at cs.indiana.edu)
Date: Wed Mar 18 17:01:51 EDT 2015

Type variables range only over types, and `(Values A B)` isn't a type.
If your program type checked, then the following program would too:

(: my-force : (All (A) (-> A) -> A))
(define (my-force f)
  (let ([tmp : A (f)]) tmp))

(my-force (lambda () (values (void) (void)))

but this program has a runtime error with the wrong number of values.

Sam

On Wed, Mar 18, 2015 at 4:48 PM, Benjamin Greenman <blg59 at cornell.edu> wrote:
> Today I got a surprising type error that I think is worth sharing.
>
> (: my-force (All (A) (-> (-> A) A))
> (define (my-force x) (x))
>
> (my-force (lambda () (values (void) (void)))
> ;; ERROR! 'my-force' cannot be applied to argument.
> ;; expected "(-> A)", got "(-> (values Void Void))"
> ;; result type "A", expected result "AnyValues"
>
> (inst my-force (Values Void Void))
> ;; Parse Error in type: "Values" is unbound
>
> That is all. I see now that Values is only allowed in result positions, but
> I'd still expected this to work.
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

Posted on the users mailing list.