Fork me on GitHub

I need to do a visualization of a chess board, placing points within various squares and lines connecting those points. I thought I might use a plotting library for this as it's sorta similar to a line plot, does anyone have any recommendations for a simple library I might use?


don't know if it helps, but this is probably the simplest as you can get for easy charting


if i wanna spin up a tiny dumb node/cljs command-line app, what's the least painful way to get started?


you can install lumo (a self hosted cljs on node) with npm


i was looking for like a lein template, but lumo seems pretty neat, thanks!


lein is a java app


i've got it installed


I'm just saying, i wouldn't expect it to be especially useful for something that's 100% node


i've used it for clojure stuff before, but haven't done much clojurescript and certainly haven't done any cljs in quite some time


i'm just trying to dump out another tracery-powered nanogenmo project


i wanted to add an rnn to generate names


and got irritated trying to use es6 maps to format training data


so i figured "why not cljs"


Hi all, I'm trying to write a simple re-frame app. So, I have code like this:

(defn note-summaries
  (let [items
        (into [] (map #(identity [:li [:p %]])
                      @(re-frame/subscribe [:notes])))]
     (if (pos? (count items)
               [:p "No notes!"]))]))
Now, I get error in browser console like this:
Uncaught Error: Assert failed: Invalid Hiccup form: [nil]

(valid-tag? tag)
    at reagent$impl$template$vec_to_elem (template.cljs?rel=1511540933817:302)
    at reagent$impl$template$as_element (template.cljs?rel=1511540933817:329)
    at f (dom.cljs?rel=1511540933878:53)
    at reagent$dom$render_comp (dom.cljs?rel=1511540933878:30)
    at Function.reagent.dom.render.cljs$core$IFn$_invoke$arity$3 (dom.cljs?rel=1511540933878:54)
    at reagent$dom$render (dom.cljs?rel=1511540933878:41)
    at Function.reagent.dom.render.cljs$core$IFn$_invoke$arity$2 (dom.cljs?rel=1511540933878:49)
    at reagent$dom$render (dom.cljs?rel=1511540933878:41)
    at Function.reagent.core.render.cljs$core$IFn$_invoke$arity$2 (core.cljs?rel=1511540934258:75)
    at reagent$core$render (core.cljs?rel=1511540934258:66)
    at ekathuwa$core$mount_root (core.cljs?rel=1511578336868:20)
    at Object.ekathuwa$core$init [as init] (core.cljs?rel=1511578336868:26)
I want to know how to go debugging something like this. I'm quite new to this of course, so I don't really need an answer for this specific bug, but advice on what tools/techniques to use to go about figuring out such a bug. Thanks!


@duminda somehow [nil] got passed as a reagent component - that's not valid and can't be rendered


but I don't see how the code you showed would create that


@noisesmith: Figured it out. (if (pos? (count items) line is missing a closing paren. Funny how often I figure out problems immediately after I ask someone else online (Even without help) :thinking_face: But, are there any standard debugging/helper tools I'm supposed to use?


@duminda aha! that if is broken


you pass too many args to pos?, so the if returns nil


@duminda no, my experience is that bugs with data passed to react lead to verbose and completely unhelpful error messages


because of the way react sets up rendering, it doesn't have a way to provide info about where the data it is rendering from came from in your code


or that's what I am led to believe


@noisesmith: Yeah, I had quite a few during yesterday. But they are totally useless - I agree.


Ok, guess I have to live with it


one thing that can help a lot is unit testing your components with representative data - at least then you know precisely which thing was being tested when the failure happened


you can make a test that mounts just that component to the dom, then makes assertions about the results


see also dev-cards, from the guy who made figwheel


similarly, it leads you to develop things one working part at a time, which makes it clear where the errors are


Got it, I tried out spec, I was under the impression that it can sort of auto-generate tests... Anyway, I didn't want to write tests right now because I'm just feeling out how this works. But guess I have no choice now


As always, thanks for your help @noisesmith


you can totally get by without writing tests - but they help, and dev-cards can actually speed up your dev process


because instead of building a whole component then rendering your page, you can try out the smaller parts one by one


so i've gotten started with lumo and i really like it, but i want to pull in specter ( and i'm not entirely sure how (best) to do that in the absence of a lein project.clj


especially in a self-contained/repeatable kind of way

Drew Verlee20:11:28

is there a core function that describes applying a series of clauses where the clause is a [pred f] and f is applied only if the pred passes? e.g

(??? {:age 5 :name "sally"}
       :age (fn [x] (update-in x [:age] inc)
       :name (fn [x] (update-in x [:name] (str "silly-" %)))
=> {:age 6 :name "silly-sally"}

Alex Miller (Clojure team)20:11:12

cond-> is kind of like that

Alex Miller (Clojure team)20:11:35

It’s good for this kind of data structure manipulation

Alex Miller (Clojure team)20:11:16

It threads so you would omit the x on the rhs

Alex Miller (Clojure team)20:11:16

(cond-> m :age (update :age inc) :name (update :name #(str “silly-“ %)))

Alex Miller (Clojure team)20:11:17

Matches don’t stop the threading so the fns are applied for all matching preds

Drew Verlee20:11:07

Yep, that looks like what i want. Thanks alex.


also, if you need to see consequences of the previous step in your conditional, you can chain multiple calls to cond-> inside ->, or use as->

Drew Verlee20:11:56

Thanks @noisesmith. Thats what i was doing already for other reasons, but i didn't know that was necessary tell you said as much. minor note, the predict functions of the clauses in cond-> aren't sent the expression. So you need to pass it directly.

(cond-> m
 (contains? m :age) (update :age inc)
 :name (update :name #(str “silly-“ %)))
Otherwise the text expression is just the keyword and thats always true

Alex Miller (Clojure team)21:11:44

Yeah, sorry about that!


right, that too 😄


so often what I really want is (as-> m (cond-> (contains? m :foo) (update :foo inc)) (cond-> (contains? m :bar) (update :bar dec))) or similar

Drew Verlee21:11:43

I'm i correct that should allow me to add jar to my project and not need to restart my repl? or i'm i mis-understanding it?


yes, it has a function that loads deps from an edited project.clj