[racket] Typed racket problem
Hi there,
I've got another problem with typed racket.
Let us say I have an assoc list with options for a program. These
options could be of type String, Boolean, or Integer.
Now in my program I want to check certain options but I don't know how
to do without Typed Racket screaming at me.
Here a minimal example:
#lang typed/racket
(define-type Myopt (U String Boolean Integer))
(define-type OptList (Listof (Pairof Symbol Myopt)))
(: olist OptList)
(define olist (list '(dir . ".")
'(verbose . #t)
'(size . 12)))
(: optval (-> Symbol OptList Myopt))
(define (optval v ol)
(let ([val (assoc v ol)])
(if val
(cdr val)
(error "Unexpected option encountered"))))
(: process (-> OptList Void))
(define (process ol)
(if (< (optval 'size ol) 0)
(displayln "wrong value")
(displayln "ok")))
I get an error:
Type Checker: type mismatch
expected: Real
given: Myopt
in: (optval (quote size) ol)
How could I solve this?
--
Thanks,
Manfred