[racket] Question about match in typed/racket

From: Timothy Nelson (tbnelson at gmail.com)
Date: Wed Apr 11 15:36:48 EDT 2012

Dear All,

I have recently been trying out typed/racket with an eye toward using it in
my regular programming. I've hit a snag, and hopefully it's a newbie
mistake that you folks can set right.

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 type of args is (Listof Any), not (Listof Sexp), and thus my-func
cannot be applied to it.

But if I have a clause like this:
[(list a) (make-mystruct (my-func a))]
the type of a is Sexp.

Am I misusing the Sexp type somehow?

Thanks for your time,
- Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120411/a0f8b948/attachment.html>

Posted on the users mailing list.