This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-10
Channels
- # aleph (4)
- # beginners (32)
- # cider (12)
- # cljs-dev (56)
- # cljsrn (7)
- # clojars (3)
- # clojure (165)
- # clojure-dev (33)
- # clojure-germany (1)
- # clojure-italy (27)
- # clojure-russia (7)
- # clojure-spec (24)
- # clojure-uk (62)
- # clojurescript (37)
- # core-async (7)
- # core-matrix (1)
- # cursive (9)
- # data-science (8)
- # datomic (8)
- # duct (4)
- # events (1)
- # figwheel (7)
- # flambo (3)
- # fulcro (43)
- # hoplon (25)
- # jobs-discuss (8)
- # lein-figwheel (4)
- # luminus (2)
- # off-topic (35)
- # om (8)
- # om-next (3)
- # onyx (30)
- # pedestal (62)
- # portkey (2)
- # protorepl (2)
- # re-frame (40)
- # reagent (9)
- # shadow-cljs (123)
- # specter (30)
- # sql (22)
- # testing (1)
- # uncomplicate (40)
- # unrepl (3)
- # vim (13)
- # yada (5)
I'm new to Clojure and CIDER. I use C-c C-k
while developing to load a file to the REPL. But if I remove a function from the file, it still stays in the namespace that's in the REPL, right? If the namespace happens to be a test namespace, then a removed/renamed test will also be run with C-c C-t n
.
So, is there a way to load a file to the REPL in a way that the namespace it contains would be completely replaced?
The simple answer is "yes" but the practical answer is "it's hard" @petri
There's a workflow with clojure.tools.namespace.repl/refresh
that addresses your issue but it comes with some baggage...
@seancorfield Ok, so there's something more to consider than just hitting C-c C-x
?
Yeah, it relies on your whole application and your workflow following the "reloaded" process.
@petri As a quick fix, running (ns-unmap 'your.ns 'removed-test)
will get rid obsolete tests, too. You can use *ns*
if you are in the test namespace in the repl.
Also, commenting out (testing...
forms with #_
for example instead of full tests helps sometimes.
can anyone review this simple http route matcher? https://pastebin.com/3j0Ua17P
also I apologise for pastebin, apparently it really sucks at highlighting clojure. perhaps there's a better site
@mseddon You can add code snippets to this slack directly using hte [+] symbol on the left.
I'm not thrilled by my (apply hash-map (mapcat ...
at the bottom, it feels like there's probably a better way
@mseddon 1. Why clojure.string
not aliased? 2. Don't use str
as a binding name. 3. Why not destructure on the last line? 4. Use when-some
on second last line. 5. Ln#13: Doens't join
take an interpose parameter? 6. Ln#5: (zipmap (range 1) ...
7. But overall, all minor suggestions here. Looks pretty good.
Only one I couldn't get to work was (range 1), since that returns [0..1], rather than [1..], is there a different function for that?
@mseddon also for future reference, (into {} [[:a 1] [:b 2]]) -> {:a 1 :b 2}
@tbaldridge doh! i knew there was a way to do that sanely, thanks
@mseddon Yeah, it looks like range
was bad advice. I always have to look up the params 🙂
@mseddon i think (for [[idx key] imap] [key (matches idx)])
is a tad clearer than that map
I would like to have separate names for test and production uberjars compiled from the same project.clj file. Is that possible? Can you put an uberjar-name key is a profile and make uberjars with 2 different profiles?
@jrootham that's possible, you can set the uberjar-name in a profile, so when you make an uberjar with that profile, it gets that name.
@jrootham You can use the profiles feature for that:
❯ lein help with-profile
Apply the given task with the profile(s) specified.
Comma-separated profiles may be given to merge profiles and perform the task.
Colon-separated profiles may be given for sequential profile task application.
A profile list may either be a list of profiles to use, or may specify the
profiles to add or remove from the active profile list using + or - prefixes.
For example:
lein with-profile user,dev test
lein with-profile -dev test
lein with-profile +1.4:+1.4,-dev:base,user test
To list all profiles or show a single one, see the show-profiles task.
For a detailed description of profiles, see `lein help profiles`.
Arguments: ([profiles task-name & args])
Then you could have:
❯ lein with-profile dev my-thing uberjar # dev
❯ lein with-profile prod my-thing uberjar # prod
Is there a better way to say (defn negligible? [x] (if (seqable? x) (empty? x) (not x)))
?
there’s also () “” #{} and a few others the original encompases
oh right, I forgot contains? uses collection equality d’oh
and ""
and (into-array Object [])
etc. - lots of things are sequable but not equal to clojure colls