This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-22
Channels
- # ai (1)
- # announcements (4)
- # babashka (23)
- # beginners (27)
- # biff (17)
- # calva (5)
- # clerk (6)
- # clj-commons (27)
- # clj-kondo (35)
- # clojars (12)
- # clojure (27)
- # clojure-denver (3)
- # clojure-europe (71)
- # clojure-norway (7)
- # clojure-spec (5)
- # clojure-uk (2)
- # clojurescript (45)
- # data-science (9)
- # datomic (4)
- # dev-tooling (2)
- # devcards (1)
- # hoplon (2)
- # hyperfiddle (36)
- # introduce-yourself (3)
- # malli (11)
- # missionary (2)
- # off-topic (63)
- # polylith (5)
- # rdf (2)
- # reagent (12)
- # schema (1)
- # shadow-cljs (11)
- # sql (6)
- # tools-deps (23)
- # xtdb (6)
Currently, I have an algorithm that create the left side structure. If I apply flatten
on it, then it returns me ()
.
How can I go from left to right?
(({} {}) () ({} {} {})) -> [{} {} {} {} {}]
I would take a look at mapcat
You could also do
(into [] (comp cat (map (fn [m] (cond (instance? clojure.lang.IPersistentMap m) m)))) (({} {}) () ({} {} {})))
simply (into [] cat ...), why do you check for element type ? but since you're creating it with nested fors, you can simply do:
(for [{:keys [identificacaoExecutoras]} projetos
{:keys [id nome]} identificacaoExecutoras]
{:id id :nome nome})
Yeah, fair enough @U02F0C62TC1. I guess cat
alone will flatten out that empty ()
In the end, I did:
(flatten
(map
(fn [projeto]
(let [executoras (:identificacaoExecutoras projeto)]
(for [{:keys [id nome]} executoras]
{:id id :nome nome})))
(get-in exemplo [:chamada-publica :projetos])))
;; => ({:id "610d4764e62fa51a1c957592", :nome "ABC"}
;; {:id "6230b44717deea5454721e0f", :nome "Esther e Josefa Eletrônica Ltda"}
;; {:id "6178157ce615845c5cb0209d",
;; :nome "Nicolas e Rebeca Locações de Automóveis ME"}
;; {:id "617c37409d7fb206c261bf34", :nome "Joaquim e Gael Construções Ltda"}
;; {:id "6131026b8034b53bf0e701f5", :nome "Maitê e Yuri Entregas Expressas ME"})
i'd stay away from flatten: it flattens several levels of nesting. When I need to flatten a single level, I use mapcat identity
, or into [] cat
My rule of thumb wrt flatten
is that if I am generating the data myself, I should be able to generate the data in the right shape without ever using flatten
. It’s OK to use flatten
on data that’s passed to you by another service though…
Hey everyone, I am trying to update my dependencies to their latest versions, but I am having trouble with org.clojure/clojure {:mvn/version "1.10.3"} org.clojure/clojurescript {:mvn/version "1.11.4"} com.google.javascript/closure-compiler-unshaded {:mvn/version "v20211006"}. Has anyone been able to use clojurescript with clojure 1.11.1?
do you have a deps.edn i can look at to see your versions?
whats the issue? as @U2FRKM4TW said, just clojure+clojurescript should be fine?
Upon more digging its conflicting with shadow-cljs: --- SHADOW-CLJS FAILED TO LOAD! ---------------------- This is most commonly caused by a dependency conflict. When using deps.edn or project.clj you must ensure that all required dependencies are provided with the correct version. You are using shadow-cljs version: 2.16.12 The important dependencies are: org.clojure/clojure "1.10.3" org.clojure/clojurescript "1.10.914" com.google.javascript/closure-compiler-unshaded "v20211006" Please verify that you are loading these versions. You can find all required dependencies here: https://clojars.org/thheller/shadow-cljs/versions/2.16.12
this happens when i upgrade to clojure 1.11.1
clojure should be absolutely fine though. clojurescript or the closure-compiler definitely will not be
@U05224H0W Is it sufficient to just depend on thheller/shadow-cljs
and not specify Clojure or ClojureScript as dependencies?
so shadow-clj wont work with clojurescript and clojure-compiler? I have shadow-cljs at latest version and still throwing errors
also have clojure, clojurescript and clojurescript compiler on latest versions
@U057UJB1NSC the versions need to match those that shadow-cljs expects. the latest shadow-cljs version (2.24.0) expects org.clojure/clojurescript "1.11.60"
and the com.google.javascript/closure-compiler-unshaded "v20230411"
. clojure doesn't really matter so anything 1.10+ will work, it uses org.clojure/clojure "1.11.1"
by default
and yes it might be enough to just specify the thheller/shadow-cljs
dependency, and neither clojurescript or closure-compiler. however that might lead to problems if something else also depends on those and you end up getting different versions
unfortunately the closure compiler keeps making breaking changes, so we have to be very specific about the version we use
Here are my deps: :deps {org.clojure/clojure {:mvn/version "1.11.1"} org.clojure/clojurescript {:mvn/version "1.11.60"} com.google.javascript/closure-compiler-unshaded {:mvn/version "v20230411"} org.clojure/core.async {:mvn/version "1.5.648"} org.clojure/tools.logging {:mvn/version "1.2.4"} org.clojure/tools.nrepl {:mvn/version "0.2.13"} cprop/cprop {:mvn/version "0.1.19"} reagent/reagent {:mvn/version "1.2.0"} re-frame/re-frame {:mvn/version "1.3.0"} binaryage/devtools {:mvn/version "1.0.7"} cljs-ajax/cljs-ajax {:mvn/version "0.8.4"} com.taoensso/timbre {:mvn/version "6.1.0"} com.rpl/specter {:mvn/version "1.1.4"} day8.re-frame/http-fx {:mvn/version "0.2.4"} day8.re-frame/re-frame-10x {:mvn/version "1.3.0"} day8.re-frame/tracing {:mvn/version "0.6.2"} re-com/re-com {:mvn/version "2.13.2"} org.clojars.ertucetin/re-frame-flow {:mvn/version "0.1.4"} com.lucasbradstreet/cljs-uuid-utils {:mvn/version "1.0.2"} aysylu/loom {:mvn/version "1.0.2"} thheller/shadow-cljs {:mvn/version "2.24.0"} metosin/malli {:mvn/version "0.11.0"} io.github.kovasap/oz {:git/url "https://github.com/kovasap/oz" :sha "d5d490d21ea8d42740b09def2abab7c334d52520"} ;metasoarous/oz {:mvn/version "2.0.0-alpha5"} io.github.nextjournal/clerk {:mvn/version "0.14.919"} io.github.noahtheduke/splint {:mvn/version "1.9.0"}} I get these errors: Syntax error macroexpanding clojure.core.async/go at (clojure/core/async.clj:512:6). Caused by: java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.tools.analyzer.utils/update-vals
Any idea?
I've done my best to ensure they all are the versions that shadow-cljs wants
Why do you still depend on clojurescript
and closure-compiler-unshaded
explicitly? You can remove those altogether.
Same with core.async
- don't include it unless you're using it yourself.
And definitely consider splitting your dependencies into backend- and frontend-ones. This way, you can give shadow-cljs whatever it wants and e.g. depend on the latest version of core.async
in your backend, if you do use it there.
Regarding the actual error - seems like something is trying to use an incompatible version of org.clojure/tools.analyzer
.
What is the full stacktrace of that error?
==>> Compiling ClojureScript with shadow-cljs shadow-cljs - config: /home/abowden21/IdeaProjects/bh-lib/shadow-cljs.edn shadow-cljs - starting via "clojure" WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/update-vals WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer.passes, being replaced by: #'clojure.tools.analyzer.utils/update-vals WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer.passes.uniquify, being replaced by: #'clojure.tools.analyzer.utils/update-vals --- SHADOW-CLJS FAILED TO LOAD! ---------------------- This is most commonly caused by a dependency conflict. When using deps.edn or project.clj you must ensure that all required dependencies are provided with the correct version. You are using shadow-cljs version: 2.24.0 The important dependencies are: org.clojure/clojure "1.11.1" org.clojure/clojurescript "1.11.60" com.google.javascript/closure-compiler-unshaded "v20230411" Please verify that you are loading these versions. You can find all required dependencies here: https://clojars.org/thheller/shadow-cljs/versions/2.24.0 Please refer to the Guide for more information: https://shadow-cljs.github.io/docs/UsersGuide.html#failed-to-load ----------------------------------------------------- The error encountered was: Syntax error macroexpanding clojure.core.async/go at (clojure/core/async.clj:512:6). at clojure.lang.Compiler.macroexpand1(Compiler.java:7027) at clojure.lang.Compiler.analyzeSeq(Compiler.java:7110) at clojure.lang.Compiler.analyze(Compiler.java:6806) at clojure.lang.Compiler.analyzeSeq(Compiler.java:7112) at clojure.lang.Compiler.analyze(Compiler.java:6806) at clojure.lang.Compiler.analyze(Compiler.java:6762) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6135) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5479) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:4041) at clojure.lang.Compiler.analyzeSeq(Compiler.java:7122) at clojure.lang.Compiler.analyze(Compiler.java:6806) at clojure.lang.Compiler.analyzeSeq(Compiler.java:7112) at clojure.lang.Compiler.analyze(Compiler.java:6806) at clojure.lang.Compiler.access$300(Compiler.java:38) at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:596) at clojure.lang.Compiler.analyzeSeq(Compiler.java:7124) at clojure.lang.Compiler.analyze(Compiler.java:6806) at clojure.lang.Compiler.analyze(Compiler.java:6762) at clojure.lang.Compiler.eval(Compiler.java:7198) at clojure.lang.Compiler.load(Compiler.java:7653) at clojure.lang.RT.loadResourceScript(RT.java:381) at clojure.lang.RT.loadResourceScript(RT.java:372) at clojure.lang.RT.load(RT.java:459) at clojure.lang.RT.load(RT.java:424) at clojure.core$load$fn__6908.invoke(core.clj:6161) at clojure.core$load.invokeStatic(core.clj:6160) at clojure.core$load.doInvoke(core.clj:6144) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5933) at clojure.core$load_one.invoke(core.clj:5928) at clojure.core$load_lib$fn__6850.invoke(core.clj:5975) at clojure.core$load_lib.invokeStatic(core.clj:5974) at clojure.core$load_lib.doInvoke(core.clj:5953) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$load_libs.invokeStatic(core.clj:6016) at clojure.core$load_libs.doInvoke(core.clj:6000) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$require.invokeStatic(core.clj:6038) at clojure.core$require.doInvoke(core.clj:6038) at clojure.lang.RestFn.invoke(RestFn.java:3204) at shadow.cljs.devtools.api$eval1261$loading__6789__auto____1262.invoke(api.clj:1) at shadow.cljs.devtools.api$eval1261.invokeStatic(api.clj:1) at shadow.cljs.devtools.api$eval1261.invoke(api.clj:1) at clojure.lang.Compiler.eval(Compiler.java:7194) at clojure.lang.Compiler.eval(Compiler.java:7183) at clojure.lang.Compiler.load(Compiler.java:7653) at clojure.lang.RT.loadResourceScript(RT.java:381) at clojure.lang.RT.loadResourceScript(RT.java:372) at clojure.lang.RT.load(RT.java:459) at clojure.lang.RT.load(RT.java:424) at clojure.core$load$fn__6908.invoke(core.clj:6161) at clojure.core$load.invokeStatic(core.clj:6160) at clojure.core$load.doInvoke(core.clj:6144) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5933) at clojure.core$load_one.invoke(core.clj:5928) at clojure.core$load_lib$fn__6850.invoke(core.clj:5975) at clojure.core$load_lib.invokeStatic(core.clj:5974) at clojure.core$load_lib.doInvoke(core.clj:5953) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$load_libs.invokeStatic(core.clj:6016) at clojure.core$load_libs.doInvoke(core.clj:6000) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$require.invokeStatic(core.clj:6038) at clojure.core$require.doInvoke(core.clj:6038) at clojure.lang.RestFn.invoke(RestFn.java:1289) at shadow.cljs.devtools.cli_actual$eval185$loading__6789__auto____186.invoke(cli_actual.clj:1) at shadow.cljs.devtools.cli_actual$eval185.invokeStatic(cli_actual.clj:1) at shadow.cljs.devtools.cli_actual$eval185.invoke(cli_actual.clj:1) at clojure.lang.Compiler.eval(Compiler.java:7194) at clojure.lang.Compiler.eval(Compiler.java:7183) at clojure.lang.Compiler.load(Compiler.java:7653) at clojure.lang.RT.loadResourceScript(RT.java:381) at clojure.lang.RT.loadResourceScript(RT.java:372) at clojure.lang.RT.load(RT.java:459) at clojure.lang.RT.load(RT.java:424) at clojure.core$load$fn__6908.invoke(core.clj:6161) at clojure.core$load.invokeStatic(core.clj:6160) at clojure.core$load.doInvoke(core.clj:6144) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5933) at clojure.core$load_one.invoke(core.clj:5928) at clojure.core$load_lib$fn__6850.invoke(core.clj:5975) at clojure.core$load_lib.invokeStatic(core.clj:5974) at clojure.core$load_lib.doInvoke(core.clj:5953) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$load_libs.invokeStatic(core.clj:6016) at clojure.core$load_libs.doInvoke(core.clj:6000) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$require.invokeStatic(core.clj:6038) at clojure.core$require.doInvoke(core.clj:6038) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$serialized_require.invokeStatic(core.clj:6114) at clojure.core$requiring_resolve.invokeStatic(core.clj:6123) at clojure.core$requiring_resolve.invoke(core.clj:6117) at shadow.cljs.devtools.cli$main$fn_178.invoke(cli.clj:70) at shadow.cljs.devtools.cli$_main.invokeStatic(cli.clj:69) at shadow.cljs.devtools.cli$_main.doInvoke(cli.clj:67) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.lang.Var.applyTo(Var.java:705) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.main$main_opt.invokeStatic(main.clj:514) at clojure.main$main_opt.invoke(main.clj:510) at clojure.main$main.invokeStatic(main.clj:664) at clojure.main$main.doInvoke(main.clj:616) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.lang.Var.applyTo(Var.java:705) at clojure.main.main(main.java:40) Caused by: java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.tools.analyzer.utils/update-vals at clojure.lang.Var$Unbound.throwArity(Var.java:45) at clojure.lang.AFn.invoke(AFn.java:36) at clojure.lang.AFn.applyToHelper(AFn.java:156) at clojure.lang.AFn.applyTo(AFn.java:144) at clojure.core$apply.invokeStatic(core.clj:669) at clojure.core$update_in$up__6922.invoke(core.clj:6220) at clojure.core$update_in$up__6922.invoke(core.clj:6219) at clojure.core$update_in.invokeStatic(core.clj:6221) at clojure.core$update_in.doInvoke(core.clj:6207) at clojure.lang.RestFn.invoke(RestFn.java:467) at clojure.tools.analyzer.passes.uniquify$uniquify_locals_around.invokeStatic(uniquify.clj:29) at clojure.tools.analyzer.passes.uniquify$uniquify_locals_around.invoke(uniquify.clj:26) at clojure.tools.analyzer.passes.uniquify$uniquify_locals.invokeStatic(uniquify.clj:95) at clojure.tools.analyzer.passes.uniquify$uniquify_locals.invoke(uniquify.clj:85) at clojure.lang.Var.invoke(Var.java:384) at clojure.core$comp$fn__5876.invoke(core.clj:2586) at clojure.core$comp$fn__5876.invoke(core.clj:2586) at clojure.core$comp$fn__5876.invoke(core.clj:2586) at clojure.core$comp$fn__5876.invoke(core.clj:2586) at clojure.core$comp$fn__5876.invoke(core.clj:2586) at clojure.core$comp$fn__5876.invoke(core.clj:2586) at clojure.tools.analyzer.jvm$analyze$fn__3984$fn__3989.invoke(jvm.clj:513) at clojure.tools.analyzer.jvm$analyze$fn__3984.invoke(jvm.clj:511) at clojure.lang.AFn.applyToHelper(AFn.java:152) at clojure.lang.AFn.applyTo(AFn.java:144) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1990) at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1990) at clojure.lang.RestFn.invoke(RestFn.java:425) at clojure.tools.analyzer.jvm$analyze.invokeStatic(jvm.clj:500) at clojure.tools.analyzer.jvm$analyze.invoke(jvm.clj:480) at clojure.core.async.impl.ioc_macros$state_machine.invokeStatic(ioc_macros.clj:1102) at clojure.core.async.impl.ioc_macros$state_machine.invoke(ioc_macros.clj:1100) at clojure.core.async$go.invokeStatic(async.clj:463) at clojure.core.async$go.doInvoke(async.clj:441) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.lang.Var.applyTo(Var.java:705) at clojure.lang.Compiler.macroexpand1(Compiler.java:7010)
I removed everything except clojure 1.11.1 and still get these errors. so these are dependencies of clojure?
Run clj -Stree
with whatever aliases you're using when building CLJS and see where org.clojure/tools.analyzer
comes from. It seems like it's either a "bad" version or there's something that overrides one of its namespaces. Can't quite think of any other explanation.
org.clojure/clojure 1.11.1 . org.clojure/spec.alpha 0.3.218 . org.clojure/core.specs.alpha 0.2.62 io.github.nextjournal/clerk 0.14.919 . com.pngencoder/pngencoder 0.13.1 . weavejester/dependency 0.2.1 . org.clojure/tools.analyzer 1.1.0 . mvxcvi/multiformats 0.3.107 . mvxcvi/alphabase 2.1.1 . commons-codec/commons-codec 1.15 X org.clojure/tools.analyzer.jvm 1.1.0 :superseded X org.clojure/tools.analyzer 1.0.0 :older-version X org.clojure/core.memoize 1.0.236 :superseded X org.clojure/core.cache 1.0.207 :parent-omitted X org.ow2.asm/asm 5.2 :superseded X org.clojure/tools.reader 1.3.2 :older-version . rewrite-clj/rewrite-clj 1.1.45
Ah, Clerk. Try removing it. IIRC I had some similar issues with Clerk, had to move it to its own alias.
In general, it's a good practice to split dependencies that are used by different processes into different aliases. CLJS compilation - one alias. Backend running in production - another (or maybe the "default" one). Backend in dev - another. Clerk, Portal, Reval, whatever - yet another, or many others.
Gotcha, Ive removed clerk and no success
Mm. Do you, by chance, have any clojure.tools.analyzer.*
namespaces in your own sources?
I dont import that namespace in any of my code no. Searched project and its only found inside clj.kondo
There seems to be a weird incompatibility where clojure.tools.analyzer.passes.uniquify/uniquify-locals-around
calls clojure.tools.analyzer.utils/update-vals
but the latter is for some reason unbound. As if someone did (def update-vals)
without a value somewhere, or (declare update-vals)
. And as if that (defn update-vals ...)
was never there.
In any case, try to reduce the amount of dependencies that the process building CLJS sees to a bare minimum. If that works - great, you have a reason to split your deps into aliases. If that doesn't work - create a minimal reproducible example based on those deps and I'll take a look.
found that the problem was this dependency: ;io.github.kovasap/oz {:git/url "https://github.com/kovasap/oz" ; :sha "d5d490d21ea8d42740b09def2abab7c334d52520"}
Hmm. A bit surprised that it's problematic but glad you got it sorted out. The list of its dependencies is huge, perhaps there's a transitive dependency that did something unpleasant. Also, IME using Vega directly is pretty straightforward if you only need to embed a few charts on a web page.