Fork me on GitHub

Hey! I naïvely tried this:

(when-let [current (:current-page @state)
             title (get-in model [current :title])]
    [:p (str "Current page is: " title)])
but when-let doen't allow multiple values. Is there another xxx-let I can use?


I can use a double when-let to get the behavior I want:

(when-let [current (:current-page @state)]
  (when-let [title (get-in model [current :title])]
    [:p (str "Current page is: " title)]))


The Encore library has multi-assign when-let and if-let

👍 6

@U2APCNHCN the behavior in the Encore library seems to be exactly what I'm asking for. Thanks! Since it's been reimplemented this way in an external library, I assume that there's not a clojure.core alternative. taoensso.encore/if-let documentation if anyone else are interested:

"Like `core/if-let` but can bind multiple values for `then` iff all tests
  are truthy, supports internal unconditional `:let`s."


Hey, happy for input on suggested Clojure ”stacks”. I’ll be doing some prototypes for solutions with backend/DB/API and in some cases web GUI (likely plain React). I want to move quickly as it’s not my main task, but with a serious enough approach that I can use to “sell” the solution to developer colleagues. I’d like to implement both regular rest endpoints and GraphQL in parallel unless it’s very wasteful. Suggestions on libraries or tools? Projects to have a look at? What’s an easy way forward with the DB that’s quick but looks serious from a distance? (If things live on it will very likely be SQL dbs.)


I use Reagent for frontend and Pedestal for backend, both are well-established libraries that are being used in production by lots of companies


Fantastic, thanks 👍


On the same topic, what’s the quickest way to get going with a (preferably SQL) db? I need some way to resolve relations and stuff, even it it’s small scale 🙂


next.jdbc and honeysql are winners

👌 3

I use both extensively in my applications


Cool, thanks. Any suggestions or pointers on the workflow when in dev/prototyping mode? I’ll read up on the libraries, guess it might be self evident ☺️


There are #honeysql and #sql channels if you have questions about HoneySQL or about SQL in general (and next.jdbc in particular).


Doh. Thanks!

Zor10:10:35 is another option. It is not, however, the quickest way. So far you collected lists of interesting dependencies to your mix. I suggest adding some component-system to your stack - seems to be an established, popular one. I've been having lots of success with Last note - if you're looking for the fastest possible way, you might be looking for a framework rather than a collection of libraries. Check out the Web Frameworks section of for all the links you need.

👍 3

juxt clip is another alternative to component and integrant. works really well


(Oh, and I’m learning Clojure as I go. Have some a simple thing with Ring/Compojure/Hiccup, with an ArangoDB using (the somewhat clunky) interop to Java.)


Fulcro is great for writing React SPAs


Sorry for the basic question but I’m trying to run the introductory examples of how to use Protocols in Clojure and I get really incomprehensible errors, any idea what’s going on?

(defprotocol P
  (foo [x])
  (bar-me [x] [x y]))
; Syntax error compiling at (core.clj:46:1).
; Unable to resolve symbol: .replace.P in this context
[{:file "" :line 6808 :method "analyze" :flags [:tooling :java]}
 {:file "" :line 6745 :method "analyze" :flags [:dup :tooling :java]}
 {:file "" :line 3104 :method "parse" :flags [:tooling :java]}


I believe the issue with incomprehensible error was fixed in the release yesterday.


(running this in calva vscode)

Alex Miller (Clojure team)16:10:27

Multi arity is not supported in protocols with that syntax, but that seems like a weird error, maybe due to tooling


thank you, definitely a tooling thing, cheers!


We currently are working on producing better stack traces for Calva. Which part of the error is weird? (Not sure we can fix it, but would be nice with some elaboration.)


The in the error is nonsense


So my guess is alex is suggesting that some tool is mangling it


But the alternative is it isn't an error from defining the protocol, but somewhere else in the file, which is the sort of thing question askers in #beginners have trouble with


@U0ETXRFEW Answered you in the other thread


It's quite strange with that symbol name in the message. Doesn't seem to be nrepl or cider-nrepl though, so maybe something else in your project.

Alex Miller (Clojure team)16:10:00

For multi arity, declare the method twice with different arities


Is the protocols page out of date? I took this sample from Thanks again!

Alex Miller (Clojure team)16:10:20

Well maybe I’m misremembering then!

Alex Miller (Clojure team)16:10:43

I always have to look it up because it’s different

Alex Miller (Clojure team)16:10:39

I think I’m confusing it with impl in defrecord/deftype sorry

Alex Miller (Clojure team)16:10:04

But I still think the error is weird and looks like tooling


I don't get that error when evaluating the form, btw. It defines P, foo and bar-me.


The issue has something to do with the cursor location when I run the expression in the REPL If I put the cursor at location A it works, at B it gives the error

(     defprotocol Foo ...)
^ A   ^ B


I recommend Evaluate top-level (`alt+enter`) for all def things. Evaluating current form is for evaluating things inside those. Get a feeling for what Calva thinks is the current form by moving the cursor around and issue the Select current form command. All that said, I get this message evaluating current form from B:

Can't take value of a macro: #'clojure.core/defprotocol


Hey team, what are your favorite project-based tutorials in clojure? (Something cool someone can build, ideally without having to expose a server / install too many dependencies.) — Want to create a list I can share with friends who want to learn / potentially turn it into an essay


The project based approach is taken in much of the Practicallli books I'm writing. For example

❤️ 3

I think screencasts where you can "code along" making games are great. I really enjoyed ZombieCLJ, which is sadly only in Norwegian

❤️ 3
Markus Agwin22:10:48

Look at plus look at the page source, it is mostly Clojure. I made the according repository exactly for your purpose. I put some effort into the Readme, feedback form actual beginners would be very welcome.


Parens of the dead was a really fun one to watch:


that's a cool idea.

❤️ 3