I've attached here some "conventions" files for generating ClojureScript with LLMs. The point of these files is to give extra context to an LLM when using it to generate code. These can be pasted into a chat window, and some tools can automatically include the context files when you prompt. Somebody asked for mine so here they are. There's also https://gist.github.com/chr15m/1e52c9a246c2f8867325db3dd7085cd4which is simply a thin wrapper around the aider tool. Using that script you can convert any documentation page into a small "convention" file to give the LLM context. Enjoy!
Relatedly, I also have a context window that is meant to help with translating between React<>Uix<>Reagent https://github.com/ctxs-ai/ctxs.ai/blob/main/contexts/martinklepsch/js-cljs-conv.md
Whoops I didn't realize there was a #ai-assisted-coding channel. Will post there next time.
This message was deleted.
Reagent doesn't support react 19 afaik
mh ... that's a good reason
react 18 works tho
Yup that was it.
Has anyone run into spurious warnings with core async go blocks in ClojureScript? I've run into a strange one that only occurs when I call another macro within the go block which expands to a function call in another namespace. I made ahttps://github.com/lynaghk/repro-cljs-go-unreachable if anyone is looking for a weekend puzzle.
? it's in clojurescript's https://github.com/clojure/clojurescript/blob/fc8522e12036e4e72feff17b3bc73dbdf84f69eb/src/main/clojure/cljs/core.cljc#L2893. The pp macro works when called at the toplevel too.
Oh, oops. My bad. I was weirded out that my IDE didn't find that symbol, but I guess not enough to manually search for it.
You don't need any custom macros to reproduce it, this is enough:
(defn my-go []
(go
(with-out-str)))
I also couldn't reproduce it with vanilla CLJS with -co '{:closure-warnings {:check-useless-code :warning}}', only with shadow-cljs, so perhaps @thheller knows.well the warning is probably correct, there is likely some useless code. can't tell you what exactly but I trust the warning being correct more than this being a bug
But why couldn't I reproduce it with the vanilla? I assume my -co is correct.
no clue. you are free to check whether shadow-cljs actually generates different code here but I very much doubt that
I vaguely remember something about jumping through extra hoops to get warnings out after optimizations. possible that by default they are just dropped. too long ago though, so can't remember details
Ah, bloody hell.
Not only does that warning require :advanced, the option also has to be specified before the -c flag.
Now I'm getting
WARNING: /home/p-himik/tmp/repro-cljs-go-unreachable/out/repro/main.js:134:0: WARNING - [JSC_UNREACHABLE_CODE] unreachable code
134| return cljs.core.cst$kw$recur;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Not exactly there, but close to the reported line number the out/repro/main.js file has these lines:
throw ex4057;
return cljs.core.cst$kw$recur;
Somewhat weird that these lines at a different location do not produce a similar warning even though break is unreachable:
if (cljs.core.keyword_identical_QMARK_(result__2015__auto__, cljs.core.cst$kw$recur)) {
continue;
} else {
return result__2015__auto__;
}
break;
I have no clue how to properly debug core.async but this part in cljs.core.async.impl.ioc-macros looks suspicious:
(defrecord CatchHandler [catches]
IInstruction
(reads-from [this] [])
(writes-to [this] [])
(block-references [this] (map first catches))
ITerminator
(terminate-block [this state-sym _]
(let [ex (gensym 'ex)]
`(let [~ex (aget ~state-sym ~VALUE-IDX)]
(aset-all! ~state-sym ~CURRENT-EXCEPTION ~ex)
(cond
~@(for [[handler-idx type] catches
i [(if (= type :default)
`true
`(instance? ~type ~ex)) ` (aset-all! ~state-sym
~STATE-IDX ~handler-idx
~CURRENT-EXCEPTION nil)]]
i)
:else (throw ~ex))
:recur))))CLJS doesn't have with-out-str.