[racket] [typed] optional parameter

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Fri Nov 11 09:02:38 EST 2011

On Fri, Nov 11, 2011 at 6:22 AM, Eric Tanter <etanter at dcc.uchile.cl> wrote:
> but if I annotate g using case->, the same error happens:
> (: g (case-> (-> Number) (Number -> Number)))
> (define (g [x 10])
>  x)
> Type Checker: Expected Number, but got Any in: (define (g (x 10)) x)
> Can someone explain why this error happens, and how to correctly annotate g?

Unfortunately, Typed Racket needs a little more help from the
programmer here.  This will work:

#lang typed/racket
(: g (case-> (-> Number)
             (Number -> Number)))
(define (g [#{x : Number} 10]) x)

I hope to make what you wrote work eventually, but it doesn't yet.
sam th
samth at ccs.neu.edu

Posted on the users mailing list.