Fork me on GitHub
#meander
<
2020-03-11
>
noprompt00:03:36

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.

timothypratley00:03:47

FWIW I’ve had good success with defsyntax (see original thread for example), and with using (m/app) to do futher transformations.

noprompt00:03:53

But, again, that perspective is context sensitive.

noprompt00:03:05

Oh, yeah, thats a nice way to do it.

noprompt00:03:20

Actually, I recently used defsyntax for just that purpose

Ethan Miller00:03:47

I see what you mean. It is subjective indeed.

noprompt00:03:52

(defsyntax cool-thing [?a ?b]
  {:a ?a :b ?b})
Would give you the ability to match and substitute with cool-thing.

Ethan Miller00:03:47

Why do you here use those arguments [?a ?b]?

noprompt00:03:25

Out of habit. 🙂

noprompt00:03:00

(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]}

Ethan Miller00:03:32

Gonna give this a try.

noprompt00:03:56

If anything isn’t clear in the docs or if you want to improve them etc. open a ticket, pull request, or chat here. 🙂

timothypratley00:03:58

Here’s an example of what I mean by m/apphttps://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

Ethan Miller00:03:37

Thanks to you both for the quick responses. Gonna study these links.

noprompt00:03:11

Definitely! I think you will find folks here to be helpful. Its rare that a question gets left on the stack without a response.

noprompt00:03:02

Coincidentally, I do need to step away for a moment. 🙂

noprompt05:03:27

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. 🙂

timothypratley13:03:08

I’ll play around with it tonight

timothypratley01:03:11

works as advertised :thumbsup: