faster-minikanren icon indicating copy to clipboard operation
faster-minikanren copied to clipboard

Support variable unification in matche patterns

Open Reilithion opened this issue 7 years ago • 1 comments

When given an existing variable name in a pattern, matche appears to treat it as a new variable. Example:

(run 2 (q r) (matche (r) (((Foo ,q))) (((Bar ,q)))) (== q 'Qux))
'((Qux (Foo _.0)) (Qux (Bar _.0)))

I expected the output to be '((Qux (Foo Qux)) (Qux (Bar Qux))).

I glanced at the paper describing the implementation of matche, lambdae, and defmatche and the problems encountered therein, but this didn't look like one of them. Is this feature doable?

Reilithion avatar Feb 08 '18 19:02 Reilithion

Upon reflection (and reading an e-mail from B), I realize this is the expected and desirable behavior. Nevertheless, it would be nice to be able to support unification in matche patterns by referencing variables in the patterns themselves. Perhaps it would make sense to use different syntax when referencing a variable than when introducing one.

Reilithion avatar Feb 09 '18 19:02 Reilithion