Fork me on GitHub

Hi All, can anyone help me out with, how we can debug clojurescript in visual studio ? Please share steps if possible. Thanks.


Hi All Any good courses for learning closure


I've heard good things about


Thank you... but any free resource available


I don't know of any free video courses. This book is free however


Thank you... but any free resource available


Is it okay for a predicate to return truthy/falsy values? Or they should always return true/false?

(defn repeated-first? [[first & rest]]
  (some #{first} rest))

(repeated-first? [1 2 35 6 1])
;; => 1

(repeated-first? [13 2 35 6 1])
;; => nil


Always up to you but I think most would be surprised to see the question mark on the end of that and no Boolean.

parens 12

Yep, I would also be surprised hehe


I was just checking 😄


What is the easiest way to put a vector into a map using index as a key?


I can write code using a loop and transient, but there might be something more straightforward…


(into {} (map-indexed (fn [i e] [i e]) [:hey :there :buddy]))
=> {0 :hey, 1 :there, 2 :buddy}


Thanks! I believe, you can shorten it to (into {} (map-indexed vector [:hey :there :buddy]))=> {0 :hey, 1 :there, 2 :buddy}


nice! i was trying to think of how to do that haha


#beginners amiright

Alex Miller (Clojure team)17:12:18

(zipmap (range) [:hey :there :buddy])

👏 8
👍 8
Alex Miller (Clojure team)17:12:49

zipmap takes a key seq and a val seq and zips them up (and stops at end of first finite seq)

Eric Ihli18:12:58

[:> Dialog {:full-screen true :open @show-login-screen? :on-close #(dispatch [:show-login-screen false])
                   :Transition-component [:> Slide {:direction "up"}]}
What is the :> symbol in that code? Is that something the community has standardized for something, something from Reagent?


I posted an incorrect answer yesterday-- :> is the syntactic sugar for reagent/adapt-react-class, see under “Creating Reagent Components from React Components” at

💯 4

:> is a keyword


just like :foo


it's up to the library that is inspecting that datastructure to decide what it means. In this case, I believe that is something special in Reagent


not to be pedantic, but foo and > are symbols, whereas :foo and :> are keywords


This is incorrect-- :> is the syntactic sugar for reagent/adapt-react-class, see under “Creating Reagent Components from React Components” at

AJ Jaro18:12:29

Is there somewhere that I can find the documentation about :> related to create-class or is that just common knowledge?

AJ Jaro14:12:02

@UCQL6E7PY On a similar note, do you know where I can find documentation on :<> as well?


Here’s the pull request where they were added! Looks like it’s short hand for a React Fragment


Just FYI, to find the first one I searched ‘reagent colon greater than’ on google, and for the 2nd one I went to the Reagent changelog and CTRL-F’d for :<> . Just mentioning my method in case you run into more special keywords that don’t have easy to find documentation @UGMAVSMUM

AJ Jaro16:12:07

@UCQL6E7PY Thanks for the assist! They were certainly difficult ones to find so I appreciate you sharing your search methods


I’m working on a test case with clojure.test but when I try to run code in my REPL it’s giving me an error because my database spec is empty. I see some setup at the top of the test file that seems to set up mock data. For example: (use-fixtures :once #'fix/global-fixture) with global-fixture being defined as:

(defn global-fixture
  "should be used in every test namespace"
  (binding [*test-context* {::db/pool (mk-pool) ::conf/config test-config}]
    (log/with-level :error (f))))
So in my code, to get the database spec I have (::db/pool fixtures/*test-context*). So, my question is, how can I initialize all of those fixtures in the REPL so that I can call my function with a spec that doesn’t eval to nil?


how do you run the test code?


I use vim-fireplace so usually I do cpr to run all the tests or :.RunTests on one of the test to run just that one.


if you call the test as if it were a function, you can pass it as an arg to the fixture, otherwise if using clojure.test functions the fixture should be applied already

Alex Miller (Clojure team)19:12:25

it depends which functions you call


So, here’s an example test I have:

(deftest checking-something
    (let [id (data.stuff/first-id (::db/pool fixtures/*test-context*))]
        (testing "something"
            (is (= id 99)))))
And I can run that test with cpr to run all the tests and they’ll run just fine. But if put my cursor over (data.stuff/first-id (::db/pool fixtures/*test-context*)) and type cpp to just run that one function in the REPL it fails because (::db/pool fixtures/*test-context*) evals to nil.


Actually, I’m wrong. cpr also gives me an error. Both basically saying that test-context is nil or null.


right, because in both cases you are running a function, not a "test", per se, so the fixture isn't applied


see @alexmiller’s link above - there should be something in fireplace that hooks into that as well


hmm, cpr should be applying the fixture


I’m getting Unable to resolve symbol: test-vars in this context when I run (test-vars fix/*test-context*) . Is that the wrong way to run it?


it's clojure.test/test-vars

Alex Miller (Clojure team)20:12:07

I think it takes a collection of vars too iirc


Ah, that fixed that problem at least. 🙂


So, I should be able to run test-vars (GOD does Slack’s new markdown handling suck) and then run, for example; (::db/pool fix/*test-context*) and get something more than nil?


if ::db aliases the same ns in your test ns as it did in the fixture ns


perhaps it would help to look at what fix/**test-context** is


It’s initially defined as (def ^:dynamic *test-context* {}) but then global-fixture seems to set it up:

(defn global-fixture
  "should be used in every test namespace"
  (binding [*test-context* {::db/pool (mk-pool) ::conf/config test-config}]
    (log/with-level :error (f))))
Which makes me question whether global-fixture is getting called within my repl. I’d think so since I have (use-fixtures :once #'fix/global-fixture) in my test file.


you are doing the things that ensure any fixtures get invoked, which is why I suspected it might be you are using the wrong key


you could eg. (print (keys fix/**test-context*))*


this new wysiwyg editing mode for inline source is terrible


That returns nil so yeah, looks like those fixtures aren’t getting set up somehow.


what happens if you call the fixture by hand with your test function as an argument?


it could be the fixture is broken also


Except that they are because tests that use, for example, fix/*test-context* that were written by someone else are passing.


any chance you are calling something lazy in your test, so that by the time the value is forced the context binding the values has exited?


that's not the case in your example, but it's definitely a gotcha with dynamic bindings


I moved (print (keys fix/*test-context*)) to right after the use-fixtures call and still get nil.


that's not the right place to use it - put it inside the test code itself


code at the top level will never be run inside the fixture


@darrell this is my attempt at a minimal demo of how it works properly

foo$ clj
Clojure 1.10.0
(cmd)user=> (require '[clojure.test :as test :refer [deftest is test-vars use-fixtures]])
(cmd)user=> (def ^:dynamic *foo* nil)
(cmd)user=> (deftest foo-test (is (= *foo* 2)))
(cmd)user=> (test-vars [#'foo-test])

FAIL in (foo-test) (NO_SOURCE_FILE:1)
expected: (= *foo* 2)
  actual: (not (= nil 2))
(cmd)user=> (defn foo-fixture [f] (binding [*foo* 2] (f)))
(cmd)user=> (test/use-fixtures :once foo-fixture)
#:clojure.test{:once-fixtures (#object[user$foo_fixture 0x5c00384f "user$foo_fixture@5c00384f"])}
(cmd)user=> (test-vars [#'foo-test])
(ins)user=> ^D


Thanks @U051SS2EU! I’ll take a look and apologies for the delayed reply. I had to step away for a few hours.


What are people using to debug code in VS Code?


@glfinn83 What do you mean by "debug"?


(I get the impression that very few Clojure devs use a "traditional" (i.e., step) debugger -- but instead use a variety of REPL-based techniques)


off-tangent but, I've found that Spacemacs' CIDER has a step-debugger that just works


FWIW, I haven't used a step debugger for maybe two decades now -- and I've never felt the need for it in Clojure.


yea I've found this to be the case too. It's so much easier to reason about your code and I think thats how it should be. Although, one thing that trips me up sometimes is holding the types in my head (since, dynamic typing). Any tips to overcome that?


I don't know. I just don't find that to be a problem. In what sort of situations do you find that to be a problem?


(I used to rely on a step debugger when I did C++ and I used them a little when I first got started with Java in the late 90's but not since)


Exactly what Raf said. Using REPL is nice, but it would also be good to be able to step through running code.


VScode is actually my main editor but Calva was conflicting with my vim keybindings, so I decided to give Spacemacs a try. Really great so far (for Clojure, at least)


Thanks, I'll check it out

👍 4

Cider's debugger is pretty sweet. Its not exactly like a traditional debugger, and can't debug into Java code, but I recommend trying it out if you use Cider. Check it out:


Or just try doing C-u C-M-x on a function and then calling it.