Fork me on GitHub
#beginners
<
2024-01-02
>
jwind00:01:10

So I use cider-jack-in to start a shadow-cljs repl in Doom Emacs, then when I go to eval a file, I'm seemingly hung on a "Loading .../app.cljs" message in the minibuffer. I'll get a REPL at the bottom of my window, but I can't send anything to it. Anything I should do? I started with the quickstart code for Shadow CLJS here: https://github.com/thheller/shadow-cljs?tab=readme-ov-file#quick-start

jwind00:01:30

Do I need to start a separate watch process, then connect to that as a REPL?

hiredman00:01:02

I sort of recall that working in conjunction with a running browser to actually run the js

hiredman00:01:28

so it is likely waiting for the browser to poll for compiled js to run

hiredman00:01:52

you can search the quick start above for "browser" to find it talking about the html page you load in the browser, and it talks about using npx commands to start repls, dunno how any of that works with cider-jack-in

jwind00:01:57

hmm ok, yes scrolling up in the REPL buffer shows some additional info like what the address of the dev http server is... But now I'm seeing that the shadow-cljs connect fails because the server might be dead? Maybe I do need to have a watch process going

jwind00:01:43

Ok I see now that the watch process does start an nREPL server... almost there

vemv12:01:55

I'd suggest to spawn a nrepl server from the CLI, that way you'll see exactly what's going on. It's generally more robust and debuggable. Then you can cider-connect-clj&cljs from Emacs Make sure to have the different moving pieces (shadow, cider-nrepl, cider.el) at their latest stable versions

jwind00:01:31

Thanks I'll try that next. I'll need to (unpin! cider-nrepl) and others I believe. I'm using Doom

jwind00:01:51

What I'm really after is getting CLJS autocomplete in my Emacs buffer. It works when jacking-in to Clojure nREPL but I don't get autocomplete with ShadowCLJS

jwind00:01:22

Solved, I setup an explicit :nrepl key in my shadow-cljs.edn file and added cider-nrepl middleware. Thanks everyone 🙂

🙌 1
Alex10:01:46

I'd like to have a deps.edn alias for running tests with clojure.test/run-tests, but it seems that the :exec-args only expects a map? I tried a few variants, but they all result in some class cast errors. Do I have to provide my own function just for that?

Alex11:01:57

Thought that something like that would be my next step anyway. But as a general question — one can only run a function with a single map arg this way, is that correct?

k_14:01:45

hi there, out of curiosity is there a way to compile to wasm from clojure ? or is there any plans to have it as a target ?

Aleix Morgadas21:01:33

(Resolved) Hi there 👋 , I'm facing a challenge on a very simple task, and I need some guidance. I have two lists: 1. Invited users 2. Registered users (a sublist of the first) I want to have the list of invited users that didn't register. How I can do it? I tried it with filter and with reduce but no success

2
phronmophobic21:01:11

Can you share what you tried? It will be easier to give better feedback that way.

Aleix Morgadas21:01:30

(def invited ["" ""])
(def registered [""])

(def not-registered (filter (fn [r] (not(some #(= r %) invited))) registered))

Aleix Morgadas21:01:21

(def not-registered-reduce (reduce (fn [final register]
            (into final (if (some #(= register %) registered) invited)))
        registered))

Sam Ferrell21:01:14

The typical way to do this is to use sets with clojure.set/difference

1
Sam Ferrell21:01:10

Here's an example just using reduce

(let [a ["foo" "bar" "baz"]
      b ["bar" "baz"]]
  (reduce (fn [acc av]
            (if (not (some (fn [bv] (= bv av)) b))
              (conj acc av)
              acc)) [] a))

Aleix Morgadas21:01:31

Oh... I do need to get familiar with the standard library

Aleix Morgadas21:01:37

Clojure has an amazing community

Sam Ferrell21:01:50

I am amazing its true

😂 2
Aleix Morgadas21:01:09

and humble 😜

bortexz08:01:19

Another alternative:

(remove (set registered) invited)

1
☝️ 1
Umar Mahmud23:01:10

Hi! Can someone let me know why this returns the error "Cannot call 1 as a function"? (for [x (1,22) y (1,44)] (+ x y)) But this code runs fine? (for [x [1,22] y [1,44]] (+ x y))

Bob B23:01:54

parens are lists, which get evaluated, braces are vectors, which don't

👍 1
huy23:01:30

(1, 22) is the same as (1 22) which is calling a function 1 with 2 as its argument

👍 1
Samuel Ludwig23:01:12

if you want you should be able to write ("quoting" the lists): (for [x '(1,22) y '(1,44)] (+ x y))

👍 1
huy23:01:19

If you want a list, write '(1 22)

Bob B23:01:07

put a different way, if you enter [1 22] into a repl, you'll get back [1 22], but if you enter (1 22) at a repl, you'll get the same error

Umar Mahmud23:01:21

ok, that makes perfect sense, thanks!

Alex06:01:03

Did you actually intend to use fractional numbers like 1.22 and 1.44? Comma is not what you want here then. ;)