Like SQL for nested maps in Clojureland. Neat. The DSL [ALL :a even?] does feel a tiny bit un-clojurey to me as well, maybe making it look like [:all :a even?] would make it clearer.
Keywords don’t form a DSL in Specter, they just do keyword navigation into maps, the same way ‘0’ navigates into the first element of a list.
This touches upon a really nice element of Specter, which is its pattern for reuse. Here’s a very real but deliberately simple example of using it:
(def chat-threads
{[“sova” “tekacs”]
[{:text [“hey” “you there?”]}
{:text [“line 1” “line 2”]}]})
(def ALL-TEXT
[sr/ALL :text sr/ALL])
(defn text-for [chat]
(sr/select [chat ALL-TEXT]))
(def ALL-CHAT-TEXT
[sr/MAP-VALS ALL-TEXT])
(text-for [“sova” “tekacs”]) ;=> [...]
Here the navigator into a list, then the :text field and then the list is bottled simply by putting several navigators in a vector.Then, it can be used alongside other navigators in a first class fashion — [chat ALL-TEXT] is just a nested vector. :)
{:all {:a 2} :foo {:a 4}}
Maybe namespaced keys would fit that usecase