I'm trying to use polymorphic types in a match pattern and cannot get certain 
type constructions to work.  Here are examples.

match will work for the polymorphic type (Some a) (from the typed racket guide):

(struct: None ())
(struct: (a) Some ([v : a]))  
(define-type (Opt a) (U None (Some a)))
(: f (All (a) ((Opt a) -> String)))
(define (f x)
  (match x
    [(None) "nothing here"]
    [(Some s) (format "found ~a" s)]))

but it seems match is not able to work on a polymorphic type that has been 
specified:

(struct: (a) Record ([values : (HashTable String a)]))
(define-type ValueFlat (U Number (Record Number)))
(: format-value-flat (ValueFlat -> String))
(define (format-value-flat value)
  (match value
    ; [(? number? n) "number"] ;; commented out to show this is not part of the 
problem
    [(Record vs) "record"]))

> Type Checker: Cannot apply expression of type Procedure, since it is not a 
> function type in: (match value ((Record vs) "record"))

Is this a bug in the way match interacts with the type checker, or is there a 
more preferred way to use match that I am missing?

Thanks,
David Darais
_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev

Reply via email to