Fork me on GitHub

is there a cider "pprint to the repl buffer" command?


nevermind, found something better


Maybe that's what you found, but C-c C-p can be really handy.


yeah, knew that one but it doesn't output to the rep,l


Oh, so cider-pprint-eval-last-sexp-to-repl


yeah 😉


but the better one I found is cider-pprint-eval-last-sexp with a prefix arg


possibly dumb question, but why :keys option map destructuring isn't allowed to be a map of bindings to default values? why repeat same names in :or?


Hi, I have something puzzling me I’d like to share. I wanna have reflection warnings always enabled on some project I am working on. To do so I have been advised to use the user.cljns as a way to set up this kind of config to be automatically loaded during development. Here is where I am a bit confused. In user.cljif If (set **warn-on-reflection** true) the reflection warnings are only enabled in the user ns. If I (alter-var-root #'*warn-on-reflection* (constantly true)) reflection warnings won’t work in the userns but will work everywhere else... What would be the clean and proper way to have reflections warnings enabled for everything ?


So it is not sufficient for your purposes to have it enabled everywhere except in the user namespace?


Have you tried both the set! and the alter expressions in the user.clj file?


hi! It is perfectly sufficient for me to have it enabled everywhere but the user.clj file. I was wondering why this behaves the ways it does particularly the alter-var, and if directly fiddling this way with var state wasn’t bad practice!


@U0CMVHBL2 also using both unables the warning really everywhere. I guess am just puzzled why the alter doesn’t work in the ns it’s called in. It’s interesting 🙂


I do not have in my head already a brief explanation why. I do know that warn-on-reflection is one of a very small number of Vars that are pushed/popped in the Clojure compiler in some basis, per file if I recall correctly. Also set! only changes the current thread’s value for a Var, not all threads. Alter-var-root changes the “root” value of a Var, which is independent of the per-thread values a var may have


yes it must not be a simple thing to figure out! thanks Andy.


Well, I think understanding it fully can be broken up, analyzed, and explained in simple steps, but I suspect the number of those simple steps might be a few dozen.


yeah, making things simple doesn’t make them easy...


before using the user.clj trick actually looked a lot to find a way to specify those global values as argument to clojure’s main, or env variable... it turned out that there might be one global that can be set via java properties. It wasn’t warn-on-reflect 🙂


@keymone hey mate, having :keysas a map would force you to have default values for everything you destructure, with the :or you supply defaults only where you want them.


also it allows for defaut values to be applied to nay binding you are creating not just the :keys one {n :not-n :keys [a b] :or {n 1 a 2}}


sure, but it could be an option


i mean, it looks nice with :keys [a b] :or [a 1 b 2] but in real world those are not single letter vars and repeating a dozen of them in keys and in or is quite verbose, i'd rather have a bunch of nils in the :keys section instead


hey there is anyone experienced with the environ library? I'm not sure if the way i'm using it to return a default when an env var isn't found is wrong.


have used it, wouldn't say experienced, show the code?


i'm accessing an env var doing this:

(env :env-var "")


the idea being that if :env-var is empty, it returns an empty string ""


i'm not sure if this is correct, or, in the case where there is an :env-var, it simply adds an empty string and returns something like: "the env var" ""


env is just a hasmap, i would be surprised if (env :var "") would have any side effects or change any state


okay - thanks

Andrea Imparato14:11:05

hello,question: is there a way to call a defrecord method dynamically like (.f record) where f is passed as parameter?


@imparato.andrea you can treat records as maps: ((keyword f) record)

Andrea Imparato14:11:47

interesting! thx a lot

Aleks Abla17:11:51

hey everyone! a few days ago, I had a question about changing the content-type header to csv. I got some great help and was able to do it. Now, I would like to make some changes on the client side, so we get a prompt with a downloaded csv file as seen below.

Aleks Abla17:11:22

I assume it's going to be the reg-event-fx part, particularly in the :http-xhrio :response-format part. I tried looking through the docs but wasn't able to find how to change it to download prompt


@ablazevix Here's what I used recently in a project - it wasn't re-frame specific and I brought in an extra dependency, but hopefully it gives you a place to start

Aleks Abla18:11:29

awesome, thanks for the lead! so, in your experience this was the most efficient way to do it?


(defn download-csv [filename content]
  (let [mime-type (str "text/csv;charset="
                       (.-characterSet js/document))

        blob (new js/Blob
                  (clj->js [content])
                  (clj->js {:type mime-type}))]
    (js/saveAs blob filename)))


Then I used something like [:button {:on-click #(download "file.csv")}] to trigger the download


Which you should be able to put in to your :on-success function instead

Aleks Abla18:11:40

ohhhh.. that's neat!!


I have no idea if it's the most efficient way, but it has been working well for what we wanted to do with it. Based on it looks like there is a standard Filesaver interface in the W3C File API, so you could probably use that instead if you didn't want to bring in the dependency.

Aleks Abla18:11:06

yea I read through the docs, and I realized that perhaps I don't need to figure this out on the client side, so instead I am trying to add a content-disposition header.

Aleks Abla18:11:30

(response/header (response/content-type base-response-map "text/csv") "Content-Disposition" "attachment/download.csv"))


Finally I have a question where I can provide some code. I’m generating some mock data using existing mock data:

(def research-claims
  (map (fn [id company-id user-id is-completed] {:id id
                                                 :company_id company-id
                                                 :user_id (:id user-id)
                                                 :is_completed is-completed})
       (let [max-ids (count company-ids)]
         (map rand-id (range max-ids))
         (take max-ids (mk-users basic-user-ids basic-role))
         (repeatedly max-ids #(= (rand-int 2) 0)))))
The existing mock data are things like company-ids and (mk-users basic-user-ids basic-role) but those have different lengths so I’m trying to generate my mock data based on the one with the smallest count (`company-ids`). Originally I had (count company-ids) in place of max-ids without the let but I realized I could define max-ids in a let and reuse that. However, when I run that and eval research-claims I get the following error:
Error printing return value (ArityException) at clojure.lang.AFn/throwArity (
Wrong number of args (1) passed to: my-app.utils.seed-data/fn--27217
My first question is; is there a trick to reading that error that will tell me which function I’m passing the wrong number of args to? Barring that, can anyone see where my problem lies?


Expressions result in a single value


The result of your let is the final seq created with repeatedly


When you get an exception like this, it can be really useful to do (clojure.repl/pst) to print the stack trace of the most recent exception. In this case, the first line of the stack trace (after it prints the exception that you’ve already seen) should point to clojure.core/map, which would give you a clue that the function getting the wrong number of args is the fn being mapped.

thanks3 4

you are only passing a single arg to the top level function you are mapping with. (fn [id company-id user-id is-completed]...) expects four args and is receiving only one.


if you just eval

(let [max-ids (count company-ids)]
         (map rand-id (range max-ids))
         (take max-ids (mk-users basic-user-ids basic-role))
         (repeatedly max-ids #(= (rand-int 2) 0)))
in the repl you'll see that only returns the last expression not the four collections you are expecting




dan@pop-os:~/projects/clojure/lsp4j$ clj
Clojure 1.10.1
user=> (map (fn [x y] (inc x)) (range 3))
Error printing return value (ArityException) at clojure.lang.AFn/throwArity (
Wrong number of args (1) passed to: user/eval1/fn--137
(user=> (map (fn my-function [x y] (inc x)) (range 3))
Error printing return value (ArityException) at clojure.lang.AFn/throwArity (
Wrong number of args (1) passed to: user/eval140/my-function--141


and the error is difficult to read because you are using a function without a name. look at the error messages here

Aleks Abla20:11:00

ahhh, so as it turns out, adding a :content-disposition var to the header won't work with :xhrio (noted)

Aleks Abla20:11:59

Instead, I am trying to have add an anchor [:a] that would link to the localhost:8080 and commence the download, but for some reason it is not working.. anyone knows why this would not work?


dumb question: does adding the "http://" at the front explicitly change anything?

🌟 4

because if that was on http://localhost, the link might resolve as http://localhost/localhost:8080 etc. - as if it were a relative link

Aleks Abla20:11:12

we have a winner ladies and gents!!


np, it was a shot in the dark

Aleks Abla20:11:45

do you have night vision 🙂


years of suffering working on a front-to-back cljs / clj web app sold as a service - when finding an answer is painful enough you are less likely to forget the answer :D

Aleks Abla20:11:56

so you sort of have night vision lol

Aleks Abla20:11:10

for some reason the file comes back as a json though


that might need to be fixed on the server side in the headers coming from ring

Aleks Abla20:11:54

hmm, I thought I had a fix from that before

Aleks Abla20:11:00

(response/content-type base-response-map "text/csv")


aha - now I remember


yeah, that should have addressed that

Aleks Abla20:11:15

yea it's weird because it does succesfully add the header, not sure what went wrong


I wonder if the multi-hop of xhr (maybe with csrf in there too) might cause the browser to use a different header than the one in your dedicated handler?


(just speculating here...)

Aleks Abla20:11:18

will leave it up to the sr engineers! thanks for the help tho


there should be clues in the network history in the debug console if you have the right dev tools turned on, but if you have srs who can handle stuff easily that's always an option

Aleks Abla20:11:49

yep, spoke to the chief, and he said json is a server default, will do some changes that should fix that


How can I make sure I am writing an integer to the atom and not string?


reset! vs assoc-in?


@seancorfield btw thanks to Slack the ! is not recognized as part of the link. 😄


which depending on the writer's mood might or might not seem intentional. 😉


turns out i'm a genius and was saving strings


B-) caps lock is cruise control for cool


@gerred Thanks Slack 😐


slack is there to help you against your own will.