Fork me on GitHub

if you dissoc x, it downgrades to a hash-map, last I checked

Dustin Getz00:04:52

Yeah, so (defrecord [mandatory-id]…) and then we good


When I start #datomic -ions + #shadow-cljs in the same repl, my JVM just freezes. How can I debug this? I think that I'm running out of threads


which platform does that run on? JVM can take quite a few threads so its unlikely you are running out?


It's a [email protected] I'm using a i7 so there is 8vcpu. When jvm freeze, it keep at "0%" of cpu usage. When I query first, the start shadow, it keep compiling forever (web UI works, but do nothing about stop/start builds ) When I start shadow first, then query, the query freezes / lock my repl


can you be a bit more detailed and tell me what code exactly you execute?


I have basically never seen a JVM freeze so that sounds very weird to me


but in general: why are you running shadow-cljs as part of a datomic ion? that makes little sense to me?


It's just my dev setup. I like to keep everything in one repl. At home I will try to make something reproducible


if you use Control-\ or use jstack you can trigger a dump of the stack traces of all running threads. My hunch is that something is running and not getting expected input.

eccentric J14:04:41

I could use a little help designing an algorithm. How would you go about transforming between the two formats?

{:logger {:name :logger
          :deps [:render]}
 :render {:name :render
          :deps [:store]}
 :store {:name :store
         :deps [:router]}
 :router {:name :router
          :deps []}}

;; Would like to format as:

[[:router []]
 [:store  [:router]]
 [:render [:store]]
 [:logger [:render]]]

eccentric J14:04:40

I implemented a gross solution in JS by first transforming the input into {:router {:store {:render {:logger {}}}}} then walking it again to build a list like the bottom. However, I feel like I’m making it messier\more complicated than it needs to be.


(reduce-kv (fn [res k v] (conj res [k (:deps v)])) [] input-map)


(mapv (fn [[k v]] [k (:deps v)]) input-map)


(mapv (juxt first (comp :deps second)) input-map)


this doesn't give the right order @U6N4HSMFW


Ahh, order matters?


I guess so, but can't speak for the OP


the problem being solved here is topological sorting


Ahhh, I thought it was simply transforming data format to another, which is quite trivial though. It’s likely that I didn’t get the point from the example. 🙂


But yeah, now looking at it it makes sense. I’d maybe look how integrant or component does that.


the algorithm is not very complex so it's not rare too see ad-hoc implementations in libraries having to do some kind of dependency resolution

eccentric J15:04:52

Oops sorry for not being clear but yes, order does matter.

eccentric J15:04:17

Thanks for the help, finding out the name of the algo for it is a ton of help!


If it helps, this is very close to being an adjacency-list / tree transform, which is well studied and well documented. And loom itself has code that turns a tree into an adjacency list and visa versa (every tree can be converted to an adjacency list, an adjacency list can only be converted to a tree if its graph is non-cyclical, directed, and each node has only one incoming link)

eccentric J18:04:11

Thanks @U051SS2EU. Learning the term helped me find a section about it in an algorithms text book I impulsively bought but never used. After reading that section then watching a youtube talk on topological sorting I was able to implement a depth-first-search topological sort for directed-acyclic-graphs on my own 😄


adjacency-lists are especially useful in a language with immutable data structures, as they allow cycles and complex nested updates without doing a tree worth of mutations

eccentric J18:04:27

Ah that makes sense, the book’s solution used an AdjacencyList but it also used a mutable list to track what was visited. I’m not quite sure how to handle that part in an immutable language without something like an atom.

eccentric J18:04:12

Actually I take that back. The recursive function would need to return the updated sorted list and the updated visited list is all.


precisely - we can use normal updating / recursion tricks, and it's simplified since it's flattened


I am using the but how does this work in development env? In the case of defroutes it is a var and evaling(c-x c-e) changes just works. In the case of closure, I have to keep restarting the server.


@munichlinux Component out-of-the-box needs a little setup to have it work well in a hot-reloading environment. I'm assuming you're using CIDER + Emacs, my setup defines reloading functionality for component called user/reset in dev/user.clj. Then I have key chord C-x C-r setup to call user/reset, which refreshes component. It works perfectly. For example, I could define some new functionality for a closure, test it with C-x C-e, and then hit C-x C-r to see the changes appear.


@munichlinux This isn't my own idea it's based off the article: Though the article won't get you all the way, if you follow through it and tinker with your emacs config for a bit, you'll be able to find a good solution. If you want to check out my .emacs config file I can send it over in a private message.

piyer15:04:47 Thanks for the link


I doing the same thing. I though there could be a better way since I have to keep firing (reset) all the time.


@munichlinux yeah I hoped as well, if you find one message me about it. Though I think it's unsolvable due to components use of protocols.


Here's my elisp code for resetting component.


@munichlinux so this will save and refresh component every time you reset buffer?


Thank you for the link.


Also what happens when there are errors in the saved buffer?

piyer16:04:19 you can turn the logger on *cider-ns-refresh-log*


now I change my code, do C-M-r, that does the magic.

Wes Hall18:04:28

Is it possible to compose aliases in deps.edn? For example, if my ~/.clojure/deps.edn contains a test alias (adding test directory to the path) and a cider alias (adding some cider libs), can I create a dev alias in my main project deps.edn which says, "switch on the test and cider aliases when dev is used"?


I don’t believe so


you can add them both in the args. e.g. -A:test:cider


but you can’t create aggregates


that would combine them by name like -A:test-cider like you’re saying

Wes Hall18:04:38

Ok, thanks. What I was really trying to do here was to configure cider to start with the dev alias by setting cider-clojure-cli-global-options to -A:dev and then configure the dev profile on a per project basis. I suppose I can either just put all of the config in the project dev alias (little duplication, but nothing too worry too much about), or get into .dir-locals.el stuff, though emacs seems to complain about setting this the cider-clojure-cli-global-options variable in dir locals. Apparently it "may not be safe", but I am not sure exactly what determines that. Probably simpler to do the first thing I suppose.


yeah. it’s super annoying to set those options right now in CIDER


we should open up a ticket


I hate that message that pops up everytime I open a new file 😧

Wes Hall18:04:05

It does seem to give me an option to say, "Mark this variable as safe in the future", but I am not sure I understand why it is unsafe. Something makes me anxious about overriding a message like this without fully understanding it 🙂


one of the things I’ve noticed is sometimes those settings bleed between projects

Wes Hall18:04:59

Ahhh... yeah, that would be a little unsafe I guess 🙂


If you cider jack in with a prefix argument you can edit the actual startup form. Makes it easy to tweak those without knowing which config to set


I just want to SPC m ' and not think about it 🙃


Hello. I want to present you yet another nobody needed Clojure gebugging library 🙂 Which channel would be right for it?


#announcements ?


maybe, I'm not sure. thanks, I'l post it there