[racket] need workaround for bug in match w/ list-no-order and a repeating pattern

From: Sam Tobin-Hochstadt (samth at cs.indiana.edu)
Date: Tue Feb 4 08:34:09 EST 2014

Unfortunately, non-linear patterns (when you use a pattern variable
more than one) and `list-no-order` don't work well together, and
probably won't in the forseeable future.  Supporting this moves
`match` from a pattern matcher into a general search procedure, and
requires quite different algorithms.

For your first example, I'd write:

    (match '(1 1) [(list b b*) #:when (equal? b b*) 'x])

This doesn't work for the larger example you're trying to implement,
which I would just write as a search procedure yourself.

The fact that this doesn't produce a good error message is definitely
a problem, which I'll try to fix soon.


On Tue, Feb 4, 2014 at 4:27 AM, Ryan Davis <zenspider at gmail.com> wrote:
> https://github.com/plt/racket/issues/562
> takikawa helped reduce the reproduction down to:
>   (match '(1 1) [(list-no-order b b) 'x])
> but what I'm actually trying to do is:
>   (match '(...
>            (nand b b w1)
>            ...
>            (nand w1 w1 w2)
>            ...)
>     [(list-no-order `(nand ,a ,a ,b)
>                     `(nand ,b ,b ,c) rest ...)
>      <rewrite c to a in rest>]
>     [else 'bad])
> I'm assuming that this bug is legit, but I know that match is incredibly powerful and assume some sort of workaround for this problem exists. Or there is the possibility of another tool that I don't yet know about. I just want to get this project off the ground to show that it can work. Suggestions / workarounds welcome. Thanks.
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.