Fork me on GitHub
paul a00:09:50

is it possible to set environment variables with deps.edn on a per-alias basis?


You could set system properties (but not env vars)


Hi Experts, How would you represent a ranked collection in clojure? Like that of ranked users on some number of points?


A map of numbers to UUIDS. (sort-by :points users) is another option.


By ranked you mean sorted?


There are various options but if your data size is big, and care about performance, you probably need to consider with peculiarities in your use case (read/write patterns)


If it’s a lot of data, it probably needs to be handled inside a database.


something like:


if you already had it in your stack, a sorted set in Redis is another good way to do this.


Depending on how you’re using it, a sorted-map or priority queue might work.


Thanks all, the data-set is not too big. Likely fewer than 10k entries


How can I get the index (rank/sort position) of an map matching on a specific key after i do (sort-by) ? tanks


Which data structure did you settle on?


Some dependency in my webapp is causing a java app to appear on my dock (macOS). Is there a clever way to figure out which dependency is doing that? (Excluding obvious things like partitioning the requires)


there is some command line option you can pass to avoid that happening if I recall




apple.awt.UIElement=true also may help


Hi all, from what I've read a lot of effort went into improving error reporting in Clojure 1.10. However, I just updated a somewhat minimal project and the error messages seem less helpful than they were in 1.9. For example: In 1.9:

clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: No such namespace: a, compiling:(my/example/ns.cljc:16:16)
In 1.10:
clojure.lang.Compiler$CompilerException: Syntax error compiling at (my/example/ns.cljc:16:16).
{:clojure.error/phase :compile-syntax-check, :clojure.error/line 16, :clojure.error/column 16,
:clojure.error/source "my/example/ns.cljc"}
The error messages no longer tells you what heuristic was broken, just that it's a general syntax error and where to find it. I'm wondering if there may be some configuration or dependency that I might be missing?

paul a16:09:40

while i don't have any specific examples handy, i've had the same feeling.

paul a16:09:02

actually, that example is exactly what i would point to - name errors are not as easy to recognize.


in this case it's not a missing dep, it's invalid syntax, newer clojure versions are more strict about syntax that older versions let slide


oh - never mind, that wasn't your point


@zalky What REPL/tooling are you using when you see that? Not all tooling has caught up with the underlying changes in 1.10/1.10.1 so some tooling now shows worse errors.

👍 4

@U04V70XH6, I thought it might be something related to that. I'm using boot 2.8.3, and nrepl 0.6.0.


what do you see if you evaluate *e after getting that error in a repl (eg. require / :reload or load-file)?


that could help establish if the error display is eliding the interesting part

👍 4

Ah, I think you may be right! I believe the discrepancy is due to my setup, which involves connecting my cider repl to a remote nrepl server and a running watch task that recompiles all my clojure code on change. When the watch task tries to reload the code, it seems like it only emmit the partial error. If I try to reload the namespace from the cider repl, the full error shows up, which includes both the syntax check, and the no such namespace error. So I guess I need to figure out what is responsible for emitting the error from the watch task.


I wouldn't be surprised if the tool had a new version that behaved better with newer clojure versions


I doubt that combination has been updated to leverage the new error triage machinery. 2.8.3 is the latest stable release of Boot so I think you're just out of luck there.


oh, boot limits the cider / nrepl layer? never mind, I misread, cider wasn't in charge of the watcher


In order to take advantage of the error reporting improvements in 1.10(.1), tooling needs to be updated to conditionally use the new triage function introduced there.


clj / clojure does this (of course) and I suspect Leiningen may have been updated (maybe?). I would expect the latest CIDER to do it -- that team is very active -- but Boot's last release was back in April and although 1.10 came out in December last year, 1.10.1 didn't appear until June. So I suspect the Boot team didn't really have the new handling on their radar that soon after 1.10...?

Alex Miller (Clojure team)18:09:22

I don’t know what boot is exactly doing in this case so hard for me to say. But the Error Reporting section of covers the various things now available to use.


So, after some digging, the tool in question (danielsz/system) uses clojure.stacktrace/print-throwable to emit the error. The error being emitted does in fact have the full error with all the relevant information, but it seems that clojure.stacktrace/print-throwable prints only the first part of the error (in the :via property). Is there some better way to produce a printable string of the error?

