[racket] Typed racket problem

From: Manfred Lotz (manfred.lotz at arcor.de)
Date: Sun Nov 30 16:52:48 EST 2014

On Sun, 30 Nov 2014 22:21:14 +0100
Manfred Lotz <manfred.lotz at arcor.de> wrote:

> No I hadn't considered the variant using type?. Thanks for this. 
> 
> Not quite sure if I'm happy about it as I would prefer to have the
> type checking at one place instead of providing a type each time I
> check/use options.
> 

Saying this I think I like this version:

(define-syntax-rule (optval s ol)
  (let ([found (assoc s ol)])
    (if found
        (let ([val (cdr found)])
          (case s
            ['size (assert val integer?)]
            ['dir (assert val string?)]
            ['verbose (assert val boolean?)]
            [else (error "Forgot to check in optval: option" s)]))
        (error "not found"))))


-- 
Manfred


Posted on the users mailing list.