faster-minikanren
faster-minikanren copied to clipboard
Support variable unification in matche patterns
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?
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.