meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
timothypratley 2020-08-26T04:23:18.175700Z

Ah right, I meant that the notion that for all patterns p the semantics do not change …. #{^& ?rest} is arguably already breaking that (in an expected way) or is it ok because the metadata makes it different? In which case is #{^… !k} ok? Is {^... !k !v} ok?

timothypratley 2020-08-26T04:34:14.176600Z

I kinda like {^… !k !v} to be honest… o_O

yuhan 2020-08-26T05:15:29.189300Z

@timothypratley Another idea for #130: extend the familiar & syntax:

{&... [!k !v]}
;; desugars intuitively to 
{& (m/seqable [!k !v] ...)}

;; or

{&!k !v} ;; implicitly includes !v in the repeating pattern

;; or 

{&!k &!v} ;; over-specification? 
There is already precedence in ..?n for splitting a symbol up into components to bind ?n

timothypratley 2020-08-26T13:16:38.190700Z

I agree and I like the {&!k !v} notation! That seems very intuitive to me and I like that it doesn’t use metadata. I think this would be really cool and work well!

yuhan 2020-08-26T05:18:50.190600Z

This would also apply to sets: #{ &!x } looks better to me than using metadata #{ ^& !x }

timothypratley 2020-08-26T13:25:46.190900Z

+1 I think this looks way better than the metadata and I find it clearer about the structure (metadata is always weird because it looks like another element). I think this works still for expression: #{(m/pred int? &!x) &?more} seems possible and very cool 🙂

scarrucciu 2020-08-26T19:57:29.192800Z

All, just getting started with meander, and trying to match against a pattern of keys within a map to return in a search. For example

(defn testm [input]
  (m/search input
    (m/scan {(m/re #"LX") ?result})
    {:result ?result}))

(testm {"LX-1" "a" "LX-2" "b"})

scarrucciu 2020-08-26T19:59:19.193Z

where I would want to result to be

({:result "a"} {:result "b"})
is this possible?

chucklehead 2020-08-26T20:10:15.193200Z

I think this will do what you want:

(defn testm [input]
  (m/search input
            {(m/re #"LX.*") ?result}
            {:result ?result}))

➕ 1
scarrucciu 2020-08-26T20:36:27.193500Z

Thank you, if I wanted to nest that part in a broader transformation (say there were other keys that I was applying a transformation to), would you recommend apply different m/search’s and then composing the results?

jimmy 2020-08-26T20:40:32.193700Z

It all depends on what you are wanting to accomplish. You can do other keys as well inside the same search. There is no limitation on that. For example:

(m/search {"LX-1" "a" "LX-2" "b" :x 1 :y 2}
  {(m/re #"LX.*") ?result
   :x ?x
   :y ?y}
  {:result ?result
   :x (even? ?x)
   :y (even? ?y)})

chucklehead 2020-08-26T20:41:03.193900Z

I'm fairly new to meander myself, so take anything I say with a grain of salt, but most of what I have been doing is matching/transforming nested maps and I rarely have to use more than one top-level rewrite/search/etc.

scarrucciu 2020-08-26T23:26:14.194100Z

thank you, that is really helpful, attempting to translate a bunch of custom transformation base clojure to meander, so very much in the easy stages of understanding what it can do.