Fork me on GitHub

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.


But, again, that perspective is context sensitive.


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


Actually, I recently used defsyntax for just that purpose

Ethan Miller00:03:47

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.

Ethan Miller00:03:47

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


Out of habit. 🙂


(m/defsyntax cool-thing [?a ?b]
  {:a ?a :b ?b})

(m/match {:a 1 :b 2}
  (cool-thing 1 ?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.


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


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


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


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: