specter

Latest version: 1.1.3
richiardiandrea 2021-02-19T04:46:03.005500Z

is there a way to tell specter - don't stop navigation if a path is not met? I have

(def TREE-VALS
  (specter/recursive-path [] p
    (specter/if-path sequential?
	  [specter/ALL p]
	  specter/STAY)))

(defn strip-key-namespace
  "Recursively strip out namespaces from keywords."
  [m]
  ;; see <https://github.com/redplanetlabs/specter/wiki/Using-Specter-Recursively>
  (specter/setval [TREE-VALS specter/MAP-KEYS specter/NAMESPACE] nil m))
But if the navigator does not find a keyword or a symbol with a namespace it won't go further... I am thinking of tweaking the recursive navigator there but I want to make sure I am not missing something.

richiardiandrea 2021-02-19T16:34:26.006300Z

ended up with a post walk

(def POST-ORDER-TREE-VALS
  (specter/recursive-path [] p
    (specter/cond-path
     map? (specter/continue-then-stay [specter/MAP-VALS p])
     sequential? [specter/ALL p]
     set? [specter/ALL p]
     specter/STAY)))

(defn strip-key-namespace
  "Recursively strip out namespaces from keywords."
  [m]
  ;; see <https://github.com/redplanetlabs/specter/wiki/Using-Specter-Recursively>
  (specter/setval [POST-ORDER-TREE-VALS
                   specter/MAP-KEYS
                   qualified-keyword?
                   specter/NAMESPACE] nil m))
seems to work well in the tests