On Fri, Nov 11, 2011 at 12:07 PM, Paul Leger <ple...@gmail.com> wrote: > On 11/11/2011 11:02 AM, Sam Tobin-Hochstadt wrote: >> >> 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. > > I think this solution does not work if you are using modules. For example: > > (module my-module typed/racket > > (: g (case-> (-> Number) > (Number -> Number))) > > (define (g [#{x : Number} 10]) a) > ) > > The type-checker says: > "define: not an identifier, identifier with default, or keyword for > procedure argument in: (#(x : Number) 10)" > > Do I need a extra piece of code If I want to use a function with optional > parameters inside of a module?
The "#{...}" thing needs the cooperation of the #lang line, rather than the (module ...) form that you're using for writing your module. Try writing your module with #lang typed/racket, like this: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #lang typed/racket (: g (case-> (-> Number) (Number -> Number))) (define (g [#{x : Number} 10]) x) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users