Fork me on GitHub
#meander
<
2020-05-21
>
Jimmy Miller00:05:00

With match you can just use assoc or update.

(m/match {:name "jimmy"
            :stuff 1}
  {:name ?name
   :as ?my-map}

  (assoc ?my-map :extra-name ?name))
But if you want to do something a little more meandery, you could use rewrite.
(m/rewrite {:name "jimmy"
            :other-name "Stuff"
            :stuff 1}
  {:name ?name
   :other-name _
   & ?rest}

  {:name (m/app str "hello " ?name)
   :other-name "thing"
   & ?rest})

tobias00:05:37

Thanks! I'll try those out

tobias00:05:46

It seems like meander is great for querying a data structure or re-writing it in a different shape, but that if I want a straightforward assoc-in or update-in then it's just as clear and concise to use assoc-in and upate-in directly. Is that fair? I'm still getting the hang of where it makes sense to use meander.

noprompt01:05:53

It all depends on the context and what you like. šŸ™‚

noprompt01:05:44

assoc-in and update-in are nice when their mix of semantics, convenience, etc. are more practical. rewrite is specifically designed for shape to shape transformation, not ā€œin-placeā€ transformation. That being said, you can still do nested transformations with rewrite by using the cata operator, this is my personal tendency.

noprompt01:05:55

Iā€™d love to hear your thoughts, good and bad, on how it works with your re-frame app.

noprompt01:05:32

Iā€™ve wanted to mess around with something like that. šŸ‘

noprompt03:05:24

[meander/epsilon "0.0.421"] is out which addresses the cases where bad Clojure code being generated would trigger a clojure.lang.Compiler$CompilerException due to symbols being unresolveable.

noprompt03:05:53

Iā€™m sorry it took me so long to patch it. I was on vacation last week, busy before that, and couldnā€™t take a serious look until today.

nlessa13:05:45

Thank you, Joel! No problem at all. And thanks a lot for your time and effort to create meander. It really opened new paths to develop some stuff I have been working with.

tobias11:05:25

@noprompt I'll let you know how it goes with re-frame. I thought meander match might offer a clear way to write queries that involve joins, which seem to often come up when using the "https://purelyfunctional.tv/guide/database-structure-in-re-frame/#Indexed-Entities-Pattern" for db structure described by Eric Normand. So far so good :-)