[racket] Typed racket: keywords and rest arguments

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Sat Mar 9 09:56:59 EST 2013

This looks like a bug -- the code probably doesn't handle the way this
combination is encoded.

Sam

On Sat, Mar 9, 2013 at 8:33 AM, Norman Gray <norman at astro.gla.ac.uk> wrote:
>
> Greetings.
>
> (this is a separate typed-racket question, and I think distinct from the questions I was asking last month)
>
> I don't seem to be able to specify a type for a function with rest arguments and optional keywords.  The following fails to typecheck (Racket 5.3.3)
>
> (: appender (String String * [#:k String] -> String))
> (define (appender s1 #:k (v #f) . sx)
>   (let loop ((l sx)
>              (res (string-append s1 (or v "-x-"))))
>     (if (null? l)
>         res
>         (loop (cdr l) (string-append res (car l))))))
>
> -> Type Checker: Expected a function of type (case-> (String True String String * -> String) (False False String String * -> String)), but got a function with the wrong arity in: (define (appender s1 #:k (v #f) . sx) (let loop ((l sx) (res (string-append s1 (or v "-x-")))) (if (null? l) res (loop (cdr l) (string-append res (car l))))))
>
> Similar functions work, with types (: appender (String String * -> String)) and (: appender (String String [#:k String] -> String)), so I don't think I'm messing up the syntax.
>
> Best wishes,
>
> Norman
>
>
> --
> Norman Gray  :  http://nxg.me.uk
> SUPA School of Physics and Astronomy, University of Glasgow, UK
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users


Posted on the users mailing list.