Alex Miller (Clojure team)18:09:14

Yes, as described in the link I posted prior

👍 4

Roger that. Looks, straightforward, thanks!


it looks like that error reporter is showing the ex-info data but not the error message


deps.edn question: I'm using a repo that has three artifacts (, core, dom and rn, each with their own deps.edn. How can I use tools.deps with git resolution to make this work?


@denik you're looking for :deps/root


@denik that's actually listed at the top of the readme 😛


:man-facepalming: thanks @dominicm


Writing a grammar in instaparse I get stuck at the following problem:

(let [expr   "> abc :foo bar baz :and 300"
      parser (insta/parser
              "expr = token (<whitespace> token)*
              <token> = cmd | search-phrase | key-arg-pair
              cmd = '>' | 'cb' | '>cb'
              search-phrase = not-cmd-and-words-or-numbers
              key-arg-pair = keyword <whitespace> arg
              <keyword> = #':[a-zA-Z0-9]+'
              <arg> = (keyword | not-cmd-and-words-or-numbers)
              (* not cmd and then any words and numbers *)
              <not-cmd-and-words-or-numbers> = !cmd words-numbers
              words-numbers = word | number (<whitespace> words-numbers)*
              <word> = #'[a-zA-Z]+'
              <number> = #'[0-9]+'
              whitespace = #'\\s+'
     [:cmd ">"]
     [:search-phrase [:words-numbers "abc"]]
     [:key-arg-pair ":foo" [:words-numbers "bar" "baz"]]
     [:key-arg-pair ":and" [:words-numbers "300"]]]
    (parser expr))))
FAIL in () (command_bar.cljc:102)
expected: (= [:expr [:cmd ">"] [:search-phrase [:words-numbers "abc"]] [:key-arg-pair ":foo" [:words-numbers "bar" "baz"]] [:key-arg-pair ":and" [:words-numbers "300"]]] (parser expr))
  actual: (not (= [:expr [:cmd ">"] [:search-phrase [:words-numbers "abc"]] [:key-arg-pair ":foo" [:words-numbers "bar" "baz"]] [:key-arg-pair ":and" [:words-numbers "300"]]] [:expr [:cmd ">"] [:search-phrase [:words-numbers "abc"]] [:key-arg-pair ":foo" [:words-numbers "bar"]] [:search-phrase [:words-numbers "baz"]] [:key-arg-pair ":and" [:words-numbers "300"]]]))


argis supposed to match multiple words through the underlying not-cmd-and-words-or-numbers. Instead search-phrase takes precedence.


instaparse doesn’t guarantee precedence unless you use an ordered choice operator (`/` as opposed to |), or a negative lookahead (`!`) to enforce that certain rules are a “last resort”


wisdom from the source! thanks @aengelberg. still I'm not able to force precedence, even with the ordered operator


ah, looking more closely at your grammar I can see why that wouldn’t work


@denik it seems like the DSL you’re implementing has the property that once you start adding keyword arguments, everything from that point forward should be part of a keyword argument pair (not a search phrase)


but you aren’t encoding that into the grammar


@aengelberg exactly right. isn't this part encoding it?

key-arg-pair = keyword <whitespace> arg
<keyword> = #':[a-zA-Z0-9]+'
<arg> = (keyword | not-cmd-and-words-or-numbers)


that part is accurately defining what keyword arguments look like, but when you write :kw arg1 arg2, arg2 could legitimately either be the second argument or a new search phrase


so it isn’t ruling out the possibility of more search phrases after your keywords


hmm, I wonder how to do that. search-phrase should also only match once


I think you need to re-organize the grammar top-down. at a high level it should look something like this:

expr = cmd search-phrase+ key-arg-pair+


I’m making some assumptions there, and also missing the whitespace, but that might be a starting point


ok thanks @aengelberg any way to match search-phrase only once?


expr = cmd <whitespace> search-phrase <whitespace> key-arg-pair*


ah, (<whitespace> token)* is preventing that


ok, I'll try my luck


i might not have gotten the bits and pieces exactly right, but the idea is to tell instaparse “all the search terms go first, then all the keyword arguments”