Fork me on GitHub
#clojure
<
2022-09-10
>
seepel00:09:35

When building an end user application do folks usually use a namespace like src/{project-name}/{module}/{namespace}.clj or do you omit the project name like src/{module}/{namespaces}.clj?

Drew Verlee03:09:41

I like to include the project name, because it makes it easier for the caller (the developer) to connect the dots when there are in a namespace.

seepel05:09:50

That definitely makes sense it's also nice that project code can then be sorted together in the require portion of the namespace. I find that with my datomic schema files I'd like to use ::attr-name for a lot of my queries and I'd prefer not to clutter my entities with my project prefix, so it got me to wondering if there would be other benefits to having application code at the top level.

aaron5100:09:42

Sorry to see that bat-test is deprecated… https://github.com/metosin/bat-test We use it a lot and appreciate its unique features, especially parallelization. I know we could continue to use and fork if necessary — just sorry to see its end of life, and sorry that there’s not more interest in testing.

😅 1
Drew Verlee03:09:19

I guess the authors think kaocha has better ideas > For new projects or when using Clojure CLI, check https://github.com/lambdaisland/kaocha.

borkdude09:09:11

This project seems to be coupled with boot... right?

juhoteperi12:09:09

Parallel tests isn't really a unique feature as that is implemented by Eftest, not bat-test.

juhoteperi12:09:13

It also has a Lein plugin and CLI main function was contributed, but not merged. Supporting even both lein and CLI in the same project would be inconvenient (Boot support could be dropped at this point.)

juhoteperi12:09:44

I probably never ran tests parallel, it causes too much problems with any stateful applications and usually testing pure library code is fast enough anyway.

juhoteperi12:09:27

Dropping both lein and boot support and releasing CLI main fn as version 1 might make sense, but that would be a breaking change for any existing users and except for maybe parallel tests, Kaocha should have all the other features already.

aaron5104:09:33

RIP again to metosin’s bat-test because it had: • Global pre & post hooks • Watch mode that only reruns relevant tests, not the whole suite (Kaocha runs the https://cljdoc.org/d/lambdaisland/kaocha/1.69.1069/doc/7-watch-modehttps://github.com/lambdaisland/kaocha/pull/131 is open, 3 years old) • Multithreading, which sped up our suite significantly (Kaocha’s https://github.com/lambdaisland/kaocha/pull/234 is open, 14 months old)

👍 1
Drew Verlee19:09:29

@U3JH0P5LJ what stops you from using it?

aaron5119:09:52

@U0DJ4T5U1 nothing, of course! — but especially with something so crucial as testing it's nice to be on a well worn path that other people are on, and investing in, so that when we inevitably have issues or questions we are not alone

nivekuil14:09:31

I have a sequence of 3-tuples [[x y z] ...] and want to get each tuple with a duplicate y z pair. This xforms solution is close:

(into {} (comp (x/by-key rest  x/count)
               (filter (fn [[k v]] (> v 1)))))
but I don't see how to get the full tuple, it only keeps the rest part. What's an efficient way to do this?

dpsutton14:09:55

(comp vals (partial group-by rest))?

dpsutton14:09:07

(let [coll [[1 2 3] [2 2 3] [3 4 5] [4 4 5]]]
  ((comp vals (partial group-by rest)) coll))
([[1 2 3] [2 2 3]] [[3 4 5] [4 4 5]])
returns a sequence of sequences of tuples with matching last numbers

nivekuil14:09:36

these two tuples should not be included:

(->> [[1 2 3] [2 3 4]]        ((comp vals (partial group-by rest))))

dpsutton14:09:26

They are in separate partitions. You could filter the sequence to collections that have more than one 3 tuple in them

nivekuil14:09:11

I could filter afterward, but that's less efficient than the xforms way where it only does one pass I think?

skylize15:09:59

(defn have-dupes [xs]
  (filter #(> (count %) (count (group-by identity %)))
          xs))

chrisn16:09:52

I doubt there is much of an efficiency difference. When in doubt, http://clojure-goes-fast.com/blog/benchmarking-tool-criterium/.

p-himik16:09:42

Why is args-fn in core.memoze https://github.com/clojure/core.memoize/blob/master/src/main/clojure/clojure/core/memoize.clj#L100-L102

(def ^{:private true
       :doc "Returns a function's argument transformer."}
  args-fn #(or (::args-fn (meta %)) identity))
and not as
(defn- args-fn
  "Returns a function's argument transformer."
  [f]
  (or (::args-fn (meta f)) identity))
?

p-himik18:09:30

:D I love that response. It'll be pleasant to look back to it when I inevitably stumble upon something that I wrote myself, and think the same exact thing.

borkdude18:09:29

My suspicion is that such things are the result of a refactoring, e.g. pulling a function out so you can re-use it in multiple places

seancorfield18:09:42

@U04V15CAJ The question -- a very reasonable one -- is why I wrote it as a def for an anonymous function, instead of as a defn- (especially since in that same change, I replaced a number of defn ^:private instances with defn-).

borkdude18:09:24

My suspicion is that it was first an inline predicate which was moved higher up, but this is only a suspicion :)

borkdude18:09:47

You might be able to tell by looking at the git history of course

borkdude18:09:54

Neh, it doesn't make sense what I said, now I actually looked at the commit, never mind ;)

seancorfield18:09:07

Heh, exactly my point.

true.neutral22:09:15

Hi! Is there the-one-and-only up-to-date clojure grpc package? I've tried protojure, but its protoc plugin doesn't support optional fields. Played with clj-grpc that wraps Java, but it doesn't have convenient client wrappers. And I don't really want to barebones Java interop. Am I out of luck and bound to write some library code, or is there something?