This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-21
Channels
- # announcements (3)
- # babashka (26)
- # beginners (45)
- # calva (10)
- # chlorine-clover (9)
- # cider (4)
- # clj-kondo (7)
- # cljs-dev (10)
- # clojure (95)
- # clojure-europe (33)
- # clojure-france (5)
- # clojure-nl (3)
- # clojure-spec (2)
- # clojure-sweden (3)
- # clojure-uk (33)
- # clojurescript (54)
- # conjure (101)
- # core-async (14)
- # cursive (1)
- # data-science (91)
- # datascript (3)
- # datomic (16)
- # figwheel (3)
- # figwheel-main (15)
- # fulcro (35)
- # ghostwheel (5)
- # graalvm (13)
- # helix (29)
- # java (5)
- # jobs (6)
- # kaocha (6)
- # leiningen (1)
- # meander (12)
- # off-topic (54)
- # pathom (13)
- # re-frame (16)
- # reagent (8)
- # reitit (4)
- # rum (3)
- # shadow-cljs (49)
- # spacemacs (2)
- # sql (5)
- # tools-deps (10)
- # xtdb (8)
- # yada (3)
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})
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.
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.
Iād love to hear your thoughts, good and bad, on how it works with your re-frame app.
[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.
@nlessa āļø that should patch your problem, I even used it as https://github.com/noprompt/meander/commit/3335fc72eae0e3c6d30c9ac6a265b3ccf790f3ce#diff-e7544f9bb8134fa6cdaaa573a3b2a601R2426.
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.
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.
@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 :-)