This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-08
Channels
- # admin-announcements (2)
- # beginners (35)
- # boot (353)
- # capetown (1)
- # cider (1)
- # cljs-dev (41)
- # cljsjs (3)
- # cljsrn (3)
- # clojure (118)
- # clojure-austin (12)
- # clojure-russia (17)
- # clojure-spec (21)
- # clojure-taiwan (1)
- # clojure-uk (91)
- # clojurescript (80)
- # clojurex (1)
- # cloverage (3)
- # datomic (66)
- # devcards (2)
- # events (2)
- # garden (6)
- # hoplon (54)
- # jobs-rus (1)
- # keechma (1)
- # lein-figwheel (4)
- # leiningen (3)
- # luminus (3)
- # off-topic (7)
- # om (4)
- # onyx (53)
- # other-languages (17)
- # proton (7)
- # protorepl (4)
- # re-frame (123)
- # reagent (1)
- # ring (6)
- # rum (2)
- # spacemacs (1)
- # specter (21)
- # testing (1)
- # untangled (1)
- # yada (42)
I require both com.rpl.specter
& com.rpl.specter.macros
namespaces in ClojureScript
all symbols from com.rpl.specter
work but not com.rpl.specter.macros
when I try a symbol from com.rpl.specter.macros
such as transform
I get this error message:
Uncaught TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined
core.js [32556] anonymous
core.js [19022] anonymous
core.js [19023] anonymous
core.js [19038] cljs.core.PersistentVector.cljs$core$IReduce$_reduce$arity$3
core.js [7719] cljs.core.reduce.cljs$core$IFn$_invoke$arity$3
core.js [32555] cljs$core$group_by
views.js?zx=ibkddq5mtrqz [72] anonymous
specter.js [975] $rpl$specter$protocols$Navigator$transform_STAR_$arity$3
protocols.js [46] com$rpl$specter$protocols$transform_STAR_
impl.js [2175] com.rpl.specter.impl.structure_path_impl
impl.js [2202] anonymous
impl.js [2371] anonymous
core.js [16854] anonymous
core.js [16855] cljs.core.map.cljs$core$IFn$_invoke$arity$2
core.js [10895] cljs.core.LazySeq.sval
core.js [11046] cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1
core.js [4117] cljs$core$seq
core.js [30313] cljs.core.dorun.cljs$core$IFn$_invoke$arity$1
core.js [30381] cljs.core.doall.cljs$core$IFn$_invoke$arity$1
core.js [30367] cljs$core$doall
impl.js [3239] com.rpl.specter.impl.all_transform._
impl.js [3177] com$rpl$specter$impl$all_transform
impl.js [3280] $rpl$specter$protocols$Navigator$transform_STAR_$arity$3
protocols.js [46] com$rpl$specter$protocols$transform_STAR_
impl.js [2175] com.rpl.specter.impl.structure_path_impl
impl.js [2202] anonymous
impl.js [2369] com.rpl.specter.impl.combine_same_types.combiner
impl.js [284] anonymous
impl.js [3112] com$rpl$specter$impl$compiled_transform_STAR_
views.js?zx=ibkddq5mtrqz [54] anonymous
I have ran lein clean
and lein cljsbuild once
@borkdude: yes, I guess one can "select" with specter producing something like the maps you worked on and then use something like the code you posted to perform the aggregations
I want to get a deeply nested map value from a parsed SOAP response, so the value of key :contents when the :tag value is :second or any other I choose. I used walker but I wonder if there's a more elegant way:
(select-one [(walker #(= :second (:tag %))) :content FIRST] parsed-soap)
=>
"123"
parsed-soap is
{:tag :soap:Envelope,
:attrs {:xmlns:xsi "",
:xmlns:xsd "",
:xmlns:soap " "},
:content [{:tag :soap:Body,
:attrs nil,
:content [{:tag :aResponse
:attrs {:xmlns:a ""},
:content [{:tag :a:aResult,
:attrs nil,
:content [{:tag :first
:attrs {:xsi:nil "true", :xmlns ""},
:content nil}
{:tag :second
:attrs {:xmlns ""},
:content ["123"]}
{:tag :third,
:attrs {:xsi:nil "true", :xmlns ""},
:content nil}]}]}]}]}
@jjunior130: what version and what's the exact code you're running?
@yonatanel: my only issue with that code is it relies on a strange property of clojure which is that you can do map lookups on non-map values without error
since walker will run that function on everything it finds
that also makes that particular path less performant than ideal
the alternative is to explicitly make a recursive navigator that understands the particular structure of this data
(declarepath SoapPath)
(providepath SoapPath
(continue-then-stay
:content
ALL
SoapPath
))
(select-one [SoapPath #(= :second (:tag %)) :content FIRST] parsed-soap)
@nathanmarz: can one be compiled by running an example first? Could be nice to tell it to walk the structure and learn for next time.
you mean use walker
and then have it "learn" the path that I wrote?
it's an interesting idea but seems like it would be full of minefields
there's no way for walker to know that the data structure is recursive, for one
any chance we could get anonymous recursive navigation? so you don't have to separately declare/provide the navigator? It seems to be a very common pattern
@shader: you can open up an issue for it
@nathanmarz: nvm, it's working now. After I lein clean
& lein cljsbuild once
yesterday, all I did between then and now was reboot my computer. Probably I didn't restart the repl I was in yesterday (I thought I did). I'm good now. Namespace com.rpl.specter.macros
is working now.
@jjunior130: good to hear