<div>How does one bind an identifier to the matched structure?</div><div><br></div><div>In SML, Scala one can do something along the lines of s@S (x y z)</div><div><br></div><div><div>#lang typed/racket</div><div><br></div>
<div>(struct: Thing ())</div><div>(struct: Person Thing ([fname : String] [lname : String]))</div><div><br></div><div>(: person-name (Person -&gt; String))</div><div>(define (person-name p)</div><div>  (string-append (Person-lname p) &quot;, &quot; (Person-fname p)))</div>
<div><br></div><div>(define js (Person &quot;Joe&quot; &quot;Smith&quot;))</div><div><br></div><div>(: do-it (Thing -&gt; String))</div><div>(define (do-it thing)</div><div>  (match thing</div><div>    ([Person fn ln]</div>
<div>     (displayln fn)</div><div>     (person-name thing))))</div></div><div><br></div><div>This fails as `thing&#39; is not recognized as a Person.</div><div><br></div><div>I guess I&#39;m wondering if there is something along the lines of the following in `match&#39;.</div>
<div><br></div><div><div>(match thing</div><div>    (p@[Person fn ln]</div><div>     (person-name p)))) ;; p is typed as a Person</div></div><div><br></div>