[racket] the typed Values restriction
It might be a good idea to have a special case for Values when producing error messages. Currently, even though the documentation mentions that Values is only valid as the return type of a function, the error messages can be a little confusing. For example, using Values as an expression produces the error “type name used out of context,” but it isn’t really a type.
> On Mar 18, 2015, at 14:01, Sam Tobin-Hochstadt <samth at cs.indiana.edu> wrote:
>
> 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
>>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users