[plt-scheme] Case lambda in typed scheme

From: Sam TH (samth at ccs.neu.edu)
Date: Thu Mar 19 08:29:58 EDT 2009

On Thu, Mar 19, 2009 at 8:09 AM, Paulo J. Matos <pocmatos at gmail.com> wrote:
> I will file it as a bug but why do I need case-lambda: ?
> I thought I would need it only if I didn't annotate the type of foo
> function. But I do annotate it with
>  (: foo (case-lambda [-> Symbol]
>                    [Symbol -> Symbol]))
> the type of s is defined to be a symbol there... in the second line by
> saying, Symbol -> Symbol, right?

When you write:

(: bar (Number -> Number))
(define (bar x) (+ 1 x))

Typed Scheme figures out from the type that `x' must have type Number.
 But it doesn't do anything as sophisticated for `case-lambda', partly
because `case-lambda' in types allows more things than can be written
with `case-lambda' in expressions.  But it should do this, which is
why it's a bug.
sam th
samth at ccs.neu.edu

Posted on the users mailing list.