redplanetlabs / specter

Clojure(Script)'s missing piece
Apache License 2.0
2.51k stars 102 forks source link

No implementation of method: :kv-reduce of protocol: IKVReduce #301

Closed ertugrulcetin closed 3 years ago

ertugrulcetin commented 3 years ago

Hi, I'm getting No implementation of method: :kv-reduce of protocol: #'clojure.core.protocols/IKVReduce found for class: clojure.lang.LazySeq error.

Here is my code;

(def MAP-NODES
  (s/recursive-path [] p
                    (s/cond-path
                     sequential? (s/continue-then-stay s/MAP-VALS p)
                     map? (s/continue-then-stay s/MAP-VALS p))))

Here is my fn:

(defn trim-titles [data]
  (s/transform [MAP-NODES #(and (map? %) (:title %)) :title] str/trim data))

data is a huge deeply nested data structure.

Small sample from the data;

....
{:title "COV_SYMPTOMS_ANOSMIE?",
 :id "06ecdd34-1e9d-48e5-b913-ed93a1677102",
 :children {:attached [{:id "bf1f0a4a-5f16-48bf-9fcb-f2930cdd354b",
 :title "YES",
 :children {:attached [{:title "LANGUAGE?",
                                      :id "39c61696-3037-4247-8b70-5b7180caa5f5",
                                       children {:attached [{:title "EN",
                                                                           :id "08c8f077-b1ce-4b38-8f53-1faa4dc0cd64",
...                                             
nathanmarz commented 3 years ago

Looks like you meant to use ALL on sequential? branch instead of MAP-VALS.

ertugrulcetin commented 3 years ago

@nathanmarz thanks, my mistake