This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-11
Channels
- # announcements (21)
- # aws (2)
- # babashka (20)
- # beginners (47)
- # bristol-clojurians (2)
- # calva (63)
- # cider (24)
- # clj-kondo (22)
- # cljs-dev (3)
- # cljsrn (6)
- # clojars (3)
- # clojure (147)
- # clojure-europe (21)
- # clojure-france (2)
- # clojure-italy (3)
- # clojure-losangeles (1)
- # clojure-nl (3)
- # clojure-spec (2)
- # clojure-uk (70)
- # clojurescript (37)
- # core-logic (6)
- # cursive (4)
- # data-science (2)
- # datomic (99)
- # events (1)
- # figwheel-main (20)
- # fulcro (26)
- # graalvm (6)
- # graphql (5)
- # kaocha (8)
- # leiningen (20)
- # meander (22)
- # nrepl (4)
- # off-topic (27)
- # pathom (5)
- # pedestal (3)
- # re-frame (20)
- # reagent (4)
- # shadow-cljs (43)
- # spacemacs (11)
- # tools-deps (55)
- # tree-sitter (6)
- # vim (8)
- # xtdb (18)
- # yada (14)
Ah, yeah, readability is kind of hard to address because folks have different notions of what that means. However, I would argue that having a large LHS and RHS is maybe not so bad.
FWIW I’ve had good success with defsyntax
(see original thread for example), and with using (m/app)
to do futher transformations.
I see what you mean. It is subjective indeed.
(defsyntax cool-thing [?a ?b]
{:a ?a :b ?b})
Would give you the ability to match and substitute with cool-thing
.Why do you here use those arguments [?a ?b]
?
(m/defsyntax cool-thing [?a ?b]
{:a ?a :b ?b})
(m/match {:a 1 :b 2}
(cool-thing 1 ?b)
?b)
;; => 2
(m/rewrite {:a 1 :b 2}
(cool-thing ?a ?b)
(cool-thing [?a ?a] [?b ?b]))
;; => {:a [1 1], :b [2 2]}
Gonna give this a try.
@ezmiller77 Checkout https://github.com/noprompt/meander/blob/epsilon/doc/defsyntax.md
If anything isn’t clear in the docs or if you want to improve them etc. open a ticket, pull request, or chat here. 🙂
Here’s an example of what I mean by m/app
https://github.com/timothypratley/happygapi/blob/master/dev/happy/beaver.clj#L154 which can be handy if you have deeply nested stuff that you just don’t want to think about 🙂 i.e. defsyntax is great for breaking up patterns but at some point you still have to put them back together somehow so if the putting togeter
and pulling apart
are colocated I think m/app
wins in those cases /shrug
Thanks to you both for the quick responses. Gonna study these links.
Definitely! I think you will find folks here to be helpful. Its rare that a question gets left on the stack without a response.
Normally I might commit this and release, but there were other folks involved in the previous discussions and I want to give them (and others) a chance to share any thoughts before I merge. Tim, I’m looking at you. 🙂
I’ll play around with it tonight
works as advertised :thumbsup: