This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-14
Channels
- # adventofcode (107)
- # aleph (1)
- # announcements (8)
- # beginners (57)
- # boot (3)
- # braveandtrue (18)
- # calva (374)
- # cider (6)
- # cljdoc (8)
- # cljs-dev (140)
- # clojure (199)
- # clojure-berlin (5)
- # clojure-europe (3)
- # clojure-finland (1)
- # clojure-hamburg (4)
- # clojure-italy (17)
- # clojure-nl (16)
- # clojure-spec (2)
- # clojure-uk (70)
- # clojurescript (29)
- # component (2)
- # cursive (10)
- # datomic (44)
- # docker (1)
- # figwheel (3)
- # fulcro (13)
- # immutant (2)
- # juxt (5)
- # leiningen (53)
- # nrepl (3)
- # off-topic (7)
- # pedestal (3)
- # re-frame (7)
- # ring (3)
- # ring-swagger (5)
- # rum (5)
- # shadow-cljs (14)
- # spacemacs (6)
- # specter (12)
- # tools-deps (11)
- # unrepl (11)
- # vim (7)
hey everyone, i'm trying to use specter to build a tree-structure of nested maps and struggling with what kinds of values are allowed in the path in setval
my pre-specter implementation just uses (update-in tree [:field1 field1-val ...] (fnil conj #{}) key-of-entity)
so in the end i get a big map like
{:field1 {"1" {:field2 {nil {:field3 {"B" {..}}}}}
"2" {:field2 {nil {:field3 {"C" {..}}}}}}}
my problem is that some values are nil
and some values are hashmaps themselves. and specter doesn't seem to use nil
and hashmaps in the path of setval
i already replaced nil
with a :empty
, that solved that problem
but i rely on the hashmap values for equality. my current plan for a workaround is represent that data as a sorted string and hope i can get a canonical representation working
maybe someone can help me with this problem or confirm that specter doesn't use nil
or hashmaps/hashsets as map keys in setval
?
example:
(S/setval [:field1 "1"
:field2 :empty
:field3 "A"
:field4 (S/multi-path
:c
#{:a :b}
{:a #{:b :c}})]
"ID"
{})
;; => {:field1 {"1" {:field2 {:empty {:field3 {"A" {:field4 {:c "ID"}}}}}}}}
I'd like for the paths #{:a :b}
and {:a #{:b :c}}
to also be created@timo.freiberg if you want to use a map as a key, wrap it in the keypath
navigator
only basic types like keywords, strings, and numbers are automatically inferred use keypath
navigation
see this for a complete listing of navigators available to you: https://github.com/nathanmarz/specter/wiki/Cheat-Sheet
awesome, that did it