2 ms·
Well there’s a reason it’s like that — ALL is actually a value, not just a sentinel or keyword. It’s found at com.rpl.specter/ALL. Keywords don’t form a DSL in
by tekacs 6y ago
Well there’s a reason it’s like that — ALL is actually a value, not just a sentinel or keyword. It’s found at com.rpl.specter/ALL.
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. :)