[racket] Question about match in typed/racket
That fixes it for me. Thanks, both of you!
On Thu, Apr 12, 2012 at 12:27 AM, Sam Tobin-Hochstadt <samth at ccs.neu.edu>wrote:
> On Wed, Apr 11, 2012 at 3:36 PM, Timothy Nelson <tbnelson at gmail.com>
> wrote:
> >
> > I'd like to write a function that consumes an s-expression and produces a
> > struct -- something similar to building a tree struct out of a tree
> sexp. In
> > the past, I've always used match for this kind of sexp manipulation.
> > However, if I have a match clause within a function like this:
> >
> > (: my-func (Sexp -> mystruct))
> > (define (my-func s)
> > (match s
> > [(list args ...) (make-mystruct (map my-func args))]))
>
> The problem here is that Typed Racket can't guess what type you mean
> for `args' to have, so you have to tell it when you bind `args'. That
> looks like this:
>
> (: my-func (Sexp -> mystruct))
> (define (my-func s)
> (match s
> [(list #{args : (Listof Sexp)} ...)
> (make-mystruct (map my-func args))]))
>
> which typechecks correctly for me.
> --
> sam th
> samth at ccs.neu.edu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120412/d920a83e/attachment-0001.html>