[plt-scheme] match in Typed Scheme

From: Hari Prashanth K R (krhari at ccs.neu.edu)
Date: Thu Feb 18 00:39:33 EST 2010



----- Original Message -----
From: "Sam Tobin-Hochstadt" <samth at ccs.neu.edu>
To: "Hari Prashanth K R" <krhari at ccs.neu.edu>
Cc: "plt-scheme" <plt-scheme at list.cs.brown.edu>
Sent: Thursday, February 18, 2010 12:35:03 AM GMT -05:00 US/Canada Eastern
Subject: Re: [plt-scheme] match in Typed Scheme

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.