[LOGIC-72] Unification with partial-map fails when a map contains a map value with extra keys Created: 22/Nov/12 Updated: 23/Nov/12 Resolved: 23/Nov/12 |
|
| Status: | Resolved |
| Project: | core.logic |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Hugo Duncan | Assignee: | David Nolen |
| Resolution: | Declined | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Patch: | Code and Test |
| Description |
|
Unification fails for partial-map when there is a partial match on a sub-map. A failing test case: (is (= '[#clojure.core.logic.PMap{:a {:b 2}}]
(run* [q]
(fresh [pm x]
(== (partial-map {:a {:b x}}) pm)
(== {:a {:b 2 :c 3}} pm)
(== q pm)))))
|
| Comments |
| Comment by Hugo Duncan [ 23/Nov/12 3:55 PM ] |
|
As mentioned by Kevin Lynagh, this can be achieved using walk-term, and I agree the behaviour is better off being explicit. (defn ->pmap [x]
(if (map? x)
(l/partial-map x)
x))
(l/unifier target (->pmap (l/walk-term my-map ->pmap)))
|
| Comment by David Nolen [ 23/Nov/12 3:58 PM ] |
|
having partial-map implicitly recurse is undesirable. It's easy to achieve the desired behavior now that we have a reusable walk-term built into core.logic. |