core.logic

Unification with partial-map fails when a map contains a map value with extra keys

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • 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)))))

Activity

Hide
David Nolen added a comment -

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.

Show
David Nolen added a comment - 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.
Hide
Hugo Duncan added a comment -

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)))
Show
Hugo Duncan added a comment - 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)))

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: