[plt-scheme] Typed scheme and varying arity

From: Sam Phillips (samdphillips at gmail.com)
Date: Fri Apr 30 12:35:19 EDT 2010

Hi,

I'm having trouble trying to type a function that behaves like
the following in typed/scheme.

(define (foo a . bs)
  (box
    (for/list ([e (in-list (cons a bs))])
      (unbox e))))

I can type the uniform case easily ...

(: foo (All (a) ((Boxof a) (Boxof a) * -> (Boxof (Listof a)))))
(define (foo a . bs)
  (box
    #{ (for/list ([e (in-list (cons a bs))])
         (unbox e)) :: (Listof a) }))

... but I can't seem to get the function signature correct for
the varying case.

(: foo
  (All (a b ...)
    ((Boxof a) (Boxof b) ... b -> (Boxof (List b ... b)))))

Type Checker: Type variable b must be used with ... in: b

Cheers,
Sam


Posted on the users mailing list.