[plt-scheme] match in Typed Scheme

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Thu Feb 18 00:35:03 EST 2010

On Thu, Feb 18, 2010 at 12:14 AM, Hari Prashanth K R <krhari at ccs.neu.edu> wrote:
> Hi,
> I am having trouble using match in Typed Scheme.
> My match looks something like this
> (match trees
>      [(list t1 t2 ts ...) (cons (something t1 t2) ts)]
>      ...)
> trees is of type (Listof (Node A))
> t1, t2 will be of type (Node A) but ts will be of type (Listof Any)..
> What should I do so that ts will be of type (Listof (Node A))?

You should annotate `ts' with the type (Listof (Node A)).  ts is in
binding position, and needs an annotation.  Here's an example:

(match trees
     [(list t1 t2 #{ts : (Listof (Node A))} ...) (cons (something t1 t2) ts)]

sam th
samth at ccs.neu.edu

Posted on the users mailing list.