This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-24
Channels
- # announcements (13)
- # asami (9)
- # aws (3)
- # babashka (13)
- # babashka-sci-dev (7)
- # beginners (32)
- # calva (59)
- # cider (9)
- # clj-kondo (5)
- # cljsrn (14)
- # clojure (98)
- # clojure-brasil (5)
- # clojure-dev (1)
- # clojure-europe (30)
- # clojure-france (12)
- # clojure-nl (1)
- # clojure-norway (7)
- # clojure-uk (7)
- # clojurescript (20)
- # conjure (2)
- # datahike (7)
- # datalog (38)
- # datomic (29)
- # events (1)
- # fulcro (72)
- # graalvm (1)
- # gratitude (3)
- # helix (7)
- # honeysql (3)
- # improve-getting-started (2)
- # introduce-yourself (1)
- # leiningen (13)
- # lsp (17)
- # malli (11)
- # meander (8)
- # nextjournal (3)
- # off-topic (5)
- # pathom (2)
- # portal (43)
- # rdf (2)
- # re-frame (8)
- # reagent (7)
- # reitit (1)
- # shadow-cljs (27)
- # spacemacs (31)
- # sql (2)
- # tools-deps (3)
- # vim (1)
- # xtdb (12)
Hi all, I’m using Calva and working on a Leiningen project. I have a repl running, and then decide to add a new dependency. After I do lein install
, how do I get the repl to load the new dependency? I’ve tried “Calva: Refresh All Namespaces”, “Calva: Load Current File and Dependencies”, still I’m getting “Unable to resolve symbol”. Thank you.
You will either need to restart the REPL and reconnect to it. Or, if Leiningen has some dynamic loading mechanism, you can use that and then Load Current File should do the trick. Or just (require 'the-new-lib.some-ns)
to try it out.
For completeness. For people using #tools-deps, there is a branch
. With a function add-lib
that will let you dynamically add dependencies. An earlier version of it is described here: https://insideclojure.org/2018/05/04/add-lib/ (I think the API has stayed the same.)
FYI, the Clojure CLI deps.edn function is now called add-libs
and can load multiple libraries into a running REPL process.
Examples: https://practical.li/clojure/alternative-tools/clojure-cli/hotload-libraries-editor.html
I think that with Leiningen most people solve the hot loading of dependencies using Pomegranate: https://github.com/clj-commons/pomegranate
Actually it's a constraint of the underlying Java host platform, for which there are tools in the Clojure community to mitigate. I really only do hotloading of libraries when working in unfamiliarity domains, or specifically trying out libraries that are new to me. I've never found it an issue to simply restart the REPL, it only takes a second or two. Specific application states can be set using code in rich comment blocks if required
I find huge issues with restarting my REPLs. That's brutal! I go the other way and use the add-lib branch as often as I get away with it.
btw, @U05254DQM. In your add-lib guide it is quite hard to understand that you need a special version of tools.deps.alpha. The information about this is there, but probably should be more prominently placed.
setup of the alias in in the previous page, https://practical.li/clojure/alternative-tools/clojure-cli/hotload-libraries.html I'll add a link to make it more obvious
Awesome: I think it should be mentioned that a special version is needed right in the start, where it now reads:
> The add-libs
function from clojure.tools.deps.alpha
avoids the need to restart the REPL when adding a new library to a project.
And those tabs for how to do it made it a bit hard for me to see the it was two options for adding the dependency. Maybe because it speaks about an alias and not a dependency. But also because I'm not used to tabs in an article.
In-page tabs are used liberally through the book where I offer alternatives. The default tab is always the recommended approach the book follows. Sorry you find it difficult to use, but I haven't found a more appropriate way of offering alternatives on the same page without drowning people in extraneous information. I could remove the alternatives, which would mean less work for me, but possibly offer less value.
I like the alternatives, and that they don't take up space. I think that when you read the book you will probably quickly learn what the tabs are. But many people, like me, will arrive via some link to check a specific thing out. I think maybe all that I would need is some help to quickly understand the context and my options. Something like so, maybe?
Couldn’t find a sub for that, so posting this question here, I am using https://github.com/clj-commons/camel-snake-kebab library for string conversions and but I want to treat number as a single thing rather than treating it as an upper case later, for example,
(csk/->kebab-case-keyword :s2_id)
Should return s2-id
rather than s-2-id
. Is there any way we could do that?Try:
(csk/->kebab-case-keyword :s2_id :separator \_)
; => :s2-id
Note that a super similar example is prominently https://clj-commons.org/camel-snake-kebab/:
(csk/->snake_case :s3-key :separator \-)
; => :s3_key
Hi, I have an existing http-kit - compojure server and I want to send over one of the endpoints a byte array, i am getting this error:
No implementation of method: :as-response of protocol: #'liberator.representation/Representation found for class: [B%
what is the right way to do this? (assuming I don’t want to slurp and then convert the string to bytes on the other side)How do I spec a 2-tuple (vector) where the first entry is a keyword and the second is a map?
I see coll-of, but that does not consider order or length.
I'll try. I looked for s/vec
.
Seems like there are no examples: https://clojuredocs.org/clojure.spec.alpha/tuple
Yup: (s/conform (s/tuple int? int?) [1 2])
I did not think to look for tuple since I thought it did not exist in Clojure, but that we use vec
for the same purpose.
I recommend checking out the official spec guide, which includes examples for tuple
:
https://clojure.org/guides/spec
Hello Clojurians, newbie here. Any opensource re-frame project you recommend for studying? Ideally, it would be an SPA with the kind of complexity found in typical full fledged web applications. Thanks!
Not an open source project per se, but Web Development with Clojure walks you through step by step the how and why of creating a production grade (-ish) full, SPA+back end in clojure https://pragprog.com/titles/dswdcloj3/web-development-with-clojure-third-edition/ It's also reasonably up to date, with the latest edition having been released this past summer