meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
grounded_sage 2020-03-24T08:53:21.031100Z

Is there a reason for the vector pairs here?

grounded_sage 2020-03-24T08:53:49.031300Z

As I just tried

{& {:first_name ?first-name, 
                 :email !emails, 
                 :email_2 !emails, 
                 :phone !phones, 
                 :phone_2 !phones}}
and it appears to give the same result.

jimmy 2020-03-24T13:58:00.031500Z

Yes because as your map grows it will be parsed out of order and the memory variables will be in the wrong place. I think it is 8 elements when that happens?

1👍
grounded_sage 2020-03-24T18:47:50.031700Z

Ah I see.

niclasnilsson 2020-03-24T21:16:59.036300Z

The … and lists are kind of apparent, but I don’t get how to use something similar with maps. If I have an input like

{:properties {:a {:type :int} :b {:type :string}}
and want the result
{:properties 
 [{:name :a :type :int} {:name :b :type :string}]}
What would be idiomatic meander way of doing that? The … is not apparent to me how to use in the map case. Using search, we’d get one {:properties [ . . .] } structure per property, instead of a map.

noprompt 2020-03-24T21:32:48.038300Z

We just added map-of and sub map-of operators but you can also use seqable if you’re not in a situation to have multiple solutions

noprompt 2020-03-24T21:38:30.038600Z

(m/rewrite {:properties {:a {:type :int} :b {:type :string}}}
  {:properties (m/map-of !name {:type !type})}
  {:properties [{:name !name, :type !type} ...]})
;; =>
{:properties [{:name :a, :type :int} {:name :b, :type :string}]}

noprompt 2020-03-24T21:39:46.039600Z

(m/rewrite {:properties {:a {:type :int} :b {:type :string}}}
  {:properties (m/seqable [!name {:type !type}] ...)}
  {:properties [{:name !name, :type !type} ...]})
;; =>
{:properties [{:name :a, :type :int} {:name :b, :type :string}]}

noprompt 2020-03-24T21:42:42.041400Z

One thing we haven’t gotten around to doing is making the

{& [[k v] ...]}
syntax work for pattern matching. It works for substitution due to the fact that & is works like into

niclasnilsson 2020-03-24T22:02:24.042100Z

Thanks, that was much, much nicer that what we had. Will try this on deeper nested maps as well.

noprompt 2020-03-24T22:07:43.042500Z

No problem. I’m here to help if I can. 🙂