This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-28
Channels
- # babashka (167)
- # beginners (91)
- # calva (24)
- # chlorine-clover (5)
- # cider (14)
- # clj-kondo (15)
- # cljdoc (20)
- # clojure (122)
- # clojure-czech (1)
- # clojure-europe (31)
- # clojure-france (2)
- # clojure-nl (5)
- # clojure-spec (8)
- # clojure-uk (7)
- # clojurescript (29)
- # conjure (2)
- # cursive (4)
- # data-science (4)
- # datomic (13)
- # figwheel-main (13)
- # fulcro (21)
- # lambdaisland (4)
- # meander (10)
- # observability (7)
- # off-topic (15)
- # overtone (4)
- # pathom (5)
- # pedestal (6)
- # re-frame (9)
- # reitit (13)
- # remote-jobs (2)
- # ring (1)
- # rum (5)
- # shadow-cljs (24)
- # spacemacs (19)
- # test-check (18)
- # tools-deps (82)
- # tree-sitter (1)
- # xtdb (35)
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}))
❤️ 3
🚀 3
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}))
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}))
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'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?
@U3BALC2HH Yes. me/scan
essentially expands to
(m/seqable _ … p1 ,,, pN . _ ...)
which expands to
(m/pred seqable? (m/app seq (_ ... p1 ,,, pN . _ ...))