Re: [racket] Typed racket and command line parameters

2014-06-22 Thread Matthias Felleisen
Conceptually you want to signal the error out of the 'parms' computation. So even if you introduce string->real as a variation on string->number, you probably want to catch the error it raises and re-cast it as 'params' message. On Jun 22, 2014, at 12:56 PM, Manfred Lotz wrote: > On Sun, 2

Re: [racket] Typed racket and command line parameters

2014-06-22 Thread Manfred Lotz
On Sun, 22 Jun 2014 11:58:59 -0400 Sam Tobin-Hochstadt wrote: > Fortunately, one of those casts can be eliminated with a bit of type > annotation on `NUM`. Full code here: > https://gist.github.com/samth/48bf2ccb2c510c75017e > > (define parms > (command-line >#:program "mypgm" >#:onc

Re: [racket] Typed racket and command line parameters

2014-06-22 Thread Manfred Lotz
On Sun, 22 Jun 2014 11:25:01 -0400 Matthias Felleisen wrote: > > I would use Real for the parameter type and then cast twice: > > (define parms > (command-line >#:program "mypgm" >#:once-each >[("-v" "--verbose") "Show verbose output" (opt-verbose-mode #t)] >[("-m" "--max-siz

Re: [racket] Typed racket and command line parameters

2014-06-22 Thread Sam Tobin-Hochstadt
Fortunately, one of those casts can be eliminated with a bit of type annotation on `NUM`. Full code here: https://gist.github.com/samth/48bf2ccb2c510c75017e (define parms (command-line #:program "mypgm" #:once-each [("-v" "--verbose") "Show verbose output" (opt-verbose-mode #t)] [(

Re: [racket] Typed racket and command line parameters

2014-06-22 Thread Matthias Felleisen
I would use Real for the parameter type and then cast twice: (define parms (command-line #:program "mypgm" #:once-each [("-v" "--verbose") "Show verbose output" (opt-verbose-mode #t)] [("-m" "--max-size") NUM ("Max size." "NUM") (opt-max-size (cast (string->number (ca

Re: [racket] Typed racket and command line parameters

2014-06-21 Thread Manfred Lotz
On Sat, 21 Jun 2014 10:12:27 -0400 "Alexander D. Knauth" wrote: > The first thing I notice is that opt-max-size is a (Parameterof Any), > but you use string->number on it. So you should probably put a guard > on the opt-max-size parameter something like this: (: opt-max-size > (Parameterof Any Re

Re: [racket] Typed racket and command line parameters

2014-06-21 Thread Alexander D. Knauth
The first thing I notice is that opt-max-size is a (Parameterof Any), but you use string->number on it. So you should probably put a guard on the opt-max-size parameter something like this: (: opt-max-size (Parameterof Any Real)) (: opt-max-size-guard (Any -> Real)) (define (opt-max-size-guard