[racket] TR Structure Matching
How does one bind an identifier to the matched structure?
In SML, Scala one can do something along the lines of s at S (x y z)
#lang typed/racket
(struct: Thing ())
(struct: Person Thing ([fname : String] [lname : String]))
(: person-name (Person -> String))
(define (person-name p)
(string-append (Person-lname p) ", " (Person-fname p)))
(define js (Person "Joe" "Smith"))
(: do-it (Thing -> String))
(define (do-it thing)
(match thing
([Person fn ln]
(displayln fn)
(person-name thing))))
This fails as `thing' is not recognized as a Person.
I guess I'm wondering if there is something along the lines of the
following in `match'.
(match thing
(p@[Person fn ln]
(person-name p)))) ;; p is typed as a Person
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121204/bd6f4404/attachment.html>