meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
ikrimael 2020-07-16T00:26:19.057600Z

@noprompt quick question (sorry, no complete snippet, rushed at the moment); is it possible to destructure while "capturing" something

ikrimael 2020-07-16T00:26:31.057700Z

ex:

[ {:op :ophirUseOpnDataLit :as !opdataLits} ...]

jimmy 2020-07-16T00:27:34.058400Z

What you wrote there does work. Not sure what you are looking for.

ikrimael 2020-07-16T00:28:25.058500Z

oops, @jimmy sorry pasted too soon

ikrimael 2020-07-16T00:28:29.058600Z

the array passed in is

[{:op :ophirUseOpnDataLit,
   :name :datalit_smoothArgs,
   :ctypeUid {:op :ophirCuid, :cuidstr :SmoothingChop_PrmBlk_t},
   :fldvalmap
   {:chSmplRate {:op :ophirConst, :ctypeUid :SmplRate_t, :val 1},
    :chStartSmplNum {:op :ophirConst, :ctypeUid :SmplIdx_t, :val 1}}}
  {:op :ophirUseOpnode,
   :name :loPass,
   :opdefUid {:op :ophirOpuid, :opuidstr :smootherchop},
   :oprmblkbnds
   {:op :ophirOprmblkBinds,
    :oprmbnds
    [{:op :ophirOprmbind,
      :prmname :smoothArgs,
      :prmbind {:op :ophirOprmPath, :pathstr "opgrph:./opnodes/opgrphdata/smoothArgs1"}}
     {:op :ophirOprmbind, :prmname :chIn, :prmbind {:op :ophirOprmPath, :pathstr "opgrph:./oprms/inBoneTrk"}}]}}
  {:op :ophirUseOpnode,
   :name :hiPass,
   :opdefUid {:op :ophirOpuid, :opuidstr :smootherchop},
   :oprmblkbnds
   {:op :ophirOprmblkBinds,
    :oprmbnds
    [{:op :ophirOprmbind, :prmname :smoothArgs, :prmbind {:op :ophirOprmPath, :pathstr "opgrph:/loPass/@smoothArgs"}}
     {:op :ophirOprmbind, :prmname :chIn, :prmbind {:op :ophirOprmPath, :pathstr "opgrph:/loPass/@chOut"}}]}}]

jimmy 2020-07-16T00:29:01.059200Z

And you want to get only the ones with a certain op?

ikrimael 2020-07-16T00:29:15.059300Z

i want to extract out {:name :ctypeUid} from the meander filter (but only if it's :op == :ophirUseOpnDataLit)

jimmy 2020-07-16T00:29:40.059900Z

You can use m/gather.

ikrimael 2020-07-16T00:29:51.060Z

i can't figure out how to "crack open" the inner parts through a destructure while keeping a memory variable

jimmy 2020-07-16T00:29:58.060300Z

It is like filter.

ikrimael 2020-07-16T00:30:04.060400Z

ah brilliant; let me look that up

ikrimael 2020-07-16T00:30:44.060500Z

thnx! will come back tonight and update the sample PR with it or ask questions if i stumble

ikrimael 2020-07-16T00:31:04.060600Z

(trying to check something in in <1hr šŸ¤“ )

jimmy 2020-07-16T00:32:11.060800Z

Sounds good.

JAtkins 2020-07-16T02:52:25.063800Z

I think I'm being stupid here, but I'm not sure how... I have seen this error several times now:

Execution error at scratch.overcast-xml/eval19536$fn$fn (overcast_xml.clj:29).
Can't remove struct key
I've solved it a few times now, but I'm still not sure what the causal pattern it is. Here is my most recent example:
(m/search file ; some xml, can provide a subset if needed
    (m/$ {:attrs   {:xmlUrl (m/some ?rss-feed)}
          :content (m/scan {:tag   :outline
                            :attrs !attrs})})
    {:rss ?rss-feed  :attrs !attrs})

noprompt 2020-07-16T04:12:36.065800Z

@jatkin There might be something up how Meander is interacting with the XML library. Do you have, perhaps, a deps.edn and a minimal example that triggers this problem? Iā€™m happy to have a look at it.

JAtkins 2020-07-16T04:20:39.066700Z

Looks like the type is clojure.lang.PersistentStructMap, which maybe doesn't allow dissocing... Which would make sense... It's just clojure.xml

JAtkins 2020-07-16T04:24:21.067300Z

Yup, that's it... Not meander šŸ™‚ Thanks for bringing that up, would never have thought of that!

šŸ‘ 1
JAtkins 2020-07-16T20:55:28.069200Z

So, another possible dumb question: can I unroll results? e.g. I have a match with a capture and a memory variable. can I unroll the result with the single capture reused while all the memory vars are used? My usage rn:

(m/search xml-cleared-structs
    (m/$ {:attrs   {:xmlUrl (m/some ?rss-feed)}
          :content (m/scan {:tag   :outline
                            :attrs {:progress (m/some !progress)
                                    :title    (m/some !title)}}
                     )})
    {:rss ?rss-feed :progresses !progress :titles !title})

;; =&gt; 

({:rss "<https://feeds.transistor.fm/thoughts-on-functional-programming-podcast-by-eric-normand>",
  :progresses ["3642"],
  :titles ["Why Functional Programming Matters"]}
 {:rss "<https://feeds.transistor.fm/thoughts-on-functional-programming-podcast-by-eric-normand>",
  :progresses ["2200" "3190"],
  :titles ["My response to Out of the Tar Pit" "Another Title"]})

noprompt 2020-07-16T22:23:05.070400Z

Is the value on the right of the =&gt; the expected?

JAtkins 2020-07-16T22:29:34.070600Z

The actual

JAtkins 2020-07-16T22:30:37.071300Z

I got a bit closer with this:

(m/search xml-cleared-structs
    (m/$ {:attrs   {:xmlUrl (m/some ?rss-feed)}
          :content [_ ... {:tag   :outline
                           :attrs {:progress (m/some ?progress)
                                   :title    (m/some ?title)}}
                    ]})
    {:rss ?rss-feed :progresses ?progress :titles ?title})
But it only matches the last element in the :content vector

JAtkins 2020-07-16T22:31:05.071900Z

Haven't figured out how to put the zero or more in the right place for this to match everything correctly