Problem
In Clojure maps, distribution is often based on the value of a field (e.g., type). When the value changes, the key in the map also changes.
When I pull, I need to specify all possible keys, as I don't know the value of :type.
;; Type :a has keys qualified with ns a, and similarly for type B.
((query '{:type ?type
:a/k1 ?a-k1
:a/k2 ?a-k2
:b/k1 ?b-k1 ;; keys of B must be written when pull
})
{:type :a
:a/k1 1
:a/k2 2})
;;=>
{?type :a
?a-k1 1
?a-k2 2
?b-k1 nil ;; confused.
&? {:type :a
:a/k1 1
:a/k2 2}}
Suggestion
Is it possible to provide a branching design that ensures a one-to-one correspondence between the pattern and the actual data?
Problem
In Clojure maps, distribution is often based on the value of a field (e.g., type). When the value changes, the key in the map also changes.
When I pull, I need to specify all possible keys, as I don't know the value of
:type.Suggestion
Is it possible to provide a branching design that ensures a one-to-one correspondence between the pattern and the actual data?