This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-10
Channels
- # adventofcode (54)
- # announcements (30)
- # asami (13)
- # aws (10)
- # babashka (16)
- # babashka-sci-dev (44)
- # beginners (95)
- # calva (63)
- # clara (10)
- # clj-kondo (3)
- # cljfx (6)
- # cljs-dev (7)
- # cljsrn (1)
- # clojure (68)
- # clojure-europe (59)
- # clojure-nl (7)
- # clojure-norway (12)
- # clojure-spec (6)
- # clojure-uk (6)
- # clojurescript (4)
- # component (4)
- # conjure (5)
- # datomic (3)
- # deps-new (1)
- # events (4)
- # exercism (1)
- # figwheel-main (1)
- # fulcro (33)
- # gratitude (1)
- # improve-getting-started (3)
- # jobs (3)
- # lsp (5)
- # malli (10)
- # membrane (5)
- # music (3)
- # nextjournal (6)
- # off-topic (42)
- # pedestal (2)
- # polylith (14)
- # portal (11)
- # re-frame (42)
- # releases (3)
- # reveal (4)
- # shadow-cljs (62)
- # tools-build (1)
- # tools-deps (3)
- # web-security (1)
- # xtdb (3)
If I have many (~15) maps that I want to call upon for tests, what's the best way I should go about defining them? It is too much that I wouldn't want to put it in the same file as my tests. Is putting them in a clj file called x_test_data.clj
bad practice?
okay so the problem I have is that if i do that I can't quite run my tests in the repl
because the project im working on uses lein-modules, and typically for dev there is a dev folder to start the repl from
load it from the classpath using http://clojure.java.io/resource, not directly from the filesystem
any suggestions on what i should do if my classpath is different from where i put my resource?
a hack I can do is to
(require '[cemerick.pomegranate :as pom])
(pom/add-classpath "....")
in general if you put it next to a clojure source file then it will be on the classpath, because clojure source code is loaded as a resource via classloaders
some projects will define a separate test-resources folder and setup on their tooling to include that when running tests
yeap I do have that - maybe the context is that i have a project using lein modules aka multiple lein projects in 1 project
I have a project-dev
project where I'm expected to start my lein from but the code I want to run is in the project-core
project
you know I used to work with the guy who started the lein project, he started it because he hated the maven multi module build we had at work
once lein got big enough our boss made a massive git change to the repo over the weekend to switch from maven to lein
Meanwhile, I'm unfortunately not in the position to switch my project out of a lein-modules project :x
So I'm trying my best to make repl driven development in that project still good with these limitations i guess
my initial way was to define all my resources in a namespace like recon-test-data
but putting all the data into a clj file/ns seems like bad practice
So I'm just trying to see if there's another way I can do it (cause the way of putting it into a ns was something my colleague commented on - wanting me to change it)
You're swimming in the waters that lead to a monorepo and your life will be better when you get there.
Oh god, that's even worse then! Switch to deps.edn
and the CLI as soon as you can!
We started getting into a mess with Leiningen as our repo grew and we switched to Boot in 2015 and then to the CLI in 2018. Life is so much better!
But I think I probably have to tread wisely as I make sure not to annoy my boss and earn his trust
Ah yeah, you're pretty new at this place, as I recall?
Yeap! Just transferred department and team, and started being a Clojure dev at the start of november
Yeah, you might get resistance trying to move away from "industry standard" Leiningen, unfortunately.
And other things I realise is that I'm the only one really doing repl driven development in a sense - I mean they do use a repl in great ways to inspect a running system
It's a shame because it's really rigid and it's easy to outgrow it, in my opinion.
Ah, yeah, that would mean they're not feeling the pain...
Though, my boss introduce someone new (was doing another project in his team) into the same clojure team and have been directing him to the right resources
But I'm in the meanwhile just trying to smoothen the path so that when he starts working on the project there isn't too much difficult in him wanted to do repl driven development
I spent all day today working in our legacy app, rewriting it to Clojure. It runs a Socket REPL. So I started the app, connected my editor to it, and eval'd code into it as I wrote it so the legacy app changes in real time. THAT is RDD.
sometimes I think it is a weird scenario, like my boss went from (from what i understand) repl driven development with emacs+cider, to intellij+cursive (cause his laptop was reformatted and can't install emacs again) and idk if it was a matter of shortcuts or what but he seem to stop doing RDD
I can't imagine ever going back from RDD. That's why I have socket REPLs running in the legacy apps. I can't do without it.
It's how I debug our QA and even our production processes -- via socket REPLs inside live, running apps.
Neither can I. But okay we do have a nrepl running in our application. Which we do use for debugging. Which is great
Tho probably for company security reasons, not something we can easily just connect to in the editor (probably possible but haven't tried setting it up). And just evaluate code from the editor in
But all in all, am glad to be working with Clojure, just that I have to work around certain constraints and also hopefully gradually earn my boss' trust with time (and not annoy him instead 😅 )
Hopefully, you can work to slowly modernize them and get them to move to a better monorepo setup.
Send them links to my blog 🙂
I have a PersistentHashMap
and I am doing select-keys
on it. It is returning PersistenArryMap
I think it's related to the size of the map, it's an implementation detail but if your map has more than 8 entries it's a PersistentHashMap if has less it's a PersistentArrayMap so i guess if you're selecting less than 8 keys you'll get your behaviour
Please fill out this survey on Covid-19. It takes less than 2 minutes https://forms.gle/eHhPDWAkMTwuqWhJA
Is there a way to list all dependencies and their versions with the clojure cli? (e.g. to find out if log4j is an indirect dep of my project and see all versions used)
Take a look at tools.deps.graph as well if you're looking for something fancier: https://github.com/clojure/tools.deps.graph
What's a good function for merge-with
to collect scalar values into a list? E.g. (merge-with ?? {:a 3} {:a 4} {:a 5}) -> {:a [3 4 5]}
, the usual suspects of into
/`conj`/`concat` don't really fit since the values don't start off as collections
Well, maybe this isn't a good example since you can just (map :a data)
, how about turning something like {:a 1} {:a 2} {:b [3 4]} {:b [5 6]}
into {:a [1 2] :b [[3 4] [5 6]]}
?
Map-values vector across each side first then merge-with into
Presumably you want non-clashing keys to have a vector wrapped around the singleton value in the result yeah?
Yeah, is there an easy way to do map-values without dipping into something like spectre?
clojure 1.11 has clojure.core/update-vals
(->> [{:a 1} {:a 2} {:b [3 4]} {:b [5 6]}]
(map #(update-vals % vector))
(apply merge-with into))
Oh neat!
Otherwise if you are stuck on an older version here is one way
Into keeps the value as a vector, concat would give you a lazy sequence instead
Makes sense, wish there were 1.11 packages available on the clojure/tools
homebrew tap
FYI both https://github.com/clojure/clojure/blob/abe19832c0294fec4c9c55430c9262c4b6d2f8b1/src/clj/clojure/core.clj#L7947-L7961 and https://github.com/sicmutils/sicmutils/blob/c05f21aca265acd34b67b13d9337ce389d160961/src/sicmutils/util.cljc#L59-L66 are tiny. Before you decide to bring in a whole library as a dependency consider just copying either function (with proper attribution of course)
Copy and attribute for sure
TIL map-invert
. Anybody know why it’s in clojure.set
despite it not appearing to have anything to do with sets? Looks like it’s been there from the beginning.
Maybe because the keys form a set so the values will always be sets?
After transform… but I do not know the original reason!