meander

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

@noprompt added a new example: Split stream based on filter and project https://github.com/noprompt/meander/blob/e562f563c42adf3763919dc7fb9cbab3b9c19b24/doc/cookbook.md#transform slowly getting the hang of things

ikrimael 2020-07-11T00:23:17.032100Z

part i struggled with is applying an or predicate on a pattern that can match multiple times

ikrimael 2020-07-11T00:24:13.033100Z

ie, i have an array of objects with a bitflag (possible values: EArgIn, EArgIn |EArgOut, EArgOut )

ikrimael 2020-07-11T00:24:47.033800Z

i want to split them into an arg array of inputs and outputs but fields that had ArgIn|ArgOut would only show up in one of the arrays

noprompt 2020-07-11T00:26:08.034600Z

Are you still struggling with this?

ikrimael 2020-07-11T00:26:14.035Z

heh, yeah. i finally gave up on it

noprompt 2020-07-11T00:26:19.035300Z

Ha!

ikrimael 2020-07-11T00:26:26.035600Z

and marked "feature not supported" šŸ˜›

ikrimael 2020-07-11T00:26:56.036200Z

(obvi jk, but i just let it be for now)

ikrimael 2020-07-11T00:27:32.037500Z

(meta: i also have to say I absolutely love once I manage to get things in meander. everything is instantly grokkable days later)

noprompt 2020-07-11T00:27:37.037700Z

Sure, sure. If you have a vanilla Clojure implementation and I might be able to supply a pattern for it.

noprompt 2020-07-11T00:28:19.039Z

Iā€™m really excited about the stuff youā€™re playing around with e.g. the C++ stuff because, really, this was the kind of space I wanted Meander to fit in to i.e. AST transforms, etc.

ikrimael 2020-07-11T00:28:36.039400Z

yeah, it's literally the whole reason i'm using it

ikrimael 2020-07-11T00:28:48.040100Z

i always hate how complicated term rewriting was for basic things

ikrimael 2020-07-11T00:28:59.040500Z

re: code - sure, it's in the link. i tried to make it self contained so you can copy paste it

noprompt 2020-07-11T00:29:29.041400Z

Gradually, Iā€™m realizing that what I want is essentially a DCG sort of thing but richer a bit different from whats on offer in Prolog and integrated with Clojure.

šŸ‘Œ 1
ikrimael 2020-07-11T00:30:14.042500Z

each variant is a different tactic i tried (i kept it in the doc bc it helps shows the difference between {search , match} x {memory vars, logic vars}

noprompt 2020-07-11T00:32:22.043600Z

I should have some more time over the weekend to review stuff, help with questions, etc.

ikrimael 2020-07-11T00:32:31.043900Z

sure, np

noprompt 2020-07-11T00:32:50.044700Z

Youā€™ve captured my attention. šŸ™‚

ikrimael 2020-07-11T00:32:50.044800Z

and no rush; i basically just queue up everything and using that PR as a working draft

ikrimael 2020-07-11T00:33:21.045500Z

my goal is once I finish writing this part of my dsl compiler in clojure to come back and edit the PR draft to final form

noprompt 2020-07-11T00:33:43.046300Z

Sure. Just let me know what you need on that e.g. ā€œCan you fill in this blank or that blank?ā€ sort of thing.

ikrimael 2020-07-11T00:33:50.046600Z

šŸ‘

noprompt 2020-07-11T00:34:23.047200Z

For stuff youā€™re stuck on, a Clojure implementation can help. If I canā€™t map it, Iā€™ll be honest about that.

ikrimael 2020-07-11T00:35:21.047900Z

would you prefer a straight clojure implementation or is higher level pseudocode better?

ikrimael 2020-07-11T00:36:13.049Z

ex: I wrote this as what i was trying to do and then tried to figure out how to get meander to map it

filter(
  (predA? x) => (projA x) :as !projAseq
  (predB? x) => (projB x) :as !projBseq
)

noprompt 2020-07-11T00:40:29.050Z

So I think that is

(m/or (m/pred predA? (m/app projA !projASeq))
      (m/pred predB? (m/app projB !projBSeq)))

noprompt 2020-07-11T00:41:02.051Z

Either is fine though, if Iā€™m confused Iā€™ll ask. šŸ™‚

šŸ‘ 1
ikrimael 2020-07-11T00:55:20.051900Z

hmm, still can't get it to work

ikrimael 2020-07-11T00:55:41.052400Z

Simplified snippet:

(def arglist [{:name :inBoneTrk    :argFlags #{:EArg-In}}
              {:name :inoutBoneTrk :argFlags #{:EArg-In :EArg-Out}}
              {:name :outBoneTrk   :argFlags #{:EArg-Out}}])
(m/match
 arglist
  [(m/or (m/pred #(contains? %1 :EArg-In) (m/app :name !projASeq))
         (m/pred #(contains? %1 :EArg-Out) (m/app :name !projBSeq)))
   ...]
  {:in-args !projASeq
   :out-args !projBSeq})

ikrimael 2020-07-11T00:58:44.053500Z

Actual: Error: nonĀ exhaustiveĀ patternĀ match Expected:

{:in-args [:inBoneTrk :inoutBoneTrk]
 :out-args [:outBoneTrk :inoutBoneTrk]}

noprompt 2020-07-11T02:11:10.054Z

(let [arglist [{:name :inBoneTrk    :argFlags #{:EArg-In}}
               {:name :inoutBoneTrk :argFlags #{:EArg-In :EArg-Out}}
               {:name :outBoneTrk   :argFlags #{:EArg-Out}}]]
  (m/find arglist
    [(m/and (m/or {:argFlags #{:EArg-In} :name !projASeq} _)
            (m/or {:argFlags #{:EArg-Out} :name !projBSeq} _))
     ...]
    {:in-args !projASeq
     :out-args !projBSeq}))
;; =>
{:in-args [:inBoneTrk :inoutBoneTrk],
 :out-args [:inoutBoneTrk :outBoneTrk]}

noprompt 2020-07-11T02:12:02.054800Z

You could use match instead of find in this case if you want ā€œblow upā€ semantics.

noprompt 2020-07-11T02:16:54.055800Z

Alternatively

[(m/or {:argFlags #{:EArg-In :EArg-Out} :name (m/and !projASeq !projBSeq)}
           {:argFlags #{:EArg-In}, :name !projASeq}
           {:argFlags #{:EArg-Out}, :name !projBSeq})
     ...]
works.

ikrimael 2020-07-11T02:28:00.056400Z

šŸ‘Œ