This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-22
Channels
- # announcements (1)
- # aws (4)
- # beginners (73)
- # bristol-clojurians (1)
- # calva (7)
- # cider (5)
- # cljs-dev (11)
- # cljsrn (3)
- # clojure (30)
- # clojure-europe (24)
- # clojure-italy (2)
- # clojure-nl (3)
- # clojure-spec (7)
- # clojure-uk (69)
- # clojurescript (109)
- # cursive (21)
- # datascript (1)
- # datomic (72)
- # events (1)
- # fulcro (5)
- # graalvm (2)
- # helix (12)
- # hoplon (12)
- # jobs (2)
- # juxt (2)
- # kaocha (7)
- # keechma (1)
- # lambdaisland (5)
- # meander (18)
- # off-topic (52)
- # pathom (9)
- # re-frame (18)
- # reagent (5)
- # reitit (7)
- # sci (6)
- # shadow-cljs (76)
- # sql (9)
- # testing (4)
- # tools-deps (14)
- # xtdb (28)
it's making datashaping and refactoring a lot less of a chore (both in writing complex nested joins/extractions and being able to read it 5 days later instantly)
the current part i'm trying to unravel is how the memory variables work, specifically in the context of joins
At least for me, your example of what you want to convert does not show up here.
sigh, now I forgot the exact context which I was asking around. let me circle back after I hit it again (won't be long since it's a top 3 pattern I keep hitting)
(m/match
[{:type "Operator"
:fields [{:type "int32" :name "age" :meta [[:uiSlider 1 100] [:tooltip "MyTool"]]}
{:type "uid_t" :name "id" :meta [[:hidden]]}]}
{:type "Graph"
:fields [{:type "vec<int32>" :name "nodes" :meta [[:hidden]]}
{:type "graphDesc" :name "meta" :meta [[:hidden]]}]}]
[[{:type !type :fields ?flds} ...]]
(;; Can't use meander syntax to rewrite/pattern match inside of ?flds and have to resort to let destructurings
)
[[{:type !type :fields [{:type !fldtype :name !fldname :meta !meta} ...]} ...]]
(;; !fldtype,!fldname,!meta are no longer "grouped" together to the type they were in
))
what I "discovered" last night is using (m/cata) to recurse down and creating a pattern match term for each "nesting level"
it's a decent compromise but i'm left wanting: - separating out to different terms erases context of which nested terms are allowed to appear where - found it harder to debug, both along user syntax errors and logic. What i'd end up doing is replace each pattern match term one by one starting from the top until i found which nesting level had an issue, then proceed from there
some mitigations to issues above: - discovered datawalk which has been a godsend and made the above process a lot less painful - since the nesting match terms are all together, it's not that bad. instead of instant grokking of the code, maybe it's 5-10 mins as one mentally reconstructs which terms are allowed to go where
as a real world ex: here's the code from last night: https://gist.github.com/ikrima/0353f3f1600a639797c63b2692c63334
I'm not 100% sure I followed all of what is going on. I think from what I do understand that you are probably doing the right thing by using cata. That is how we often deal with complicated patterns that need a fresh context for nested matches.
ah, here's the simplified example with an addition of something along the lines of what i'm reaching for
(m/match
[{:type "Operator"
:fields [{:type "int32" :name "age" :meta [[:uiSlider 1 100] [:tooltip "MyTool"]]}
{:type "uid_t" :name "id" :meta [[:hidden]]}]}
{:type "Graph"
:fields [{:type "vec<int32>" :name "nodes" :meta [[:hidden]]}
{:type "graphDesc" :name "meta" :meta [[:hidden]]}]}]
[[{:type !type :fields ?flds} ...]]
(;; Can't use meander syntax to rewrite/pattern match inside of ?flds and have to resort to let destructurings
)
[[{:type !type :fields [{:type !fldtype :name !fldname :meta !meta} ...]} ...]]
(;; !fldtype,!fldname,!meta are no longer "grouped" together to the type they were in
)
[[{:type !type :fields [{:type ?fldtype :name ?fldname :meta ?meta :as !fields} ...]} ...]]
(;; natural grouping in a concise way
))
The 5 days later bit especially. In the early days when I was sketching out what I wanted to do that was one of the problems I wanted to address.
Cause, you’re right, you often have to slow down, parse everything, and evaluate it in your mind when you come back to it. And it’s easy to end up with code like that when you’re in that “write only” mode, just trying to get an idea out of your head or some damn thing to work already.
ah, here's the simplified example with an addition of something along the lines of what i'm reaching for
(m/match
[{:type "Operator"
:fields [{:type "int32" :name "age" :meta [[:uiSlider 1 100] [:tooltip "MyTool"]]}
{:type "uid_t" :name "id" :meta [[:hidden]]}]}
{:type "Graph"
:fields [{:type "vec<int32>" :name "nodes" :meta [[:hidden]]}
{:type "graphDesc" :name "meta" :meta [[:hidden]]}]}]
[[{:type !type :fields ?flds} ...]]
(;; Can't use meander syntax to rewrite/pattern match inside of ?flds and have to resort to let destructurings
)
[[{:type !type :fields [{:type !fldtype :name !fldname :meta !meta} ...]} ...]]
(;; !fldtype,!fldname,!meta are no longer "grouped" together to the type they were in
)
[[{:type !type :fields [{:type ?fldtype :name ?fldname :meta ?meta :as !fields} ...]} ...]]
(;; natural grouping in a concise way
))