the beauty of extracting JIRA api response with meander, really ❤️ it
(defn format-issues [issues]
(me/search issues
(me/scan {:fields {:summary ?summary
:assignee {:displayName ?assignee}
:status {:name ?status}}})
{:summary ?summary
:assignee ?assignee
:status ?status}))
and now I have too handle some nils ...
(defn format-issues [issues]
(me/search issues
(me/scan {:fields {:summary ?summary
:assignee (me/or (me/let [?assignee nil]
nil)
{:displayName ?assignee})
:status {:name ?status}}})
{:summary ?summary
:assignee ?assignee
:status ?status}))
time for some defsyntax!
(defn logic-variable? [x]
(and (symbol? x)
(str/starts-with? (name x) "?")))
;; (logic-variable? '?x)
;; => true
(defn extract-logic-variables [m]
(sp/select (sp/walker logic-variable?) m))
;; (extract-logic-variables '{:a ?a :b ?b :c "?c" :d :?d})
;; => [?a ?b]
(me/defsyntax maybe-map
[m]
(if (me/match-syntax? &env)
`(me/or
(me/let ~(->
(extract-logic-variables m)
(interleave (repeat nil))
vec)
nil)
~m)
&form))
(defn format-issues [issues]
(me/search issues
(me/scan {:fields {:summary ?summary
:assignee (maybe-map {:displayName ?assignee})
:status {:name ?status}}})
{:summary ?summary
:assignee ?assignee
:status ?status}))
I know you got a nice little defsyntax for this. Just wanted to point out this little and
idiom.
(defn format-issues [issues]
(m/search issues
(m/scan {:fields {:summary ?summary
:assignee (m/or (m/and nil ?assignee)
{:displayName ?assignee})
:status {:name ?status}}})
{:summary ?summary
:assignee ?assignee
:status ?status}))
I'm curious, has anyone put any thought into a symbolic syntax for Meanderlang?
The two closest cousins I can find are Dyalog APL and the mathematical field of topology
Or maybe those things like me/scan
macroexpand into a more verbose data literal syntax?
@goomba Yes. me/scan
essentially expands to
(m/seqable _ … p1 ,,, pN . _ ...)
which expands to
(m/pred seqable? (m/app seq (_ ... p1 ,,, pN . _ ...))
Originally, me/scan
expanded to
(m/or (_ ... p1 ,,, pN . _ ...)
[_ ... p1 ,,, pN . _ ...))
but this expansion could result in large code explosions which is a problem which still needs to be addressed.